Merge in from trunk r64802 - r68625

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68626 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Steve Lamerton 2011-08-10 18:10:42 +00:00
commit 94e0018723
97 changed files with 2524 additions and 1712 deletions

View File

@ -49,6 +49,11 @@ AC_DEFUN([WX_VISIBILITY],
error this platform has no visibility;
#endif
/* at the time of Xcode 4.1 / Clang 3, Clang++ still didn't have the bugs sorted out: */
#if defined(__clang__)
clang compiler is still broken w.r.t. visibility;
#endif
extern __attribute__((__visibility__("hidden"))) int hiddenvar;
extern __attribute__((__visibility__("default"))) int exportedvar;
extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);

5
configure vendored
View File

@ -35001,6 +35001,11 @@ cat >>conftest.$ac_ext <<_ACEOF
error this platform has no visibility;
#endif
/* at the time of Xcode 4.1 / Clang 3, Clang++ still didn't have the bugs sorted out: */
#if defined(__clang__)
clang compiler is still broken w.r.t. visibility;
#endif
extern __attribute__((__visibility__("hidden"))) int hiddenvar;
extern __attribute__((__visibility__("default"))) int exportedvar;
extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);

View File

@ -440,10 +440,13 @@ Major new features in this release
All:
- Fix parsing of negated long options in wxCmdLineParser (roed_bis).
- Fix crash in wxArray::insert() overload taking iterator range (wsu).
All (GUI):
- Added documented, public wxNavigationEnabled<> class.
- Added wxTextCtrl::PositionToCoords() (Navaneeth).
- Added support for wxHELP button to wxMessageDialog.
- Support float, double and file name values in wxGenericValidator (troelsk).
- Fix keyboard navigation in wxGrid with hidden columns (ivan_14_32).
- Add wxDataViewEvent::IsEditCancelled() (Allonii).
@ -453,6 +456,10 @@ All (GUI):
OSX:
- Implement wxRegion::Equal() (Dr.Acula).
- Implement wxFileType::GetOpenCommand().
- wxGetOsVersion() now returns more sensible version numbers, e.g. 10 and 6
for OS X 10.6.
- Added wxApp::MacOpenFiles and deprecated wxApp::MacOpenFile.
GTK:
@ -461,6 +468,7 @@ GTK:
MSW:
- Added wxGCDC(wxEnhMetaFileDC) ctor (Marcin Wojdyr).
- Added wxTopLevelWindow::MSWGetSystemMenu().
2.9.2: (released 2011-07-05)

View File

@ -10,6 +10,10 @@
#ifndef _WX_AFFINEMATRIX2D_H_
#define _WX_AFFINEMATRIX2D_H_
#include "wx/defs.h"
#if wxUSE_GEOMETRY
#include "wx/affinematrix2dbase.h"
// A simple implementation of wxAffineMatrix2DBase interface done entirely in
@ -42,4 +46,6 @@ private:
wxDouble m_11, m_12, m_21, m_22, m_tx, m_ty;
};
#endif // wxUSE_GEOMETRY
#endif // _WX_AFFINEMATRIX2D_H_

View File

@ -11,6 +11,9 @@
#define _WX_AFFINEMATRIX2DBASE_H_
#include "wx/defs.h"
#if wxUSE_GEOMETRY
#include "wx/geometry.h"
struct wxMatrix2D
@ -37,7 +40,7 @@ class WXDLLIMPEXP_CORE wxAffineMatrix2DBase
public:
wxAffineMatrix2DBase() {}
virtual ~wxAffineMatrix2DBase() {}
// sets the matrix to the respective values
virtual void Set(const wxMatrix2D& mat2D, const wxPoint2DDouble& tr) = 0;
@ -119,4 +122,6 @@ protected:
wxPoint2DDouble DoTransformDistance(const wxPoint2DDouble& p) const = 0;
};
#endif // wxUSE_GEOMETRY
#endif // _WX_AFFINEMATRIX2DBASE_H_

View File

@ -14,6 +14,11 @@
#include "wx/defs.h"
#ifndef wxHAS_NATIVE_TAB_TRAVERSAL
// We need wxEVT_XXX declarations in this case.
#include "wx/event.h"
#endif
class WXDLLIMPEXP_FWD_CORE wxWindow;
class WXDLLIMPEXP_FWD_CORE wxWindowBase;
@ -116,9 +121,6 @@ protected:
#else // !wxHAS_NATIVE_TAB_TRAVERSAL
class WXDLLIMPEXP_FWD_CORE wxFocusEvent;
class WXDLLIMPEXP_FWD_CORE wxNavigationKeyEvent;
// ----------------------------------------------------------------------------
// wxControlContainer for TAB navigation implemented in wx itself
// ----------------------------------------------------------------------------
@ -166,13 +168,13 @@ public:
m_container.SetContainerWindow(this);
#ifndef wxHAS_NATIVE_TAB_TRAVERSAL
Connect(wxEVT_NAVIGATION_KEY,
BaseWindowClass::Connect(wxEVT_NAVIGATION_KEY,
wxNavigationKeyEventHandler(wxNavigationEnabled::OnNavigationKey));
Connect(wxEVT_SET_FOCUS,
BaseWindowClass::Connect(wxEVT_SET_FOCUS,
wxFocusEventHandler(wxNavigationEnabled::OnFocus));
Connect(wxEVT_CHILD_FOCUS,
BaseWindowClass::Connect(wxEVT_CHILD_FOCUS,
wxChildFocusEventHandler(wxNavigationEnabled::OnChildFocus));
#endif // !wxHAS_NATIVE_TAB_TRAVERSAL
}

View File

@ -395,41 +395,48 @@ private:
wxClientDataType m_clientDataItemsType;
};
// this macro must (unfortunately) be used in any class deriving from both
// wxItemContainer and wxControl because otherwise there is ambiguity when
// calling GetClientXXX() functions -- the compiler can't choose between the
// two versions
#define wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST \
void SetClientData(void *data) \
{ wxEvtHandler::SetClientData(data); } \
void *GetClientData() const \
{ return wxEvtHandler::GetClientData(); } \
void SetClientObject(wxClientData *data) \
{ wxEvtHandler::SetClientObject(data); } \
wxClientData *GetClientObject() const \
{ return wxEvtHandler::GetClientObject(); } \
void SetClientData(unsigned int n, void* clientData) \
{ wxItemContainer::SetClientData(n, clientData); } \
void* GetClientData(unsigned int n) const \
{ return wxItemContainer::GetClientData(n); } \
void SetClientObject(unsigned int n, wxClientData* clientData) \
{ wxItemContainer::SetClientObject(n, clientData); } \
wxClientData* GetClientObject(unsigned int n) const \
{ return wxItemContainer::GetClientObject(n); }
// Inheriting directly from a wxWindow-derived class and wxItemContainer
// unfortunately introduces an ambiguity for all GetClientXXX() methods as they
// are inherited twice: the "global" versions from wxWindow and the per-item
// versions taking the index from wxItemContainer.
//
// So we need to explicitly resolve them and this helper template class is
// provided to do it. To use it, simply inherit from wxWindowWithItems<Window,
// Container> instead of Window and Container interface directly.
template <class W, class C>
class wxWindowWithItems : public W, public C
{
public:
typedef W BaseWindowClass;
typedef C BaseContainerInterface;
class WXDLLIMPEXP_CORE wxControlWithItemsBase : public wxControl,
public wxItemContainer
wxWindowWithItems() { }
void SetClientData(void *data)
{ BaseWindowClass::SetClientData(data); }
void *GetClientData() const
{ return BaseWindowClass::GetClientData(); }
void SetClientObject(wxClientData *data)
{ BaseWindowClass::SetClientObject(data); }
wxClientData *GetClientObject() const
{ return BaseWindowClass::GetClientObject(); }
void SetClientData(unsigned int n, void* clientData)
{ wxItemContainer::SetClientData(n, clientData); }
void* GetClientData(unsigned int n) const
{ return wxItemContainer::GetClientData(n); }
void SetClientObject(unsigned int n, wxClientData* clientData)
{ wxItemContainer::SetClientObject(n, clientData); }
wxClientData* GetClientObject(unsigned int n) const
{ return wxItemContainer::GetClientObject(n); }
};
class WXDLLIMPEXP_CORE wxControlWithItemsBase :
public wxWindowWithItems<wxControl, wxItemContainer>
{
public:
wxControlWithItemsBase() { }
// we have to redefine these functions here to avoid ambiguities in classes
// deriving from us which would arise otherwise because both base classses
// have the methods with the same names - hopefully, a smart compiler can
// optimize away these simple inline wrappers so we don't suffer much from
// this
wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
// usually the controls like list/combo boxes have their own background
// colour
virtual bool ShouldInheritColours() const { return false; }

View File

@ -81,10 +81,11 @@ extern WXDLLIMPEXP_DATA_ADV(const char) wxDataViewCtrlNameStr[];
class WXDLLIMPEXP_ADV wxDataViewItem
{
public:
wxDataViewItem( void* id = NULL )
{ m_id = id; }
wxDataViewItem( const wxDataViewItem &item )
{ m_id = item.m_id; }
wxDataViewItem() : m_id(NULL) {}
wxDataViewItem(const wxDataViewItem &item) : m_id(item.m_id) {}
wxEXPLICIT wxDataViewItem(void* id) : m_id(id) {}
bool IsOk() const { return m_id != NULL; }
void* GetID() const { return m_id; }
operator const void* () const { return m_id; }

View File

@ -190,14 +190,6 @@ public:
virtual void StartEditor( const wxDataViewItem & item, unsigned int column );
protected:
virtual int GetSelections( wxArrayInt & sel ) const;
virtual void SetSelections( const wxArrayInt & sel );
virtual void Select( int row );
virtual void Unselect( int row );
virtual bool IsSelected( int row ) const;
virtual void SelectRange( int from, int to );
virtual void UnselectRange( int from, int to );
virtual void EnsureVisible( int row, int column );
virtual wxDataViewItem GetItemByRow( unsigned int row ) const;

View File

@ -32,6 +32,7 @@ protected:
void OnYes(wxCommandEvent& event);
void OnNo(wxCommandEvent& event);
void OnHelp(wxCommandEvent& event);
void OnCancel(wxCommandEvent& event);
// can be overridden to provide more contents to the dialog

View File

@ -40,6 +40,7 @@ private:
virtual wxString GetDefaultNoLabel() const;
virtual wxString GetDefaultOKLabel() const;
virtual wxString GetDefaultCancelLabel() const;
virtual wxString GetDefaultHelpLabel() const;
// create the real GTK+ dialog: this is done from ShowModal() to allow
// changing the message between constructing the dialog and showing it

View File

@ -167,6 +167,8 @@ protected:
virtual void DoSetValue(const wxString &value, int flags = 0);
virtual wxPoint DoPositionToCoords(long pos) const;
// wrappers hiding the differences between functions doing the same thing
// for GtkTextView and GtkEntry (all of them use current window style to
// set the given characteristic)

View File

@ -34,7 +34,8 @@ extern WXDLLIMPEXP_BASE const wxChar* wxEmptyString;
// wxComboBox
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxComboBox : public wxControl, public wxComboBoxBase
class WXDLLIMPEXP_CORE wxComboBox :
public wxWindowWithItems<wxControl, wxComboBoxBase>
{
public:
inline wxComboBox() {}
@ -154,8 +155,6 @@ public:
bool IsOwnGtkWindow( GdkWindow *window );
void DoApplyWidgetStyle(GtkRcStyle *style);
wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);

View File

@ -196,8 +196,8 @@ private:
#define wxHLB_DEFAULT_STYLE wxBORDER_SUNKEN
#define wxHLB_MULTIPLE wxLB_MULTIPLE
class WXDLLIMPEXP_HTML wxSimpleHtmlListBox : public wxHtmlListBox,
public wxItemContainer
class WXDLLIMPEXP_HTML wxSimpleHtmlListBox :
public wxWindowWithItems<wxHtmlListBox, wxItemContainer>
{
DECLARE_ABSTRACT_CLASS(wxSimpleHtmlListBox)
public:
@ -254,9 +254,6 @@ public:
int GetSelection() const
{ return wxVListBox::GetSelection(); }
// see ctrlsub.h for more info about this:
wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
// accessing strings
// -----------------

View File

@ -1097,15 +1097,15 @@ WXDLLIMPEXP_BASE class wxTextInputStream &operator>>(class wxTextInputStream &st
namespace std
{
template<> class numeric_limits<wxLongLong>
: public numeric_limits<wxLongLong_t>
{
};
template<> class numeric_limits<wxULongLong>
: public numeric_limits<wxULongLong_t>
{
};
#ifdef __clang__
// libstdc++ (used by Clang) uses struct for numeric_limits; unlike gcc, clang
// warns about this
template<> struct numeric_limits<wxLongLong> : public numeric_limits<wxLongLong_t> {};
template<> struct numeric_limits<wxULongLong> : public numeric_limits<wxULongLong_t> {};
#else
template<> class numeric_limits<wxLongLong> : public numeric_limits<wxLongLong_t> {};
template<> class numeric_limits<wxULongLong> : public numeric_limits<wxULongLong_t> {};
#endif
} // namespace std

View File

@ -176,6 +176,11 @@ public:
// level windows too
virtual bool IsTopLevel() const { return false; }
// In all ports keyboard navigation must stop at MDI child frame level and
// can't cross its boundary. Indicate this by overriding this function to
// return true.
virtual bool IsTopNavigationDomain() const { return true; }
protected:
wxMDIParentFrame *m_mdiParent;
};

View File

@ -177,10 +177,16 @@ public:
return true;
}
virtual bool SetHelpLabel(const ButtonLabel& help)
{
DoSetCustomLabel(m_help, help);
return true;
}
// test if any custom labels were set
bool HasCustomLabels() const
{
return !(m_ok.empty() && m_cancel.empty() &&
return !(m_ok.empty() && m_cancel.empty() && m_help.empty() &&
m_yes.empty() && m_no.empty());
}
@ -195,6 +201,8 @@ public:
{ return m_ok.empty() ? GetDefaultOKLabel() : m_ok; }
wxString GetCancelLabel() const
{ return m_cancel.empty() ? GetDefaultCancelLabel() : m_cancel; }
wxString GetHelpLabel() const
{ return m_help.empty() ? GetDefaultHelpLabel() : m_help; }
// based on message dialog style, returns exactly one of: wxICON_NONE,
// wxICON_ERROR, wxICON_WARNING, wxICON_QUESTION, wxICON_INFORMATION
@ -250,6 +258,7 @@ protected:
const wxString& GetCustomYesLabel() const { return m_yes; }
const wxString& GetCustomNoLabel() const { return m_no; }
const wxString& GetCustomOKLabel() const { return m_ok; }
const wxString& GetCustomHelpLabel() const { return m_help; }
const wxString& GetCustomCancelLabel() const { return m_cancel; }
private:
@ -259,13 +268,15 @@ private:
virtual wxString GetDefaultNoLabel() const { return wxGetTranslation("No"); }
virtual wxString GetDefaultOKLabel() const { return wxGetTranslation("OK"); }
virtual wxString GetDefaultCancelLabel() const { return wxGetTranslation("Cancel"); }
virtual wxString GetDefaultHelpLabel() const { return wxGetTranslation("Help"); }
// labels for the buttons, initially empty meaning that the defaults should
// be used, use GetYes/No/OK/CancelLabel() to access them
wxString m_yes,
m_no,
m_ok,
m_cancel;
m_cancel,
m_help;
wxDECLARE_NO_COPY_CLASS(wxMessageDialogBase);
};

View File

@ -61,6 +61,14 @@ public:
virtual void SetTitle(const wxString& title);
// MSW-only methods
// ----------------
// Create a new menu from the given native HMENU. Takes ownership of the
// menu handle and will delete it when this object is destroyed.
static wxMenu *MSWNewFromHMENU(WXHMENU hMenu) { return new wxMenu(hMenu); }
// implementation only from now on
// -------------------------------
@ -120,7 +128,14 @@ protected:
virtual wxMenuItem* DoRemove(wxMenuItem *item);
private:
// common part of all ctors
// This constructor is private, use MSWNewFromHMENU() to use it.
wxMenu(WXHMENU hMenu);
// Common part of all ctors, it doesn't create a new HMENU.
void InitNoCreate();
// Common part of all ctors except of the one above taking a native menu
// handler: calls InitNoCreate() and also creates a new menu.
void Init();
// common part of Append/Insert (behaves as Append is pos == (size_t)-1)

View File

@ -20,6 +20,7 @@
#include "wx/printdlg.h"
class WXDLLIMPEXP_FWD_CORE wxDC;
class WinPrinter;
//----------------------------------------------------------------------------
// wxWindowsPrintNativeData
@ -37,6 +38,7 @@ public:
virtual bool Ok() const { return IsOk(); }
virtual bool IsOk() const;
void InitializeDevMode(const wxString &printerName = wxEmptyString, WinPrinter* printer = NULL);
void* GetDevMode() const { return m_devMode; }
void SetDevMode(void* data) { m_devMode = data; }
void* GetDevNames() const { return m_devNames; }

View File

@ -30,8 +30,10 @@ namespace wxMSWMessageDialog
class wxMSWTaskDialogConfig
{
public:
enum { MAX_BUTTONS = 4 };
wxMSWTaskDialogConfig()
: buttons(new TASKDIALOG_BUTTON[3]),
: buttons(new TASKDIALOG_BUTTON[MAX_BUTTONS]),
parent(NULL),
iconId(0),
style(0),
@ -53,6 +55,7 @@ namespace wxMSWMessageDialog
wxString btnNoLabel;
wxString btnOKLabel;
wxString btnCancelLabel;
wxString btnHelpLabel;
// Will create a task dialog with it's paremeters for it's creation
// stored in the provided TASKDIALOGCONFIG parameter.

View File

@ -198,6 +198,8 @@ protected:
virtual void DoSetValue(const wxString &value, int flags = 0);
virtual wxPoint DoPositionToCoords(long pos) const;
// return true if this control has a user-set limit on amount of text (i.e.
// the limit is due to a previous call to SetMaxLength() and not built in)
bool HasSpaceLimit(unsigned int *len) const;

View File

@ -77,6 +77,19 @@ public:
virtual bool CanSetTransparent();
// MSW-specific methods
// --------------------
// Return the menu representing the "system" menu of the window. You can
// call wxMenu::AppendWhatever() methods on it but removing items from it
// is in general not a good idea.
//
// The pointer returned by this method belongs to the window and will be
// deleted when the window itself is, do not delete it yourself. May return
// NULL if getting the system menu failed.
wxMenu *MSWGetSystemMenu() const;
// implementation from now on
// --------------------------
@ -214,6 +227,10 @@ private:
void* m_activateInfo;
#endif
// The system menu: initially NULL but can be set (once) by
// MSWGetSystemMenu(). Owned by this window.
wxMenu *m_menuSystem;
DECLARE_EVENT_TABLE()
wxDECLARE_NO_COPY_CLASS(wxTopLevelWindowMSW);
};

View File

@ -233,15 +233,15 @@ private:
// the wxComboCtrl.
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxOwnerDrawnComboBox : public wxComboCtrl,
public wxItemContainer
class WXDLLIMPEXP_ADV wxOwnerDrawnComboBox :
public wxWindowWithItems<wxComboCtrl, wxItemContainer>
{
//friend class wxComboPopupWindow;
friend class wxVListBoxComboPopup;
public:
// ctors and such
wxOwnerDrawnComboBox() : wxComboCtrl() { Init(); }
wxOwnerDrawnComboBox() { Init(); }
wxOwnerDrawnComboBox(wxWindow *parent,
wxWindowID id,
@ -253,7 +253,6 @@ public:
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr)
: wxComboCtrl()
{
Init();
@ -339,8 +338,6 @@ public:
virtual bool IsSorted() const { return HasFlag(wxCB_SORT); }
wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
protected:
virtual void DoClear();
virtual void DoDeleteOneItem(unsigned int n);

View File

@ -122,7 +122,10 @@ public:
virtual short MacHandleAEQuit(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
virtual short MacHandleAERApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
#endif
// in response of an open-document apple event
// in response of an openFiles message with Cocoa and an
// open-document apple event with Carbon
virtual void MacOpenFiles(const wxArrayString &fileNames) ;
// called by MacOpenFiles for each file.
virtual void MacOpenFile(const wxString &fileName) ;
// in response of a get-url apple event
virtual void MacOpenURL(const wxString &url) ;

View File

@ -26,12 +26,13 @@ class wxComboWidgetImpl;
// Combobox item
class WXDLLIMPEXP_CORE wxComboBox :
public wxWindowWithItems<
#if wxOSX_USE_CARBON
public wxNavigationEnabled<wxControl>,
wxNavigationEnabled<wxControl>,
#else
public wxControl,
wxControl,
#endif
public wxComboBoxBase
wxComboBoxBase>
{
DECLARE_DYNAMIC_CLASS(wxComboBox)
@ -144,10 +145,6 @@ class WXDLLIMPEXP_CORE wxComboBox :
virtual bool OSXHandleClicked( double timestampsec );
#if wxOSX_USE_CARBON
wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
#endif
#if wxOSX_USE_COCOA
wxComboWidgetImpl* GetComboPeer() const;
#endif

View File

@ -56,6 +56,7 @@ private:
bool GetMimeTypes(const wxString& uti, wxArrayString& mimeTypes);
bool GetIcon(const wxString& uti, wxIconLocation *iconLoc);
bool GetDescription(const wxString& uti, wxString *desc);
bool GetApplication(const wxString& uti, wxString *command);
// Structure to represent file types
typedef struct FileTypeData
@ -63,6 +64,7 @@ private:
wxArrayString extensions;
wxArrayString mimeTypes;
wxIconLocation iconLoc;
wxString application;
wxString description;
}
FileTypeInfo;
@ -95,9 +97,9 @@ public:
bool GetMimeTypes(wxArrayString& mimeTypes) const ;
bool GetIcon(wxIconLocation *iconLoc) const ;
bool GetDescription(wxString *desc) const ;
bool GetOpenCommand(wxString *openCmd, const wxFileType::MessageParameters& params) const;
// These functions are only stubs on Mac OS X
bool GetOpenCommand(wxString *openCmd, const wxFileType::MessageParameters& params) const;
bool GetPrintCommand(wxString *printCmd, const wxFileType::MessageParameters& params) const;
size_t GetAllCommands(wxArrayString *verbs, wxArrayString *commands, const wxFileType::MessageParameters& params) const;
bool SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt = TRUE);

View File

@ -43,7 +43,7 @@ protected:
void* ConstructNSAlert();
#endif
int m_buttonId[3];
int m_buttonId[4];
int m_buttonCount;
#if wxOSX_USE_COCOA

View File

@ -134,7 +134,9 @@ public:
wxComboBox* m_styleCtrl;
wxComboBox* m_weightCtrl;
wxComboBox* m_underliningCtrl;
wxCheckBox* m_textColourLabel;
wxRichTextColourSwatchCtrl* m_colourCtrl;
wxCheckBox* m_bgColourLabel;
wxRichTextColourSwatchCtrl* m_bgColourCtrl;
wxCheckBox* m_strikethroughCtrl;
wxCheckBox* m_capitalsCtrl;
@ -151,7 +153,9 @@ public:
ID_RICHTEXTFONTPAGE_STYLECTRL = 10007,
ID_RICHTEXTFONTPAGE_WEIGHTCTRL = 10004,
ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL = 10008,
ID_RICHTEXTFONTPAGE_COLOURCTRL_LABEL = 10015,
ID_RICHTEXTFONTPAGE_COLOURCTRL = 10009,
ID_RICHTEXTFONTPAGE_BGCOLOURCTRL_LABEL = 10016,
ID_RICHTEXTFONTPAGE_BGCOLOURCTRL = 10014,
ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL = 10010,
ID_RICHTEXTFONTPAGE_CAPSCTRL = 10011,

View File

@ -141,6 +141,7 @@ public:
wxTextCtrl* m_spacingBefore;
wxTextCtrl* m_spacingAfter;
wxComboBox* m_spacingLine;
wxCheckBox* m_pageBreakCtrl;
wxRichTextCtrl* m_previewCtrl;
/// Control identifiers
enum {
@ -157,6 +158,7 @@ public:
ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE = 10114,
ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER = 10116,
ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE = 10115,
ID_RICHTEXTINDENTSSPACINGPAGE_PAGEBREAK = 10106,
ID_RICHTEXTINDENTSSPACINGPAGE_PREVIEW_CTRL = 10109
};
////@end wxRichTextIndentsSpacingPage member variables

View File

@ -574,6 +574,11 @@ public:
virtual long XYToPosition(long x, long y) const = 0;
virtual bool PositionToXY(long pos, long *x, long *y) const = 0;
// translate the given position (which is just an index in the text control)
// to client coordinates
wxPoint PositionToCoords(long pos) const;
virtual void ShowPosition(long pos) = 0;
// find the character at position given in pixels
@ -592,6 +597,13 @@ protected:
virtual bool DoLoadFile(const wxString& file, int fileType);
virtual bool DoSaveFile(const wxString& file, int fileType);
// Return true if the given position is valid, i.e. positive and less than
// the last position.
virtual bool IsValidPosition(long pos) const = 0;
// Default stub implementation of PositionToCoords() always returns
// wxDefaultPosition.
virtual wxPoint DoPositionToCoords(long pos) const;
// the name of the last file loaded with LoadFile() which will be used by
// SaveFile() by default
@ -625,6 +637,12 @@ public:
wxTextEntryBase::SetValue(value);
}
protected:
virtual bool IsValidPosition(long pos) const
{
return pos >= 0 && pos <= GetLastPosition();
}
private:
wxDECLARE_NO_COPY_CLASS(wxTextCtrlIface);
};
@ -723,6 +741,12 @@ protected:
virtual bool DoLoadFile(const wxString& file, int fileType);
virtual bool DoSaveFile(const wxString& file, int fileType);
// Another wxTextAreaBase override.
virtual bool IsValidPosition(long pos) const
{
return pos >= 0 && pos <= GetLastPosition();
}
// implement the wxTextEntry pure virtual method
virtual wxWindow *GetEditableWindow() { return this; }

View File

@ -282,6 +282,7 @@ public:
// override some base class virtuals
virtual bool Destroy();
virtual bool IsTopLevel() const { return true; }
virtual bool IsTopNavigationDomain() const { return true; }
virtual bool IsVisible() const { return IsShown(); }
// event handlers

View File

@ -34,7 +34,8 @@ class WXDLLIMPEXP_FWD_CORE wxListBox;
// NB: Normally we'd like wxComboBox to inherit from wxComboBoxBase, but here
// we can't really do that since both wxComboBoxBase and wxComboCtrl inherit
// from wxTextCtrl.
class WXDLLIMPEXP_CORE wxComboBox : public wxComboCtrl, public wxItemContainer
class WXDLLIMPEXP_CORE wxComboBox :
public wxWindowWithItems<wxComboCtrl, wxItemContainer>
{
public:
// ctors and such
@ -141,8 +142,6 @@ public:
virtual int GetSelection() const;
virtual wxString GetStringSelection() const;
wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
// we have our own input handler and our own actions
// (but wxComboCtrl already handled Popup/Dismiss)
/*

View File

@ -1422,6 +1422,15 @@ public:
virtual wxWindow *GetMainWindowOfCompositeControl()
{ return (wxWindow*)this; }
// If this function returns true, keyboard navigation events shouldn't
// escape from it. A typical example of such "navigation domain" is a top
// level window because pressing TAB in one of them must not transfer focus
// to a different top level window. But it's not limited to them, e.g. MDI
// children frames are not top level windows (and their IsTopLevel()
// returns false) but still are self-contained navigation domains as well.
virtual bool IsTopNavigationDomain() const { return false; }
protected:
// helper for the derived class Create() methods: the first overload, with
// validator parameter, should be used for child windows while the second

View File

@ -467,7 +467,7 @@ WX_STRCMP_FUNC(wxStricmp, wxCRT_StricmpA, wxCRT_StricmpW, wxStricmp_String)
// forward-declare the template and implement it below WX_STRCMP_FUNC. OTOH,
// this fails to compile with VC6, so don't do it for VC. It also causes
// problems with GCC visibility in newer GCC versions.
#if !(defined(__VISUALC__) || wxCHECK_GCC_VERSION(3,5)) || defined(__clang__)
#if !(defined(__VISUALC__) || (wxCHECK_GCC_VERSION(3,5) && !wxCHECK_GCC_VERSION(4,7))) || defined(__clang__)
#define wxNEEDS_DECL_BEFORE_TEMPLATE
#endif

View File

@ -228,11 +228,17 @@ public:
/**
Returns the i-th frame as a wxImage.
This method is not implemented in the native wxGTK implementation of
this class and always returns an invalid image there.
*/
virtual wxImage GetFrame(unsigned int i) const;
/**
Returns the number of frames for this animation.
This method is not implemented in the native wxGTK implementation of
this class and always returns 0 there.
*/
virtual unsigned int GetFrameCount() const;

View File

@ -569,7 +569,7 @@ public:
Under Windows and Linux/Unix, you should parse the command line
arguments and check for files to be opened when starting your
application. Under OS X, you need to override MacOpenFile()
application. Under OS X, you need to override MacOpenFiles()
since command line arguments are used differently there.
You may use the wxCmdLineParser to parse command line arguments.
@ -802,16 +802,35 @@ public:
*/
virtual void MacNewFile();
/**
Called in response of an openFiles message with Cocoa, or an
"open-document" Apple event with Carbon.
You need to override this method in order to open one or more document
files after the user double clicked on it or if the files and/or
folders were dropped on either the application in the dock or the
application icon in Finder.
By default this method calls MacOpenFile for each file/folder.
@onlyfor{wxosx}
@since 2.9.3
*/
virtual void MacOpenFiles(const wxArrayString& fileNames);
/**
Called in response of an "open-document" Apple event.
You need to override this method in order to open a document file after the
user double clicked on it or if the document file was dropped on either the
running application or the application icon in Finder.
@deprecated
This function is kept mostly for backwards compatibility. Please
override wxApp::MacOpenFiles method instead in any new code.
@onlyfor{wxosx}
*/
virtual void MacOpenFile(const wxString& fileName);
wxDEPRECATED_BUT_USED_INTERNALLY(
virtual void MacOpenFile(const wxString& fileName)
);
/**
Called in response of a "get-url" Apple event.

View File

@ -421,7 +421,7 @@ public:
unsigned int col) const;
/**
Returns the number of items (i.e. rows) in the list.
Returns the number of items (or rows) in the list.
*/
unsigned int GetCount() const;
@ -614,8 +614,9 @@ public:
/**
Constructor.
*/
wxDataViewItem(void* id = NULL);
wxDataViewItem();
wxDataViewItem(const wxDataViewItem& item);
explicit wxDataViewItem(void* id);
//@}
/**

View File

@ -22,6 +22,12 @@
Puts Yes and No buttons in the message box. It is recommended to always
use @c wxCANCEL with this style as otherwise the message box won't have
a close button under wxMSW and the user will be forced to answer it.
@style{wxHELP}
Puts a Help button to the message box. This button can have special
appearance or be specially positioned if its label is not changed from
the default one. Notice that using this button is not supported when
showing a message box from non-main thread in wxOSX/Cocoa and it is not
supported in wxOSX/Carbon at all. @since 2.9.3.
@style{wxNO_DEFAULT}
Makes the "No" button default, can only be used with @c wxYES_NO.
@style{wxCANCEL_DEFAULT}
@ -116,6 +122,19 @@ public:
*/
virtual void SetExtendedMessage(const wxString& extendedMessage);
/**
Sets the label for the Help button.
Please see the remarks in SetYesNoLabels() documentation.
Notice that changing the label of the help button resets its special
status (if any, this depends on the platform) and it will be treated
just like another button in this case.
@since 2.9.3
*/
virtual bool SetHelpLabel(const ButtonLabel& help);
/**
Sets the message shown by the dialog.
@ -190,7 +209,8 @@ public:
virtual bool SetYesNoLabels(const ButtonLabel& yes, const ButtonLabel& no);
/**
Shows the dialog, returning one of wxID_OK, wxID_CANCEL, wxID_YES, wxID_NO.
Shows the dialog, returning one of wxID_OK, wxID_CANCEL, wxID_YES,
wxID_NO or wxID_HELP.
Notice that this method returns the identifier of the button which was
clicked unlike wxMessageBox() function.
@ -215,9 +235,9 @@ public:
extended text and custom labels for the message box buttons, are not
provided by this function but only by wxMessageDialog.
The return value is one of: @c wxYES, @c wxNO, @c wxCANCEL or @c wxOK
(notice that this return value is @b different from the return value of
wxMessageDialog::ShowModal()).
The return value is one of: @c wxYES, @c wxNO, @c wxCANCEL, @c wxOK or @c
wxHELP (notice that this return value is @b different from the return value
of wxMessageDialog::ShowModal()).
For example:
@code

View File

@ -12,6 +12,13 @@
wxStandardPaths returns the standard locations in the file system and should be
used by applications to find their data files in a portable way.
Note that you must not create objects of class wxStandardPaths directly,
but use the global standard paths object returned by wxStandardPaths::Get()
(which can be of a type derived from wxStandardPaths and not of exactly
this type) and call the methods you need on it. The object returned by
Get() may be customized by overriding wxAppTraits::GetStandardPaths()
methods.
In the description of the methods below, the example return values are given
for the Unix, Windows and Mac OS X systems, however please note that these are
just the examples and the actual values may differ. For example, under Windows:
@ -42,10 +49,6 @@
This class is MT-safe: its methods may be called concurrently from different
threads without additional locking.
Note that you don't allocate an instance of class wxStandardPaths, but retrieve the
global standard paths object using @c wxStandardPaths::Get on which you call the
desired methods.
@library{wxbase}
@category{file}

View File

@ -220,11 +220,6 @@ public:
bool Apply(const wxTextAttr& style,
const wxTextAttr* compareWith = NULL);
/**
Creates a font from the font attributes.
*/
wxFont CreateFont() const;
/**
Copies all defined/valid properties from overlay to current object.
*/
@ -1197,19 +1192,15 @@ public:
/**
Returns the number of lines in the text control buffer.
The returned number is the number of logical lines, i.e. just the count
of the number of newline characters in the control + 1, for wxGTK and
wxOSX/Cocoa ports while it is the number of physical lines, i.e. the
count of lines actually shown in the control, in wxMSW and wxOSX/Carbon.
Because of this discrepancy, it is not recommended to use this function.
@remarks
Note that even empty text controls have one line (where the
insertion point is), so GetNumberOfLines() never returns 0.
For wxGTK using GTK+ 1.2.x and earlier, the number of lines in a
multi-line text control is calculated by actually counting newline
characters in the buffer, i.e. this function returns the number of
logical lines and doesn't depend on whether any of them are wrapped.
For all the other platforms, the number of physical lines in the
control is returned.
Also note that you may wish to avoid using functions that work with
line numbers if you are working with controls that contain large
amounts of text as this function has O(N) complexity for N being
the number of lines.
*/
virtual int GetNumberOfLines() const;
@ -1348,6 +1339,28 @@ public:
*/
virtual bool PositionToXY(long pos, long* x, long* y) const;
/**
Converts given text position to client coordinates in pixels.
This function allows to find where is the character at the given
position displayed in the text control.
@onlyfor{wxmsw,wxgtk}. Additionally, wxGTK only implements this method
for multiline controls and ::wxDefaultPosition is always returned for
the single line ones.
@param pos
Text position in 0 to GetLastPosition() range (inclusive).
@return
On success returns a wxPoint which contains client coordinates for
the given position in pixels, otherwise returns ::wxDefaultPosition.
@since 2.9.3
@see XYToPosition(), PositionToXY()
*/
wxPoint PositionToCoords(long pos) const;
/**
Saves the contents of the control in a text file.

View File

@ -262,6 +262,33 @@ public:
*/
virtual void Maximize(bool maximize = true);
/**
MSW-specific function for accessing the system menu.
Returns a wxMenu pointer representing the system menu of the window
under MSW. The returned wxMenu may be used, if non-@c NULL, to add
extra items to the system menu. The usual @c wxEVT_COMMAND_MENU_SELECTED
events (that can be processed using @c EVT_MENU event table macro) will
then be generated for them. All the other wxMenu methods may be used as
well but notice that they won't allow you to access any standard system
menu items (e.g. they can't be deleted or modified in any way
currently).
Notice that because of the native system limitations the identifiers of
the items added to the system menu must be multiples of 16, otherwise
no events will be generated for them.
The returned pointer must @em not be deleted, it is owned by the window
and will be only deleted when the window itself is destroyed.
This function is not available in the other ports by design, any
occurrences of it in the portable code must be guarded by @code #ifdef
__WXMSW__ @endcode preprocessor guards.
@since 2.9.3
*/
wxMenu *MSWGetSystemMenu() const;
/**
Use a system-dependent way to attract users attention to the window when
it is in background.

View File

@ -648,6 +648,24 @@ MyFrame::MyFrame(const wxString& title)
// covers our entire client area to avoid jarring colour jumps
SetOwnBackgroundColour(m_canvas->GetBackgroundColour());
#endif // wxUSE_INFOBAR
#ifdef __WXMSW__
// Test MSW-specific function allowing to access the "system" menu.
wxMenu * const menu = MSWGetSystemMenu();
if ( menu )
{
menu->AppendSeparator();
// The ids of the menu commands in MSW system menu must be multiple of
// 16 so we can't use DIALOGS_ABOUTDLG_SIMPLE here because it might not
// satisfy this condition and need to define and connect a separate id.
static const int DIALOGS_SYSTEM_ABOUT = 0x4010;
menu->Append(DIALOGS_SYSTEM_ABOUT, "&About...");
Connect(DIALOGS_SYSTEM_ABOUT, wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(MyFrame::ShowSimpleAboutDialog));
}
#endif // __WXMSW__
}
MyFrame::~MyFrame()
@ -2669,6 +2687,7 @@ const TestMessageBoxDialog::BtnInfo TestMessageBoxDialog::ms_btnInfo[] =
{ wxNO, "&No" },
{ wxOK, "&Ok" },
{ wxCANCEL, "&Cancel" },
{ wxHELP, "&Help" },
};
BEGIN_EVENT_TABLE(TestMessageBoxDialog, wxDialog)
@ -2889,6 +2908,11 @@ void TestMessageBoxDialog::PrepareMessageDialog(wxMessageDialogBase &dlg)
dlg.SetOKLabel(m_labels[Btn_Ok]->GetValue());
}
}
if ( style & wxHELP )
{
dlg.SetHelpLabel(m_labels[Btn_Help]->GetValue());
}
}
void TestMessageBoxDialog::OnApply(wxCommandEvent& WXUNUSED(event))
@ -2896,7 +2920,34 @@ void TestMessageBoxDialog::OnApply(wxCommandEvent& WXUNUSED(event))
wxMessageDialog dlg(this, GetMessage(), "Test Message Box", GetStyle());
PrepareMessageDialog(dlg);
dlg.ShowModal();
wxString btnName;
switch ( dlg.ShowModal() )
{
case wxID_OK:
btnName = "OK";
break;
case wxID_CANCEL:
// Avoid the extra message box if the dialog was cancelled.
return;
case wxID_YES:
btnName = "Yes";
break;
case wxID_NO:
btnName = "No";
break;
case wxID_HELP:
btnName = "Help";
break;
default:
btnName = "Unknown";
}
wxLogMessage("Dialog was closed with the \"%s\" button.", btnName);
}
void TestMessageBoxDialog::OnClose(wxCommandEvent& WXUNUSED(event))

View File

@ -228,6 +228,7 @@ private:
Btn_No,
Btn_Ok,
Btn_Cancel,
Btn_Help,
Btn_Max
};

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: printing.cpp
// Name: helpview.cpp
// Purpose: wxHtml sample: help browser
// Author: ?
// Modified by:

View File

@ -143,7 +143,7 @@ class wxMediaPlayerApp : public wxApp
{
public:
#ifdef __WXMAC__
virtual void MacOpenFile(const wxString & fileName );
virtual void MacOpenFiles(const wxArrayString & fileNames );
#endif
virtual bool OnInit();
@ -463,10 +463,10 @@ bool wxMediaPlayerApp::OnInit()
#ifdef __WXMAC__
void wxMediaPlayerApp::MacOpenFile(const wxString & fileName )
void wxMediaPlayerApp::MacOpenFiles(const wxArrayString & fileNames )
{
// Called when a user drags a file over our app
m_frame->DoOpenFile(fileName, true /* new page */);
// Called when a user drags files over our app
m_frame->DoOpenFile(fileNames[0], true /* new page */);
}
#endif // __WXMAC__

View File

@ -128,6 +128,7 @@ public:
void DoSelectText();
void DoMoveToEndOfText();
void DoMoveToEndOfEntry();
void DoGetWindowCoordinates();
// return true if currently text control has any selection
bool HasSelection() const
@ -217,6 +218,10 @@ public:
void OnMoveToEndOfText( wxCommandEvent& WXUNUSED(event) )
{ m_panel->DoMoveToEndOfText(); }
void OnGetWindowCoordinates( wxCommandEvent& WXUNUSED(event) )
{ m_panel->DoGetWindowCoordinates(); }
void OnMoveToEndOfEntry( wxCommandEvent& WXUNUSED(event) )
{ m_panel->DoMoveToEndOfEntry(); }
@ -415,6 +420,7 @@ enum
TEXT_ADD_FREEZE,
TEXT_ADD_LINE,
TEXT_MOVE_ENDTEXT,
TEXT_GET_WINDOW_COORD,
TEXT_MOVE_ENDENTRY,
TEXT_SET_EDITABLE,
TEXT_SET_ENABLED,
@ -513,6 +519,7 @@ bool MyApp::OnInit()
menuText->Append(TEXT_LINE_UP, wxT("Scroll text one line up"));
menuText->Append(TEXT_PAGE_DOWN, wxT("Scroll text one page down"));
menuText->Append(TEXT_PAGE_UP, wxT("Scroll text one page up"));
menuText->Append(TEXT_GET_WINDOW_COORD, wxT("Get window coordinates"));
menuText->AppendSeparator();
menuText->Append(TEXT_GET_LINE, wxT("Get the text of a line of the tabbed multiline"));
menuText->Append(TEXT_GET_LINELENGTH, wxT("Get the length of a line of the tabbed multiline"));
@ -1318,6 +1325,18 @@ void MyPanel::DoMoveToEndOfText()
m_multitext->SetFocus();
}
void MyPanel::DoGetWindowCoordinates()
{
wxTextCtrl * const text = GetFocusedText();
const wxPoint pt0 = text->PositionToCoords(0);
const wxPoint ptCur = text->PositionToCoords(text->GetInsertionPoint());
*m_log << "Current position coordinates: "
"(" << ptCur.x << ", " << ptCur.y << "), "
"first position coordinates: "
"(" << pt0.x << ", " << pt0.y << ")\n";
}
void MyPanel::DoMoveToEndOfEntry()
{
m_text->SetInsertionPointEnd();
@ -1380,6 +1399,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(TEXT_ADD_FREEZE, MyFrame::OnAddTextFreeze)
EVT_MENU(TEXT_ADD_LINE, MyFrame::OnAddTextLine)
EVT_MENU(TEXT_MOVE_ENDTEXT, MyFrame::OnMoveToEndOfText)
EVT_MENU(TEXT_GET_WINDOW_COORD, MyFrame::OnGetWindowCoordinates)
EVT_MENU(TEXT_MOVE_ENDENTRY, MyFrame::OnMoveToEndOfEntry)
EVT_MENU(TEXT_SET_EDITABLE, MyFrame::OnSetEditable)

View File

@ -307,7 +307,7 @@ wxString wxAcceleratorEntry::ToString() const
int flags = GetFlags();
if ( flags & wxACCEL_ALT )
text += _("Alt+");
if ( flags & wxACCEL_CTRL )
if ( flags & (wxACCEL_CTRL | wxACCEL_CMD) )
text += _("Ctrl+");
if ( flags & wxACCEL_SHIFT )
text += _("Shift+");

View File

@ -13,6 +13,8 @@
#pragma hdrstop
#endif
#if wxUSE_GEOMETRY
#include "wx/affinematrix2d.h"
#include "wx/math.h"
@ -177,3 +179,5 @@ bool wxAffineMatrix2D::IsIdentity() const
m_21 == 0 && m_22 == 1 &&
m_tx == 0 && m_ty == 0;
}
#endif // wxUSE_GEOMETRY

View File

@ -472,18 +472,21 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event )
// looping inside this panel (normally, the focus will go to
// the next/previous item after this panel in the parent
// panel).
wxWindow *focussed_child_of_parent = m_winParent;
wxWindow *focusedParent = m_winParent;
while ( parent )
{
// we don't want to tab into a different dialog or frame
if ( focussed_child_of_parent->IsTopLevel() )
// We don't want to tab into a different dialog or frame or
// even an MDI child frame, so test for this explicitly
// (and in particular don't just use IsTopLevel() which
// would return false in the latter case).
if ( focusedParent->IsTopNavigationDomain() )
break;
event.SetCurrentFocus( focussed_child_of_parent );
event.SetCurrentFocus( focusedParent );
if ( parent->GetEventHandler()->ProcessEvent( event ) )
return;
focussed_child_of_parent = parent;
focusedParent = parent;
parent = parent->GetParent();
}

View File

@ -387,7 +387,7 @@ wxDataViewIndexListModel::wxDataViewIndexListModel( unsigned int initial_size )
// build initial index
unsigned int i;
for (i = 1; i < initial_size+1; i++)
m_hash.Add( wxUIntToPtr(i) );
m_hash.Add( wxDataViewItem(wxUIntToPtr(i)) );
m_nextFreeID = initial_size + 1;
}
@ -403,7 +403,7 @@ void wxDataViewIndexListModel::Reset( unsigned int new_size )
// build initial index
unsigned int i;
for (i = 1; i < new_size+1; i++)
m_hash.Add( wxUIntToPtr(i) );
m_hash.Add( wxDataViewItem(wxUIntToPtr(i)) );
m_nextFreeID = new_size + 1;
@ -417,8 +417,8 @@ void wxDataViewIndexListModel::RowPrepended()
unsigned int id = m_nextFreeID;
m_nextFreeID++;
m_hash.Insert( wxUIntToPtr(id), 0 );
wxDataViewItem item( wxUIntToPtr(id) );
m_hash.Insert( item, 0 );
ItemAdded( wxDataViewItem(0), item );
}
@ -430,8 +430,8 @@ void wxDataViewIndexListModel::RowInserted( unsigned int before )
unsigned int id = m_nextFreeID;
m_nextFreeID++;
m_hash.Insert( wxUIntToPtr(id), before );
wxDataViewItem item( wxUIntToPtr(id) );
m_hash.Insert( item, before );
ItemAdded( wxDataViewItem(0), item );
}
@ -440,8 +440,8 @@ void wxDataViewIndexListModel::RowAppended()
unsigned int id = m_nextFreeID;
m_nextFreeID++;
m_hash.Add( wxUIntToPtr(id) );
wxDataViewItem item( wxUIntToPtr(id) );
m_hash.Add( item );
ItemAdded( wxDataViewItem(0), item );
}
@ -490,7 +490,7 @@ unsigned int wxDataViewIndexListModel::GetRow( const wxDataViewItem &item ) cons
return wxPtrToUInt(item.GetID())-1;
// assert for not found
return (unsigned int) m_hash.Index( item.GetID() );
return (unsigned int) m_hash.Index( item );
}
wxDataViewItem wxDataViewIndexListModel::GetItem( unsigned int row ) const
@ -2005,7 +2005,7 @@ wxDataViewItem wxDataViewTreeStore::GetNthChild( const wxDataViewItem& parent, u
wxDataViewTreeStoreNodeList::compatibility_iterator node = parent_node->GetChildren().Item( pos );
if (node)
return node->GetData();
return wxDataViewItem(node->GetData());
return wxDataViewItem(0);
}
@ -2111,7 +2111,7 @@ void wxDataViewTreeStore::DeleteChildren( const wxDataViewItem& item )
void wxDataViewTreeStore::DeleteAllItems()
{
DeleteChildren(m_root);
DeleteChildren(wxDataViewItem(m_root));
}
void

View File

@ -35,6 +35,7 @@
#ifndef WX_PRECOMP
#include "wx/math.h"
#include "wx/module.h"
#include "wx/window.h"
#endif
#ifdef __WXMSW__

View File

@ -358,6 +358,9 @@ void name::insert(iterator it, const_iterator first, const_iterator last) \
return; \
Grow(nInsert); \
\
/* old iterator could have been invalidated by Grow(). */ \
it = begin() + nIndex; \
\
memmove(&m_pItems[nIndex + nInsert], &m_pItems[nIndex], \
(m_nCount - nIndex)*sizeof(T)); \
for (size_t i = 0; i < nInsert; ++i, ++it, ++first) \

View File

@ -1297,17 +1297,31 @@ wxSocketEventFlags wxSocketImpl::Select(wxSocketEventFlags flags,
exceptfds; // always want to know about errors
if ( flags & wxSOCKET_INPUT_FLAG )
{
preadfds = &readfds;
if ( flags & wxSOCKET_OUTPUT_FLAG )
pwritefds = &writefds;
// When using non-blocking connect() the client socket becomes connected
// (successfully or not) when it becomes writable but when using
// non-blocking accept() the server socket becomes connected when it
// becomes readable.
if ( flags & wxSOCKET_CONNECTION_FLAG )
{
if ( m_server )
preadfds = &readfds;
else
pwritefds = &writefds;
}
if ( preadfds )
{
wxFD_ZERO(preadfds);
wxFD_SET(m_fd, preadfds);
}
// when using non-blocking connect() the socket becomes connected
// (successfully or not) when it becomes writable
if ( flags & (wxSOCKET_OUTPUT_FLAG | wxSOCKET_CONNECTION_FLAG) )
if ( pwritefds )
{
pwritefds = &writefds;
wxFD_ZERO(pwritefds);
wxFD_SET(m_fd, pwritefds);
}

View File

@ -1084,6 +1084,19 @@ wxTextAreaBase::HitTest(const wxPoint& WXUNUSED(pt), long * WXUNUSED(pos)) const
return wxTE_HT_UNKNOWN;
}
wxPoint wxTextAreaBase::PositionToCoords(long pos) const
{
wxCHECK_MSG( IsValidPosition(pos), wxDefaultPosition,
wxS("Position argument out of range.") );
return DoPositionToCoords(pos);
}
wxPoint wxTextAreaBase::DoPositionToCoords(long WXUNUSED(pos)) const
{
return wxDefaultPosition;
}
#else // !wxUSE_TEXTCTRL
// define this one even if !wxUSE_TEXTCTRL because it is also used by other

View File

@ -1361,6 +1361,8 @@ int wxMessageBox(const wxString& message, const wxString& caption, long style,
return wxNO;
case wxID_CANCEL:
return wxCANCEL;
case wxID_HELP:
return wxHELP;
}
wxFAIL_MSG( wxT("unexpected return code from wxMessageDialog") );

View File

@ -388,6 +388,21 @@ public:
}
}
// returns node corresponding to 'item' if its in m_nodes or NULL otherwise
wxDataViewTreeNode *FindItemAsNode(const wxDataViewItem& item) const
{
for ( wxDataViewTreeNodes::const_iterator i = m_nodes.begin();
i != m_nodes.end();
++i )
{
if( (*i)->GetItem() == item )
return *i;
}
return NULL;
}
private:
wxDataViewTreeNode *m_parent;
wxDataViewTreeNodes m_nodes;
@ -406,7 +421,7 @@ int LINKAGEMODE wxGenericTreeModelNodeCmp( wxDataViewTreeNode ** node1,
int LINKAGEMODE wxGenericTreeModelItemCmp( void ** id1, void ** id2)
{
return g_model->Compare( *id1, *id2, g_column, g_asending );
return g_model->Compare( wxDataViewItem(*id1), wxDataViewItem(*id2), g_column, g_asending );
}
@ -414,10 +429,7 @@ int LINKAGEMODE wxGenericTreeModelItemCmp( void ** id1, void ** id2)
// wxDataViewMainWindow
//-----------------------------------------------------------------------------
WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_SIZE_T(unsigned int, wxDataViewSelection,
WXDLLIMPEXP_ADV);
WX_DECLARE_LIST(wxDataViewItem, ItemList);
WX_DEFINE_LIST(ItemList)
WX_DEFINE_SORTED_ARRAY_SIZE_T(unsigned int, wxDataViewSelection);
class wxDataViewMainWindow: public wxWindow
{
@ -2009,70 +2021,112 @@ bool wxDataViewMainWindow::ItemDeleted(const wxDataViewItem& parent,
(wxDataViewVirtualListModel*) GetOwner()->GetModel();
m_count = list_model->GetCount();
if( m_currentRow > GetRowCount() )
m_currentRow = m_count - 1;
// TODO: why empty the entire selection?
m_selection.Empty();
UpdateDisplay();
return true;
}
wxDataViewTreeNode * node = FindNode(parent);
// Notice that it is possible that the item being deleted is not in the
// tree at all, for example we could be deleting a never shown (because
// collapsed) item in a tree model. So it's not an error if we don't know
// about this item, just return without doing anything then.
if ( !node || node->GetChildren().Index(item.GetID()) == wxNOT_FOUND )
return false;
int sub = -1;
node->GetChildren().Remove( item.GetID() );
// Manipolate selection
if( m_selection.GetCount() > 1 )
{
m_selection.Empty();
}
bool isContainer = false;
wxDataViewTreeNodes nds = node->GetNodes();
for (size_t i = 0; i < nds.GetCount(); i ++)
{
if (nds[i]->GetItem() == item)
if ( !m_selection.empty() )
{
isContainer = true;
break;
}
}
if( isContainer )
{
wxDataViewTreeNode * n = NULL;
wxDataViewTreeNodes nodes = node->GetNodes();
int len = nodes.GetCount();
for( int i = 0; i < len; i ++)
{
if( nodes[i]->GetItem() == item )
const int row = GetRowByItem(item);
const size_t selCount = m_selection.size();
for ( size_t i = 0; i < selCount; i++ )
{
n = nodes[i];
if ( m_selection[i] > (unsigned)row )
m_selection[i]--;
}
int itemRow = m_selection.Index(row);
if ( itemRow != wxNOT_FOUND )
m_selection.RemoveAt(itemRow);
}
}
else // general case
{
wxDataViewTreeNode * node = FindNode(parent);
int itemPosInNode = node ? node->GetChildren().Index(item.GetID()) : wxNOT_FOUND;
// Notice that it is possible that the item being deleted is not in the
// tree at all, for example we could be deleting a never shown (because
// collapsed) item in a tree model. So it's not an error if we don't know
// about this item, just return without doing anything then.
if ( !node || itemPosInNode == wxNOT_FOUND )
return false;
bool isContainer = false;
wxDataViewTreeNode *itemNode = NULL;
const wxDataViewTreeNodes nds = node->GetNodes();
for (size_t i = 0; i < nds.GetCount(); i ++)
{
if (nds[i]->GetItem() == item)
{
isContainer = true;
itemNode = nds[i];
break;
}
}
wxCHECK_MSG( n != NULL, false, "item not found" );
// Delete the item from wxDataViewTreeNode representation:
int itemsDeleted = 1;
node->GetChildren().Remove( item.GetID() );
node->GetNodes().Remove( n );
sub -= n->GetSubTreeCount();
::DestroyTreeHelper(n);
if( isContainer )
{
wxDataViewTreeNode *n = node->FindItemAsNode(item);
wxCHECK_MSG( n != NULL, false, "item not found" );
node->GetNodes().Remove( n );
itemsDeleted += n->GetSubTreeCount();
::DestroyTreeHelper(n);
}
// Make the row number invalid and get a new valid one when user call GetRowCount
m_count = -1;
node->ChangeSubTreeCount(-itemsDeleted);
// Update selection by removing 'item' and its entire children tree from the selection.
if ( !m_selection.empty() )
{
// we can't call GetRowByItem() on 'item', as it's already deleted, so compute it from
// the parent ('node') and position in its list of children
int itemRow;
if ( itemPosInNode == 0 )
{
// 1st child, row number is that of the parent node + 1
itemRow = GetRowByItem(node->GetItem()) + 1;
}
else
{
// row number is that of the sibling above 'item' + its subtree if any + 1
const wxDataViewItem sibling = wxDataViewItem(node->GetChildren()[itemPosInNode - 1]);
const wxDataViewTreeNode *siblingNode = node->FindItemAsNode(sibling);
itemRow = GetRowByItem(sibling);
if ( siblingNode )
itemRow += siblingNode->GetSubTreeCount();
itemRow += 1;
}
wxDataViewSelection newsel(wxDataViewSelectionCmp);
for ( wxDataViewSelection::const_iterator i = m_selection.begin();
i != m_selection.end();
++i )
{
const int s = *i;
if ( s < itemRow )
newsel.push_back(s);
else if ( s >= itemRow + itemsDeleted )
newsel.push_back(s - itemsDeleted);
// else: deleted item, remove from selection
}
m_selection = newsel;
}
}
// Make the row number invalid and get a new valid one when user call GetRowCount
m_count = -1;
node->ChangeSubTreeCount(sub);
// Change the current row to the last row if the current exceed the max row number
if( m_currentRow > GetRowCount() )
m_currentRow = m_count - 1;
ChangeCurrentRow(m_count - 1);
UpdateDisplay();
@ -2710,7 +2764,7 @@ public:
if( node->GetNodes().GetCount() == 0)
{
int index = static_cast<int>(row) - current - 1;
ret = node->GetChildren().Item( index );
ret = wxDataViewItem(node->GetChildren().Item( index ));
return DoJob::OK;
}
return DoJob::CONT;
@ -4436,13 +4490,22 @@ int wxDataViewCtrl::GetSelections( wxDataViewItemArray & sel ) const
{
sel.Empty();
wxDataViewSelection selection = m_clientArea->GetSelections();
int len = selection.GetCount();
for( int i = 0; i < len; i ++)
const size_t len = selection.size();
for ( size_t i = 0; i < len; i++ )
{
unsigned int row = selection[i];
sel.Add( m_clientArea->GetItemByRow( row ) );
wxDataViewItem item = m_clientArea->GetItemByRow(selection[i]);
if ( item.IsOk() )
{
sel.Add(item);
}
else
{
wxFAIL_MSG( "invalid item in selection - bad internal state" );
}
}
return len;
return sel.size();
}
void wxDataViewCtrl::SetSelections( const wxDataViewItemArray & sel )
@ -4506,73 +4569,6 @@ bool wxDataViewCtrl::IsSelected( const wxDataViewItem & item ) const
return false;
}
// Selection code with row number as parameter
int wxDataViewCtrl::GetSelections( wxArrayInt & sel ) const
{
sel.Empty();
wxDataViewSelection selection = m_clientArea->GetSelections();
int len = selection.GetCount();
for( int i = 0; i < len; i ++)
{
unsigned int row = selection[i];
sel.Add( row );
}
return len;
}
void wxDataViewCtrl::SetSelections( const wxArrayInt & sel )
{
wxDataViewSelection selection(wxDataViewSelectionCmp);
int len = sel.GetCount();
for( int i = 0; i < len; i ++ )
{
int row = sel[i];
if( row >= 0 )
selection.Add( static_cast<unsigned int>(row) );
}
m_clientArea->SetSelections( selection );
}
void wxDataViewCtrl::Select( int row )
{
if( row >= 0 )
{
if (m_clientArea->IsSingleSel())
m_clientArea->SelectAllRows(false);
m_clientArea->SelectRow( row, true );
}
}
void wxDataViewCtrl::Unselect( int row )
{
if( row >= 0 )
m_clientArea->SelectRow(row, false);
}
bool wxDataViewCtrl::IsSelected( int row ) const
{
if( row >= 0 )
return m_clientArea->IsRowSelected(row);
return false;
}
void wxDataViewCtrl::SelectRange( int from, int to )
{
wxArrayInt sel;
for( int i = from; i < to; i ++ )
sel.Add( i );
m_clientArea->Select(sel);
}
void wxDataViewCtrl::UnselectRange( int from, int to )
{
wxDataViewSelection sel = m_clientArea->GetSelections();
for( int i = from; i < to; i ++ )
if( sel.Index( i ) != wxNOT_FOUND )
sel.Remove( i );
m_clientArea->SetSelections(sel);
}
void wxDataViewCtrl::SelectAll()
{
m_clientArea->SelectAllRows(true);

View File

@ -4027,7 +4027,7 @@ void wxListMainWindow::InsertItem( wxListItem &item )
wxListLineData *line = new wxListLineData(this);
line->SetItem( item.m_col, item );
if ( item.m_mask & wxLIST_MASK_IMAGE )
if ( item.m_mask & wxLIST_MASK_IMAGE && item.GetImage() != -1)
{
// Reset the buffered height if it's not big enough for the new image.
if (m_small_image_list)
@ -4866,7 +4866,9 @@ long wxGenericListCtrl::InsertItem( long index, const wxString &label, int image
wxListItem info;
info.m_text = label;
info.m_image = imageIndex;
info.m_mask = wxLIST_MASK_TEXT | wxLIST_MASK_IMAGE;
info.m_mask = wxLIST_MASK_TEXT;
if (imageIndex > -1)
info.m_mask |= wxLIST_MASK_IMAGE;
info.m_itemId = index;
return InsertItem( info );
}

View File

@ -74,6 +74,7 @@ protected:
BEGIN_EVENT_TABLE(wxGenericMessageDialog, wxDialog)
EVT_BUTTON(wxID_YES, wxGenericMessageDialog::OnYes)
EVT_BUTTON(wxID_NO, wxGenericMessageDialog::OnNo)
EVT_BUTTON(wxID_HELP, wxGenericMessageDialog::OnHelp)
EVT_BUTTON(wxID_CANCEL, wxGenericMessageDialog::OnCancel)
END_EVENT_TABLE()
@ -133,6 +134,13 @@ wxSizer *wxGenericMessageDialog::CreateMsgDlgButtonSizer()
btnDef = yes;
}
if ( m_dialogStyle & wxHELP )
{
wxButton * const
help = new wxButton(this, wxID_HELP, GetCustomHelpLabel());
sizerStd->AddButton(help);
}
if ( btnDef )
{
btnDef->SetDefault();
@ -148,7 +156,7 @@ wxSizer *wxGenericMessageDialog::CreateMsgDlgButtonSizer()
// Use standard labels for all buttons
return CreateSeparatedButtonSizer
(
m_dialogStyle & (wxOK | wxCANCEL | wxYES_NO |
m_dialogStyle & (wxOK | wxCANCEL | wxHELP | wxYES_NO |
wxNO_DEFAULT | wxCANCEL_DEFAULT)
);
}
@ -242,6 +250,11 @@ void wxGenericMessageDialog::OnNo(wxCommandEvent& WXUNUSED(event))
EndModal( wxID_NO );
}
void wxGenericMessageDialog::OnHelp(wxCommandEvent& WXUNUSED(event))
{
EndModal( wxID_HELP );
}
void wxGenericMessageDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
{
// Allow cancellation via ESC/Close button except if

View File

@ -902,7 +902,6 @@ wxOwnerDrawnComboBox::wxOwnerDrawnComboBox(wxWindow *parent,
long style,
const wxValidator& validator,
const wxString& name)
: wxComboCtrl()
{
Init();

View File

@ -300,7 +300,7 @@ private:
static
int LINKAGEMODE wxGtkTreeModelChildCmp( void** id1, void** id2 )
{
int ret = gs_internal->GetDataViewModel()->Compare( *id1, *id2,
int ret = gs_internal->GetDataViewModel()->Compare( wxDataViewItem(*id1), wxDataViewItem(*id2),
gs_internal->GetSortColumn(), (gs_internal->GetSortOrder() == GTK_SORT_ASCENDING) );
return ret;
@ -3334,7 +3334,7 @@ int wxGtkTreeModelChildWithPosCmp( const void* data1, const void* data2, const v
static
int LINKAGEMODE wxGtkTreeModelChildPtrCmp( void*** data1, void*** data2 )
{
return gs_internal->GetDataViewModel()->Compare( **data1, **data2,
return gs_internal->GetDataViewModel()->Compare( wxDataViewItem(**data1), wxDataViewItem(**data2),
gs_internal->GetSortColumn(), (gs_internal->GetSortOrder() == GTK_SORT_ASCENDING) );
}

View File

@ -74,6 +74,11 @@ wxString wxMessageDialog::GetDefaultCancelLabel() const
return GTK_STOCK_CANCEL;
}
wxString wxMessageDialog::GetDefaultHelpLabel() const
{
return GTK_STOCK_HELP;
}
void wxMessageDialog::DoSetCustomLabel(wxString& var, const ButtonLabel& label)
{
int stockId = label.GetStockId();
@ -135,16 +140,21 @@ void wxMessageDialog::GTKCreateMsgDialog()
// when using custom labels, we have to add all the buttons ourselves
if ( !HasCustomLabels() )
{
if ( m_dialogStyle & wxYES_NO )
// "Help" button is not supported by predefined combinations so we
// always need to create the buttons manually when it's used.
if ( !(m_dialogStyle & wxHELP) )
{
if ( !(m_dialogStyle & wxCANCEL) )
buttons = GTK_BUTTONS_YES_NO;
//else: no standard GTK_BUTTONS_YES_NO_CANCEL so leave as NONE
}
else if ( m_dialogStyle & wxOK )
{
buttons = m_dialogStyle & wxCANCEL ? GTK_BUTTONS_OK_CANCEL
: GTK_BUTTONS_OK;
if ( m_dialogStyle & wxYES_NO )
{
if ( !(m_dialogStyle & wxCANCEL) )
buttons = GTK_BUTTONS_YES_NO;
//else: no standard GTK_BUTTONS_YES_NO_CANCEL so leave as NONE
}
else if ( m_dialogStyle & wxOK )
{
buttons = m_dialogStyle & wxCANCEL ? GTK_BUTTONS_OK_CANCEL
: GTK_BUTTONS_OK;
}
}
}
@ -211,9 +221,16 @@ void wxMessageDialog::GTKCreateMsgDialog()
const bool addButtons = buttons == GTK_BUTTONS_NONE;
#endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON
if ( m_dialogStyle & wxYES_NO ) // Yes/No or Yes/No/Cancel dialog
if ( addButtons )
{
if ( addButtons )
if ( m_dialogStyle & wxHELP )
{
gtk_dialog_add_button(dlg, wxGTK_CONV(GetHelpLabel()),
GTK_RESPONSE_HELP);
}
if ( m_dialogStyle & wxYES_NO ) // Yes/No or Yes/No/Cancel dialog
{
// Add the buttons in the correct order which is, according to
// http://library.gnome.org/devel/hig-book/stable/windows-alert.html.en
@ -233,32 +250,29 @@ void wxMessageDialog::GTKCreateMsgDialog()
gtk_dialog_add_button(dlg, wxGTK_CONV(GetYesLabel()),
GTK_RESPONSE_YES);
}
// it'd probably be harmless to call gtk_dialog_set_default_response()
// twice but why do it if we're going to change the default below
// anyhow
if ( !(m_dialogStyle & wxCANCEL_DEFAULT) )
else // Ok or Ok/Cancel dialog
{
gtk_dialog_set_default_response(dlg,
m_dialogStyle & wxNO_DEFAULT
? GTK_RESPONSE_NO
: GTK_RESPONSE_YES);
}
}
else if ( addButtons ) // Ok or Ok/Cancel dialog
{
gtk_dialog_add_button(dlg, wxGTK_CONV(GetOKLabel()), GTK_RESPONSE_OK);
if ( m_dialogStyle & wxCANCEL )
{
gtk_dialog_add_button(dlg, wxGTK_CONV(GetCancelLabel()),
GTK_RESPONSE_CANCEL);
gtk_dialog_add_button(dlg, wxGTK_CONV(GetOKLabel()), GTK_RESPONSE_OK);
if ( m_dialogStyle & wxCANCEL )
{
gtk_dialog_add_button(dlg, wxGTK_CONV(GetCancelLabel()),
GTK_RESPONSE_CANCEL);
}
}
}
gint defaultButton;
if ( m_dialogStyle & wxCANCEL_DEFAULT )
{
gtk_dialog_set_default_response(dlg, GTK_RESPONSE_CANCEL);
}
defaultButton = GTK_RESPONSE_CANCEL;
else if ( m_dialogStyle & wxNO_DEFAULT )
defaultButton = GTK_RESPONSE_NO;
else if ( m_dialogStyle & wxYES_NO )
defaultButton = GTK_RESPONSE_YES;
else // No need to change the default value, whatever it is.
defaultButton = GTK_RESPONSE_NONE;
if ( defaultButton != GTK_RESPONSE_NONE )
gtk_dialog_set_default_response(dlg, defaultButton);
}
int wxMessageDialog::ShowModal()
@ -302,6 +316,8 @@ int wxMessageDialog::ShowModal()
return wxID_YES;
case GTK_RESPONSE_NO:
return wxID_NO;
case GTK_RESPONSE_HELP:
return wxID_HELP;
}
}

View File

@ -1218,6 +1218,37 @@ int wxTextCtrl::GetLineLength(long lineNo) const
}
}
wxPoint wxTextCtrl::DoPositionToCoords(long pos) const
{
if ( !IsMultiLine() )
{
// Single line text entry (GtkTextEntry) doesn't have support for
// getting the coordinates for the given offset. Perhaps we could
// find them ourselves by using GetTextExtent() but for now just leave
// it unimplemented, this function is more useful for multiline
// controls anyhow.
return wxDefaultPosition;
}
// Window coordinates for the given position is calculated by getting
// the buffer coordinates and converting them to window coordinates.
GtkTextView *textview = GTK_TEXT_VIEW(m_text);
GtkTextIter iter;
gtk_text_buffer_get_iter_at_offset(m_buffer, &iter, pos);
GdkRectangle bufferCoords;
gtk_text_view_get_iter_location(textview, &iter, &bufferCoords);
gint winCoordX = 0,
winCoordY = 0;
gtk_text_view_buffer_to_window_coords(textview, GTK_TEXT_WINDOW_WIDGET,
bufferCoords.x, bufferCoords.y,
&winCoordX, &winCoordY);
return wxPoint(winCoordX, winCoordY);
}
int wxTextCtrl::GetNumberOfLines() const
{
if ( IsMultiLine() )

View File

@ -1906,7 +1906,7 @@ void wxGDIPlusRenderer::Unload()
if ( m_gditoken )
{
GdiplusShutdown(m_gditoken);
m_gditoken = NULL;
m_gditoken = 0;
}
m_loaded = -1; // next Load() will try again
}

View File

@ -1727,7 +1727,9 @@ long wxListCtrl::InsertItem(long index, const wxString& label, int imageIndex)
wxListItem info;
info.m_image = imageIndex;
info.m_text = label;
info.m_mask = wxLIST_MASK_IMAGE | wxLIST_MASK_TEXT;
info.m_mask = wxLIST_MASK_TEXT;
if (imageIndex > -1)
info.m_mask |= wxLIST_MASK_IMAGE;
info.m_itemId = index;
return InsertItem(info);
}

View File

@ -260,7 +260,7 @@ inline bool IsGreaterThanStdSize(const wxBitmap& bmp)
// ---------------------------------------------------------------------------
// Construct a menu with optional title (then use append)
void wxMenu::Init()
void wxMenu::InitNoCreate()
{
m_radioData = NULL;
m_doBreak = false;
@ -270,6 +270,11 @@ void wxMenu::Init()
m_maxBitmapWidth = 0;
m_maxAccelWidth = -1;
#endif // wxUSE_OWNER_DRAWN
}
void wxMenu::Init()
{
InitNoCreate();
// create the menu
m_hMenu = (WXHMENU)CreatePopupMenu();
@ -287,6 +292,24 @@ void wxMenu::Init()
}
}
wxMenu::wxMenu(WXHMENU hMenu)
{
InitNoCreate();
m_hMenu = hMenu;
// Ensure that our internal idea of how many items we have corresponds to
// the real number of items in the menu.
//
// We could also retrieve the real labels of the items here but it doesn't
// seem to be worth the trouble.
const int numExistingItems = ::GetMenuItemCount(m_hMenu);
for ( int n = 0; n < numExistingItems; n++ )
{
wxMenuBase::DoAppend(wxMenuItem::New(this, wxID_SEPARATOR));
}
}
// The wxWindow destructor will take care of deleting the submenus.
wxMenu::~wxMenu()
{

View File

@ -511,6 +511,11 @@ int wxMessageDialog::ShowMessageBox()
}
}
if ( wxStyle & wxHELP )
{
msStyle |= MB_HELP;
}
// set the icon style
switch ( GetEffectiveIcon() )
{
@ -630,7 +635,7 @@ void wxMessageDialog::DoCentre(int dir)
#ifdef wxHAS_MSW_TASKDIALOG
wxMSWTaskDialogConfig::wxMSWTaskDialogConfig(const wxMessageDialogBase& dlg)
: buttons(new TASKDIALOG_BUTTON[3])
: buttons(new TASKDIALOG_BUTTON[MAX_BUTTONS])
{
parent = dlg.GetParentForModalDialog();
caption = dlg.GetCaption();
@ -665,6 +670,7 @@ wxMSWTaskDialogConfig::wxMSWTaskDialogConfig(const wxMessageDialogBase& dlg)
btnNoLabel = dlg.GetNoLabel();
btnOKLabel = dlg.GetOKLabel();
btnCancelLabel = dlg.GetCancelLabel();
btnHelpLabel = dlg.GetHelpLabel();
}
void wxMSWTaskDialogConfig::MSWCommonTaskDialogInit(TASKDIALOGCONFIG &tdc)
@ -755,6 +761,15 @@ void wxMSWTaskDialogConfig::MSWCommonTaskDialogInit(TASKDIALOGCONFIG &tdc)
AddTaskDialogButton(tdc, IDCANCEL, TDCBF_CANCEL_BUTTON, btnOKLabel);
}
}
if ( style & wxHELP )
{
// There is no support for "Help" button in the task dialog, it can
// only show "Retry" or "Close" ones.
useCustomLabels = true;
AddTaskDialogButton(tdc, IDHELP, 0 /* not used */, btnHelpLabel);
}
}
void wxMSWTaskDialogConfig::AddTaskDialogButton(TASKDIALOGCONFIG &tdc,
@ -770,6 +785,10 @@ void wxMSWTaskDialogConfig::AddTaskDialogButton(TASKDIALOGCONFIG &tdc,
tdBtn.nButtonID = btnCustomId;
tdBtn.pszButtonText = customLabel.wx_str();
tdc.cButtons++;
// We should never have more than 4 buttons currently as this is the
// maximal number of buttons supported by the message dialog.
wxASSERT_MSG( tdc.cButtons <= MAX_BUTTONS, wxT("Too many buttons") );
}
else
{
@ -839,6 +858,9 @@ int wxMSWMessageDialog::MSWTranslateReturnCode(int msAns)
case IDNO:
ans = wxID_NO;
break;
case IDHELP:
ans = wxID_HELP;
break;
}
return ans;

View File

@ -192,6 +192,9 @@ bool wxWindowsPrintNativeData::IsOk() const
bool wxWindowsPrintNativeData::TransferTo( wxPrintData &data )
{
if ( !m_devMode )
InitializeDevMode();
if ( !m_devMode )
return false;
@ -383,20 +386,21 @@ bool wxWindowsPrintNativeData::TransferTo( wxPrintData &data )
return true;
}
bool wxWindowsPrintNativeData::TransferFrom( const wxPrintData &data )
void wxWindowsPrintNativeData::InitializeDevMode(const wxString& printerName, WinPrinter* printer)
{
HGLOBAL hDevMode = static_cast<HGLOBAL>(m_devMode);
WinPrinter printer;
LPTSTR szPrinterName = (LPTSTR)data.GetPrinterName().wx_str();
if (m_devMode)
return;
LPTSTR szPrinterName = (LPTSTR)printerName.wx_str();
// From MSDN: How To Modify Printer Settings with the DocumentProperties() Function
// The purpose of this is to fill the DEVMODE with privdata from printer driver.
// If we have a printer name and OpenPrinter sucessfully returns
// this replaces the PrintDlg function which creates the DEVMODE filled only with data from default printer.
if ( !m_devMode && !data.GetPrinterName().IsEmpty() )
if ( !m_devMode && !printerName.IsEmpty() )
{
// Open printer
if ( printer.Open( data.GetPrinterName() ) == TRUE )
if ( printer && printer->Open( printerName ) == TRUE )
{
DWORD dwNeeded, dwRet;
@ -424,12 +428,11 @@ bool wxWindowsPrintNativeData::TransferFrom( const wxPrintData &data )
{
// If failure, cleanup
GlobalFree( tempDevMode );
printer.Close();
printer->Close();
}
else
{
hDevMode = tempDevMode;
m_devMode = hDevMode;
m_devMode = tempDevMode;
tempDevMode = NULL;
}
}
@ -471,8 +474,7 @@ bool wxWindowsPrintNativeData::TransferFrom( const wxPrintData &data )
}
else
{
hDevMode = pd.hDevMode;
m_devMode = hDevMode;
m_devMode = pd.hDevMode;
pd.hDevMode = NULL;
// We'll create a new DEVNAMEs structure below.
@ -487,6 +489,18 @@ bool wxWindowsPrintNativeData::TransferFrom( const wxPrintData &data )
}
}
}
bool wxWindowsPrintNativeData::TransferFrom( const wxPrintData &data )
{
WinPrinter printer;
LPTSTR szPrinterName = (LPTSTR)data.GetPrinterName().wx_str();
if (!m_devMode)
InitializeDevMode(data.GetPrinterName(), &printer);
HGLOBAL hDevMode = static_cast<HGLOBAL>(m_devMode);
if ( hDevMode )
{
GlobalPtrLock lockDevMode(hDevMode);

View File

@ -1489,6 +1489,93 @@ wxTextCtrl::HitTest(const wxPoint& pt, long *posOut) const
return rc;
}
wxPoint wxTextCtrl::DoPositionToCoords(long pos) const
{
// FIXME: This code is broken for rich edit version 2.0 as it uses the same
// API as plain edit i.e. the coordinates are returned directly instead of
// filling the POINT passed as WPARAM with them but we can't distinguish
// between 2.0 and 3.0 unfortunately (see also the use of EM_POSFROMCHAR
// above).
#if wxUSE_RICHEDIT
if ( IsRich() )
{
POINT pt;
LRESULT rc = ::SendMessage(GetHwnd(), EM_POSFROMCHAR, (WPARAM)&pt, pos);
if ( rc != -1 )
return wxPoint(pt.x, pt.y);
}
else
#endif // wxUSE_RICHEDIT
{
LRESULT rc = ::SendMessage(GetHwnd(), EM_POSFROMCHAR, pos, 0);
if ( rc == -1 )
{
// Finding coordinates for the last position of the control fails
// in plain EDIT control, try to compensate for it by finding it
// ourselves from the position of the previous character.
if ( pos < GetLastPosition() )
{
// It's not the expected correctable failure case so just fail.
return wxDefaultPosition;
}
if ( pos == 0 )
{
// We're being asked the coordinates of the first (and last and
// only) position in an empty control. There is no way to get
// it directly with EM_POSFROMCHAR but EM_GETMARGINS returns
// the correct value for at least the horizontal offset.
rc = ::SendMessage(GetHwnd(), EM_GETMARGINS, 0, 0);
// Text control seems to effectively add 1 to margin.
return wxPoint(LOWORD(rc) + 1, 1);
}
// We do have a previous character, try to get its coordinates.
rc = ::SendMessage(GetHwnd(), EM_POSFROMCHAR, pos - 1, 0);
if ( rc == -1 )
{
// If getting coordinates of the previous character failed as
// well, just give up.
return wxDefaultPosition;
}
wxString prevChar = GetRange(pos - 1, pos);
wxSize prevCharSize = GetTextExtent(prevChar);
if ( prevChar == wxT("\n" ))
{
// 'pos' is at the beginning of a new line so its X coordinate
// should be the same as X coordinate of the first character of
// any other line while its Y coordinate will be approximately
// (but we can't compute it exactly...) one character height
// more than that of the previous character.
LRESULT coords0 = ::SendMessage(GetHwnd(), EM_POSFROMCHAR, 0, 0);
if ( coords0 == -1 )
return wxDefaultPosition;
rc = MAKELPARAM(LOWORD(coords0), HIWORD(rc) + prevCharSize.y);
}
else
{
// Simple case: previous character is in the same line so this
// one is just after it.
rc += MAKELPARAM(prevCharSize.x, 0);
}
}
// Notice that {LO,HI}WORD macros return WORDs, i.e. unsigned shorts,
// while we want to have signed values here (the y coordinate of any
// position above the first currently visible line is negative, for
// example), hence the need for casts.
return wxPoint(static_cast<short>(LOWORD(rc)),
static_cast<short>(HIWORD(rc)));
}
return wxDefaultPosition;
}
// ----------------------------------------------------------------------------
//
// ----------------------------------------------------------------------------

View File

@ -141,6 +141,8 @@ void wxTopLevelWindowMSW::Init()
m_activateInfo = (void*) info;
#endif
m_menuSystem = NULL;
}
WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const
@ -326,9 +328,9 @@ WXLRESULT wxTopLevelWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WX
WXLRESULT rc = 0;
bool processed = false;
#if defined(__SMARTPHONE__) || defined(__POCKETPC__)
switch ( message )
{
#if defined(__SMARTPHONE__) || defined(__POCKETPC__)
case WM_ACTIVATE:
{
SHACTIVATEINFO* info = (SHACTIVATEINFO*) m_activateInfo;
@ -355,8 +357,32 @@ WXLRESULT wxTopLevelWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WX
}
break;
}
#endif // __SMARTPHONE__ || __POCKETPC__
case WM_SYSCOMMAND:
// We may need to generate events for the items added to the system
// menu if it had been created (and presumably modified).
if ( m_menuSystem )
{
// From MSDN:
//
// ... the four low-order bits of the wParam parameter are
// used internally by the system. To obtain the correct
// result when testing the value of wParam, an application
// must combine the value 0xFFF0 with the wParam value by
// using the bitwise AND operator.
unsigned id = wParam & 0xfff0;
// SC_SIZE is the first of the system-defined commands and we
// leave those to DefWindowProc().
if ( id < SC_SIZE )
{
if ( m_menuSystem->MSWCommand(0 /* unused anyhow */, id) )
processed = true;
}
}
break;
}
#endif
if ( !processed )
rc = wxTopLevelWindowBase::MSWWindowProc(message, wParam, lParam);
@ -413,25 +439,26 @@ bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate,
}
#endif // !__WXWINCE__
#if !defined(__WXWINCE__) || defined(__WINCE_STANDARDSDK__)
// move the dialog to its initial position without forcing repainting
int x, y, w, h;
(void)MSWGetCreateWindowCoords(pos, size, x, y, w, h);
if ( x == (int)CW_USEDEFAULT )
{
// centre it on the screen - what else can we do?
wxSize sizeDpy = wxGetDisplaySize();
x = (sizeDpy.x - w) / 2;
y = (sizeDpy.y - h) / 2;
// Let the system position the window, just set its size.
::SetWindowPos(GetHwnd(), 0,
0, 0, w, h,
SWP_NOMOVE | SWP_NOZORDER);
}
#if !defined(__WXWINCE__) || defined(__WINCE_STANDARDSDK__)
if ( !::MoveWindow(GetHwnd(), x, y, w, h, FALSE) )
else // Move the window to the desired location and set its size too.
{
wxLogLastError(wxT("MoveWindow"));
if ( !::MoveWindow(GetHwnd(), x, y, w, h, FALSE) )
{
wxLogLastError(wxT("MoveWindow"));
}
}
#endif
#endif // !__WXWINCE__
if ( !title.empty() )
{
@ -578,6 +605,8 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent,
wxTopLevelWindowMSW::~wxTopLevelWindowMSW()
{
delete m_menuSystem;
SendDestroyEvent();
#if defined(__SMARTPHONE__) || defined(__POCKETPC__)
@ -608,7 +637,13 @@ void wxTopLevelWindowMSW::DoShowWindow(int nShowCmd)
{
::ShowWindow(GetHwnd(), nShowCmd);
m_iconized = nShowCmd == SW_MINIMIZE;
// Hiding the window doesn't change its iconized state.
if ( nShowCmd != SW_HIDE )
{
// Otherwise restoring, maximizing or showing the window normally also
// makes it not iconized and only minimizing it does make it iconized.
m_iconized = nShowCmd == SW_MINIMIZE;
}
}
void wxTopLevelWindowMSW::ShowWithoutActivating()
@ -737,6 +772,13 @@ bool wxTopLevelWindowMSW::IsMaximized() const
void wxTopLevelWindowMSW::Iconize(bool iconize)
{
if ( iconize == m_iconized )
{
// Do nothing, in particular don't restore non-iconized windows when
// Iconize(false) is called as this would wrongly un-maximize them.
return;
}
if ( IsShown() )
{
// change the window state immediately
@ -1219,6 +1261,39 @@ void wxTopLevelWindowMSW::RequestUserAttention(int flags)
}
}
wxMenu *wxTopLevelWindowMSW::MSWGetSystemMenu() const
{
if ( !m_menuSystem )
{
HMENU hmenu = ::GetSystemMenu(GetHwnd(), FALSE);
if ( !hmenu )
{
wxLogLastError(wxT("GetSystemMenu()"));
return NULL;
}
wxTopLevelWindowMSW * const
self = const_cast<wxTopLevelWindowMSW *>(this);
self->m_menuSystem = wxMenu::MSWNewFromHMENU(hmenu);
// We need to somehow associate this menu with this window to ensure
// that we get events from it. A natural idea would be to pretend that
// it's attached to our menu bar but this wouldn't work if we don't
// have any menu bar which is a common case for applications using
// custom items in the system menu (they mostly do it exactly because
// they don't have any other menus).
//
// So reuse the invoking window pointer instead, this is not exactly
// correct but doesn't seem to have any serious drawbacks.
m_menuSystem->SetInvokingWindow(self);
}
return m_menuSystem;
}
// ----------------------------------------------------------------------------
// Transparency support
// ---------------------------------------------------------------------------
bool wxTopLevelWindowMSW::SetTransparent(wxByte alpha)

View File

@ -881,7 +881,7 @@ bool wxWindowMSW::SetCursor(const wxCursor& cursor)
return false;
}
const wxWindow* win = wxFindWindowAtPoint(wxPoint(pt.x, pt.y));
const wxWindowMSW* win = wxFindWindowAtPoint(wxPoint(pt.x, pt.y));
if ( !win )
win = this;

View File

@ -130,7 +130,7 @@ pascal OSErr AEHandleGURL( const AppleEvent *event , AppleEvent *reply , SRefCon
}
// AEODoc Calls MacOpenFile on each of the files passed
// AEODoc Calls MacOpenFiles with all of the files passed
short wxApp::MacHandleAEODoc(const WXEVENTREF event, WXEVENTREF WXUNUSED(reply))
{
@ -158,6 +158,7 @@ short wxApp::MacHandleAEODoc(const WXEVENTREF event, WXEVENTREF WXUNUSED(reply))
wxString fName ;
FSRef theRef ;
wxArrayString fileNames;
for (i = 1; i <= itemsInList; i++)
{
AEGetNthPtr(
@ -165,9 +166,11 @@ short wxApp::MacHandleAEODoc(const WXEVENTREF event, WXEVENTREF WXUNUSED(reply))
(Ptr)&theRef, sizeof(theRef), &actualSize);
fName = wxMacFSRefToPath( &theRef ) ;
MacOpenFile(fName);
fileNames.Add(fName);
}
MacOpenFiles(fileNames);
return noErr;
}
@ -274,6 +277,16 @@ short wxApp::MacHandleAERApp(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNU
// Support Routines linking the Mac...File Calls to the Document Manager
//----------------------------------------------------------------------
void wxApp::MacOpenFiles(const wxArrayString & fileNames )
{
size_t i;
const size_t fileCount = fileNames.GetCount();
for (i = 0; i < fileCount; i++)
{
MacOpenFile(fileNames[i]);
}
}
void wxApp::MacOpenFile(const wxString & fileName )
{
#if wxUSE_DOC_VIEW_ARCHITECTURE

View File

@ -138,6 +138,8 @@ int wxMessageDialog::ShowModal()
}
}
wxASSERT_MSG( !(style & wxHELP), "wxHELP not supported in non-GUI thread" );
CFOptionFlags exitButton;
OSStatus err = CFUserNotificationDisplayAlert(
0, alertType, NULL, NULL, NULL, cfTitle, cfText,
@ -285,5 +287,15 @@ void* wxMessageDialog::ConstructNSAlert()
}
}
if ( style & wxHELP )
{
wxCFStringRef cfHelpString( GetHelpLabel(), GetFont().GetEncoding() );
[alert addButtonWithTitle:cfHelpString.AsNSString()];
m_buttonId[ m_buttonCount++ ] = wxID_HELP;
}
wxASSERT_MSG( m_buttonCount <= WXSIZEOF(m_buttonId), "Too many buttons" );
return alert;
}

View File

@ -57,11 +57,18 @@
- (void)setSelectable:(BOOL)flag;
@end
// An object of this class is created before the text is modified
// programmatically and destroyed as soon as this is done. It does several
// things, like ensuring that the control is editable to allow setting its text
// at all and eating any unwanted focus loss events from textDidEndEditing:
// which don't really correspond to focus change.
class wxMacEditHelper
{
public :
wxMacEditHelper( NSView* textView )
{
m_viewPreviouslyEdited = ms_viewCurrentlyEdited;
ms_viewCurrentlyEdited =
m_textView = textView;
m_formerEditable = YES;
if ( textView )
@ -79,14 +86,27 @@ public :
[m_textView setEditable:m_formerEditable];
[m_textView setSelectable:m_formerSelectable];
}
ms_viewCurrentlyEdited = m_viewPreviouslyEdited;
}
// Returns the last view we were instantiated for or NULL.
static NSView *GetCurrentlyEditedView() { return ms_viewCurrentlyEdited; }
protected :
BOOL m_formerEditable ;
BOOL m_formerSelectable;
NSView* m_textView;
// The original value of ms_viewCurrentlyEdited when this object was
// created.
NSView* m_viewPreviouslyEdited;
static NSView* ms_viewCurrentlyEdited;
} ;
NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil;
@implementation wxNSSecureTextField
+ (void)initialize
@ -222,6 +242,15 @@ protected :
- (void)textDidEndEditing:(NSNotification *)aNotification
{
wxUnusedVar(aNotification);
if ( self == wxMacEditHelper::GetCurrentlyEditedView() )
{
// This notification is generated as the result of calling our own
// wxTextCtrl method (e.g. WriteText()) and doesn't correspond to any
// real focus loss event so skip generating it.
return;
}
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
if ( impl )
{

View File

@ -55,12 +55,18 @@ void wxBell()
wxUnusedVar(application);
}
- (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename
- (void)application:(NSApplication *)sender openFiles:(NSArray *)fileNames
{
wxUnusedVar(sender);
wxCFStringRef cf(wxCFRetain(filename));
wxTheApp->MacOpenFile(cf.AsString()) ;
return YES;
wxArrayString fileList;
size_t i;
const size_t count = [fileNames count];
for (i = 0; i < count; i++)
{
fileList.Add( wxCFStringRef::AsString([fileNames objectAtIndex:i]) );
}
wxTheApp->MacOpenFiles(fileList);
}
- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender

View File

@ -368,7 +368,16 @@ void wxWidgetCocoaImpl::SetupKeyEvent(wxKeyEvent &wxevent , NSEvent * nsEvent, N
}
#if wxUSE_UNICODE
wxevent.m_uniChar = aunichar;
// OS X generates events with key codes in Unicode private use area for
// unprintable symbols such as cursor arrows (WXK_UP is mapped to U+F700)
// and function keys (WXK_F2 is U+F705). We don't want to use them as the
// result of wxKeyEvent::GetUnicodeKey() however as it's supposed to return
// WXK_NONE for "non characters" so explicitly exclude them.
//
// We only exclude the private use area inside the Basic Multilingual Plane
// as key codes beyond it don't seem to be currently used.
if ( !(aunichar >= 0xe000 && aunichar < 0xf900) )
wxevent.m_uniChar = aunichar;
#endif
wxevent.m_keyCode = keyval;

View File

@ -25,10 +25,6 @@ wxComboBox::~wxComboBox()
{
}
void wxComboBox::Init()
{
}
bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
const wxString& value,
const wxPoint& pos,

View File

@ -447,7 +447,11 @@ void wxMimeTypesManagerImpl::LoadDisplayDataForUti(const wxString& uti)
if( !bundle )
return;
// Get a all the document type data in this bundle
// Also get the open command while we have the bundle
wxCFStringRef cfsAppPath(CFURLCopyFileSystemPath(appUrl, kCFURLPOSIXPathStyle));
m_utiMap[ uti ].application = cfsAppPath.AsString();
// Get all the document type data in this bundle
CFTypeRef docTypeData;
docTypeData = CFBundleGetValueForInfoDictionaryKey( bundle, docTypesKey );
@ -587,6 +591,19 @@ bool wxMimeTypesManagerImpl::GetDescription(const wxString& uti, wxString *desc)
return true;
}
bool wxMimeTypesManagerImpl::GetApplication(const wxString& uti, wxString *command)
{
const UtiMap::const_iterator itr = m_utiMap.find( uti );
if( itr == m_utiMap.end() )
{
command->clear();
return false;
}
*command = itr->second.application;
return true;
}
/////////////////////////////////////////////////////////////////////////////
// The remaining functionality has not yet been implemented for OS X
@ -626,9 +643,36 @@ bool wxFileTypeImpl::GetDescription(wxString *desc) const
return m_manager->GetDescription( m_uti, desc );
}
bool wxFileTypeImpl::GetOpenCommand(wxString *WXUNUSED(openCmd), const wxFileType::MessageParameters& WXUNUSED(params)) const
namespace
{
return false;
// Helper function for GetOpenCommand(): returns the string surrounded by
// (singly) quotes if it contains spaces.
wxString QuoteIfNecessary(const wxString& path)
{
wxString result(path);
if ( path.find(' ') != wxString::npos )
{
result.insert(0, "'");
result.append("'");
}
return result;
}
} // anonymous namespace
bool wxFileTypeImpl::GetOpenCommand(wxString *openCmd, const wxFileType::MessageParameters& params) const
{
wxString application;
if ( !m_manager->GetApplication(m_uti, &application) )
return false;
*openCmd << QuoteIfNecessary(application)
<< ' ' << QuoteIfNecessary(params.GetFileName());
return true;
}
bool wxFileTypeImpl::GetPrintCommand(wxString *WXUNUSED(printCmd), const wxFileType::MessageParameters& WXUNUSED(params)) const

View File

@ -77,6 +77,19 @@ long UMAGetSystemVersion()
// our OS version is the same in non GUI and GUI cases
wxOperatingSystemId wxGetOsVersion(int *majorVsn, int *minorVsn)
{
// This returns 10 and 6 for OS X 10.6, consistent with behaviour on
// other platforms.
SInt32 maj, min;
Gestalt(gestaltSystemVersionMajor, &maj);
Gestalt(gestaltSystemVersionMinor, &min);
if ( majorVsn != NULL )
*majorVsn = maj;
if ( minorVsn != NULL )
*minorVsn = min;
#if 0
SInt32 theSystem;
Gestalt(gestaltSystemVersion, &theSystem);
@ -85,7 +98,7 @@ wxOperatingSystemId wxGetOsVersion(int *majorVsn, int *minorVsn)
if ( minorVsn != NULL )
*minorVsn = (theSystem & 0xFF);
#endif
return wxOS_MAC_OSX_DARWIN;
}

View File

@ -775,9 +775,10 @@ int wxTextWidgetImpl::GetLineLength(long lineNo) const
count = 0;
for (size_t j = i; j < content.length(); j++)
{
count++;
if (content[j] == '\n')
return count;
count++;
}
return count;

File diff suppressed because it is too large Load Diff

View File

@ -39,6 +39,10 @@ BEGIN_EVENT_TABLE( wxRichTextFontPage, wxRichTextDialogPage )
EVT_COMBOBOX( ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL, wxRichTextFontPage::OnUnderliningCtrlSelected )
EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_COLOURCTRL_LABEL, wxRichTextFontPage::OnUnderliningCtrlSelected )
EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_BGCOLOURCTRL_LABEL, wxRichTextFontPage::OnUnderliningCtrlSelected )
EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL, wxRichTextFontPage::OnStrikethroughctrlClick )
EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_CAPSCTRL, wxRichTextFontPage::OnCapsctrlClick )
@ -85,7 +89,9 @@ void wxRichTextFontPage::Init()
m_styleCtrl = NULL;
m_weightCtrl = NULL;
m_underliningCtrl = NULL;
m_textColourLabel = NULL;
m_colourCtrl = NULL;
m_bgColourLabel = NULL;
m_bgColourCtrl = NULL;
m_strikethroughCtrl = NULL;
m_capitalsCtrl = NULL;
@ -216,8 +222,9 @@ void wxRichTextFontPage::CreateControls()
wxBoxSizer* itemBoxSizer24 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer13->Add(itemBoxSizer24, 0, wxGROW, 5);
wxStaticText* itemStaticText25 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Colour:"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer24->Add(itemStaticText25, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
m_textColourLabel = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_COLOURCTRL_LABEL, _("&Colour:"), wxDefaultPosition, wxDefaultSize, 0 );
m_textColourLabel->SetValue(false);
itemBoxSizer24->Add(m_textColourLabel, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP, 5);
m_colourCtrl = new wxRichTextColourSwatchCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_COLOURCTRL, wxDefaultPosition, wxSize(40, 20), 0 );
m_colourCtrl->SetHelpText(_("Click to change the text colour."));
@ -228,8 +235,9 @@ void wxRichTextFontPage::CreateControls()
wxBoxSizer* itemBoxSizer27 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer13->Add(itemBoxSizer27, 0, wxGROW, 5);
wxStaticText* itemStaticText28 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Bg colour:"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer27->Add(itemStaticText28, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
m_bgColourLabel = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_BGCOLOURCTRL_LABEL, _("&Bg colour:"), wxDefaultPosition, wxDefaultSize, 0 );
m_bgColourLabel->SetValue(false);
itemBoxSizer27->Add(m_bgColourLabel, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP, 5);
m_bgColourCtrl = new wxRichTextColourSwatchCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_BGCOLOURCTRL, wxDefaultPosition, wxSize(40, 20), 0 );
m_bgColourCtrl->SetHelpText(_("Click to change the text background colour."));
@ -280,12 +288,15 @@ void wxRichTextFontPage::CreateControls()
m_faceListBox->UpdateFonts();
m_styleCtrl->Append(_("(none)"));
m_styleCtrl->Append(_("Regular"));
m_styleCtrl->Append(_("Italic"));
m_weightCtrl->Append(_("(none)"));
m_weightCtrl->Append(_("Regular"));
m_weightCtrl->Append(_("Bold"));
m_underliningCtrl->Append(_("(none)"));
m_underliningCtrl->Append(_("Not underlined"));
m_underliningCtrl->Append(_("Underlined"));
@ -327,10 +338,10 @@ bool wxRichTextFontPage::TransferDataFromWindow()
else
attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_SIZE));
if (m_styleCtrl->GetSelection() != wxNOT_FOUND)
if (m_styleCtrl->GetSelection() != wxNOT_FOUND && m_styleCtrl->GetSelection() != 0)
{
wxFontStyle style;
if (m_styleCtrl->GetStringSelection() == _("Italic"))
if (m_styleCtrl->GetSelection() == 2)
style = wxFONTSTYLE_ITALIC;
else
style = wxFONTSTYLE_NORMAL;
@ -340,10 +351,10 @@ bool wxRichTextFontPage::TransferDataFromWindow()
else
attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_ITALIC));
if (m_weightCtrl->GetSelection() != wxNOT_FOUND)
if (m_weightCtrl->GetSelection() != wxNOT_FOUND && m_weightCtrl->GetSelection() != 0)
{
wxFontWeight weight;
if (m_weightCtrl->GetStringSelection() == _("Bold"))
if (m_weightCtrl->GetSelection() == 2)
weight = wxFONTWEIGHT_BOLD;
else
weight = wxFONTWEIGHT_NORMAL;
@ -353,10 +364,10 @@ bool wxRichTextFontPage::TransferDataFromWindow()
else
attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_WEIGHT));
if (m_underliningCtrl->GetSelection() != wxNOT_FOUND)
if (m_underliningCtrl->GetSelection() != wxNOT_FOUND && m_underliningCtrl->GetSelection() != 0)
{
bool underlined;
if (m_underliningCtrl->GetStringSelection() == _("Underlined"))
if (m_underliningCtrl->GetSelection() == 2)
underlined = true;
else
underlined = false;
@ -366,14 +377,14 @@ bool wxRichTextFontPage::TransferDataFromWindow()
else
attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_UNDERLINE));
if (m_colourPresent)
if (m_textColourLabel->GetValue())
{
attr->SetTextColour(m_colourCtrl->GetColour());
}
else
attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_TEXT_COLOUR));
if (m_bgColourPresent)
if (m_bgColourLabel->GetValue())
{
attr->SetBackgroundColour(m_bgColourCtrl->GetColour());
}
@ -456,50 +467,62 @@ bool wxRichTextFontPage::TransferDataToWindow()
if (attr->HasFontWeight())
{
if (attr->GetFontWeight() == wxBOLD)
m_weightCtrl->SetSelection(1);
m_weightCtrl->SetSelection(2);
else
m_weightCtrl->SetSelection(0);
m_weightCtrl->SetSelection(1);
}
else
{
m_weightCtrl->SetSelection(wxNOT_FOUND);
m_weightCtrl->SetSelection(0);
}
if (attr->HasFontItalic())
{
if (attr->GetFontStyle() == wxITALIC)
m_styleCtrl->SetSelection(1);
m_styleCtrl->SetSelection(2);
else
m_styleCtrl->SetSelection(0);
m_styleCtrl->SetSelection(1);
}
else
{
m_styleCtrl->SetSelection(wxNOT_FOUND);
m_styleCtrl->SetSelection(0);
}
if (attr->HasFontUnderlined())
{
if (attr->GetFontUnderlined())
m_underliningCtrl->SetSelection(1);
m_underliningCtrl->SetSelection(2);
else
m_underliningCtrl->SetSelection(0);
m_underliningCtrl->SetSelection(1);
}
else
{
m_underliningCtrl->SetSelection(wxNOT_FOUND);
m_underliningCtrl->SetSelection(0);
}
if (attr->HasTextColour())
{
m_colourCtrl->SetColour(attr->GetTextColour());
m_textColourLabel->SetValue(true);
m_colourPresent = true;
}
else
{
m_colourCtrl->SetColour(*wxBLACK);
m_textColourLabel->SetValue(false);
}
if (attr->HasBackgroundColour())
{
m_bgColourCtrl->SetColour(attr->GetBackgroundColour());
m_bgColourLabel->SetValue(true);
m_bgColourPresent = true;
}
else
{
m_bgColourCtrl->SetColour(*wxWHITE);
m_bgColourLabel->SetValue(false);
}
if (attr->HasTextEffects())
{
@ -572,11 +595,30 @@ void wxRichTextFontPage::UpdatePreview()
{
wxRichTextAttr attr;
if (m_colourPresent)
m_previewCtrl->SetForegroundColour(m_colourCtrl->GetBackgroundColour());
if (m_textColourLabel->GetValue())
m_previewCtrl->SetForegroundColour(m_colourCtrl->GetColour());
else
{
m_previewCtrl->SetForegroundColour(*wxBLACK);
if (!(m_colourCtrl->GetColour() == *wxBLACK))
{
m_colourCtrl->SetColour(*wxBLACK);
m_colourCtrl->Refresh();
}
}
if (m_bgColourPresent)
m_previewCtrl->SetBackgroundColour(m_bgColourCtrl->GetBackgroundColour());
if (m_bgColourLabel->GetValue())
m_previewCtrl->SetBackgroundColour(m_bgColourCtrl->GetColour());
else
{
m_previewCtrl->SetBackgroundColour(*wxWHITE);
if (!(m_bgColourCtrl->GetColour() == *wxWHITE))
{
m_bgColourCtrl->SetColour(*wxWHITE);
m_bgColourCtrl->Refresh();
}
}
if (m_faceListBox->GetSelection() != wxNOT_FOUND)
{
@ -592,10 +634,10 @@ void wxRichTextFontPage::UpdatePreview()
attr.SetFontSize(sz);
}
if (m_styleCtrl->GetSelection() != wxNOT_FOUND)
if (m_styleCtrl->GetSelection() != wxNOT_FOUND && m_styleCtrl->GetSelection() != 0)
{
wxFontStyle style;
if (m_styleCtrl->GetStringSelection() == _("Italic"))
if (m_styleCtrl->GetSelection() == 2)
style = wxFONTSTYLE_ITALIC;
else
style = wxFONTSTYLE_NORMAL;
@ -603,10 +645,10 @@ void wxRichTextFontPage::UpdatePreview()
attr.SetFontStyle(style);
}
if (m_weightCtrl->GetSelection() != wxNOT_FOUND)
if (m_weightCtrl->GetSelection() != wxNOT_FOUND && m_weightCtrl->GetSelection() != 0)
{
wxFontWeight weight;
if (m_weightCtrl->GetStringSelection() == _("Bold"))
if (m_weightCtrl->GetSelection() == 2)
weight = wxFONTWEIGHT_BOLD;
else
weight = wxFONTWEIGHT_NORMAL;
@ -614,10 +656,10 @@ void wxRichTextFontPage::UpdatePreview()
attr.SetFontWeight(weight);
}
if (m_underliningCtrl->GetSelection() != wxNOT_FOUND)
if (m_underliningCtrl->GetSelection() != wxNOT_FOUND && m_underliningCtrl->GetSelection() != 0)
{
bool underlined;
if (m_underliningCtrl->GetStringSelection() == _("Underlined"))
if (m_underliningCtrl->GetSelection() == 2)
underlined = true;
else
underlined = false;
@ -740,11 +782,15 @@ void wxRichTextFontPage::OnSizeTextCtrlUpdated( wxCommandEvent& WXUNUSED(event)
void wxRichTextFontPage::OnSizeListBoxSelected( wxCommandEvent& event )
{
bool oldDontUpdate = m_dontUpdate;
m_dontUpdate = true;
m_sizeTextCtrl->SetValue(event.GetString());
m_dontUpdate = false;
m_dontUpdate = oldDontUpdate;
if (m_dontUpdate)
return;
UpdatePreview();
}
@ -755,11 +801,15 @@ void wxRichTextFontPage::OnSizeListBoxSelected( wxCommandEvent& event )
void wxRichTextFontPage::OnFaceListBoxSelected( wxCommandEvent& WXUNUSED(event) )
{
bool oldDontUpdate = m_dontUpdate;
m_dontUpdate = true;
m_faceTextCtrl->SetValue(m_faceListBox->GetFaceName(m_faceListBox->GetSelection()));
m_dontUpdate = false;
m_dontUpdate = oldDontUpdate;
if (m_dontUpdate)
return;
UpdatePreview();
}
@ -770,6 +820,9 @@ void wxRichTextFontPage::OnFaceListBoxSelected( wxCommandEvent& WXUNUSED(event)
void wxRichTextFontPage::OnStyleCtrlSelected( wxCommandEvent& WXUNUSED(event) )
{
if (m_dontUpdate)
return;
UpdatePreview();
}
@ -780,6 +833,9 @@ void wxRichTextFontPage::OnStyleCtrlSelected( wxCommandEvent& WXUNUSED(event) )
void wxRichTextFontPage::OnUnderliningCtrlSelected( wxCommandEvent& WXUNUSED(event) )
{
if (m_dontUpdate)
return;
UpdatePreview();
}
@ -790,6 +846,9 @@ void wxRichTextFontPage::OnUnderliningCtrlSelected( wxCommandEvent& WXUNUSED(eve
void wxRichTextFontPage::OnWeightCtrlSelected( wxCommandEvent& WXUNUSED(event) )
{
if (m_dontUpdate)
return;
UpdatePreview();
}
@ -800,6 +859,19 @@ void wxRichTextFontPage::OnColourClicked( wxCommandEvent& event )
else if (event.GetId() == m_bgColourCtrl->GetId())
m_bgColourPresent = true;
m_dontUpdate = true;
if (event.GetId() == m_colourCtrl->GetId())
{
m_textColourLabel->SetValue(true);
}
else if (event.GetId() == m_bgColourCtrl->GetId())
{
m_bgColourLabel->SetValue(true);
}
m_dontUpdate = false;
UpdatePreview();
}
/*!
@ -808,6 +880,9 @@ void wxRichTextFontPage::OnColourClicked( wxCommandEvent& event )
void wxRichTextFontPage::OnStrikethroughctrlClick( wxCommandEvent& WXUNUSED(event) )
{
if (m_dontUpdate)
return;
UpdatePreview();
}
@ -817,6 +892,9 @@ void wxRichTextFontPage::OnStrikethroughctrlClick( wxCommandEvent& WXUNUSED(even
void wxRichTextFontPage::OnCapsctrlClick( wxCommandEvent& WXUNUSED(event) )
{
if (m_dontUpdate)
return;
UpdatePreview();
}
@ -826,6 +904,9 @@ void wxRichTextFontPage::OnCapsctrlClick( wxCommandEvent& WXUNUSED(event) )
void wxRichTextFontPage::OnRichtextfontpageSuperscriptClick( wxCommandEvent& WXUNUSED(event) )
{
if (m_dontUpdate)
return;
if ( m_superscriptCtrl->Get3StateValue() == wxCHK_CHECKED)
m_subscriptCtrl->Set3StateValue( wxCHK_UNCHECKED );
@ -838,6 +919,9 @@ void wxRichTextFontPage::OnRichtextfontpageSuperscriptClick( wxCommandEvent& WXU
void wxRichTextFontPage::OnRichtextfontpageSubscriptClick( wxCommandEvent& WXUNUSED(event) )
{
if (m_dontUpdate)
return;
if ( m_subscriptCtrl->Get3StateValue() == wxCHK_CHECKED)
m_superscriptCtrl->Set3StateValue( wxCHK_UNCHECKED );

View File

@ -92,6 +92,7 @@ void wxRichTextIndentsSpacingPage::Init()
m_spacingBefore = NULL;
m_spacingAfter = NULL;
m_spacingLine = NULL;
m_pageBreakCtrl = NULL;
m_previewCtrl = NULL;
////@end wxRichTextIndentsSpacingPage member initialisation
@ -207,44 +208,35 @@ void wxRichTextIndentsSpacingPage::CreateControls()
wxStaticText* itemStaticText23 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Left:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer22->Add(itemStaticText23, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer24 = new wxBoxSizer(wxHORIZONTAL);
itemFlexGridSizer22->Add(itemBoxSizer24, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5);
m_indentLeft = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
m_indentLeft->SetHelpText(_("The left indent."));
if (wxRichTextIndentsSpacingPage::ShowToolTips())
m_indentLeft->SetToolTip(_("The left indent."));
itemBoxSizer24->Add(m_indentLeft, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemFlexGridSizer22->Add(m_indentLeft, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText26 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("Left (&first line):"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer22->Add(itemStaticText26, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer27 = new wxBoxSizer(wxHORIZONTAL);
itemFlexGridSizer22->Add(itemBoxSizer27, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5);
wxStaticText* itemStaticText25 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("Left (&first line):"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer22->Add(itemStaticText25, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
m_indentLeftFirst = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
m_indentLeftFirst->SetHelpText(_("The first line indent."));
if (wxRichTextIndentsSpacingPage::ShowToolTips())
m_indentLeftFirst->SetToolTip(_("The first line indent."));
itemBoxSizer27->Add(m_indentLeftFirst, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemFlexGridSizer22->Add(m_indentLeftFirst, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText29 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Right:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer22->Add(itemStaticText29, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer30 = new wxBoxSizer(wxHORIZONTAL);
itemFlexGridSizer22->Add(itemBoxSizer30, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5);
wxStaticText* itemStaticText27 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Right:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer22->Add(itemStaticText27, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
m_indentRight = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
m_indentRight->SetHelpText(_("The right indent."));
if (wxRichTextIndentsSpacingPage::ShowToolTips())
m_indentRight->SetToolTip(_("The right indent."));
itemBoxSizer30->Add(m_indentRight, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemFlexGridSizer22->Add(m_indentRight, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText32 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Outline level:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer22->Add(itemStaticText32, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText29 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Outline level:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer22->Add(itemStaticText29, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxArrayString m_outlineLevelCtrlStrings;
m_outlineLevelCtrlStrings.Add(_("Normal"));
m_outlineLevelCtrlStrings.Add(_("(none)"));
m_outlineLevelCtrlStrings.Add(_("1"));
m_outlineLevelCtrlStrings.Add(_("2"));
m_outlineLevelCtrlStrings.Add(_("3"));
@ -254,65 +246,57 @@ void wxRichTextIndentsSpacingPage::CreateControls()
m_outlineLevelCtrlStrings.Add(_("7"));
m_outlineLevelCtrlStrings.Add(_("8"));
m_outlineLevelCtrlStrings.Add(_("9"));
m_outlineLevelCtrl = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_OUTLINELEVEL, _("Normal"), wxDefaultPosition, wxSize(90, -1), m_outlineLevelCtrlStrings, wxCB_READONLY );
m_outlineLevelCtrl->SetStringSelection(_("Normal"));
m_outlineLevelCtrlStrings.Add(_("10"));
m_outlineLevelCtrl = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_OUTLINELEVEL, _("(none)"), wxDefaultPosition, wxSize(85, -1), m_outlineLevelCtrlStrings, wxCB_READONLY );
m_outlineLevelCtrl->SetStringSelection(_("(none)"));
m_outlineLevelCtrl->SetHelpText(_("The outline level."));
if (wxRichTextIndentsSpacingPage::ShowToolTips())
m_outlineLevelCtrl->SetToolTip(_("The outline level."));
itemFlexGridSizer22->Add(m_outlineLevelCtrl, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemFlexGridSizer22->Add(m_outlineLevelCtrl, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
wxStaticLine* itemStaticLine35 = new wxStaticLine( itemRichTextDialogPage1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
itemBoxSizer4->Add(itemStaticLine35, 0, wxGROW|wxTOP|wxBOTTOM, 5);
wxStaticLine* itemStaticLine32 = new wxStaticLine( itemRichTextDialogPage1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
itemBoxSizer4->Add(itemStaticLine32, 0, wxGROW|wxTOP|wxBOTTOM, 5);
itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
wxBoxSizer* itemBoxSizer37 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer4->Add(itemBoxSizer37, 0, wxGROW, 5);
wxBoxSizer* itemBoxSizer34 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer4->Add(itemBoxSizer34, 0, wxGROW, 5);
wxStaticText* itemStaticText38 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Spacing (tenths of a mm)"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer37->Add(itemStaticText38, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
wxStaticText* itemStaticText35 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Spacing (tenths of a mm)"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer34->Add(itemStaticText35, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
wxBoxSizer* itemBoxSizer39 = new wxBoxSizer(wxHORIZONTAL);
itemBoxSizer37->Add(itemBoxSizer39, 0, wxALIGN_LEFT|wxALL, 5);
wxBoxSizer* itemBoxSizer36 = new wxBoxSizer(wxHORIZONTAL);
itemBoxSizer34->Add(itemBoxSizer36, 0, wxALIGN_LEFT|wxALL, 5);
itemBoxSizer39->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 5);
itemBoxSizer36->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 5);
wxFlexGridSizer* itemFlexGridSizer41 = new wxFlexGridSizer(30, 2, 0, 0);
itemFlexGridSizer41->AddGrowableCol(1);
itemBoxSizer39->Add(itemFlexGridSizer41, 0, wxALIGN_CENTER_VERTICAL, 5);
wxFlexGridSizer* itemFlexGridSizer38 = new wxFlexGridSizer(30, 2, 0, 0);
itemBoxSizer36->Add(itemFlexGridSizer38, 0, wxALIGN_CENTER_VERTICAL, 5);
wxStaticText* itemStaticText42 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Before a paragraph:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer41->Add(itemStaticText42, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer43 = new wxBoxSizer(wxHORIZONTAL);
itemFlexGridSizer41->Add(itemBoxSizer43, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5);
wxStaticText* itemStaticText39 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Before a paragraph:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer38->Add(itemStaticText39, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
m_spacingBefore = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
m_spacingBefore->SetHelpText(_("The spacing before the paragraph."));
if (wxRichTextIndentsSpacingPage::ShowToolTips())
m_spacingBefore->SetToolTip(_("The spacing before the paragraph."));
itemBoxSizer43->Add(m_spacingBefore, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemFlexGridSizer38->Add(m_spacingBefore, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText45 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&After a paragraph:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer41->Add(itemStaticText45, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer46 = new wxBoxSizer(wxHORIZONTAL);
itemFlexGridSizer41->Add(itemBoxSizer46, 1, wxGROW|wxALIGN_CENTER_VERTICAL, 5);
wxStaticText* itemStaticText41 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&After a paragraph:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer38->Add(itemStaticText41, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
m_spacingAfter = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
if (wxRichTextIndentsSpacingPage::ShowToolTips())
m_spacingAfter->SetToolTip(_("The spacing after the paragraph."));
itemBoxSizer46->Add(m_spacingAfter, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemFlexGridSizer38->Add(m_spacingAfter, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText48 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("L&ine spacing:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer41->Add(itemStaticText48, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer49 = new wxBoxSizer(wxHORIZONTAL);
itemFlexGridSizer41->Add(itemBoxSizer49, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5);
wxStaticText* itemStaticText43 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("L&ine spacing:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer38->Add(itemStaticText43, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxArrayString m_spacingLineStrings;
m_spacingLineStrings.Add(_("(none)"));
m_spacingLineStrings.Add(_("Single"));
m_spacingLineStrings.Add(_("1.1"));
m_spacingLineStrings.Add(_("1.2"));
@ -324,12 +308,19 @@ void wxRichTextIndentsSpacingPage::CreateControls()
m_spacingLineStrings.Add(_("1.8"));
m_spacingLineStrings.Add(_("1.9"));
m_spacingLineStrings.Add(_("2"));
m_spacingLine = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE, _("Single"), wxDefaultPosition, wxSize(90, -1), m_spacingLineStrings, wxCB_READONLY );
m_spacingLine->SetStringSelection(_("Single"));
m_spacingLine = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE, _("(none)"), wxDefaultPosition, wxSize(85, -1), m_spacingLineStrings, wxCB_READONLY );
m_spacingLine->SetStringSelection(_("(none)"));
m_spacingLine->SetHelpText(_("The line spacing."));
if (wxRichTextIndentsSpacingPage::ShowToolTips())
m_spacingLine->SetToolTip(_("The line spacing."));
itemBoxSizer49->Add(m_spacingLine, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemFlexGridSizer38->Add(m_spacingLine, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
m_pageBreakCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_PAGEBREAK, _("&Page Break"), wxDefaultPosition, wxDefaultSize, 0 );
m_pageBreakCtrl->SetValue(false);
m_pageBreakCtrl->SetHelpText(_("Inserts a page break before the paragraph."));
if (wxRichTextIndentsSpacingPage::ShowToolTips())
m_pageBreakCtrl->SetToolTip(_("Inserts a page break before the paragraph."));
itemBoxSizer34->Add(m_pageBreakCtrl, 0, wxALIGN_LEFT|wxALL, 5);
itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL, 5);
@ -448,9 +439,9 @@ bool wxRichTextIndentsSpacingPage::TransferDataFromWindow()
else
attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_BEFORE));
int spacingIndex = m_spacingLine->GetSelection();
int spacingIndex = m_spacingLine->GetSelection() - 1;
int lineSpacing = 0;
if (spacingIndex != -1)
if (spacingIndex > -1)
lineSpacing = 10 + spacingIndex;
if (lineSpacing == 0)
@ -459,8 +450,15 @@ bool wxRichTextIndentsSpacingPage::TransferDataFromWindow()
attr->SetLineSpacing(lineSpacing);
int outlineLevel = m_outlineLevelCtrl->GetSelection();
if (outlineLevel != wxNOT_FOUND)
attr->SetOutlineLevel(outlineLevel);
if (outlineLevel == wxNOT_FOUND || outlineLevel == 0)
{
attr->SetOutlineLevel(-1);
attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_OUTLINE_LEVEL));
}
else
attr->SetOutlineLevel(outlineLevel-1);
attr->SetPageBreak(m_pageBreakCtrl->GetValue());
return true;
}
@ -536,14 +534,14 @@ bool wxRichTextIndentsSpacingPage::TransferDataToWindow()
int lineSpacing = attr->GetLineSpacing();
if (lineSpacing >= 10 && lineSpacing <= 20)
index = lineSpacing - 10;
index = (lineSpacing - 10) + 1;
else
index = -1;
index = 0;
m_spacingLine->SetSelection(index);
}
else
m_spacingLine->SetSelection(-1);
m_spacingLine->SetSelection(0);
if (attr->HasOutlineLevel())
{
@ -553,10 +551,12 @@ bool wxRichTextIndentsSpacingPage::TransferDataToWindow()
if (outlineLevel > 9)
outlineLevel = 9;
m_outlineLevelCtrl->SetSelection(outlineLevel);
m_outlineLevelCtrl->SetSelection(outlineLevel+1);
}
else
m_outlineLevelCtrl->SetSelection(-1);
m_outlineLevelCtrl->SetSelection(0);
m_pageBreakCtrl->SetValue(attr->HasPageBreak());
UpdatePreview();

View File

@ -382,91 +382,88 @@ void wxRichTextListStylePage::CreateControls()
wxStaticText* itemStaticText58 = new wxStaticText( itemPanel37, wxID_STATIC, _("&Left:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer57->Add(itemStaticText58, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer59 = new wxBoxSizer(wxHORIZONTAL);
itemFlexGridSizer57->Add(itemBoxSizer59, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
m_indentLeft = new wxTextCtrl( itemPanel37, ID_RICHTEXTLISTSTYLEPAGE_INDENTLEFT, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
m_indentLeft->SetHelpText(_("The left indent."));
if (wxRichTextListStylePage::ShowToolTips())
m_indentLeft->SetToolTip(_("The left indent."));
itemBoxSizer59->Add(m_indentLeft, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemFlexGridSizer57->Add(m_indentLeft, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText61 = new wxStaticText( itemPanel37, wxID_STATIC, _("Left (&first line):"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer57->Add(itemStaticText61, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText60 = new wxStaticText( itemPanel37, wxID_STATIC, _("Left (&first line):"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer57->Add(itemStaticText60, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer62 = new wxBoxSizer(wxHORIZONTAL);
itemFlexGridSizer57->Add(itemBoxSizer62, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
m_indentLeftFirst = new wxTextCtrl( itemPanel37, ID_RICHTEXTLISTSTYLEPAGE_INDENTFIRSTLINE, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
m_indentLeftFirst->SetHelpText(_("The first line indent."));
if (wxRichTextListStylePage::ShowToolTips())
m_indentLeftFirst->SetToolTip(_("The first line indent."));
itemBoxSizer62->Add(m_indentLeftFirst, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemFlexGridSizer57->Add(m_indentLeftFirst, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText64 = new wxStaticText( itemPanel37, wxID_STATIC, _("&Right:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer57->Add(itemStaticText64, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText62 = new wxStaticText( itemPanel37, wxID_STATIC, _("&Right:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer57->Add(itemStaticText62, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer65 = new wxBoxSizer(wxHORIZONTAL);
itemFlexGridSizer57->Add(itemBoxSizer65, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
m_indentRight = new wxTextCtrl( itemPanel37, ID_RICHTEXTLISTSTYLEPAGE_INDENTRIGHT, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
m_indentRight->SetHelpText(_("The right indent."));
if (wxRichTextListStylePage::ShowToolTips())
m_indentRight->SetToolTip(_("The right indent."));
itemBoxSizer65->Add(m_indentRight, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemFlexGridSizer57->Add(m_indentRight, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemBoxSizer39->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
wxStaticLine* itemStaticLine68 = new wxStaticLine( itemPanel37, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
itemBoxSizer39->Add(itemStaticLine68, 0, wxGROW|wxTOP|wxBOTTOM, 5);
wxStaticLine* itemStaticLine65 = new wxStaticLine( itemPanel37, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
itemBoxSizer39->Add(itemStaticLine65, 0, wxGROW|wxTOP|wxBOTTOM, 5);
itemBoxSizer39->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
wxBoxSizer* itemBoxSizer70 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer39->Add(itemBoxSizer70, 0, wxGROW, 5);
wxStaticText* itemStaticText71 = new wxStaticText( itemPanel37, wxID_STATIC, _("&Spacing (tenths of a mm)"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer70->Add(itemStaticText71, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
wxBoxSizer* itemBoxSizer67 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer39->Add(itemBoxSizer67, 0, wxGROW, 5);
wxStaticText* itemStaticText68 = new wxStaticText( itemPanel37, wxID_STATIC, _("&Spacing (tenths of a mm)"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer67->Add(itemStaticText68, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
wxBoxSizer* itemBoxSizer72 = new wxBoxSizer(wxHORIZONTAL);
itemBoxSizer70->Add(itemBoxSizer72, 0, wxALIGN_LEFT|wxALL, 5);
itemBoxSizer72->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 5);
wxBoxSizer* itemBoxSizer69 = new wxBoxSizer(wxHORIZONTAL);
itemBoxSizer67->Add(itemBoxSizer69, 0, wxALIGN_LEFT|wxALL, 5);
itemBoxSizer69->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 5);
wxFlexGridSizer* itemFlexGridSizer74 = new wxFlexGridSizer(0, 2, 0, 0);
itemBoxSizer72->Add(itemFlexGridSizer74, 0, wxALIGN_CENTER_VERTICAL, 5);
wxStaticText* itemStaticText75 = new wxStaticText( itemPanel37, wxID_STATIC, _("Before a paragraph:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer74->Add(itemStaticText75, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxFlexGridSizer* itemFlexGridSizer71 = new wxFlexGridSizer(0, 2, 0, 0);
itemBoxSizer69->Add(itemFlexGridSizer71, 0, wxALIGN_CENTER_VERTICAL, 5);
wxStaticText* itemStaticText72 = new wxStaticText( itemPanel37, wxID_STATIC, _("Before a paragraph:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer71->Add(itemStaticText72, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer76 = new wxBoxSizer(wxHORIZONTAL);
itemFlexGridSizer74->Add(itemBoxSizer76, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
m_spacingBefore = new wxTextCtrl( itemPanel37, ID_RICHTEXTLISTSTYLEPAGE_SPACINGBEFORE, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
m_spacingBefore->SetHelpText(_("The spacing before the paragraph."));
if (wxRichTextListStylePage::ShowToolTips())
m_spacingBefore->SetToolTip(_("The spacing before the paragraph."));
itemBoxSizer76->Add(m_spacingBefore, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemFlexGridSizer71->Add(m_spacingBefore, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText78 = new wxStaticText( itemPanel37, wxID_STATIC, _("After a paragraph:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer74->Add(itemStaticText78, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText74 = new wxStaticText( itemPanel37, wxID_STATIC, _("After a paragraph:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer71->Add(itemStaticText74, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer79 = new wxBoxSizer(wxHORIZONTAL);
itemFlexGridSizer74->Add(itemBoxSizer79, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
m_spacingAfter = new wxTextCtrl( itemPanel37, ID_RICHTEXTLISTSTYLEPAGE_SPACINGAFTER, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
m_spacingAfter->SetHelpText(_("The spacing after the paragraph."));
if (wxRichTextListStylePage::ShowToolTips())
m_spacingAfter->SetToolTip(_("The spacing after the paragraph."));
itemBoxSizer79->Add(m_spacingAfter, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemFlexGridSizer71->Add(m_spacingAfter, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText81 = new wxStaticText( itemPanel37, wxID_STATIC, _("Line spacing:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer74->Add(itemStaticText81, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText76 = new wxStaticText( itemPanel37, wxID_STATIC, _("Line spacing:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer71->Add(itemStaticText76, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer82 = new wxBoxSizer(wxHORIZONTAL);
itemFlexGridSizer74->Add(itemBoxSizer82, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
wxArrayString m_spacingLineStrings;
m_spacingLineStrings.Add(_("(none)"));
m_spacingLineStrings.Add(_("Single"));
m_spacingLineStrings.Add(_("1.1"));
m_spacingLineStrings.Add(_("1.2"));
m_spacingLineStrings.Add(_("1.3"));
m_spacingLineStrings.Add(_("1.4"));
m_spacingLineStrings.Add(_("1.5"));
m_spacingLineStrings.Add(_("1.6"));
m_spacingLineStrings.Add(_("1.7"));
m_spacingLineStrings.Add(_("1.8"));
m_spacingLineStrings.Add(_("1.9"));
m_spacingLineStrings.Add(_("2"));
m_spacingLine = new wxComboBox( itemPanel37, ID_RICHTEXTLISTSTYLEPAGE_LINESPACING, _("Single"), wxDefaultPosition, wxDefaultSize, m_spacingLineStrings, wxCB_READONLY );
m_spacingLine->SetStringSelection(_("Single"));
m_spacingLine = new wxComboBox( itemPanel37, ID_RICHTEXTLISTSTYLEPAGE_LINESPACING, _("(none)"), wxDefaultPosition, wxSize(85, -1), m_spacingLineStrings, wxCB_READONLY );
m_spacingLine->SetStringSelection(_("(none)"));
m_spacingLine->SetHelpText(_("The line spacing."));
if (wxRichTextListStylePage::ShowToolTips())
m_spacingLine->SetToolTip(_("The line spacing."));
itemBoxSizer82->Add(m_spacingLine, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemFlexGridSizer71->Add(m_spacingLine, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemNotebook9->AddPage(itemPanel37, _("Spacing"));
@ -631,14 +628,10 @@ bool wxRichTextListStylePage::TransferDataFromWindow()
else
attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_BEFORE));
int spacingIndex = m_spacingLine->GetSelection();
int spacingIndex = m_spacingLine->GetSelection() - 1;
int lineSpacing = 0;
if (spacingIndex == 0)
lineSpacing = 10;
else if (spacingIndex == 1)
lineSpacing = 15;
else if (spacingIndex == 2)
lineSpacing = 20;
if (spacingIndex > -1)
lineSpacing = 10 + spacingIndex;
if (lineSpacing == 0)
attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_LINE_SPACING));
@ -785,19 +778,15 @@ void wxRichTextListStylePage::DoTransferDataToWindow()
int index = 0;
int lineSpacing = attr->GetLineSpacing();
if (lineSpacing == 10)
index = 0;
else if (lineSpacing == 15)
index = 1;
else if (lineSpacing == 20)
index = 2;
if (lineSpacing >= 10 && lineSpacing <= 20)
index = (lineSpacing - 10) + 1;
else
index = -1;
index = 0;
m_spacingLine->SetSelection(index);
}
else
m_spacingLine->SetSelection(-1);
m_spacingLine->SetSelection(0);
/// BULLETS
if (attr->HasBulletStyle())

View File

@ -46,7 +46,7 @@ wx_top_builddir = @wx_top_builddir@
DESTDIR =
WX_RELEASE = 2.9
WX_VERSION = $(WX_RELEASE).2
WX_VERSION = $(WX_RELEASE).3
LIBDIRNAME = $(wx_top_builddir)/lib
TEST_CXXFLAGS = $(__test_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
$(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
@ -166,6 +166,7 @@ TEST_GUI_OBJECTS = \
test_gui_choicebooktest.o \
test_gui_choicetest.o \
test_gui_comboboxtest.o \
test_gui_dataviewctrltest.o \
test_gui_datepickerctrltest.o \
test_gui_frametest.o \
test_gui_gaugetest.o \
@ -732,6 +733,9 @@ test_gui_choicetest.o: $(srcdir)/controls/choicetest.cpp $(TEST_GUI_ODEP)
test_gui_comboboxtest.o: $(srcdir)/controls/comboboxtest.cpp $(TEST_GUI_ODEP)
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/comboboxtest.cpp
test_gui_dataviewctrltest.o: $(srcdir)/controls/dataviewctrltest.cpp $(TEST_GUI_ODEP)
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/dataviewctrltest.cpp
test_gui_datepickerctrltest.o: $(srcdir)/controls/datepickerctrltest.cpp $(TEST_GUI_ODEP)
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/datepickerctrltest.cpp

View File

@ -0,0 +1,140 @@
///////////////////////////////////////////////////////////////////////////////
// Name: tests/controls/treectrltest.cpp
// Purpose: wxDataViewCtrl unit test
// Author: Vaclav Slavik
// Created: 2011-08-08
// RCS-ID: $Id$
// Copyright: (c) 2011 Vaclav Slavik <vslavik@gmail.com>
///////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "testprec.h"
#if wxUSE_DATAVIEWCTRL
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/app.h"
#include "wx/dataview.h"
#include "testableframe.h"
// ----------------------------------------------------------------------------
// test class
// ----------------------------------------------------------------------------
class DataViewCtrlTestCase : public CppUnit::TestCase
{
public:
DataViewCtrlTestCase() { }
virtual void setUp();
virtual void tearDown();
private:
CPPUNIT_TEST_SUITE( DataViewCtrlTestCase );
CPPUNIT_TEST( DeleteSelected );
CPPUNIT_TEST( DeleteNotSelected );
CPPUNIT_TEST_SUITE_END();
void DeleteSelected();
void DeleteNotSelected();
// the dataview control itself
wxDataViewTreeCtrl *m_dvc;
// and some of its items
wxDataViewItem m_root,
m_child1,
m_child2,
m_grandchild;
DECLARE_NO_COPY_CLASS(DataViewCtrlTestCase)
};
// register in the unnamed registry so that these tests are run by default
CPPUNIT_TEST_SUITE_REGISTRATION( DataViewCtrlTestCase );
// also include in its own registry so that these tests can be run alone
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( DataViewCtrlTestCase, "DataViewCtrlTestCase" );
// ----------------------------------------------------------------------------
// test initialization
// ----------------------------------------------------------------------------
void DataViewCtrlTestCase::setUp()
{
m_dvc = new wxDataViewTreeCtrl(wxTheApp->GetTopWindow(),
wxID_ANY,
wxDefaultPosition,
wxSize(400, 200),
wxDV_MULTIPLE);
m_root = m_dvc->AppendContainer(wxDataViewItem(), "The root");
m_child1 = m_dvc->AppendContainer(m_root, "child1");
m_grandchild = m_dvc->AppendItem(m_child1, "grandchild");
m_child2 = m_dvc->AppendItem(m_root, "child2");
m_dvc->SetSize(400, 200);
m_dvc->ExpandAncestors(m_root);
m_dvc->Refresh();
m_dvc->Update();
}
void DataViewCtrlTestCase::tearDown()
{
delete m_dvc;
m_dvc = NULL;
m_root =
m_child1 =
m_child2 =
m_grandchild = wxDataViewItem();
}
// ----------------------------------------------------------------------------
// the tests themselves
// ----------------------------------------------------------------------------
void DataViewCtrlTestCase::DeleteSelected()
{
wxDataViewItemArray sel;
sel.push_back(m_child1);
sel.push_back(m_grandchild);
sel.push_back(m_child2);
m_dvc->SetSelections(sel);
// delete a selected item
m_dvc->DeleteItem(m_child1);
m_dvc->GetSelections(sel);
// m_child1 and its children should be removed from the selection now
CPPUNIT_ASSERT( sel.size() == 1 );
CPPUNIT_ASSERT( sel[0] == m_child2 );
}
void DataViewCtrlTestCase::DeleteNotSelected()
{
wxDataViewItemArray sel;
sel.push_back(m_child1);
sel.push_back(m_grandchild);
m_dvc->SetSelections(sel);
// delete unselected item
m_dvc->DeleteItem(m_child2);
m_dvc->GetSelections(sel);
// m_child1 and its children should be removed from the selection now
CPPUNIT_ASSERT( sel.size() == 2 );
CPPUNIT_ASSERT( sel[0] == m_child1 );
CPPUNIT_ASSERT( sel[1] == m_grandchild );
}
#endif //wxUSE_TREECTRL

View File

@ -59,6 +59,9 @@ private:
CPPUNIT_TEST( Style );
CPPUNIT_TEST( Lines );
CPPUNIT_TEST( LogTextCtrl );
CPPUNIT_TEST( PositionToCoords );
CPPUNIT_TEST( PositionToCoordsRich );
CPPUNIT_TEST( PositionToCoordsRich2 );
CPPUNIT_TEST_SUITE_END();
void MultiLineReplace();
@ -71,6 +74,11 @@ private:
void Style();
void Lines();
void LogTextCtrl();
void PositionToCoords();
void PositionToCoordsRich();
void PositionToCoordsRich2();
void DoPositionToCoordsTestWithStyle(long style);
wxTextCtrl *m_text;
@ -380,7 +388,6 @@ void TextCtrlTestCase::Style()
void TextCtrlTestCase::Lines()
{
#ifndef __WXOSX__
delete m_text;
m_text = new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, "",
wxDefaultPosition, wxSize(400, 200), wxTE_MULTILINE | wxTE_DONTWRAP);
@ -399,6 +406,17 @@ void TextCtrlTestCase::Lines()
CPPUNIT_ASSERT_EQUAL(5, m_text->GetNumberOfLines());
CPPUNIT_ASSERT_EQUAL(0, m_text->GetLineLength(3));
CPPUNIT_ASSERT_EQUAL("", m_text->GetLineText(3));
// Verify that wrapped lines count as 2 lines.
//
// This currently doesn't work neither in wxGTK nor wxOSX/Cocoa, see
// #12366, where GetNumberOfLines() always returns the number of logical,
// not physical, lines.
m_text->AppendText("\n" + wxString(50, '1') + ' ' + wxString(50, '2'));
#if defined(__WXGTK__) || defined(__WXOSX_COCOA__)
CPPUNIT_ASSERT_EQUAL(6, m_text->GetNumberOfLines());
#else
CPPUNIT_ASSERT_EQUAL(7, m_text->GetNumberOfLines());
#endif
}
@ -422,4 +440,98 @@ void TextCtrlTestCase::LogTextCtrl()
CPPUNIT_ASSERT(!m_text->IsEmpty());
}
void TextCtrlTestCase::PositionToCoords()
{
DoPositionToCoordsTestWithStyle(0);
}
void TextCtrlTestCase::PositionToCoordsRich()
{
DoPositionToCoordsTestWithStyle(wxTE_RICH);
}
void TextCtrlTestCase::PositionToCoordsRich2()
{
DoPositionToCoordsTestWithStyle(wxTE_RICH2);
}
void TextCtrlTestCase::DoPositionToCoordsTestWithStyle(long style)
{
static const int TEXT_HEIGHT = 200;
delete m_text;
m_text = new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, "",
wxDefaultPosition, wxSize(400, TEXT_HEIGHT),
wxTE_MULTILINE | style);
// Asking for invalid index should fail.
WX_ASSERT_FAILS_WITH_ASSERT( m_text->PositionToCoords(1) );
// Getting position shouldn't return wxDefaultPosition except if the method
// is not implemented at all in the current port.
const wxPoint pos0 = m_text->PositionToCoords(0);
if ( pos0 == wxDefaultPosition )
{
#if defined(__WXMSW__) || defined(__WXGTK20__)
CPPUNIT_FAIL( "PositionToCoords() unexpectedly failed." );
#endif
return;
}
CPPUNIT_ASSERT(pos0.x >= 0);
CPPUNIT_ASSERT(pos0.y >= 0);
m_text->SetValue("Hello");
wxYield(); // Let GTK layout the control correctly.
// Position of non-first character should be positive.
const long posHello4 = m_text->PositionToCoords(4).x;
CPPUNIT_ASSERT( posHello4 > 0 );
// Asking for position beyond the last character should succeed and return
// reasonable result.
CPPUNIT_ASSERT( m_text->PositionToCoords(5).x > posHello4 );
// But asking for the next position should fail.
WX_ASSERT_FAILS_WITH_ASSERT( m_text->PositionToCoords(6) );
// Test getting the coordinates of the last character when it is in the
// beginning of a new line to exercise MSW code which has specific logic
// for it.
m_text->AppendText("\n");
const wxPoint posLast = m_text->PositionToCoords(m_text->GetLastPosition());
CPPUNIT_ASSERT_EQUAL( pos0.x, posLast.x );
CPPUNIT_ASSERT( posLast.y > 0 );
// Add enough contents to the control to make sure it has a scrollbar.
m_text->SetValue("First line" + wxString(50, '\n') + "Last line");
m_text->SetInsertionPoint(0);
wxYield(); // Let GTK layout the control correctly.
// This shouldn't change anything for the first position coordinates.
CPPUNIT_ASSERT_EQUAL( pos0, m_text->PositionToCoords(0) );
// And the last one must be beyond the window boundary and so not be
// visible -- but getting its coordinate should still work.
CPPUNIT_ASSERT
(
m_text->PositionToCoords(m_text->GetLastPosition()).y > TEXT_HEIGHT
);
// Now make it scroll to the end and check that the first position now has
// negative offset as its above the visible part of the window while the
// last position is in its bounds.
m_text->SetInsertionPointEnd();
CPPUNIT_ASSERT( m_text->PositionToCoords(0).y < 0 );
CPPUNIT_ASSERT
(
m_text->PositionToCoords(m_text->GetInsertionPoint()).y <= TEXT_HEIGHT
);
}
#endif //wxUSE_TEXTCTRL

View File

@ -151,6 +151,7 @@ TEST_GUI_OBJECTS = \
$(OBJS)\test_gui_choicebooktest.obj \
$(OBJS)\test_gui_choicetest.obj \
$(OBJS)\test_gui_comboboxtest.obj \
$(OBJS)\test_gui_dataviewctrltest.obj \
$(OBJS)\test_gui_datepickerctrltest.obj \
$(OBJS)\test_gui_frametest.obj \
$(OBJS)\test_gui_gaugetest.obj \
@ -780,6 +781,9 @@ $(OBJS)\test_gui_choicetest.obj: .\controls\choicetest.cpp
$(OBJS)\test_gui_comboboxtest.obj: .\controls\comboboxtest.cpp
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\comboboxtest.cpp
$(OBJS)\test_gui_dataviewctrltest.obj: .\controls\dataviewctrltest.cpp
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\dataviewctrltest.cpp
$(OBJS)\test_gui_datepickerctrltest.obj: .\controls\datepickerctrltest.cpp
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\datepickerctrltest.cpp

View File

@ -144,6 +144,7 @@ TEST_GUI_OBJECTS = \
$(OBJS)\test_gui_choicebooktest.o \
$(OBJS)\test_gui_choicetest.o \
$(OBJS)\test_gui_comboboxtest.o \
$(OBJS)\test_gui_dataviewctrltest.o \
$(OBJS)\test_gui_datepickerctrltest.o \
$(OBJS)\test_gui_frametest.o \
$(OBJS)\test_gui_gaugetest.o \
@ -761,6 +762,9 @@ $(OBJS)\test_gui_choicetest.o: ./controls/choicetest.cpp
$(OBJS)\test_gui_comboboxtest.o: ./controls/comboboxtest.cpp
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\test_gui_dataviewctrltest.o: ./controls/dataviewctrltest.cpp
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\test_gui_datepickerctrltest.o: ./controls/datepickerctrltest.cpp
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<

View File

@ -146,6 +146,7 @@ TEST_GUI_OBJECTS = \
$(OBJS)\test_gui_choicebooktest.obj \
$(OBJS)\test_gui_choicetest.obj \
$(OBJS)\test_gui_comboboxtest.obj \
$(OBJS)\test_gui_dataviewctrltest.obj \
$(OBJS)\test_gui_datepickerctrltest.obj \
$(OBJS)\test_gui_frametest.obj \
$(OBJS)\test_gui_gaugetest.obj \
@ -906,6 +907,9 @@ $(OBJS)\test_gui_choicetest.obj: .\controls\choicetest.cpp
$(OBJS)\test_gui_comboboxtest.obj: .\controls\comboboxtest.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\comboboxtest.cpp
$(OBJS)\test_gui_dataviewctrltest.obj: .\controls\dataviewctrltest.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\dataviewctrltest.cpp
$(OBJS)\test_gui_datepickerctrltest.obj: .\controls\datepickerctrltest.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\datepickerctrltest.cpp

View File

@ -390,6 +390,7 @@ TEST_GUI_OBJECTS = &
$(OBJS)\test_gui_choicebooktest.obj &
$(OBJS)\test_gui_choicetest.obj &
$(OBJS)\test_gui_comboboxtest.obj &
$(OBJS)\test_gui_dataviewctrltest.obj &
$(OBJS)\test_gui_datepickerctrltest.obj &
$(OBJS)\test_gui_frametest.obj &
$(OBJS)\test_gui_gaugetest.obj &
@ -820,6 +821,9 @@ $(OBJS)\test_gui_choicetest.obj : .AUTODEPEND .\controls\choicetest.cpp
$(OBJS)\test_gui_comboboxtest.obj : .AUTODEPEND .\controls\comboboxtest.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
$(OBJS)\test_gui_dataviewctrltest.obj : .AUTODEPEND .\controls\dataviewctrltest.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
$(OBJS)\test_gui_datepickerctrltest.obj : .AUTODEPEND .\controls\datepickerctrltest.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<

View File

@ -147,6 +147,7 @@
controls/choicebooktest.cpp
controls/choicetest.cpp
controls/comboboxtest.cpp
controls/dataviewctrltest.cpp
controls/datepickerctrltest.cpp
controls/frametest.cpp
controls/gaugetest.cpp

View File

@ -307,6 +307,10 @@ SOURCE=.\config\config.cpp
# End Source File
# Begin Source File
SOURCE=.\controls\dataviewctrltest.cpp
# End Source File
# Begin Source File
SOURCE=.\controls\datepickerctrltest.cpp
# End Source File
# Begin Source File

View File

@ -619,6 +619,9 @@
<File
RelativePath=".\config\config.cpp">
</File>
<File
RelativePath=".\controls\dataviewctrltest.cpp">
</File>
<File
RelativePath=".\controls\datepickerctrltest.cpp">
</File>

View File

@ -899,6 +899,10 @@
RelativePath=".\config\config.cpp"
>
</File>
<File
RelativePath=".\controls\dataviewctrltest.cpp"
>
</File>
<File
RelativePath=".\controls\datepickerctrltest.cpp"
>

View File

@ -871,6 +871,10 @@
RelativePath=".\config\config.cpp"
>
</File>
<File
RelativePath=".\controls\dataviewctrltest.cpp"
>
</File>
<File
RelativePath=".\controls\datepickerctrltest.cpp"
>

View File

@ -279,10 +279,10 @@ bool hvApp::OpenBook(wxHtmlHelpController* controller)
#ifdef __WXMAC__
/// Respond to Apple Event for opening a document
void hvApp::MacOpenFile(const wxString& filename)
void hvApp::MacOpenFiles(const wxArrayString& fileNames)
{
wxBusyCursor bcur;
wxFileName fileName(filename);
wxFileName fileName(fileNames[0]);
m_helpController->AddBook(fileName);
m_helpController->DisplayContents();
}

View File

@ -36,7 +36,7 @@ public:
#ifdef __WXMAC__
/// Respond to Apple Event for opening a document
virtual void MacOpenFile(const wxString& filename);
virtual void MacOpenFiles(const wxArrayString& fileNames);
#endif
/// Prompt the user for a book to open