mirror of
https://github.com/reactos/reactos.git
synced 2024-12-26 00:54:40 +00:00
create two new functions String::str() and String::toLower() to avoid _tcslwr() calls and allow convenient string conversions
svn path=/trunk/; revision=18937
This commit is contained in:
parent
0749054fcf
commit
07a232d2e7
10 changed files with 34 additions and 43 deletions
|
@ -151,9 +151,7 @@ void FindProgramDlg::Refresh(bool delete_cache)
|
|||
|
||||
TCHAR buffer[1024];
|
||||
GetWindowText(GetDlgItem(_hwnd, IDC_FILTER), buffer, COUNTOF(buffer));
|
||||
#ifndef __WINE__ ///@todo _tcslwr() for Wine
|
||||
_tcslwr(buffer);
|
||||
#endif
|
||||
CharLower(buffer);
|
||||
_lwr_filter = buffer;
|
||||
|
||||
HiddenWindow hide_listctrl(_list_ctrl);
|
||||
|
@ -230,10 +228,8 @@ void FindProgramDlg::add_entry(const FPDEntry& cache_entry)
|
|||
String lwr_path = cache_entry._path;
|
||||
String lwr_name = cache_entry._entry->_display_name;
|
||||
|
||||
#ifndef __WINE__ ///@todo _tcslwr() for Wine
|
||||
_tcslwr(&lwr_path.at(0));
|
||||
_tcslwr(&lwr_name.at(0));
|
||||
#endif
|
||||
lwr_path.toLower();
|
||||
lwr_name.toLower();
|
||||
|
||||
if (_lwr_filter.empty())
|
||||
if (_tcsstr(lwr_name, _T("uninstal")) || _tcsstr(lwr_name, _T("deinstal"))) // filter out deinstallation links
|
||||
|
|
|
@ -182,9 +182,7 @@ bool FileTypeManager::is_exe_file(LPCTSTR ext)
|
|||
|
||||
const FileTypeInfo& FileTypeManager::operator[](String ext)
|
||||
{
|
||||
#ifndef __WINE__ ///@todo _tcslwr() for Wine
|
||||
_tcslwr(&ext.at(0));
|
||||
#endif
|
||||
ext.toLower();
|
||||
|
||||
iterator found = find(ext);
|
||||
if (found != end())
|
||||
|
@ -414,9 +412,7 @@ const Icon& IconCache::extract(LPCTSTR path, int idx)
|
|||
{
|
||||
CachePair key(path, idx);
|
||||
|
||||
#ifndef __WINE__ ///@todo _tcslwr() for Wine
|
||||
_tcslwr(&key.first.at(0));
|
||||
#endif
|
||||
key.first.toLower();
|
||||
|
||||
PathIdxMap::iterator found = _pathIdxMap.find(key);
|
||||
|
||||
|
|
|
@ -514,7 +514,7 @@ bool Entry::get_path_base ( PTSTR path, size_t path_count, ENTRY_TYPE etype ) co
|
|||
LPCTSTR name = NULL;
|
||||
TCHAR buffer[MAX_PATH];
|
||||
|
||||
if ( !path || 0 == path_count )
|
||||
if (!path || path_count==0)
|
||||
return false;
|
||||
|
||||
const Entry* entry;
|
||||
|
|
|
@ -679,7 +679,7 @@ void MainFrameBase::FillBookmarks()
|
|||
tvi.hInsertAfter = TVI_LAST;
|
||||
tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
|
||||
ResString sFavorites(IDS_FAVORITES);
|
||||
tvi.item.pszText = (LPTSTR)sFavorites.c_str();
|
||||
tvi.item.pszText = sFavorites.str();
|
||||
tvi.item.iSelectedImage = tvi.item.iImage = 0;
|
||||
|
||||
HTREEITEM hitem_bookmarks = TreeView_InsertItem(_hsidebar, &tvi);
|
||||
|
@ -1673,7 +1673,7 @@ void SDIMainFrame::entry_selected(Entry* entry)
|
|||
|
||||
TCHAR path[MAX_PATH];
|
||||
|
||||
if (shell_entry->get_path(path,COUNTOF(path))) {
|
||||
if (shell_entry->get_path(path, COUNTOF(path))) {
|
||||
String url;
|
||||
|
||||
if (path[0] == ':')
|
||||
|
|
|
@ -128,7 +128,7 @@ ShellPath ShellEntry::create_absolute_pidl() const
|
|||
// get full path of a shell entry
|
||||
bool ShellEntry::get_path(PTSTR path, size_t path_count) const
|
||||
{
|
||||
if ( !path || 0 == path_count )
|
||||
if (!path || path_count==0)
|
||||
return false;
|
||||
/*
|
||||
path[0] = TEXT('\0');
|
||||
|
@ -152,7 +152,7 @@ bool ShellDirectory::get_path(PTSTR path, size_t path_count) const
|
|||
{
|
||||
CONTEXT("ShellDirectory::get_path()");
|
||||
|
||||
if ( !path || 0 == path_count )
|
||||
if (!path || path_count==0)
|
||||
return false;
|
||||
|
||||
path[0] = TEXT('\0');
|
||||
|
|
|
@ -161,7 +161,7 @@ bool UnixEntry::get_path(PTSTR path, size_t path_count) const
|
|||
int level = 0;
|
||||
size_t len = 0;
|
||||
|
||||
if ( !path || 0 == path_count )
|
||||
if (!path || path_count==0)
|
||||
return false;
|
||||
|
||||
if ( path_count > 1 )
|
||||
|
|
|
@ -282,7 +282,7 @@ int QuickLaunchBar::Notify(int id, NMHDR* pnmh)
|
|||
NMTTDISPINFO* ttdi = (NMTTDISPINFO*) pnmh;
|
||||
|
||||
int id = ttdi->hdr.idFrom;
|
||||
ttdi->lpszText = (LPTSTR)_entries[id]._title.c_str();
|
||||
ttdi->lpszText = _entries[id]._title.str();
|
||||
#ifdef TTF_DI_SETITEM
|
||||
ttdi->uFlags |= TTF_DI_SETITEM;
|
||||
#endif
|
||||
|
|
|
@ -257,9 +257,7 @@ void StartMenu::AddShellEntries(const ShellDirectory& dir, int max, const String
|
|||
*ignore_name = '\0';
|
||||
|
||||
String lwr_filter = _create_info._filter;
|
||||
#ifndef __WINE__ ///@todo _tcslwr() for Wine
|
||||
_tcslwr((LPTSTR)lwr_filter.c_str());
|
||||
#endif
|
||||
lwr_filter.toLower();
|
||||
|
||||
int cnt = 0;
|
||||
for(Entry*entry=dir._down; entry; entry=entry->_next) {
|
||||
|
@ -281,10 +279,8 @@ void StartMenu::AddShellEntries(const ShellDirectory& dir, int max, const String
|
|||
String lwr_name = entry->_data.cFileName;
|
||||
String lwr_disp = entry->_display_name;
|
||||
|
||||
#ifndef __WINE__ ///@todo _tcslwr() for Wine
|
||||
_tcslwr((LPTSTR)lwr_name.c_str());
|
||||
_tcslwr((LPTSTR)lwr_disp.c_str());
|
||||
#endif
|
||||
lwr_name.toLower();
|
||||
lwr_disp.toLower();
|
||||
|
||||
if (!_tcsstr(lwr_name,lwr_filter) && !_tcsstr(lwr_disp,lwr_filter))
|
||||
continue;
|
||||
|
@ -1548,7 +1544,6 @@ StartMenuRoot::StartMenuRoot(HWND hwnd)
|
|||
|
||||
try {
|
||||
// insert directory "<user name>\Start Menu"
|
||||
|
||||
ShellDirectory usr_startmenu(GetDesktopFolder(), SpecialFolderPath(CSIDL_STARTMENU, _hwnd), _hwnd);
|
||||
_dirs.push_back(StartMenuDirectory(usr_startmenu, (LPCTSTR)SpecialFolderFSPath(CSIDL_PROGRAMS, _hwnd)));
|
||||
} catch(COMException&) {
|
||||
|
@ -2217,9 +2212,7 @@ void FavoritesMenu::AddEntries()
|
|||
super::AddEntries();
|
||||
|
||||
String lwr_filter = _create_info._filter;
|
||||
#ifndef __WINE__ ///@todo _tcslwr() for Wine
|
||||
_tcslwr((LPTSTR)lwr_filter.c_str());
|
||||
#endif
|
||||
lwr_filter.toLower();
|
||||
|
||||
for(BookmarkList::iterator it=_bookmarks.begin(); it!=_bookmarks.end(); ++it) {
|
||||
BookmarkNode& node = *it;
|
||||
|
@ -2246,11 +2239,9 @@ void FavoritesMenu::AddEntries()
|
|||
String lwr_desc = bookmark._description;
|
||||
String lwr_url = bookmark._url;
|
||||
|
||||
#ifndef __WINE__ ///@todo _tcslwr() for Wine
|
||||
_tcslwr((LPTSTR)lwr_name.c_str());
|
||||
_tcslwr((LPTSTR)lwr_desc.c_str());
|
||||
_tcslwr((LPTSTR)lwr_url.c_str());
|
||||
#endif
|
||||
lwr_name.toLower();
|
||||
lwr_desc.toLower();
|
||||
lwr_url.toLower();
|
||||
|
||||
if (!_tcsstr(lwr_name,lwr_filter) && !_tcsstr(lwr_desc,lwr_filter) && !_tcsstr(lwr_url,lwr_filter))
|
||||
continue;
|
||||
|
|
|
@ -555,7 +555,7 @@ int NotifyArea::Notify(int id, NMHDR* pnmh)
|
|||
static ResString sShowIcons(IDS_SHOW_HIDDEN_ICONS);
|
||||
static ResString sHideIcons(IDS_HIDE_ICONS);
|
||||
|
||||
pdi->lpszText = (LPTSTR)(_show_hidden? sHideIcons: sShowIcons).c_str();
|
||||
pdi->lpszText = (_show_hidden? sHideIcons: sShowIcons).str();
|
||||
} else {
|
||||
NotifyIconSet::iterator found = IconHitTest(pt);
|
||||
|
||||
|
@ -565,7 +565,7 @@ int NotifyArea::Notify(int id, NMHDR* pnmh)
|
|||
// enable multiline tooltips (break at CR/LF and for very long one-line strings)
|
||||
SendMessage(pnmh->hwndFrom, TTM_SETMAXTIPWIDTH, 0, 400);
|
||||
|
||||
pdi->lpszText = (LPTSTR)entry._tipText.c_str();
|
||||
pdi->lpszText = entry._tipText.str();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -974,24 +974,24 @@ void TrayNotifyDlg::Refresh()
|
|||
tv.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
|
||||
|
||||
ResString str_cur(IDS_ITEMS_CUR);
|
||||
tv.pszText = (LPTSTR)str_cur.c_str();
|
||||
tv.pszText = str_cur.str();
|
||||
tv.iSelectedImage = tv.iImage = 0; // IDI_DOT
|
||||
_hitemCurrent = TreeView_InsertItem(_tree_ctrl, &tvi);
|
||||
|
||||
ResString str_conf(IDS_ITEMS_CONFIGURED);
|
||||
tv.pszText = (LPTSTR)str_conf.c_str();
|
||||
tv.pszText = str_conf.str();
|
||||
tv.iSelectedImage = tv.iImage = 2; // IDI_DOT_RED
|
||||
_hitemConfig = TreeView_InsertItem(_tree_ctrl, &tvi);
|
||||
|
||||
tvi.hParent = _hitemCurrent;
|
||||
|
||||
ResString str_visible(IDS_ITEMS_VISIBLE);
|
||||
tv.pszText = (LPTSTR)str_visible.c_str();
|
||||
tv.pszText = str_visible.str();
|
||||
tv.iSelectedImage = tv.iImage = 0; // IDI_DOT
|
||||
_hitemCurrent_visible = TreeView_InsertItem(_tree_ctrl, &tvi);
|
||||
|
||||
ResString str_hidden(IDS_ITEMS_HIDDEN);
|
||||
tv.pszText = (LPTSTR)str_hidden.c_str();
|
||||
tv.pszText = str_hidden.str();
|
||||
tv.iSelectedImage = tv.iImage = 1; // IDI_DOT_TRANS
|
||||
_hitemCurrent_hidden = TreeView_InsertItem(_tree_ctrl, &tvi);
|
||||
|
||||
|
@ -1075,7 +1075,7 @@ void TrayNotifyDlg::InsertItem(HTREEITEM hparent, HTREEITEM after, const NotifyI
|
|||
tv.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM;
|
||||
|
||||
tv.lParam = (LPARAM)idx;
|
||||
tv.pszText = (LPTSTR)txt.c_str();
|
||||
tv.pszText = txt.str();
|
||||
tv.iSelectedImage = tv.iImage = ImageList_AddAlphaIcon(_himl, hicon, GetStockBrush(WHITE_BRUSH), hdc);
|
||||
(void)TreeView_InsertItem(_tree_ctrl, &tvi);
|
||||
}
|
||||
|
|
|
@ -798,6 +798,8 @@ struct String
|
|||
operator wstring() const {WCHAR b[BUFFER_LEN]; return wstring(b, MultiByteToWideChar(CP_ACP, 0, c_str(), -1, b, BUFFER_LEN)-1);}
|
||||
#endif
|
||||
|
||||
LPTSTR str() {return (LPTSTR)data();} /// return modifyable character string pointer
|
||||
|
||||
String& printf(LPCTSTR fmt, ...)
|
||||
{
|
||||
va_list l;
|
||||
|
@ -839,6 +841,12 @@ struct String
|
|||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void toLower()
|
||||
{
|
||||
if (!empty())
|
||||
CharLower(str());
|
||||
}
|
||||
};
|
||||
|
||||
#define _STRING_DEFINED
|
||||
|
|
Loading…
Reference in a new issue