1 #ifndef GUI_WIDGETS_WX___UTILS__HPP
2 #define GUI_WIDGETS_WX___UTILS__HPP
42 #include <wx/artprov.h>
43 #include <wx/colour.h>
45 #include <wx/arrstr.h>
47 #include <wx/string.h>
61 class wxTopLevelWindow;
67 #define wxTR_GBENCH_LINES wxTR_LINES_AT_ROOT
69 #define wxTR_GBENCH_LINES wxTR_NO_LINES
134 , mf_Reentry(
false )
139 void OnCommandEvent( wxCommandEvent& event );
140 void OnMenuEvent( wxCommandEvent& event );
141 void OnUpdateUIEvent( wxUpdateUIEvent& event );
147 DECLARE_EVENT_TABLE()
163 return string(s.ToAscii());
168 const wxScopedCharBuffer line(
input.ToUTF8());
176 std::replace_if(clean.begin(), clean.end(),
177 [](
const char& c) ->
bool { return c < 0 || c > 127; },
'?');
178 return wxString::FromAscii(clean.c_str());
183 string clean(s,
len);
184 std::replace_if(clean.begin(), clean.end(),
185 [](
const char& c) ->
bool { return c < 0 || c > 127; },
'?');
186 return wxString::FromAscii(clean.c_str());
189 inline ostream&
operator <<( ostream& os,
const wxCharBuffer& buff )
191 return os << buff.data();
196 return diag << line.ToUTF8().data();
220 wxColour
GetAverage(
const wxColor& c1,
const wxColor& c2,
double ratio);
243 wxString
TruncateText(wxDC& dc,
const wxString& s,
int w,
249 void WrapText(wxDC& dc,
const string&
text,
int w, vector<int>& line_lens);
256 virtual wxBitmap CreateBitmap(
const wxArtID&
id,
257 const wxArtClient&
client,
325 void ConnectToControl(wxListCtrl& listCtrl);
328 void OnChildFocus(wxCommandEvent& event);
CChecksum – Checksum calculator.
CCommandToFocusHandler(wxWindow *window=NULL)
class CRegistryReadView provides a nested hierarchical view at a particular key.
class CRgbaColor provides a simple abstraction for managing colors.
CwxSplittingArtProvider - an adapter for old-style image aliases.
std::ofstream out("events_result.xml")
main entry point for tests
Workaround for wxWidgets header errors in certain configurations; MUST be included (at least indirect...
thread_local unique_ptr< FtaMsgPost > bmp
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define NCBI_GUIWIDGETS_WX_EXPORT
string UTF8ToAsciiString(const char *src, const SUnicodeTranslation *default_translation, const TUnicodeTable *table=NULL, EConversionResult *result=NULL)
Convert UTF8 into ASCII string.
static void text(MDB_val *v)
const struct ncbi::grid::netcache::search::fields::SIZE size
std::istream & in(std::istream &in_, double &x_)
static SQLCHAR output[256]
static CNamedPipeClient * client
void SetMenuItemMarginWidth(wxMenuItem *item, wxBitmap *bmp)
Set margin width for menu item.
void OpenFileBrowser(const wxString &path)
void ReportIDError(const string &id_label, bool is_local, const string &title="Error message")
void GetMacDragWindowBounds(wxTopLevelWindow *win, int &menubar_height, int &maxy, int &maxx)
Returns window boundaries for mac (top menubar width and max height)
wxColour ConvertColor(const CRgbaColor &color)
wxMenu * CreateMenu(const CMenuItem *item)
Creates a wxMenu object replicating the structure of CMenuItem.
wxString ToRelativePath(const wxString &base, const wxString &abs_path)
converts an absolute path to a relative one based on current workspace directory
void LoadWindowRectFromRegistry(wxRect &rc, const CRegistryReadView &view)
void InitDefaultFileArtProvider(const wxString &dir)
wxString GetAbsolutePath(const wxString &localpath)
wxFileArtProvider * GetDefaultFileArtProvider()
void UseDefaultMarginWidth(wxMenu &menu)
Using default menu item margin width.
int TruncTextLength(wxDC &dc, const wxString &s, int w, Ewx_Truncate trunc=ewxTruncate_Ellipsis)
returns number of characters representing a truncated version of "s" which fits in the gievn width "w...
void FromArrayString(const wxArrayString &in, vector< string > &out)
void Merge(wxMenu &menu_1, const wxMenu &menu_2)
merges all items form menu_2 into menu_1, preserving the structure if possible
void RemoveChildWindow(wxFrame *parent, wxWindow *child)
For OSX Cocoa, removes child window connection (for layering) to parent.
wxString ToWxString(const string &s)
void AddChildWindowBelow(wxFrame *parent, wxWindow *child)
For OSX Cocoa, puts child window behind the parent.
string GetVideoId()
Returns id of video configuration to be used for saving settings.
void BroadcastCommandToChildWindows(wxWindow *window, int cmd_id, int cmd_data=0)
Sends command event with id 'cmd_id' to window and all its children.
string GetMD5Digest(const CChecksum &cs)
string ToStdString(const wxString &s)
void ToArrayString(const vector< string > &out, wxArrayString &in)
wxString FindExeFile(const wxString &exeFile)
string ToString(const wxRect &rc)
wxString FnToWxString(const string &s)
void CorrectWindowRect(wxTopLevelWindow *win, wxRect &rc)
wxString ToAbsolutePath(const wxString &base, const wxString &rel_path)
converts relative path from the current workspace directory to an absolute path
ostream & operator<<(ostream &os, const wxCharBuffer &buff)
wxRect GetScreenRect(const wxWindow &win)
string FnToStdString(const wxString &s)
wxString TruncateText(wxDC &dc, const wxString &s, int w, Ewx_Truncate trunc=ewxTruncate_Ellipsis)
truncates given string so that its length is less or equal "w" "trunc" controls truncation,...
void WindowSetText(const wxWindow &win, const wxChar *text)
Windows specific function, equivalent of SetWindowText() WinAPI.
Ewx_Truncate
Truncate options for drawing text with FLTK API.
@ ewxTruncate_Ellipsis
truncate text if needed
@ ewxTruncate_EllipsisAlways
truncate text if needed, add "..." if truncated
wxImageList * CreateCheckboxImages(wxWindow *wnd)
void WrapText(wxDC &dc, const string &text, int w, vector< int > &line_lens)
divides given "text" into lines, so that every line has width less or equal to "w".
wxMenu * CloneMenu(const wxMenu &menu)
create a copy of the given menu
wxMenuItem * FindSubItem(wxMenu &menu, const wxString &text)
Find a subitem of the given menu by text.
bool NcbiChooseColor(wxWindow *parent, CRgbaColor &color)
wxColour GetAverage(const wxColor &c1, const wxColor &c2, double ratio)
void AddChildWindowAbove(wxFrame *parent, wxWindow *child)
For OSX Cocoa, puts child window in front of (visually) parent.
bool DlgGLWinOverlayFix(wxWindow *win)
Fix a problem on windows where after a dialog overlays an opengl window the opengl window may be cons...
string ToAsciiStdString(const wxString &input)
bool GetMacOptionKeyDown()
For mac, return an ID for the current space (of "Spaces" fame)
wxSize GetDisplayPPI()
Mac always seems to return 72 for screen PPI so use wx function for non-mac and on mac divide the dis...
wxWindow * FindChildWindowById(long id, wxWindow *parent)
void SaveWindowRectToRegistry(const wxRect &rc, CRegistryWriteView view)
void CleanupSeparators(wxMenu &menu)
Removes extra separators (in the begining or at the end of the menu, ot those that precede other sepa...