void ResourceLibraryDialog::ConstructList() { wxLogNull noLogPlease; listCtrl->ClearAll(); wxImageList * imageList = new wxImageList(40,40); imageList->Add(gd::CommonBitmapProvider::Get()->parentFolder40); //If we are in the root path, do not display Parent folder item wxFileName currentDirPath(currentDir); currentDirPath.Normalize(); wxFileName rootPath(wxGetCwd()+"/Free resources/"); rootPath.Normalize(); if ( currentDirPath.GetFullPath() != rootPath.GetFullPath() ) listCtrl->InsertItem(0, _("Parent folder"), 0); //Browse file and directories wxDir dir(currentDir); wxString filename; bool cont = dir.GetFirst(&filename, "", wxDIR_DEFAULT); while ( cont ) { if ( wxDirExists(currentDir+"/"+filename) ) { //Only add a directory if there is a GDLibrary.txt file inside it. if ( wxFileExists(currentDir+"/"+filename+"/GDLibrary.txt") ) { wxBitmap folderBmp = gd::CommonBitmapProvider::Get()->folder40; if ( wxFileExists(currentDir+"/"+filename+"/GDLibraryIcon.png") ) PasteBitmap(folderBmp, wxBitmap(currentDir+"/"+filename+"/GDLibraryIcon.png", wxBITMAP_TYPE_ANY), 20,20 ); imageList->Add(folderBmp); listCtrl->InsertItem(1, filename, imageList->GetImageCount()-1); } } else { //Do not display the library icon if ( filename != "GDLibraryIcon.png" ) { wxLogNull noLogPlease; wxBitmap bmp(currentDir+"/"+filename, wxBITMAP_TYPE_ANY); if ( bmp.IsOk() ) { wxBitmap resizedBmp = Rescale(bmp,40,40); imageList->Add(resizedBmp); listCtrl->InsertItem(listCtrl->GetItemCount(), filename, imageList->GetImageCount()-1); } } } cont = dir.GetNext(&filename); } listCtrl->AssignImageList(imageList, wxIMAGE_LIST_NORMAL); }
BOOL PasteFromClipboard( HWND hWindow, BOOL fNeedMask ) /************************************************************************/ { // The MGX format will stuff the path strings since the files already exist if ( IsClipboardFormatAvailable( Control.cfImage ) ) return( PasteMGXImage( hWindow, Names.PasteImageFile, Names.PasteMaskFile)); // Other formats need to create the file, therefore we stuff the path // strings first GetExtNamePath( Names.PasteImageFile, IDN_CLIPBOARD ); lstrcat( Names.PasteImageFile, "WINCLIP.BMP" ); Names.PasteMaskFile[0] = '\0'; if ( IsClipboardFormatAvailable( CF_DIB ) ) return( PasteDIB( hWindow, Names.PasteImageFile, NULL ) ); else if ( IsClipboardFormatAvailable( CF_BITMAP ) ) return( PasteBitmap( hWindow, Names.PasteImageFile, NULL ) ); return( FALSE ); }
void BitmapView::MessageReceived(BMessage *msg) { if (msg->WasDropped() && AcceptsDrops()) { // We'll handle two types of drops: those from Tracker and those from ShowImage if (msg->what == B_SIMPLE_DATA) { int32 actions; if (msg->FindInt32("be:actions", &actions) == B_OK) { // ShowImage drop. This is a negotiated drag&drop, so send a reply BMessage reply(B_COPY_TARGET), response; reply.AddString("be:types", "image/jpeg"); reply.AddString("be:types", "image/png"); msg->SendReply(&reply, &response); // now, we've gotten the response if (response.what == B_MIME_DATA) { // Obtain and translate the received data uint8 *imagedata; ssize_t datasize; // Try JPEG first if (response.FindData("image/jpeg", B_MIME_DATA, (const void **)&imagedata, &datasize) != B_OK) { // Try PNG next and piddle out if unsuccessful if (response.FindData("image/png", B_PNG_FORMAT, (const void **)&imagedata, &datasize) != B_OK) return; } // Set up to decode into memory BMemoryIO memio(imagedata, datasize); BTranslatorRoster *roster = BTranslatorRoster::Default(); BBitmapStream bstream; if (roster->Translate(&memio, NULL, NULL, &bstream, B_TRANSLATOR_BITMAP) == B_OK) { BBitmap *bmp; if (bstream.DetachBitmap(&bmp) != B_OK) return; SetBitmap(bmp); if (fConstrainDrops) ConstrainBitmap(); Invoke(); } } return; } entry_ref ref; if (msg->FindRef("refs", &ref) == B_OK) { // Tracker drop BBitmap *bmp = BTranslationUtils::GetBitmap(&ref); if (bmp) { SetBitmap(bmp); if (fConstrainDrops) ConstrainBitmap(); Invoke(); } } } return; } switch (msg->what) { case M_REMOVE_IMAGE: { BAlert *alert = new BAlert("ResEdit", "This cannot be undone. " "Remove the image?", "Remove", "Cancel"); alert->SetShortcut(1, B_ESCAPE); int32 value = alert->Go(); if (value == 0) { SetBitmap(NULL); if (Target()) { BMessenger msgr(Target()); msgr.SendMessage(new BMessage(M_BITMAP_REMOVED)); return; } } } case M_PASTE_IMAGE: { PasteBitmap(); Invoke(); } } BView::MessageReceived(msg); }