NCBI C++ ToolKit
Functions | Variables
wx_utils.cpp File Reference
#include <ncbi_pch.hpp>
#include <util/checksum.hpp>
#include <gui/utils/string_utils.hpp>
#include <gui/widgets/wx/wx_utils.hpp>
#include <gui/widgets/wx/sys_path.hpp>
#include <gui/widgets/wx/fileartprov.hpp>
#include <gui/widgets/wx/text_report_dlg.hpp>
#include <gui/utils/menu_item.hpp>
#include <gui/utils/rgba_color.hpp>
#include <connect/ncbi_conn_test.hpp>
#include <corelib/ncbiexec.hpp>
#include <corelib/ncbi_system.hpp>
#include <corelib/ncbifile.hpp>
#include <wx/app.h>
#include <wx/menu.h>
#include <wx/menuitem.h>
#include <wx/colordlg.h>
#include <wx/dc.h>
#include <wx/listctrl.h>
#include <wx/frame.h>
#include <wx/filename.h>
#include <wx/renderer.h>
#include <wx/dcmemory.h>
#include <wx/imaglist.h>
#include <wx/display.h>
#include <Winnetwk.h>
+ Include dependency graph for wx_utils.cpp:

Go to the source code of this file.

Go to the SVN repository for this file.

Functions

wxString FindExeFile (const wxString &exeFile)
 
void ReportIDError (const string &id_label, bool is_local, const string &title)
 
void ReportMemoryUsage ()
 
void OpenFileBrowser (const wxString &path)
 
wxString GetAbsolutePath (const wxString &localpath)
 
string GetMD5Digest (const CChecksum &cs)
 
string GetVideoId ()
 Returns id of video configuration to be used for saving settings. More...
 
wxString FnToWxString (const string &s)
 
string FnToStdString (const wxString &s)
 
wxString ToRelativePath (const wxString &base, const wxString &abs_path)
 converts an absolute path to a relative one based on current workspace directory More...
 
wxString ToAbsolutePath (const wxString &base, const wxString &rel_path)
 converts relative path from the current workspace directory to an absolute path More...
 
void InitDefaultFileArtProvider (const wxString &dir)
 
wxFileArtProviderGetDefaultFileArtProvider ()
 
void FromArrayString (const wxArrayString &in, vector< string > &out)
 
void ToArrayString (const vector< string > &in, wxArrayString &out)
 
wxMenu * CreateMenu (const CMenuItem *item)
 Creates a wxMenu object replicating the structure of CMenuItem. More...
 
wxMenuItem * FindSubItem (wxMenu &menu, const wxString &text)
 Find a subitem of the given menu by text. More...
 
static wxMenuItemList::const_iterator s_FindSeparator (wxMenu &menu, const wxString &text)
 
static wxMenuItemList::const_iterator s_FindSubItem (wxMenuItemList::const_iterator begin, wxMenuItemList::const_iterator end, const wxString &text, bool skip_named_groups)
 
static void s_InsertInUnnamedGroup (wxMenu &menu, wxMenuItem &item)
 
static wxString s_GetCleanMenuText (const wxMenuItem &item)
 
static wxMenuItem * s_CloneMenuItem (wxMenu &menu, const wxMenuItem &item)
 
wxMenu * CloneMenu (const wxMenu &menu)
 create a copy of the given menu More...
 
void Merge (wxMenu &menu_1, const wxMenu &menu_2)
 This function merges the content of menu_2 into menu_1 based on equivalence of item labels Menu trees are merged based on item's labels. More...
 
void CleanupSeparators (wxMenu &menu)
 Removes extra separators (in the begining or at the end of the menu, ot those that precede other separators) More...
 
void UseDefaultMarginWidth (wxMenu &menu)
 Using default menu item margin width. More...
 
void SetMenuItemMarginWidth (wxMenuItem *item, wxBitmap *bmp)
 Set margin width for menu item. More...
 
string ToString (const wxRect &rc)
 
wxRect GetScreenRect (const wxWindow &win)
 
void WindowSetText (const wxWindow &win, const wxChar *text)
 Windows specific function, equivalent of SetWindowText() WinAPI. More...
 
static unsigned char s_Average (unsigned char c1, unsigned char c2, double ratio)
 
wxColour GetAverage (const wxColor &c1, const wxColor &c2, double ratio)
 
int TruncTextLength (wxDC &dc, const wxString &s, int w, Ewx_Truncate trunc)
 returns number of characters representing a truncated version of "s" which fits in the gievn width "w" "trunc" controls truncation, if "trunc" == eTruncate_Ellipsis "..." is appended to the end of the truncated string. More...
 
wxString TruncateText (wxDC &dc, const wxString &s, int w, Ewx_Truncate trunc)
 truncates given string so that its length is less or equal "w" "trunc" controls truncation, if "trunc" == eTruncate_Ellipsis "..." is appended to the end of the truncated string. More...
 
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". More...
 
wxColour ConvertColor (const CRgbaColor &c2)
 
CRgbaColor ConvertColor (const wxColour &c)
 
void SaveWindowRectToRegistry (const wxRect &rc, CRegistryWriteView view)
 
void LoadWindowRectFromRegistry (wxRect &rc, const CRegistryReadView &view)
 
void CorrectWindowRect (wxTopLevelWindow *win, wxRect &rc)
 
bool NcbiChooseColor (wxWindow *parent, CRgbaColor &color)
 
wxWindow * FindChildWindowById (long id, wxWindow *parent)
 
void BroadcastCommandToChildWindows (wxWindow *window, int cmd_id, int cmd_data)
 Sends command event with id 'cmd_id' to window and all its children. More...
 
void AddChildWindowAbove (wxFrame *parent, wxWindow *child)
 For OSX Cocoa, puts child window in front of (visually) parent. More...
 
void AddChildWindowBelow (wxFrame *parent, wxWindow *child)
 For OSX Cocoa, puts child window behind the parent. More...
 
void RemoveChildWindow (wxFrame *parent, wxWindow *child)
 For OSX Cocoa, removes child window connection (for layering) to parent. More...
 
void GetMacDragWindowBounds (wxTopLevelWindow *win, int &menubar_height, int &maxy, int &maxx)
 Returns window boundaries for mac (top menubar width and max height) More...
 
bool GetMacOptionKeyDown ()
 For mac, return an ID for the current space (of "Spaces" fame) More...
 
bool DlgGLWinOverlayFix (wxWindow *win)
 Fix a problem on windows where after a dialog overlays an opengl window the opengl window may be constrained to just the area under the dialog until some window-changing event. More...
 
wxSize GetDisplayPPI ()
 Mac always seems to return 72 for screen PPI so use wx function for non-mac and on mac divide the displays number of pixels by its physical size to get actual PPI. More...
 
bool RunningInsideNCBI ()
 
wxImageList * CreateCheckboxImages (wxWindow *wnd)
 

Variables

wxFileArtProviders_FileArtProvider = NULL
 
bool sf_FileArtProviderPushed = false
 

Function Documentation

◆ AddChildWindowAbove()

void AddChildWindowAbove ( wxFrame *  parent,
wxWindow *  child 
)

For OSX Cocoa, puts child window in front of (visually) parent.

Definition at line 1194 of file wx_utils.cpp.

References NULL.

Referenced by CTooltipFrame::AddChildWindow(), CSequenceGotoDlg::Show(), and CwxMarkerInfoDlg::Show().

◆ AddChildWindowBelow()

void AddChildWindowBelow ( wxFrame *  parent,
wxWindow *  child 
)

For OSX Cocoa, puts child window behind the parent.

Definition at line 1209 of file wx_utils.cpp.

References NULL.

◆ BroadcastCommandToChildWindows()

void BroadcastCommandToChildWindows ( wxWindow *  window,
int  cmd_id,
int  cmd_data 
)

◆ CleanupSeparators()

void CleanupSeparators ( wxMenu &  menu)

◆ CloneMenu()

wxMenu* CloneMenu ( const wxMenu &  menu)

create a copy of the given menu

Definition at line 559 of file wx_utils.cpp.

References ITERATE, and s_CloneMenuItem().

Referenced by CWindowManagerService::GetMenu(), CMenuService::ResetMenuBar(), and s_CloneMenuItem().

◆ ConvertColor() [1/2]

wxColour ConvertColor ( const CRgbaColor c2)

◆ ConvertColor() [2/2]

CRgbaColor ConvertColor ( const wxColour &  c)

Definition at line 1003 of file wx_utils.cpp.

◆ CorrectWindowRect()

void CorrectWindowRect ( wxTopLevelWindow *  win,
wxRect &  rc 
)

◆ CreateCheckboxImages()

wxImageList* CreateCheckboxImages ( wxWindow *  wnd)

Definition at line 1352 of file wx_utils.cpp.

References Get(), and TRUE.

Referenced by wxCheckedListCtrl::Create(), and CTrackListCtrl::CTrackListCtrl().

◆ CreateMenu()

wxMenu* CreateMenu ( const CMenuItem item)

◆ DlgGLWinOverlayFix()

bool DlgGLWinOverlayFix ( wxWindow *  win)

Fix a problem on windows where after a dialog overlays an opengl window the opengl window may be constrained to just the area under the dialog until some window-changing event.

Problem only occurs if Aero theme is Not being used.

Definition at line 1290 of file wx_utils.cpp.

Referenced by CGlWidgetPane::DlgOverlayFix(), and IQueryWidget::DlgOverlayFix().

◆ FindChildWindowById()

wxWindow* FindChildWindowById ( long  id,
wxWindow *  parent 
)

Definition at line 1130 of file wx_utils.cpp.

References ITERATE, and NULL.

◆ FindExeFile()

wxString FindExeFile ( const wxString &  exeFile)

◆ FindSubItem()

wxMenuItem* FindSubItem ( wxMenu &  menu,
const wxString &  text 
)

Find a subitem of the given menu by text.

Definition at line 426 of file wx_utils.cpp.

References ITERATE, NULL, and text().

Referenced by CAlnMultiWidget::x_CreatePopupMenu(), and CWindowManager::x_UpdateWindowsMenu().

◆ FnToStdString()

string FnToStdString ( const wxString &  s)

◆ FnToWxString()

wxString FnToWxString ( const string s)

◆ FromArrayString()

void FromArrayString ( const wxArrayString &  in,
vector< string > &  out 
)

◆ GetAbsolutePath()

wxString GetAbsolutePath ( const wxString &  localpath)

◆ GetAverage()

wxColour GetAverage ( const wxColor &  c1,
const wxColor &  c2,
double  ratio 
)

◆ GetDefaultFileArtProvider()

wxFileArtProvider* GetDefaultFileArtProvider ( )

◆ GetDisplayPPI()

wxSize GetDisplayPPI ( )

Mac always seems to return 72 for screen PPI so use wx function for non-mac and on mac divide the displays number of pixels by its physical size to get actual PPI.

Definition at line 1309 of file wx_utils.cpp.

References _TRACE, and NULL.

Referenced by CTextPanel::GetFont().

◆ GetMacDragWindowBounds()

void GetMacDragWindowBounds ( wxTopLevelWindow *  win,
int menubar_height,
int maxy,
int maxx 
)

Returns window boundaries for mac (top menubar width and max height)

Definition at line 1239 of file wx_utils.cpp.

References int, NULL, and r().

Referenced by CorrectWindowRect(), CWorkbenchFrame::OnIdle(), and CDockManager::x_MoveDragFrame().

◆ GetMacOptionKeyDown()

bool GetMacOptionKeyDown ( )

For mac, return an ID for the current space (of "Spaces" fame)

Definition at line 1274 of file wx_utils.cpp.

◆ GetMD5Digest()

string GetMD5Digest ( const CChecksum cs)

Definition at line 211 of file wx_utils.cpp.

References buf, CChecksum::GetMD5Digest(), i, and result.

Referenced by GetVideoId(), s_GetMD5Tag(), and CQueryParsePanel::SetDataSource().

◆ GetScreenRect()

wxRect GetScreenRect ( const wxWindow &  win)

◆ GetVideoId()

string GetVideoId ( )

◆ InitDefaultFileArtProvider()

void InitDefaultFileArtProvider ( const wxString &  dir)

◆ LoadWindowRectFromRegistry()

void LoadWindowRectFromRegistry ( wxRect &  rc,
const CRegistryReadView view 
)

Definition at line 1018 of file wx_utils.cpp.

References CRegistryReadView::GetInt().

Referenced by CDialog::LoadSettings(), and CMainFrame::LoadSettings().

◆ Merge()

void Merge ( wxMenu &  menu_1,
const wxMenu &  menu_2 
)

◆ NcbiChooseColor()

bool NcbiChooseColor ( wxWindow *  parent,
CRgbaColor color 
)

Definition at line 1114 of file wx_utils.cpp.

References color, and data.

Referenced by CWindowManager::OnSetClientColor().

◆ OpenFileBrowser()

void OpenFileBrowser ( const wxString &  path)

◆ RemoveChildWindow()

void RemoveChildWindow ( wxFrame *  parent,
wxWindow *  child 
)

For OSX Cocoa, removes child window connection (for layering) to parent.

Definition at line 1224 of file wx_utils.cpp.

References NULL.

Referenced by CTooltipFrame::RemoveChildWindow(), CSequenceGotoDlg::Show(), and CwxMarkerInfoDlg::Show().

◆ ReportIDError()

void ReportIDError ( const string id_label,
bool  is_local,
const string title 
)

◆ ReportMemoryUsage()

void ReportMemoryUsage ( )

Definition at line 116 of file wx_utils.cpp.

References CCurrentProcess::GetMemoryUsage(), Info(), LOG_POST, and usage.

◆ RunningInsideNCBI()

bool RunningInsideNCBI ( )

Definition at line 1335 of file wx_utils.cpp.

References CConnTest::IsNcbiInhouseClient(), CSysPath::ResolvePathExisting(), and wxT.

Referenced by CClickableSortUniqueCount::CClickableSortUniqueCount(), CDiscrepancyDlg::Create(), CAECRFrame::CreateControls(), CDiscrepancyDlg::CreateControls(), CDiscrepancyPanel::CreateControls(), CValidateFrame::CreateControls(), CValidatePanel::CreateControls(), CEditSequence::CreateControls(), CRawSeqToDeltaByNPanel::CreateControls(), CUpdateSeqPanel::CreateControls(), CValidatorReportCfgDlg::CreateControls(), CTextViewOptionsDlg::CreateControls(), CUICommandRegistry::CreateMenu(), CUpdateSeqPanel::GetData(), CSequenceEditingEventHandler::GetFeatureLocation(), CAlignPackage::Init(), CSeqEditPackage::Init(), CDescriptorTextPanel::IsExportEnabled(), CLocationPanel::IsExportEnabled(), CStructuredCommentPanel::IsExportEnabled(), CDescriptorTextPanel::IsImportEnabled(), CLocationPanel::IsImportEnabled(), CStructuredCommentPanel::IsImportEnabled(), CSequenceEditingEventHandler::IsLocationSelected(), CAECRFrame::LoadSettings(), CEditingBtnsPanel::LoadSettings(), CDiscrepancyDlg::OnDataChanged(), CDiscrepancyPanel::OnDblClk(), CUpdateSeqPanel::OnIgnoreAlignmentClick(), CUpdateSeqPanel::OnImportChecked(), CValidatePanel::OnListItemRightClick(), CValidatePanel::OnListItemSelected(), CValidatePanel::OnMouseMove(), CUpdateSeqPanel::OnReplaceBtnSelected(), CUpdateSeq_Dlg::OnUpdateSequence(), CDiscrepancyPanel::RefreshData(), CAECRFrame::SaveSettings(), CUpdateSeqPanel::SetData(), CAECRFrame::SetInitParameters(), CFlatFileViewContext::ShowEditIcons(), CUpdateSeqPanel::UpdatePanel(), CSrcDescEditorPanel::UpdateSeqdesc(), CSequenceEditingEventHandler::UpdateSingleSequence(), CValidatePanel::x_DisplayList(), CTableDataValidateJob::x_FetchAll(), and CUpdateSeqPanel::x_InitAlnMultiWidgetAndUpdateTypes().

◆ s_Average()

static unsigned char s_Average ( unsigned char  c1,
unsigned char  c2,
double  ratio 
)
static

Definition at line 803 of file wx_utils.cpp.

Referenced by GetAverage().

◆ s_CloneMenuItem()

static wxMenuItem* s_CloneMenuItem ( wxMenu &  menu,
const wxMenuItem &  item 
)
static

Definition at line 521 of file wx_utils.cpp.

References CloneMenu(), NULL, s_GetCleanMenuText(), and SetMenuItemMarginWidth().

Referenced by CloneMenu(), and Merge().

◆ s_FindSeparator()

static wxMenuItemList::const_iterator s_FindSeparator ( wxMenu &  menu,
const wxString &  text 
)
static

Definition at line 440 of file wx_utils.cpp.

References ITERATE, and text().

Referenced by Merge().

◆ s_FindSubItem()

static wxMenuItemList::const_iterator s_FindSubItem ( wxMenuItemList::const_iterator  begin,
wxMenuItemList::const_iterator  end,
const wxString &  text,
bool  skip_named_groups 
)
static

Definition at line 455 of file wx_utils.cpp.

References text().

Referenced by Merge().

◆ s_GetCleanMenuText()

static wxString s_GetCleanMenuText ( const wxMenuItem &  item)
static

Definition at line 505 of file wx_utils.cpp.

References i.

Referenced by Merge(), and s_CloneMenuItem().

◆ s_InsertInUnnamedGroup()

static void s_InsertInUnnamedGroup ( wxMenu &  menu,
wxMenuItem &  item 
)
static

Definition at line 484 of file wx_utils.cpp.

References ITERATE.

Referenced by Merge().

◆ SaveWindowRectToRegistry()

void SaveWindowRectToRegistry ( const wxRect &  rc,
CRegistryWriteView  view 
)

Definition at line 1009 of file wx_utils.cpp.

References CRegistryWriteView::Set().

Referenced by CDialog::SaveSettings(), and CMainFrame::SaveSettings().

◆ SetMenuItemMarginWidth()

void SetMenuItemMarginWidth ( wxMenuItem *  item,
wxBitmap *  bmp 
)

Set margin width for menu item.

Definition at line 709 of file wx_utils.cpp.

References bmp.

Referenced by CUICommand::AppendMenuItem(), CreateMenu(), and s_CloneMenuItem().

◆ ToAbsolutePath()

wxString ToAbsolutePath ( const wxString &  base,
const wxString &  rel_path 
)

converts relative path from the current workspace directory to an absolute path

Definition at line 301 of file wx_utils.cpp.

References wxT.

◆ ToArrayString()

void ToArrayString ( const vector< string > &  in,
wxArrayString &  out 
)

◆ ToRelativePath()

wxString ToRelativePath ( const wxString &  base,
const wxString &  abs_path 
)

converts an absolute path to a relative one based on current workspace directory

Definition at line 281 of file wx_utils.cpp.

References wxT.

◆ ToString()

string ToString ( const wxRect &  rc)

◆ TruncateText()

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, if "trunc" == eTruncate_Ellipsis "..." is appended to the end of the truncated string.

Definition at line 878 of file wx_utils.cpp.

References ewxTruncate_Ellipsis, ewxTruncate_EllipsisAlways, int, len, n, trunc, TruncTextLength(), and wxT.

Referenced by CMessageSlot::OnPaint(), CSelectionBroadcastSlot::OnPaint(), CMapItem::x_CalculateRealTextWidth(), CDockPanel::x_DrawClientElements(), CMinPanelContainer::x_DrawItem(), and CMapItem::x_DrawText().

◆ TruncTextLength()

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" "trunc" controls truncation, if "trunc" == eTruncate_Ellipsis "..." is appended to the end of the truncated string.

Definition at line 820 of file wx_utils.cpp.

References ewxTruncate_Ellipsis, ewxTruncate_EllipsisAlways, ewxTruncate_Empty, int, len, min(), n, trunc, and wxT.

Referenced by TruncateText(), and WrapText().

◆ UseDefaultMarginWidth()

void UseDefaultMarginWidth ( wxMenu &  menu)

◆ WindowSetText()

void WindowSetText ( const wxWindow &  win,
const wxChar *  text 
)

Windows specific function, equivalent of SetWindowText() WinAPI.

Definition at line 794 of file wx_utils.cpp.

References text().

Referenced by CTaskTablePanel::CreateControls().

◆ WrapText()

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".

Returns length of lines in "line_lens".

Definition at line 895 of file wx_utils.cpp.

References ewxTruncate_Empty, int, text(), ToWxString(), and TruncTextLength().

Referenced by CMapItem::x_CalculateRealTextWidth(), CMapItem::x_DrawText(), and CMapItem::x_PreferredLabelHeight().

Variable Documentation

◆ s_FileArtProvider

wxFileArtProvider* s_FileArtProvider = NULL

Definition at line 320 of file wx_utils.cpp.

Referenced by GetDefaultFileArtProvider().

◆ sf_FileArtProviderPushed

bool sf_FileArtProviderPushed = false

Definition at line 321 of file wx_utils.cpp.

Referenced by InitDefaultFileArtProvider().

Modified on Fri Sep 20 14:58:29 2024 by modify_doxy.py rev. 669887