initial commit
Signed-off-by: Peter Siegmund <mars3142@noreply.mars3142.dev>
This commit is contained in:
50
libs/wxWidgets-3.3.1/include/wx/osx/cocoa/private/date.h
Normal file
50
libs/wxWidgets-3.3.1/include/wx/osx/cocoa/private/date.h
Normal file
@@ -0,0 +1,50 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/osx/cocoa/private/date.h
|
||||
// Purpose: NSDate-related helpers
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2011-12-19
|
||||
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_OSX_COCOA_PRIVATE_DATE_H_
|
||||
#define _WX_OSX_COCOA_PRIVATE_DATE_H_
|
||||
|
||||
#include "wx/datetime.h"
|
||||
|
||||
namespace wxOSXImpl
|
||||
{
|
||||
|
||||
// Functions to convert between NSDate and wxDateTime.
|
||||
|
||||
// Returns an NSDate corresponding to the given wxDateTime which can be invalid
|
||||
// (in which case nil is returned).
|
||||
inline NSDate* NSDateFromWX(const wxDateTime& dt)
|
||||
{
|
||||
if ( !dt.IsValid() )
|
||||
return nil;
|
||||
|
||||
// Get the internal representation as a double used by NSDate.
|
||||
double ticks = dt.GetValue().ToDouble();
|
||||
|
||||
// wxDateTime uses milliseconds while NSDate uses (fractional) seconds.
|
||||
return [NSDate dateWithTimeIntervalSince1970:ticks/1000.];
|
||||
}
|
||||
|
||||
|
||||
// Returns wxDateTime corresponding to the given NSDate (which may be nil).
|
||||
inline wxDateTime NSDateToWX(const NSDate* d)
|
||||
{
|
||||
if ( !d )
|
||||
return wxDefaultDateTime;
|
||||
|
||||
// Reverse everything done above.
|
||||
wxLongLong ll;
|
||||
ll.Assign([d timeIntervalSince1970]*1000);
|
||||
wxDateTime dt(ll);
|
||||
return dt;
|
||||
}
|
||||
|
||||
} // namespace wxOSXImpl
|
||||
|
||||
#endif // _WX_OSX_COCOA_PRIVATE_DATE_H_
|
||||
181
libs/wxWidgets-3.3.1/include/wx/osx/cocoa/private/markuptoattr.h
Normal file
181
libs/wxWidgets-3.3.1/include/wx/osx/cocoa/private/markuptoattr.h
Normal file
@@ -0,0 +1,181 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/osx/cocoa/private/markuptoattr.h
|
||||
// Purpose: Class to convert markup to Cocoa attributed strings.
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2011-02-22
|
||||
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_OSX_COCOA_PRIVATE_MARKUPTOATTR_H_
|
||||
#define _WX_OSX_COCOA_PRIVATE_MARKUPTOATTR_H_
|
||||
|
||||
#include "wx/private/markupparserattr.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxMarkupToAttrString: create NSAttributedString from markup.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxMarkupToAttrStringBase : public wxMarkupParserAttrOutput
|
||||
{
|
||||
protected:
|
||||
// We don't care about the original colours because we never use them but
|
||||
// we do need the correct initial font as we apply modifiers (e.g. create a
|
||||
// font larger than it) to it and so it must be valid.
|
||||
wxMarkupToAttrStringBase(const wxFont& font)
|
||||
: wxMarkupParserAttrOutput(font, wxColour(), wxColour()),
|
||||
m_attrString(nullptr)
|
||||
{}
|
||||
|
||||
void Parse(const wxFont& font, const wxString& markup)
|
||||
{
|
||||
const wxCFStringRef label(PrepareText(wxMarkupParser::Strip(markup)));
|
||||
m_attrString = [[NSMutableAttributedString alloc]
|
||||
initWithString: label.AsNSString()];
|
||||
|
||||
m_pos = 0;
|
||||
|
||||
[m_attrString beginEditing];
|
||||
|
||||
// First thing we do is change the default string font: as mentioned in
|
||||
// Apple documentation, attributed strings use "Helvetica 12" font by
|
||||
// default which is different from the system "Lucida Grande" font. So
|
||||
// we need to explicitly change the font for the entire string.
|
||||
ApplyFont(font, NSMakeRange(0, [m_attrString length]));
|
||||
|
||||
// Now translate the markup tags to corresponding attributes.
|
||||
wxMarkupParser parser(*this);
|
||||
parser.Parse(markup);
|
||||
|
||||
[m_attrString endEditing];
|
||||
}
|
||||
|
||||
~wxMarkupToAttrStringBase()
|
||||
{
|
||||
if ( m_attrString )
|
||||
[m_attrString release];
|
||||
}
|
||||
|
||||
void ApplyFont(const wxFont& font, const NSRange& range)
|
||||
{
|
||||
[m_attrString addAttribute:NSFontAttributeName
|
||||
value:font.OSXGetNSFont()
|
||||
range:range];
|
||||
|
||||
if ( font.GetStrikethrough() )
|
||||
{
|
||||
[m_attrString addAttribute:NSStrikethroughStyleAttributeName
|
||||
value:@(NSUnderlineStyleSingle)
|
||||
range:range];
|
||||
}
|
||||
|
||||
if ( font.GetUnderlined() )
|
||||
{
|
||||
[m_attrString addAttribute:NSUnderlineStyleAttributeName
|
||||
value:@(NSUnderlineStyleSingle)
|
||||
range:range];
|
||||
}
|
||||
}
|
||||
|
||||
// prepare text chunk for display, e.g. strip mnemonics from it
|
||||
virtual wxString PrepareText(const wxString& text) = 0;
|
||||
|
||||
public:
|
||||
// Accessor for the users of this class.
|
||||
//
|
||||
// We keep ownership of the returned string.
|
||||
NSMutableAttributedString *GetNSAttributedString() const
|
||||
{
|
||||
return m_attrString;
|
||||
}
|
||||
|
||||
|
||||
// Implement base class pure virtual methods to process markup tags.
|
||||
virtual void OnText(const wxString& text) override
|
||||
{
|
||||
m_pos += PrepareText(text).length();
|
||||
}
|
||||
|
||||
virtual void OnAttrStart(const Attr& WXUNUSED(attr)) override
|
||||
{
|
||||
// Just remember the starting position of the range, we can't really
|
||||
// set the attribute until we find the end of it.
|
||||
m_rangeStarts.push(m_pos);
|
||||
}
|
||||
|
||||
virtual void OnAttrEnd(const Attr& attr) override
|
||||
{
|
||||
unsigned start = m_rangeStarts.top();
|
||||
m_rangeStarts.pop();
|
||||
|
||||
const NSRange range = NSMakeRange(start, m_pos - start);
|
||||
|
||||
ApplyFont(attr.font, range);
|
||||
|
||||
if ( attr.foreground.IsOk() )
|
||||
{
|
||||
[m_attrString addAttribute:NSForegroundColorAttributeName
|
||||
value:attr.foreground.OSXGetNSColor()
|
||||
range:range];
|
||||
}
|
||||
|
||||
if ( attr.background.IsOk() )
|
||||
{
|
||||
[m_attrString addAttribute:NSBackgroundColorAttributeName
|
||||
value:attr.background.OSXGetNSColor()
|
||||
range:range];
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
// The attributed string we're building.
|
||||
NSMutableAttributedString *m_attrString;
|
||||
|
||||
// The current position in the output string.
|
||||
unsigned m_pos;
|
||||
|
||||
// The positions of starting ranges.
|
||||
wxStack<unsigned> m_rangeStarts;
|
||||
};
|
||||
|
||||
|
||||
// for use with labels with mnemonics
|
||||
class wxMarkupToAttrString : public wxMarkupToAttrStringBase
|
||||
{
|
||||
public:
|
||||
wxMarkupToAttrString(const wxFont& font, const wxString& markup)
|
||||
: wxMarkupToAttrStringBase(font)
|
||||
{
|
||||
Parse(font, markup);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual wxString PrepareText(const wxString& text) override
|
||||
{
|
||||
return wxControl::RemoveMnemonics(text);
|
||||
}
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxMarkupToAttrString);
|
||||
};
|
||||
|
||||
|
||||
// for raw markup with no mnemonics
|
||||
class wxItemMarkupToAttrString : public wxMarkupToAttrStringBase
|
||||
{
|
||||
public:
|
||||
wxItemMarkupToAttrString(const wxFont& font, const wxString& markup)
|
||||
: wxMarkupToAttrStringBase(font)
|
||||
{
|
||||
Parse(font, markup);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual wxString PrepareText(const wxString& text) override
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxItemMarkupToAttrString);
|
||||
};
|
||||
|
||||
#endif // _WX_OSX_COCOA_PRIVATE_MARKUPTOATTR_H_
|
||||
212
libs/wxWidgets-3.3.1/include/wx/osx/cocoa/private/textimpl.h
Normal file
212
libs/wxWidgets-3.3.1/include/wx/osx/cocoa/private/textimpl.h
Normal file
@@ -0,0 +1,212 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/osx/cocoa/private/textimpl.h
|
||||
// Purpose: textcontrol implementation classes that have to be exposed
|
||||
// Author: Stefan Csomor
|
||||
// Created: 03/02/99
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_
|
||||
#define _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_
|
||||
|
||||
#include "wx/combobox.h"
|
||||
#include "wx/osx/private.h"
|
||||
|
||||
@class wxTextEntryFormatter;
|
||||
|
||||
class wxNSTextBase : public wxWidgetCocoaImpl, public wxTextWidgetImpl
|
||||
{
|
||||
public :
|
||||
wxNSTextBase( wxTextCtrl *text, WXWidget w )
|
||||
: wxWidgetCocoaImpl(text, w),
|
||||
wxTextWidgetImpl(text)
|
||||
{
|
||||
}
|
||||
wxNSTextBase( wxWindow *wxPeer, wxTextEntry *entry, WXWidget w )
|
||||
: wxWidgetCocoaImpl(wxPeer, w),
|
||||
wxTextWidgetImpl(entry)
|
||||
{
|
||||
}
|
||||
virtual ~wxNSTextBase() = default;
|
||||
|
||||
virtual bool ShouldHandleKeyNavigation(const wxKeyEvent &event) const override;
|
||||
|
||||
virtual void SetInitialLabel(const wxString& WXUNUSED(title)) override
|
||||
{
|
||||
// Don't do anything here, text controls don't have any label and
|
||||
// setting it would overwrite the string value set when creating it.
|
||||
}
|
||||
};
|
||||
|
||||
// implementation exposed, so that search control can pull it
|
||||
|
||||
class wxNSTextFieldControl : public wxNSTextBase
|
||||
{
|
||||
public :
|
||||
// wxNSTextFieldControl must always be associated with a wxTextEntry. If
|
||||
// it's associated with a wxTextCtrl then we can get the associated entry
|
||||
// from it but otherwise the second ctor should be used to explicitly pass
|
||||
// us the entry.
|
||||
wxNSTextFieldControl( wxTextCtrl *text, WXWidget w );
|
||||
wxNSTextFieldControl( wxWindow *wxPeer, wxTextEntry *entry, WXWidget w );
|
||||
virtual ~wxNSTextFieldControl();
|
||||
|
||||
virtual bool CanClipMaxLength() const override { return true; }
|
||||
virtual void SetMaxLength(unsigned long len) override;
|
||||
|
||||
virtual bool CanForceUpper() override { return true; }
|
||||
virtual void ForceUpper() override;
|
||||
|
||||
virtual wxTextSearchResult SearchText(const wxTextSearch& WXUNUSED(search)) const override
|
||||
{
|
||||
wxFAIL_MSG("SearchText() should only be used with multiline controls.");
|
||||
return wxTextSearchResult{};
|
||||
}
|
||||
|
||||
virtual wxString GetStringValue() const override ;
|
||||
virtual void SetStringValue( const wxString &str) override ;
|
||||
virtual wxString GetRTFValue() const override
|
||||
{
|
||||
wxFAIL_MSG("GetRTFValue() should only be used with multiline controls.");
|
||||
return wxEmptyString;
|
||||
}
|
||||
virtual void SetRTFValue(const wxString& WXUNUSED(str)) override
|
||||
{
|
||||
wxFAIL_MSG("SetRTFValue() should only be used with multiline controls.");
|
||||
}
|
||||
virtual void Copy() override ;
|
||||
virtual void Cut() override ;
|
||||
virtual void Paste() override ;
|
||||
virtual bool CanPaste() const override ;
|
||||
virtual void SetEditable(bool editable) override ;
|
||||
virtual long GetLastPosition() const override;
|
||||
virtual void GetSelection( long* from, long* to) const override ;
|
||||
virtual void SetSelection( long from , long to ) override;
|
||||
virtual bool PositionToXY(long pos, long *x, long *y) const override;
|
||||
virtual long XYToPosition(long x, long y) const override;
|
||||
virtual void ShowPosition(long pos) override;
|
||||
virtual void WriteText(const wxString& str) override ;
|
||||
virtual bool HasOwnContextMenu() const override { return true; }
|
||||
virtual bool SetHint(const wxString& hint) override;
|
||||
virtual void SetJustification() override;
|
||||
|
||||
virtual void controlAction(WXWidget slf, void* _cmd, void *sender) override;
|
||||
virtual bool becomeFirstResponder(WXWidget slf, void *_cmd) override;
|
||||
virtual bool resignFirstResponder(WXWidget slf, void *_cmd) override;
|
||||
|
||||
virtual void EnableNewLineReplacement(bool enable) override;
|
||||
virtual bool GetNewLineReplacement() override;
|
||||
virtual void SetInternalSelection( long from , long to );
|
||||
virtual void UpdateInternalSelectionFromEditor( wxNSTextFieldEditor* editor);
|
||||
|
||||
virtual wxSize GetBestSize() const override;
|
||||
|
||||
protected :
|
||||
NSTextField* m_textField;
|
||||
long m_selStart;
|
||||
long m_selEnd;
|
||||
|
||||
private:
|
||||
// Common part of both ctors.
|
||||
void Init(WXWidget w);
|
||||
|
||||
// Get our formatter, creating it if necessary.
|
||||
wxTextEntryFormatter* GetFormatter();
|
||||
};
|
||||
|
||||
class wxNSTextViewControl : public wxNSTextBase
|
||||
{
|
||||
public:
|
||||
wxNSTextViewControl( wxTextCtrl *wxPeer, WXWidget w, long style );
|
||||
virtual ~wxNSTextViewControl();
|
||||
|
||||
virtual void insertText(NSString* text, WXWidget slf, void *_cmd) override;
|
||||
|
||||
virtual wxTextSearchResult SearchText(const wxTextSearch &search) const override;
|
||||
|
||||
virtual wxString GetStringValue() const override ;
|
||||
virtual void SetStringValue( const wxString &str) override ;
|
||||
virtual wxString GetRTFValue() const override;
|
||||
virtual void SetRTFValue(const wxString& str) override;
|
||||
virtual void Copy() override ;
|
||||
virtual void Cut() override ;
|
||||
virtual void Paste() override ;
|
||||
virtual bool CanPaste() const override ;
|
||||
virtual void SetEditable(bool editable) override ;
|
||||
virtual long GetLastPosition() const override;
|
||||
virtual void GetSelection( long* from, long* to) const override ;
|
||||
virtual void SetSelection( long from , long to ) override;
|
||||
virtual bool PositionToXY(long pos, long *x, long *y) const override;
|
||||
virtual long XYToPosition(long x, long y) const override;
|
||||
virtual void ShowPosition(long pos) override;
|
||||
virtual void WriteText(const wxString& str) override ;
|
||||
virtual void SetFont(const wxFont & font) override;
|
||||
|
||||
virtual bool GetStyle(long position, wxTextAttr& style) override;
|
||||
virtual void SetStyle(long start, long end, const wxTextAttr& style) override;
|
||||
|
||||
virtual bool CanFocus() const override;
|
||||
|
||||
virtual bool HasOwnContextMenu() const override { return true; }
|
||||
|
||||
#if wxUSE_SPELLCHECK
|
||||
virtual void CheckSpelling(const wxTextProofOptions& options) override;
|
||||
virtual wxTextProofOptions GetCheckingOptions() const override;
|
||||
#endif // wxUSE_SPELLCHECK
|
||||
virtual void EnableAutomaticQuoteSubstitution(bool enable) override;
|
||||
virtual void EnableAutomaticDashSubstitution(bool enable) override;
|
||||
virtual void EnableNewLineReplacement(bool enable) override;
|
||||
virtual bool GetNewLineReplacement() override;
|
||||
|
||||
virtual wxSize GetBestSize() const override;
|
||||
virtual void SetJustification() override;
|
||||
|
||||
virtual void controlTextDidChange() override;
|
||||
|
||||
virtual bool CanUndo() const override;
|
||||
virtual void Undo() override;
|
||||
virtual bool CanRedo() const override;
|
||||
virtual void Redo() override;
|
||||
virtual void EmptyUndoBuffer() override;
|
||||
|
||||
protected:
|
||||
void DoUpdateTextStyle();
|
||||
|
||||
NSScrollView* m_scrollView;
|
||||
NSTextView* m_textView;
|
||||
bool m_useCharWrapping;
|
||||
NSUndoManager* m_undoManager;
|
||||
};
|
||||
|
||||
class wxNSComboBoxControl : public wxNSTextFieldControl, public wxComboWidgetImpl
|
||||
{
|
||||
public :
|
||||
wxNSComboBoxControl( wxComboBox *wxPeer, WXWidget w );
|
||||
virtual ~wxNSComboBoxControl();
|
||||
|
||||
virtual int GetSelectedItem() const override;
|
||||
virtual void SetSelectedItem(int item) override;
|
||||
|
||||
virtual int GetNumberOfItems() const override;
|
||||
|
||||
virtual void InsertItem(int pos, const wxString& item) override;
|
||||
virtual void RemoveItem(int pos) override;
|
||||
|
||||
virtual void Clear() override;
|
||||
|
||||
virtual wxString GetStringAtIndex(int pos) const override;
|
||||
|
||||
virtual int FindString(const wxString& text) const override;
|
||||
virtual void Popup() override;
|
||||
virtual void Dismiss() override;
|
||||
|
||||
virtual void SetEditable(bool editable) override;
|
||||
|
||||
virtual void mouseEvent(WX_NSEvent event, WXWidget slf, void *_cmd) override;
|
||||
|
||||
private:
|
||||
NSComboBox* m_comboBox;
|
||||
};
|
||||
|
||||
#endif // _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_
|
||||
Reference in New Issue
Block a user