Skip to content

Commit

Permalink
making NSString conversion functions available in private.h
Browse files Browse the repository at this point in the history
  • Loading branch information
csomor committed Feb 28, 2018
1 parent 5e61527 commit 0fc5301
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
5 changes: 5 additions & 0 deletions include/wx/osx/cocoa/private.h
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,11 @@ extern ClassicCursor gMacCursors[];

extern NSLayoutManager* gNSLayoutManager;

// NSString<->wxString

wxString wxStringWithNSString(NSString *nsstring);
NSString* wxNSStringWithWxString(const wxString &wxstring);

#endif // wxUSE_GUI

#endif
Expand Down
24 changes: 0 additions & 24 deletions src/html/htmlctrl/webkit/webkit.mm
Original file line number Diff line number Diff line change
Expand Up @@ -93,30 +93,6 @@
}
}



//---------------------------------------------------------
// helper functions for NSString<->wxString conversion
//---------------------------------------------------------

inline wxString wxStringWithNSString(NSString *nsstring)
{
#if wxUSE_UNICODE
return wxString([nsstring UTF8String], wxConvUTF8);
#else
return wxString([nsstring lossyCString]);
#endif // wxUSE_UNICODE
}

inline NSString* wxNSStringWithWxString(const wxString &wxstring)
{
#if wxUSE_UNICODE
return [NSString stringWithUTF8String: wxstring.mb_str(wxConvUTF8)];
#else
return [NSString stringWithCString: wxstring.c_str() length:wxstring.Len()];
#endif // wxUSE_UNICODE
}

inline int wxNavTypeFromWebNavType(int type){
if (type == WebNavigationTypeLinkClicked)
return wxWEBKIT_NAV_LINK_CLICKED;
Expand Down
22 changes: 22 additions & 0 deletions src/osx/carbon/utilscocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -562,5 +562,27 @@ void wxMacCocoaShowCursor()
[NSCursor unhide];
}

//---------------------------------------------------------
// helper functions for NSString<->wxString conversion
//---------------------------------------------------------

wxString wxStringWithNSString(NSString *nsstring)
{
#if wxUSE_UNICODE
return wxString([nsstring UTF8String], wxConvUTF8);
#else
return wxString([nsstring lossyCString]);
#endif // wxUSE_UNICODE
}

NSString* wxNSStringWithWxString(const wxString &wxstring)
{
#if wxUSE_UNICODE
return [NSString stringWithUTF8String: wxstring.mb_str(wxConvUTF8)];
#else
return [NSString stringWithCString: wxstring.c_str() length:wxstring.Len()];
#endif // wxUSE_UNICODE
}

#endif

0 comments on commit 0fc5301

Please sign in to comment.