void Cloud01::Load() { g_pCloud01 = _LoadImage(0, ".\\RESOURCES\\cloud01.png", 224, 160); }
GDImage::~GDImage( void ) { // This deletes the image if loaded _LoadImage( NULL ); }
void Window01::Load() { g_pWindow01 = _LoadImage(0, ".\\RESOURCES\\house01_windowBack.png", 128, 128); }
void ShowImageWindow::MessageReceived(BMessage* message) { if (message->WasDropped()) { uint32 type; int32 count; status_t status = message->GetInfo("refs", &type, &count); if (status == B_OK && type == B_REF_TYPE) { message->what = B_REFS_RECEIVED; be_app->PostMessage(message); } } switch (message->what) { case kMsgImageCacheImageLoaded: { fProgressWindow->Stop(); BitmapOwner* bitmapOwner = NULL; message->FindPointer("bitmapOwner", (void**)&bitmapOwner); bool first = fImageView->Bitmap() == NULL; entry_ref ref; message->FindRef("ref", &ref); if (!first && ref != fNavigator.CurrentRef()) { // ignore older images if (bitmapOwner != NULL) bitmapOwner->ReleaseReference(); break; } int32 page = message->FindInt32("page"); int32 pageCount = message->FindInt32("pageCount"); if (!first && page != fNavigator.CurrentPage()) { // ignore older pages if (bitmapOwner != NULL) bitmapOwner->ReleaseReference(); break; } status_t status = fImageView->SetImage(message); if (status != B_OK) { if (bitmapOwner != NULL) bitmapOwner->ReleaseReference(); _LoadError(ref); // quit if file could not be opened if (first) Quit(); break; } fImageType = message->FindString("type"); fNavigator.SetTo(ref, page, pageCount); fImageView->FitToBounds(); if (first) { fImageView->MakeFocus(true); // to receive key messages Show(); } _UpdateRatingMenu(); // Set width and height attributes of the currently showed file. // This should only be a temporary solution. _SaveWidthAndHeight(); break; } case kMsgImageCacheProgressUpdate: { entry_ref ref; if (message->FindRef("ref", &ref) == B_OK && ref == fNavigator.CurrentRef()) { message->what = kMsgProgressUpdate; fProgressWindow->PostMessage(message); } break; } case MSG_MODIFIED: // If image has been modified due to a Cut or Paste fModified = true; break; case MSG_OUTPUT_TYPE: // User clicked Save As then choose an output format if (!fSavePanel) // If user doesn't already have a save panel open _SaveAs(message); break; case MSG_SAVE_PANEL: // User specified where to save the output image _SaveToFile(message); break; case B_CANCEL: delete fSavePanel; fSavePanel = NULL; break; case MSG_UPDATE_STATUS: { int32 pages = fNavigator.PageCount(); int32 currentPage = fNavigator.CurrentPage(); _EnableMenuItem(fBar, MSG_PAGE_FIRST, fNavigator.HasPreviousPage()); _EnableMenuItem(fBar, MSG_PAGE_LAST, fNavigator.HasNextPage()); _EnableMenuItem(fBar, MSG_PAGE_NEXT, fNavigator.HasNextPage()); _EnableMenuItem(fBar, MSG_PAGE_PREV, fNavigator.HasPreviousPage()); fGoToPageMenu->SetEnabled(pages > 1); _EnableMenuItem(fBar, MSG_FILE_NEXT, fNavigator.HasNextFile()); _EnableMenuItem(fBar, MSG_FILE_PREV, fNavigator.HasPreviousFile()); if (fGoToPageMenu->CountItems() != pages) { // Only rebuild the submenu if the number of // pages is different while (fGoToPageMenu->CountItems() > 0) { // Remove all page numbers delete fGoToPageMenu->RemoveItem((int32)0); } for (int32 i = 1; i <= pages; i++) { // Fill Go To page submenu with an entry for each page BMessage* goTo = new BMessage(MSG_GOTO_PAGE); goTo->AddInt32("page", i); char shortcut = 0; if (i < 10) shortcut = '0' + i; BString strCaption; strCaption << i; BMenuItem* item = new BMenuItem(strCaption.String(), goTo, shortcut, B_SHIFT_KEY); if (currentPage == i) item->SetMarked(true); fGoToPageMenu->AddItem(item); } } else { // Make sure the correct page is marked BMenuItem* currentItem = fGoToPageMenu->ItemAt(currentPage - 1); if (currentItem != NULL && !currentItem->IsMarked()) currentItem->SetMarked(true); } _UpdateStatusText(message); BPath path(fImageView->Image()); SetTitle(path.Path()); break; } case MSG_UPDATE_STATUS_TEXT: { _UpdateStatusText(message); break; } case MSG_SELECTION: { // The view sends this message when a selection is // made or the selection is cleared so that the window // can update the state of the appropriate menu items bool enable; if (message->FindBool("has_selection", &enable) == B_OK) { _EnableMenuItem(fBar, B_COPY, enable); _EnableMenuItem(fBar, MSG_CLEAR_SELECT, enable); } break; } case B_COPY: fImageView->CopySelectionToClipboard(); break; case MSG_SELECTION_MODE: { bool selectionMode = _ToggleMenuItem(MSG_SELECTION_MODE); fImageView->SetSelectionMode(selectionMode); if (!selectionMode) fImageView->ClearSelection(); break; } case MSG_CLEAR_SELECT: fImageView->ClearSelection(); break; case MSG_SELECT_ALL: fImageView->SelectAll(); break; case MSG_PAGE_FIRST: if (_ClosePrompt() && fNavigator.FirstPage()) _LoadImage(); break; case MSG_PAGE_LAST: if (_ClosePrompt() && fNavigator.LastPage()) _LoadImage(); break; case MSG_PAGE_NEXT: if (_ClosePrompt() && fNavigator.NextPage()) _LoadImage(); break; case MSG_PAGE_PREV: if (_ClosePrompt() && fNavigator.PreviousPage()) _LoadImage(); break; case MSG_GOTO_PAGE: { if (!_ClosePrompt()) break; int32 newPage; if (message->FindInt32("page", &newPage) != B_OK) break; int32 currentPage = fNavigator.CurrentPage(); int32 pages = fNavigator.PageCount(); // TODO: use radio mode instead! if (newPage > 0 && newPage <= pages) { BMenuItem* currentItem = fGoToPageMenu->ItemAt(currentPage - 1); BMenuItem* newItem = fGoToPageMenu->ItemAt(newPage - 1); if (currentItem != NULL && newItem != NULL) { currentItem->SetMarked(false); newItem->SetMarked(true); if (fNavigator.GoToPage(newPage)) _LoadImage(); } } break; } case kMsgFitToWindow: fImageView->FitToBounds(); break; case kMsgStretchToWindow: fImageView->SetStretchToBounds( _ToggleMenuItem(kMsgStretchToWindow)); break; case MSG_FILE_PREV: if (_ClosePrompt() && fNavigator.PreviousFile()) _LoadImage(false); break; case MSG_FILE_NEXT: case kMsgNextSlide: if (_ClosePrompt() && fNavigator.NextFile()) _LoadImage(); break; case kMsgDeleteCurrentFile: { if (fNavigator.MoveFileToTrash()) _LoadImage(); else PostMessage(B_QUIT_REQUESTED); break; } case MSG_ROTATE_90: fImageView->Rotate(90); break; case MSG_ROTATE_270: fImageView->Rotate(270); break; case MSG_FLIP_LEFT_TO_RIGHT: fImageView->Flip(true); break; case MSG_FLIP_TOP_TO_BOTTOM: fImageView->Flip(false); break; case MSG_SLIDE_SHOW: { bool fullScreen = false; message->FindBool("full screen", &fullScreen); BMenuItem* item = fBar->FindItem(message->what); if (item == NULL) break; if (item->IsMarked()) { item->SetMarked(false); _StopSlideShow(); fToolBar->SetActionPressed(MSG_SLIDE_SHOW, false); } else if (_ClosePrompt()) { item->SetMarked(true); if (!fFullScreen && fullScreen) _ToggleFullScreen(); _StartSlideShow(); fToolBar->SetActionPressed(MSG_SLIDE_SHOW, true); } break; } case kMsgStopSlideShow: { BMenuItem* item = fBar->FindItem(MSG_SLIDE_SHOW); if (item != NULL) item->SetMarked(false); _StopSlideShow(); fToolBar->SetActionPressed(MSG_SLIDE_SHOW, false); break; } case MSG_SLIDE_SHOW_DELAY: { bigtime_t delay; if (message->FindInt64("delay", &delay) == B_OK) { _SetSlideShowDelay(delay); // in case message is sent from popup menu _MarkSlideShowDelay(delay); } break; } case MSG_FULL_SCREEN: _ToggleFullScreen(); break; case MSG_EXIT_FULL_SCREEN: if (fFullScreen) _ToggleFullScreen(); break; case MSG_SHOW_CAPTION: { fShowCaption = _ToggleMenuItem(message->what); ShowImageSettings* settings = my_app->Settings(); if (settings->Lock()) { settings->SetBool("ShowCaption", fShowCaption); settings->Unlock(); } if (fFullScreen) fImageView->SetShowCaption(fShowCaption); } break; case MSG_PAGE_SETUP: _PageSetup(); break; case MSG_PREPARE_PRINT: _PrepareForPrint(); break; case MSG_PRINT: _Print(message); break; case MSG_ZOOM_IN: fImageView->ZoomIn(); break; case MSG_ZOOM_OUT: fImageView->ZoomOut(); break; case MSG_UPDATE_STATUS_ZOOM: fStatusView->SetZoom(fImageView->Zoom()); break; case kMsgOriginalSize: if (message->FindInt32("behavior") == BButton::B_TOGGLE_BEHAVIOR) { bool force = (message->FindInt32("be:value") == B_CONTROL_ON); fImageView->ForceOriginalSize(force); if (!force) break; } fImageView->SetZoom(1.0); break; case MSG_SCALE_BILINEAR: fImageView->SetScaleBilinear(_ToggleMenuItem(message->what)); break; case MSG_DESKTOP_BACKGROUND: { BMessage backgroundsMessage(B_REFS_RECEIVED); backgroundsMessage.AddRef("refs", fImageView->Image()); // This is used in the Backgrounds code for scaled placement backgroundsMessage.AddInt32("placement", 'scpl'); be_roster->Launch("application/x-vnd.haiku-backgrounds", &backgroundsMessage); break; } case MSG_SET_RATING: { int32 rating; if (message->FindInt32("rating", &rating) != B_OK) break; BFile file(&fNavigator.CurrentRef(), B_WRITE_ONLY); if (file.InitCheck() != B_OK) break; file.WriteAttr("Media:Rating", B_INT32_TYPE, 0, &rating, sizeof(rating)); _UpdateRatingMenu(); break; } case kMsgToggleToolBar: { fShowToolBar = _ToggleMenuItem(message->what); _SetToolBarVisible(fShowToolBar, true); ShowImageSettings* settings = my_app->Settings(); if (settings->Lock()) { settings->SetBool("ShowToolBar", fShowToolBar); settings->Unlock(); } break; } case kShowToolBarIfEnabled: { bool show; if (message->FindBool("show", &show) != B_OK) break; _SetToolBarVisible(fShowToolBar && show, true); break; } case kMsgSlideToolBar: { float offset; if (message->FindFloat("offset", &offset) == B_OK) { fToolBar->MoveBy(0, offset); fScrollView->ResizeBy(0, -offset); fScrollView->MoveBy(0, offset); UpdateIfNeeded(); snooze(15000); } break; } case kMsgFinishSlidingToolBar: { float offset; bool show; if (message->FindFloat("offset", &offset) == B_OK && message->FindBool("show", &show) == B_OK) { // Compensate rounding errors with the final placement fToolBar->MoveTo(fToolBar->Frame().left, offset); if (!show) fToolBar->Hide(); BRect frame = fToolBar->Parent()->Bounds(); frame.top = fToolBar->Frame().bottom + 1; fScrollView->MoveTo(fScrollView->Frame().left, frame.top); fScrollView->ResizeTo(fScrollView->Bounds().Width(), frame.Height() + 1); } break; } default: BWindow::MessageReceived(message); break; } }
void Cloud02::Load() { g_pCloud02 = _LoadImage(0, ".\\RESOURCES\\cloud02.png", 192, 192); }
void Crate04::Load() { g_pCrate04 = _LoadImage(0, ".\\RESOURCES\\box04.png", 64, 64); }
ShowImageWindow::ShowImageWindow(BRect frame, const entry_ref& ref, const BMessenger& trackerMessenger) : BWindow(frame, "", B_DOCUMENT_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS), fNavigator(ref, trackerMessenger), fSavePanel(NULL), fBar(NULL), fBrowseMenu(NULL), fGoToPageMenu(NULL), fSlideShowDelayMenu(NULL), fToolBar(NULL), fImageView(NULL), fStatusView(NULL), fProgressWindow(new ProgressWindow()), fModified(false), fFullScreen(false), fShowCaption(true), fShowToolBar(true), fPrintSettings(NULL), fSlideShowRunner(NULL), fSlideShowDelay(kDefaultSlideShowDelay) { _ApplySettings(); SetLayout(new BGroupLayout(B_VERTICAL, 0)); // create menu bar fBar = new BMenuBar("menu_bar"); _AddMenus(fBar); float menuBarMinWidth = fBar->MinSize().width; AddChild(fBar); // Add a content view so the tool bar can be moved outside of the // visible portion without colliding with the menu bar. BView* contentView = new BView(BRect(), "content", B_FOLLOW_NONE, 0); contentView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); contentView->SetExplicitMinSize(BSize(250, 100)); AddChild(contentView); // Create the tool bar BRect viewFrame = contentView->Bounds(); viewFrame.right -= B_V_SCROLL_BAR_WIDTH; fToolBar = new BToolBar(viewFrame); // Add the tool icons. // fToolBar->AddAction(MSG_FILE_OPEN, be_app, // tool_bar_icon(kIconDocumentOpen), B_TRANSLATE("Open" B_UTF8_ELLIPSIS)); fToolBar->AddAction(MSG_FILE_PREV, this, tool_bar_icon(kIconGoPrevious), B_TRANSLATE("Previous file"), false); fToolBar->AddAction(MSG_FILE_NEXT, this, tool_bar_icon(kIconGoNext), B_TRANSLATE("Next file"), false); BMessage* fullScreenSlideShow = new BMessage(MSG_SLIDE_SHOW); fullScreenSlideShow->AddBool("full screen", true); fToolBar->AddAction(fullScreenSlideShow, this, tool_bar_icon(kIconMediaMovieLibrary), B_TRANSLATE("Slide show"), false); fToolBar->AddSeparator(); fToolBar->AddAction(MSG_SELECTION_MODE, this, tool_bar_icon(kIconDrawRectangularSelection), B_TRANSLATE("Selection mode"), false); fToolBar->AddSeparator(); fToolBar->AddAction(kMsgOriginalSize, this, tool_bar_icon(kIconZoomOriginal), B_TRANSLATE("Original size"), true); fToolBar->AddAction(kMsgFitToWindow, this, tool_bar_icon(kIconZoomFitBest), B_TRANSLATE("Fit to window"), false); fToolBar->AddAction(MSG_ZOOM_IN, this, tool_bar_icon(kIconZoomIn), B_TRANSLATE("Zoom in"), false); fToolBar->AddAction(MSG_ZOOM_OUT, this, tool_bar_icon(kIconZoomOut), B_TRANSLATE("Zoom out"), false); fToolBar->AddSeparator(); fToolBar->AddAction(MSG_PAGE_PREV, this, tool_bar_icon(kIconPagePrevious), B_TRANSLATE("Previous page"), false); fToolBar->AddAction(MSG_PAGE_NEXT, this, tool_bar_icon(kIconPageNext), B_TRANSLATE("Next page"), false); fToolBar->AddGlue(); fToolBar->AddAction(MSG_FULL_SCREEN, this, tool_bar_icon(kIconViewWindowed), B_TRANSLATE("Leave full screen"), false); fToolBar->SetActionVisible(MSG_FULL_SCREEN, false); fToolBar->ResizeTo(viewFrame.Width(), fToolBar->MinSize().height); contentView->AddChild(fToolBar); if (fShowToolBar) viewFrame.top = fToolBar->Frame().bottom + 1; else fToolBar->Hide(); fToolBarVisible = fShowToolBar; viewFrame.bottom = contentView->Bounds().bottom; viewFrame.bottom -= B_H_SCROLL_BAR_HEIGHT; // create the image view fImageView = new ShowImageView(viewFrame, "image_view", B_FOLLOW_ALL, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_PULSE_NEEDED | B_FRAME_EVENTS); // wrap a scroll view around the view fScrollView = new BScrollView("image_scroller", fImageView, B_FOLLOW_ALL, 0, true, true, B_PLAIN_BORDER); contentView->AddChild(fScrollView); fStatusView = new ShowImageStatusView(fScrollView); fScrollView->AddChild(fStatusView); // Update minimum window size float toolBarMinWidth = fToolBar->MinSize().width; SetSizeLimits(std::max(menuBarMinWidth, toolBarMinWidth), 100000, 100, 100000); // finish creating the window if (_LoadImage() != B_OK) { _LoadError(ref); Quit(); return; } // add View menu here so it can access ShowImageView methods BMenu* menu = new BMenu(B_TRANSLATE_CONTEXT("View", "Menus")); _BuildViewMenu(menu, false); fBar->AddItem(menu); fBar->AddItem(_BuildRatingMenu()); SetPulseRate(100000); // every 1/10 second; ShowImageView needs it for marching ants _MarkMenuItem(menu, MSG_SELECTION_MODE, fImageView->IsSelectionModeEnabled()); // Tell application object to query the clipboard // and tell this window if it contains interesting data or not be_app_messenger.SendMessage(B_CLIPBOARD_CHANGED); // The window will be shown on screen automatically Run(); }
void Crate01::Load() { g_pCrate01 = _LoadImage(0, ".\\RESOURCES\\box01.png", 64, 64); }
void Building01::Load() { g_pBuild01 = _LoadImage(0, ".\\RESOURCES\\firstHouse.png", 256, 446); }
void Skyscraper03::Load() { g_pSkyscraper03 = _LoadImage(0, ".\\RESOURCES\\level_02_Assests\\skyScaper03.png", 416, 743); }
void Floor01::Load() { g_pFloor01 = _LoadImage(0, ".\\RESOURCES\\floorTile.png", 192, 32); }
bool CGUIWindow::LoadXML( const std::string &xmlGuiFile, const Vect2i& screenResolution) { //Read the xml gui file LOGGER->AddNewLog(ELL_INFORMATION, "CGUIWindow:: Iniciando el parseo del fichero %s", xmlGuiFile.c_str()); bool isOK = false; CXMLTreeNode newFile; if (!newFile.LoadFile(xmlGuiFile.c_str())) { LOGGER->AddNewLog(ELL_ERROR, "CGUIWindow:: No se ha podido leer correctamente el fichero ->%s", xmlGuiFile.c_str()); isOK = false; } else { CTextureManager* textureM = CORE->GetTextureManager(); CXMLTreeNode windows = newFile["Windows"]; m_sLuaCode_OnLoadWindows = windows.GetPszProperty("OnLoadWindows"); m_sLuaCode_OnSaveWindows = windows.GetPszProperty("OnSaveWindows"); m_sLuaCode_OnUpdateWindows = windows.GetPszProperty("OnUpdateWindows"); if (windows.Exists()) { int count = windows.GetNumChildren(); for (int i = 0; i < count; ++i) { CXMLTreeNode pNewNode = windows(i); //Para cada guielement leemos su informacion comun--> std::string name = pNewNode.GetPszProperty("name", "defaultGuiElement"); float posx = pNewNode.GetFloatProperty("posx", 0.f); float posy = pNewNode.GetFloatProperty("posy", 0.f); float w = pNewNode.GetFloatProperty("width", 50.f); float h = pNewNode.GetFloatProperty("height", 50.f); bool visible = pNewNode.GetBoolProperty("visible", true); bool activated = pNewNode.GetBoolProperty("active", true); std::string tagName = pNewNode.GetName(); if (tagName.compare("Button")==0) { CButton* newButton = NULL; LoadButton(&newButton,pNewNode,screenResolution, textureM); AddGuiElement(newButton); } else if (tagName.compare("CheckButton")==0) { CCheckButton* new_checkButton = NULL; LoadCheckButton(&new_checkButton,pNewNode,screenResolution, textureM); AddGuiElement(new_checkButton); } else if (tagName.compare("Slider")==0) { CSlider* new_slider = NULL; LoadSlider(&new_slider,pNewNode,screenResolution, textureM); AddGuiElement(new_slider); } else if (tagName.compare("DialogBox")==0) { CDialogBox* new_dialogBox = NULL; LoadDialogBox(&new_dialogBox,pNewNode,screenResolution, textureM); AddGuiElement(new_dialogBox); } else if (tagName.compare("EditableTextBox")==0) { CEditableTextBox* new_editableTextBox = NULL; LoadEditableTextBox(&new_editableTextBox,pNewNode,screenResolution, textureM); AddGuiElement(new_editableTextBox); } else if (tagName.compare("RadioBox")==0) { CRadioBox* new_radioBox = NULL; LoadRadioBox(&new_radioBox,pNewNode,screenResolution, textureM); AddGuiElement(new_radioBox); } else if (tagName.compare("Image")==0) { CImage* new_image = NULL; _LoadImage(&new_image,pNewNode,screenResolution, textureM); AddGuiElement(new_image); } else if (tagName.compare("AnimatedImage")==0) { CAnimatedImage* new_image = NULL; LoadAnimatedImage(&new_image,pNewNode,screenResolution, textureM); AddGuiElement(new_image); } else if (tagName.compare("ProgressBar")==0) { CProgressBar* new_progressBar = NULL; LoadProgressBar(&new_progressBar,pNewNode,screenResolution, textureM); AddGuiElement(new_progressBar); } else if (tagName.compare("StaticText")==0) { CStaticText* new_staticText = NULL; LoadStaticText(&new_staticText,pNewNode,screenResolution, textureM); AddGuiElement(new_staticText); } else if (tagName.compare("KeyBoard_Back")==0) { //<KeyBoard_Back input="DIK_A" OnKeyDown="blablaLua"/> m_sLuaCode_OnKeyDown = pNewNode.GetPszProperty("OnKeyDown", ""); m_uInputKeyDown = pNewNode.GetIntProperty("input", 0); } else { //Warning LOGGER->AddNewLog(ELL_WARNING, "GUIWindow:: No se reconoce el tag %s del fichero %s", tagName.c_str(), xmlGuiFile.c_str()); } } isOK = true; } else { LOGGER->AddNewLog(ELL_ERROR, "GUIWindow:: No se ha podido leer el tag Windows del fichero ->%s", xmlGuiFile.c_str()); isOK = false; } }//END else de if (!newFile.LoadFile(xmlGuiFile.c_str())) if (!isOK) { LOGGER->AddNewLog(ELL_ERROR, "GUIWindow:: No se ha podido leer correctamente el fichero -->%s", xmlGuiFile.c_str()); isOK = false; } else { LOGGER->AddNewLog(ELL_INFORMATION, "GUIWindow:: Finalizado correctamente el parseo el fichero %s", xmlGuiFile.c_str()); } return isOK; }
void Floor02::Load() { g_pFloor02 = _LoadImage(0, ".\\RESOURCES\\floor.png", 768, 384); }
void GameOverScene::Load() { g_pDeath = _LoadImage(3, ".\\RESOURCES\\gameOver.png", 1024, 720); }