"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/celestia/winbookmarks.cpp" between
Celestia-1.6.2.1.tar.gz and Celestia-1.6.2.2.tar.gz

About: Celestia is an OpenGL-based 3D space simulation that lets you travel through the solar system, to the stars, and even beyond the galaxy.

winbookmarks.cpp  (Celestia-1.6.2.1):winbookmarks.cpp  (Celestia-1.6.2.2)
skipping to change at line 423 skipping to change at line 423
} }
} }
} }
void SyncTreeFoldersWithFavoriteFolders(HWND hTree, CelestiaCore* appCore) void SyncTreeFoldersWithFavoriteFolders(HWND hTree, CelestiaCore* appCore)
{ {
FavoritesList* favorites = appCore->getFavorites(); FavoritesList* favorites = appCore->getFavorites();
FavoritesList::iterator iter; FavoritesList::iterator iter;
TVITEMW tvItem; TVITEMW tvItem;
HTREEITEM hItem, hParent; HTREEITEM hItem, hParent;
char itemName[33]; wchar_t itemName[33];
bool found; bool found;
if (favorites != NULL) if (favorites != NULL)
{ {
// Scan through tree control folders and add any folder that does // Scan through tree control folders and add any folder that does
// not exist in Favorites. // not exist in Favorites.
if (hParent = TreeView_GetChild(hTree, TVI_ROOT)) if (hParent = TreeView_GetChild(hTree, TVI_ROOT))
{ {
hItem = TreeView_GetChild(hTree, hParent); hItem = TreeView_GetChild(hTree, hParent);
do do
{ {
// Get information on item // Get information on item
tvItem.hItem = hItem; tvItem.hItem = hItem;
tvItem.mask = TVIF_TEXT | TVIF_PARAM | TVIF_HANDLE; tvItem.mask = TVIF_TEXT | TVIF_PARAM | TVIF_HANDLE;
wstring name = CurrentCPToWide(itemName); tvItem.pszText = itemName;
tvItem.pszText = const_cast<wchar_t*>(name.c_str()); tvItem.cchTextMax = sizeof(itemName) / sizeof(wchar_t);
tvItem.cchTextMax = sizeof(itemName);
if (SendMessage(hTree, TVM_GETITEMW, 0, (LPARAM)&tvItem)) if (SendMessage(hTree, TVM_GETITEMW, 0, (LPARAM)&tvItem))
{ {
// Skip non-folders. // Skip non-folders.
if(tvItem.lParam == 0) if(tvItem.lParam == 0)
continue; continue;
string name(itemName); string name(WideToCurrentCP(itemName));
if (favorites->size() == 0) if (favorites->size() == 0)
{ {
// Just append the folder // Just append the folder
appCore->addFavoriteFolder(name); appCore->addFavoriteFolder(name);
continue; continue;
} }
// Loop through favorites to find item = itemName // Loop through favorites to find item = itemName
found = false; found = false;
iter = favorites->begin(); iter = favorites->begin();
while (iter != favorites->end()) while (iter != favorites->end())
{ {
if ((*iter)->isFolder && (*iter)->name == itemName) if ((*iter)->isFolder && (*iter)->name == name)
{ {
found = true; found = true;
break; break;
} }
iter++; iter++;
} }
if (!found) if (!found)
{ {
// If not found in favorites, add it. // If not found in favorites, add it.
skipping to change at line 503 skipping to change at line 502
} while (hItem = TreeView_GetNextSibling(hTree, hItem)); } while (hItem = TreeView_GetNextSibling(hTree, hItem));
} }
} }
} }
void InsertBookmarkInFavorites(HWND hTree, char* name, CelestiaCore* appCore) void InsertBookmarkInFavorites(HWND hTree, char* name, CelestiaCore* appCore)
{ {
FavoritesList* favorites = appCore->getFavorites(); FavoritesList* favorites = appCore->getFavorites();
TVITEMW tvItem; TVITEMW tvItem;
HTREEITEM hItem; HTREEITEM hItem;
char itemName[33]; wchar_t itemName[33];
string newBookmark(name); string newBookmark(name);
// SyncTreeFoldersWithFavoriteFolders(hTree, appCore); // SyncTreeFoldersWithFavoriteFolders(hTree, appCore);
// Determine which tree item (folder) is selected (if any) // Determine which tree item (folder) is selected (if any)
hItem = TreeView_GetSelection(hTree); hItem = TreeView_GetSelection(hTree);
if (!TreeView_GetParent(hTree, hItem)) if (!TreeView_GetParent(hTree, hItem))
hItem = NULL; hItem = NULL;
if (hItem) if (hItem)
{ {
tvItem.hItem = hItem; tvItem.hItem = hItem;
tvItem.mask = TVIF_TEXT | TVIF_HANDLE; tvItem.mask = TVIF_TEXT | TVIF_HANDLE;
wstring name = CurrentCPToWide(itemName); tvItem.pszText = itemName;
tvItem.pszText = const_cast<wchar_t*>(name.c_str()); tvItem.cchTextMax = sizeof(itemName) / sizeof(wchar_t);
tvItem.cchTextMax = sizeof(itemName);
if (SendMessage(hTree, TVM_GETITEMW, 0, (LPARAM)&tvItem)) if (SendMessage(hTree, TVM_GETITEMW, 0, (LPARAM)&tvItem))
{ {
FavoritesEntry* fav = reinterpret_cast<FavoritesEntry*>(tvItem.lPara m); FavoritesEntry* fav = reinterpret_cast<FavoritesEntry*>(tvItem.lPara m);
if (fav != NULL && fav->isFolder) if (fav != NULL && fav->isFolder)
{ {
appCore->addFavorite(newBookmark, string(itemName)); appCore->addFavorite(newBookmark, WideToCurrentCP(itemName));
} }
} }
} }
else else
{ {
// Folder not specified, add to end of favorites // Folder not specified, add to end of favorites
appCore->addFavorite(newBookmark, ""); appCore->addFavorite(newBookmark, "");
} }
} }
void DeleteBookmarkFromFavorites(HWND hTree, CelestiaCore* appCore) void DeleteBookmarkFromFavorites(HWND hTree, CelestiaCore* appCore)
{ {
FavoritesList* favorites = appCore->getFavorites(); FavoritesList* favorites = appCore->getFavorites();
TVITEMW tvItem; TVITEMW tvItem;
HTREEITEM hItem; HTREEITEM hItem;
char itemName[33]; wchar_t itemName[33];
hItem = TreeView_GetSelection(hTree); hItem = TreeView_GetSelection(hTree);
if (!hItem) if (!hItem)
return; return;
// Get the selected item text (which is the bookmark name) // Get the selected item text (which is the bookmark name)
tvItem.hItem = hItem; tvItem.hItem = hItem;
tvItem.mask = TVIF_TEXT | TVIF_PARAM | TVIF_HANDLE; tvItem.mask = TVIF_TEXT | TVIF_PARAM | TVIF_HANDLE;
wstring name = CurrentCPToWide(itemName); tvItem.pszText = itemName;
tvItem.pszText = const_cast<wchar_t*>(name.c_str()); tvItem.cchTextMax = sizeof(itemName) / sizeof(wchar_t);
tvItem.cchTextMax = sizeof(itemName);
if (!SendMessage(hTree, TVM_GETITEMW, 0, (LPARAM)&tvItem)) if (!SendMessage(hTree, TVM_GETITEMW, 0, (LPARAM)&tvItem))
return; return;
FavoritesEntry* fav = reinterpret_cast<FavoritesEntry*>(tvItem.lParam); FavoritesEntry* fav = reinterpret_cast<FavoritesEntry*>(tvItem.lParam);
if (!fav) if (!fav)
return; return;
// Delete the item from the tree view; give up if this fails for some // Delete the item from the tree view; give up if this fails for some
// reason (it shouldn't . . .) // reason (it shouldn't . . .)
if (!TreeView_DeleteItem(hTree, hItem)) if (!TreeView_DeleteItem(hTree, hItem))
return; return;
// Delete item in favorites, as well as all of it's children // Delete item in favorites, as well as all of it's children
for (int i = favorites->size() - 1; i >= 0; --i) for (int i = favorites->size() - 1; i >= 0; --i)
{ {
FavoritesEntry *cur = favorites->at(i); FavoritesEntry *cur = favorites->at(i);
if (cur == fav || (fav->isFolder && cur->parentFolder == itemName)) if (cur == fav || (fav->isFolder && cur->parentFolder == WideToCurrentCP (itemName)))
{ {
favorites->erase(favorites->begin() + i); favorites->erase(favorites->begin() + i);
} }
} }
} }
void RenameBookmarkInFavorites(HWND hTree, char* newName, CelestiaCore* appCore) void RenameBookmarkInFavorites(HWND hTree, char* newName, CelestiaCore* appCore)
{ {
FavoritesList* favorites = appCore->getFavorites(); FavoritesList* favorites = appCore->getFavorites();
TVITEMW tvItem; TVITEMW tvItem;
skipping to change at line 629 skipping to change at line 626
} }
} }
} }
void MoveBookmarkInFavorites(HWND hTree, CelestiaCore* appCore) void MoveBookmarkInFavorites(HWND hTree, CelestiaCore* appCore)
{ {
FavoritesList* favorites = appCore->getFavorites(); FavoritesList* favorites = appCore->getFavorites();
TVITEMW tvItem; TVITEMW tvItem;
TVINSERTSTRUCTW tvis; TVINSERTSTRUCTW tvis;
HTREEITEM hDragItemFolder, hDropItem; HTREEITEM hDragItemFolder, hDropItem;
char dragItemName[33]; wchar_t dragItemName[33];
char dragItemFolderName[33]; wchar_t dragItemFolderName[33];
char dropFolderName[33]; wchar_t dropFolderName[33];
bool bMovedInTree = false; bool bMovedInTree = false;
FavoritesEntry* draggedFav = NULL; FavoritesEntry* draggedFav = NULL;
FavoritesEntry* dropFolderFav = NULL; FavoritesEntry* dropFolderFav = NULL;
// First get the target folder name // First get the target folder name
tvItem.hItem = hDropTargetItem; tvItem.hItem = hDropTargetItem;
tvItem.mask = TVIF_TEXT | TVIF_HANDLE; tvItem.mask = TVIF_TEXT | TVIF_HANDLE;
wstring itemName = CurrentCPToWide(dropFolderName); tvItem.pszText = dropFolderName;
tvis.item.pszText = const_cast<wchar_t*>(itemName.c_str()); tvItem.cchTextMax = sizeof(dropFolderName) / sizeof(wchar_t);
tvItem.cchTextMax = sizeof(dropFolderName);
if (!SendMessage(hTree, TVM_GETITEMW, 0, (LPARAM)&tvItem)) if (!SendMessage(hTree, TVM_GETITEMW, 0, (LPARAM)&tvItem))
return; return;
if (!TreeView_GetParent(hTree, hDropTargetItem)) if (!TreeView_GetParent(hTree, hDropTargetItem))
dropFolderName[0] = '\0'; dropFolderName[0] = '\0';
// Get the dragged item text // Get the dragged item text
tvItem.lParam = NULL; tvItem.lParam = NULL;
tvItem.hItem = hDragItem; tvItem.hItem = hDragItem;
tvItem.mask = TVIF_TEXT | TVIF_HANDLE; tvItem.mask = TVIF_TEXT | TVIF_HANDLE;
itemName = CurrentCPToWide(dragItemName); tvItem.pszText = dragItemName;
tvis.item.pszText = const_cast<wchar_t*>(itemName.c_str()); tvItem.cchTextMax = sizeof(dragItemName) / sizeof(wchar_t);
tvItem.cchTextMax = sizeof(dragItemName);
if (SendMessage(hTree, TVM_GETITEMW, 0, (LPARAM)&tvItem)) if (SendMessage(hTree, TVM_GETITEMW, 0, (LPARAM)&tvItem))
{ {
draggedFav = reinterpret_cast<FavoritesEntry*>(tvItem.lParam); draggedFav = reinterpret_cast<FavoritesEntry*>(tvItem.lParam);
// Get the dragged item folder // Get the dragged item folder
if (hDragItemFolder = TreeView_GetParent(hTree, hDragItem)) if (hDragItemFolder = TreeView_GetParent(hTree, hDragItem))
{ {
tvItem.hItem = hDragItemFolder; tvItem.hItem = hDragItemFolder;
tvItem.mask = TVIF_TEXT | TVIF_HANDLE; tvItem.mask = TVIF_TEXT | TVIF_HANDLE;
wstring itemName = CurrentCPToWide(dragItemFolderName); tvItem.pszText = dragItemFolderName;
tvItem.pszText = const_cast<wchar_t*>(itemName.c_str()); tvItem.cchTextMax = sizeof(dragItemFolderName) / sizeof(wchar_t);
tvItem.cchTextMax = sizeof(dragItemFolderName);
if (SendMessage(hTree, TVM_GETITEMW, 0, (LPARAM)&tvItem)) if (SendMessage(hTree, TVM_GETITEMW, 0, (LPARAM)&tvItem))
{ {
if (!TreeView_GetParent(hTree, hDragItemFolder)) if (!TreeView_GetParent(hTree, hDragItemFolder))
dragItemFolderName[0] = '\0'; dragItemFolderName[0] = '\0';
// Make sure drag and target folders are different // Make sure drag and target folders are different
if (strcmp(dragItemFolderName, dropFolderName)) if (wcscmp(dragItemFolderName, dropFolderName))
{ {
// Delete tree item from source bookmark // Delete tree item from source bookmark
if (TreeView_DeleteItem(hTree, hDragItem)) if (TreeView_DeleteItem(hTree, hDragItem))
{ {
// Add item to dest bookmark // Add item to dest bookmark
tvis.hParent = hDropTargetItem; tvis.hParent = hDropTargetItem;
tvis.hInsertAfter = TVI_LAST; tvis.hInsertAfter = TVI_LAST;
tvis.item.mask = StdItemMask; tvis.item.mask = StdItemMask;
wstring itemName = CurrentCPToWide(dragItemName); wstring itemName = dragItemName;
tvis.item.pszText = const_cast<wchar_t*>(itemName.c_str( )); tvis.item.pszText = const_cast<wchar_t*>(itemName.c_str( ));
tvis.item.lParam = reinterpret_cast<LPARAM>(draggedFav); tvis.item.lParam = reinterpret_cast<LPARAM>(draggedFav);
tvis.item.iImage = 3; tvis.item.iImage = 3;
tvis.item.iSelectedImage = 3; tvis.item.iSelectedImage = 3;
if (hDropItem = (HTREEITEM)SendMessage(hTree, TVM_INSERT ITEMW, 0, (LPARAM)&tvis)) if (hDropItem = (HTREEITEM)SendMessage(hTree, TVM_INSERT ITEMW, 0, (LPARAM)&tvis))
{ {
TreeView_Expand(hTree, hDropTargetItem, TVE_EXPAND); TreeView_Expand(hTree, hDropTargetItem, TVE_EXPAND);
// Make the dropped item selected // Make the dropped item selected
TreeView_SelectItem(hTree, hDropItem); TreeView_SelectItem(hTree, hDropItem);
skipping to change at line 705 skipping to change at line 699
} }
} }
} }
} }
} }
} }
// Now perform the move in favorites // Now perform the move in favorites
if (bMovedInTree && draggedFav != NULL) if (bMovedInTree && draggedFav != NULL)
{ {
draggedFav->parentFolder = dropFolderName; draggedFav->parentFolder = WideToCurrentCP(dropFolderName);
} }
} }
bool isOrganizeBookmarksDragDropActive() bool isOrganizeBookmarksDragDropActive()
{ {
return dragging; return dragging;
} }
void OrganizeBookmarksOnBeginDrag(HWND hTree, LPNMTREEVIEW lpnmtv) void OrganizeBookmarksOnBeginDrag(HWND hTree, LPNMTREEVIEW lpnmtv)
{ {
skipping to change at line 864 skipping to change at line 858
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// This function returns the handle of the tree item specified using standar d // This function returns the handle of the tree item specified using standar d
// path notation. // path notation.
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
HTREEITEM GetTreeViewItemHandle(HWND hTree, char* path, HTREEITEM hParent) HTREEITEM GetTreeViewItemHandle(HWND hTree, char* path, HTREEITEM hParent)
{ {
if (!hTree || !hParent) if (!hTree || !hParent)
return NULL; return NULL;
char* cP; char* cP;
char itemName[33]; char_t itemName[33];
char pathBuf[66]; char pathBuf[66];
TVITEMW Item; TVITEMW Item;
HTREEITEM hItem; HTREEITEM hItem;
strcpy(pathBuf, path); strcpy(pathBuf, path);
if (cP = strchr(pathBuf, '/')) if (cP = strchr(pathBuf, '/'))
*cP = '\0'; *cP = '\0';
hItem = NULL; hItem = NULL;
 End of changes. 18 change blocks. 
32 lines changed or deleted 26 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)