AboutWindow::AboutWindow(const Rect & r) :Window(r, "AboutAlbert", MSG_ABOUTWND_TITLE, // WND_NO_CLOSE_BUT | WND_NO_ZOOM_BUT | WND_NO_DEPTH_BUT | // WND_NO_BORDER | WND_NO_TITLE | WND_NOT_RESIZABLE, CURRENT_DESKTOP) { os::Resources cRes(get_image_id()); os::ResStream* pcStream = cRes.GetResourceStream("Calculator.png"); if(pcStream == NULL) throw(os::errno_exception("Can't find resource Calculator.png!")); m_pcImage = new BitmapImage( pcStream ); BitmapView* imv = new BitmapView( m_pcImage->GetBounds(), "bitmap", m_pcImage ); AddChild(imv); Rect frame = m_pcImage->GetBounds(); Desktop desktop; Point offset(desktop.GetResolution()); offset.x = offset.x/2 - frame.Width()/2; offset.y = offset.y/2 - frame.Height()/2; SetFrame(frame + offset); delete pcStream; }
MainWindow::MainWindow() : os::Window( os::Rect( 0, 0, 300, 250 ), "main_wnd", "Format" ) { os::LayoutView* pcView = new os::LayoutView( GetBounds(), "layout_view" ); #include "mainwindowLayout.cpp" pcView->SetRoot( m_pcRoot ); AddChild( pcView ); /* Set Icon */ os::Resources cCol( get_image_id() ); os::ResStream *pcStream = cCol.GetResourceStream( "icon48x48.png" ); os::BitmapImage *pcIcon = new os::BitmapImage( pcStream ); SetIcon( pcIcon->LockBitmap() ); delete( pcIcon ); /* Show Splash Screen */ Splash* pcWindow = new Splash(LoadImageFromResource("logo.png"),"Format is scanning devices",false,0.0); pcWindow->Go(); /* Clear All */ m_pcDevice_Selection->Clear(); m_pcFilesystem_Selection->Clear(); m_pcVolumename_Text->Clear(); m_pcArguments_Text->Clear(); /* Load Devices & Filesystems */ LoadDevices(); LoadFilesystems(); /* Remove Splash Screen */ pcWindow->Quit(); }
void SetButtonImageFromResource( os::ImageButton* pcButton, os::String zResource ) { os::File cSelf( open_image_file( get_image_id() ) ); os::Resources cCol( &cSelf ); os::ResStream *pcStream = cCol.GetResourceStream( zResource ); pcButton->SetImage( pcStream ); delete( pcStream ); }
BitmapImage* MainWindow::LoadImageFromResource( String zResource ) { BitmapImage *pcImage = new BitmapImage(); Resources cRes( get_image_id() ); ResStream *pcStream = cRes.GetResourceStream( zResource ); pcImage->Load( pcStream ); delete ( pcStream ); return pcImage; }
static int parse_image_display(struct skin_element *element, struct wps_token *token, struct wps_data *wps_data) { char *label = element->params[0].data.text; char sublabel = '\0'; int subimage; struct gui_img *img; struct image_display *id = skin_buffer_alloc(sizeof(struct image_display)); if (element->params_count == 1 && strlen(label) <= 2) { /* backwards compatability. Allow %xd(Aa) to still work */ sublabel = label[1]; label[1] = '\0'; } /* sanity check */ img = find_image(label, wps_data); if (!img || !id) { return WPS_ERROR_INVALID_PARAM; } id->label = label; id->offset = 0; id->token = NULL; if (img->using_preloaded_icons) { token->type = SKIN_TOKEN_IMAGE_DISPLAY_LISTICON; } if (element->params_count > 1) { if (element->params[1].type == CODE) id->token = element->params[1].data.code->data; /* specify a number. 1 being the first subimage (i.e top) NOT 0 */ else if (element->params[1].type == INTEGER) id->subimage = element->params[1].data.number - 1; if (element->params_count > 2) id->offset = element->params[2].data.number; } else { if ((subimage = get_image_id(sublabel)) != -1) { if (subimage >= img->num_subimages) return WPS_ERROR_INVALID_PARAM; id->subimage = subimage; } else { id->subimage = 0; } } token->value.data = id; return 0; }
void pms::serialization::spritedesc::node_parser_sprite_declaration::parse_node ( const resources::image_mapping& images, layout::atlas_page& desc, const tree_node& node ) const { layout::atlas_page::sprite s; s.bleed = false; std::size_t n( 0 ); if ( ( node.children[n].value.id() == grammar::id_properties ) || ( node.children[n].value.id() == grammar::id_identifier ) ) apply_sprite_properties( s, node.children[ n++ ] ); const tree_node name_node( node.children[n++] ); const tree_node size_node( node.children[n++] ); const tree_node image_node( node.children[n++] ); const tree_node layers_node( node.children[n++] ); get_sprite_name( s, name_node ); if ( desc.get_sprite_by_name(s.name) != desc.sprite_end() ) std::cerr << "warning: duplicate sprite entry '" << s.name << "'." << std::endl; get_image_id( s, image_node ); boost::optional< const resources::image& > image ( get_image_from_id( images, desc, s.image_id ) ); if ( !image ) return; get_layers_and_size( *image, s, size_node, layers_node ); if ( n < node.children.size() ) s.mask = get_layers( *image, node.children[n++] ); desc.add_sprite( s ); }
MainWindow::MainWindow( os::String zPath ) : os::Window( os::Rect( 0, 0, 500, 400 ), "main_wnd", MSG_MAINWND_TITLE ) { SetTitle( zPath ); CenterInScreen(); /* Create toolbar */ m_pcToolBar = new os::ToolBar( os::Rect( 0, 0, GetBounds().Width(), 40 ), "" ); os::HLayoutNode* pcNode = new os::HLayoutNode( "h_root" ); pcNode->SetBorders( os::Rect( 0, 4, 5, 4 ) ); os::ImageButton* pcBreaker = new os::ImageButton(os::Rect(), "breaker", "",NULL,NULL, os::ImageButton::IB_TEXT_BOTTOM,false,false,false); SetButtonImageFromResource( pcBreaker, "breaker.png" ); pcNode->AddChild( pcBreaker, 0.0f ); m_pcBackButton = new os::ImageButton( os::Rect(), "back", "",new os::Message( M_BACK ) ,NULL, os::ImageButton::IB_TEXT_BOTTOM, true, false, true ); m_pcBackButton->SetEnable( false ); SetButtonImageFromResource( m_pcBackButton, "back.png" ); pcNode->AddChild( m_pcBackButton, 0.0f ); os::ImageButton* pcUp = new os::ImageButton( os::Rect(), "up", "",new os::Message( M_UP ) ,NULL, os::ImageButton::IB_TEXT_BOTTOM, true, false, true ); SetButtonImageFromResource( pcUp, "up.png" ); pcNode->AddChild( pcUp, 0.0f ); os::ImageButton* pcReload = new os::ImageButton( os::Rect(), "reload", "",new os::Message( M_RELOAD ) ,NULL, os::ImageButton::IB_TEXT_BOTTOM, true, false, true ); SetButtonImageFromResource( pcReload, "reload.png" ); pcNode->AddChild( pcReload, 0.0f ); os::ImageButton* pcHome = new os::ImageButton( os::Rect(), "home", "",new os::Message( M_HOME ) ,NULL, os::ImageButton::IB_TEXT_BOTTOM, true, false, true ); SetButtonImageFromResource( pcHome, "home.png" ); pcNode->AddChild( pcHome, 0.0f ); pcNode->AddChild( new os::HLayoutSpacer( "" ) ); /* Create popupmenu */ os::Menu* pcPopupMenu = new os::Menu( os::Rect(), "", os::ITEMS_IN_COLUMN ); pcPopupMenu->AddItem( MSG_MENU_VIEW_ICONS, new os::Message( M_VIEW_ICONS ) ); pcPopupMenu->AddItem( MSG_MENU_VIEW_LIST, new os::Message( M_VIEW_LIST ) ); pcPopupMenu->AddItem( MSG_MENU_VIEW_DETAILS, new os::Message( M_VIEW_DETAILS ) ); pcPopupMenu->AddItem( new os::MenuSeparator() ); pcPopupMenu->AddItem( MSG_MENU_VIEW_SAVE, new os::Message( M_SAVE_WINDOW ) ); pcPopupMenu->AddItem( MSG_MENU_VIEW_SAVE_DEFAULT, new os::Message( M_SAVE_DEFAULT ) ); pcPopupMenu->SetTargetForItems( this ); os::BitmapImage* pcView = new os::BitmapImage(); os::File cSelf( open_image_file( get_image_id() ) ); os::Resources cCol( &cSelf ); os::ResStream *pcStream = cCol.GetResourceStream( "view.png" ); pcView->Load( pcStream ); delete( pcStream ); m_pcViewMenu = new os::PopupMenu( os::Rect( GetBounds().Width() - 70, 2, GetBounds().Width() - 5, 32 ), "", MSG_MENU_VIEW, pcPopupMenu, pcView, os::CF_FOLLOW_RIGHT | os::CF_FOLLOW_RIGHT ); pcNode->AddChild( m_pcViewMenu ); /* Create icon view */ m_pcView = new os::IconDirectoryView( os::Rect( 0, 41, GetBounds().Width(), GetBounds().Height() ), zPath, os::CF_FOLLOW_ALL ); m_pcView->SetDirChangeMsg( new os::Message( M_CHANGE_DIR ) ); os::BitmapImage* pcDirIcon = static_cast<os::BitmapImage*>(m_pcView->GetDirIcon()); pcDirIcon->SetSize( os::Point( 24, 24 ) ); SetIcon( pcDirIcon->LockBitmap() ); delete( pcDirIcon ); m_cBackStack.push( zPath ); m_pcToolBar->SetRoot( pcNode ); AddChild( m_pcToolBar ); AddChild( m_pcView ); m_pcView->MakeFocus(); /* Load default folder style & window position; this will be overridden later by folder-specific settings, if any */ LoadDefault(); LoadWindow( false ); /* Load folder's saved style, window position */ m_pcView->ReRead(); }
MainWindow::MainWindow( const os::Rect & cFrame ):os::Window( cFrame, "MainWindow", MSG_MAINWND_TITLE ) { os::Rect cBounds = GetBounds(); os::Rect cRect = os::Rect( 0, 0, 0, 0 ); m_nDeviceSelect = -1; os::MediaManager::Get(); // Create the layouts/views pcLRoot = new os::LayoutView( cBounds, "L", NULL, os::CF_FOLLOW_ALL ); pcVLRoot = new os::VLayoutNode( "VL" ); pcVLRoot->SetBorders( os::Rect( 10, 5, 10, 5 ) ); // Create settings tree os::HLayoutNode* pcHDevice = new os::HLayoutNode( "HDevice", 0.0f ); pcHDevice->SetBorders( os::Rect( 0, 5, 0, 5 ) ); pcHDevice->AddChild( new os::StringView( os::Rect(), "DeviceLabel", MSG_MAINWND_DEVICE ), 0.0f ); pcDevice = new os::DropdownMenu( os::Rect(), "Device" ); pcDevice->SetMinPreferredSize( 18 ); pcDevice->SetSelectionMessage( new os::Message( M_MW_DEVICE ) ); pcDevice->SetTarget( this ); pcDevice->SetReadOnly( true ); pcHDevice->AddChild( new os::HLayoutSpacer( "", 5.0f, 5.0f ) ); pcHDevice->AddChild( pcDevice ); pcHDevice->AddChild( new os::HLayoutSpacer( "" ) ); pcVLRoot->AddChild( pcHDevice ); // Create settings view pcSettingsView = new os::FrameView( os::Rect(), "SettingView", "" ); pcVLRoot->AddChild( new os::VLayoutSpacer( "", 5.0f, 5.0f ) ); pcVLRoot->AddChild( pcSettingsView ); pcVLRoot->SetHAlignment( os::ALIGN_LEFT ); pcVLRoot->AddChild( new os::Separator( os::Rect(), "", os::HORIZONTAL ), 0.0f ); // Create default dropdown menus os::HLayoutNode* pcHDefaultInput = new os::HLayoutNode( "HDefaultInput", 0.0f ); pcHDefaultInput->SetBorders( os::Rect( 0, 5, 0, 5 ) ); pcHDefaultInput->AddChild( new os::StringView( os::Rect(), "DefInputString", MSG_MAINWND_DEFAULT_INPUT ) ); pcDefaultInput = new os::DropdownMenu( os::Rect(), "DefaultInput" ); pcDefaultInput->SetMinPreferredSize( 18 ); pcDefaultInput->SetSelectionMessage( new os::Message( M_MW_INPUT ) ); pcDefaultInput->SetTarget( this ); pcDefaultInput->SetReadOnly( true ); pcHDefaultInput->AddChild( new os::HLayoutSpacer( "", 5.0f, 5.0f ) ); pcHDefaultInput->AddChild( pcDefaultInput ); pcHDefaultInput->AddChild( new os::HLayoutSpacer( "" ) ); pcVLRoot->AddChild( pcHDefaultInput ); os::HLayoutNode* pcHDefaultAudioOut = new os::HLayoutNode( "HDefaultAudioOut", 0.0f ); pcHDefaultAudioOut->SetBorders( os::Rect( 0, 5, 0, 5 ) ); pcHDefaultAudioOut->AddChild( new os::StringView( os::Rect(), "DefAudioOutString", MSG_MAINWND_DEFAULT_OUTPUT_AUDIO ) ); pcDefaultAudioOut = new os::DropdownMenu( os::Rect(), "DefaultAudioOut" ); pcDefaultAudioOut->SetMinPreferredSize( 18 ); pcDefaultAudioOut->SetSelectionMessage( new os::Message( M_MW_AUDIOOUTPUT ) ); pcDefaultAudioOut->SetTarget( this ); pcDefaultAudioOut->SetReadOnly( true ); pcHDefaultAudioOut->AddChild( new os::HLayoutSpacer( "", 5.0f, 5.0f ) ); pcHDefaultAudioOut->AddChild( pcDefaultAudioOut ); pcHDefaultAudioOut->AddChild( new os::HLayoutSpacer( "" ) ); pcVLRoot->AddChild( pcHDefaultAudioOut ); os::HLayoutNode* pcHDefaultVideoOut = new os::HLayoutNode( "HDefaultVideoOut", 0.0f ); pcHDefaultVideoOut->SetBorders( os::Rect( 0, 5, 0, 5 ) ); pcHDefaultVideoOut->AddChild( new os::StringView( os::Rect(), "DefVideoOutString", MSG_MAINWND_DEFAULT_OUTPUT_VIDEO ) ); pcDefaultVideoOut = new os::DropdownMenu( os::Rect(), "DefaultVideoOut" ); pcDefaultVideoOut->SetMinPreferredSize( 18 ); pcDefaultVideoOut->SetSelectionMessage( new os::Message( M_MW_VIDEOOUTPUT ) ); pcDefaultVideoOut->SetTarget( this ); pcDefaultVideoOut->SetReadOnly( true ); pcHDefaultVideoOut->AddChild( new os::HLayoutSpacer( "", 5.0f, 5.0f ) ); pcHDefaultVideoOut->AddChild( pcDefaultVideoOut ); pcHDefaultAudioOut->AddChild( new os::HLayoutSpacer( "" ) ); pcVLRoot->AddChild( pcHDefaultVideoOut ); pcVLRoot->SameWidth( "DefInputString", "DefAudioOutString", "DefVideoOutString", NULL ); pcVLRoot->SameWidth( "DefaultInput", "DefaultAudioOut", "DefaultVideoOut", NULL ); pcVLRoot->AddChild( new os::Separator( os::Rect(), "", os::HORIZONTAL ), 0.0f ); // Create apply/revert/close buttons pcHLButtons = new os::HLayoutNode( "HLButtons" ); pcHLButtons->SetBorders( os::Rect( 0, 5, 0, 0 ) ); pcHLButtons->AddChild( new os::HLayoutSpacer( "" ) ); pcHLButtons->AddChild( pcBControls = new os::Button( cRect, "BControls", MSG_MAINWND_BUTTON_STREAMVOLUMES, new os::Message( M_MW_CONTROLS ) ) ); pcHLButtons->AddChild( new os::HLayoutSpacer( "", 5.0f, 5.0f ) ); pcHLButtons->AddChild( pcBApply = new os::Button( cRect, "BApply", MSG_MAINWND_BUTTON_APPLY, new os::Message( M_MW_APPLY ) ) ); pcHLButtons->AddChild( new os::HLayoutSpacer( "", 5.0f, 5.0f ) ); pcHLButtons->AddChild( pcBUndo = new os::Button( cRect, "BUndo", MSG_MAINWND_BUTTON_UNDO, new os::Message( M_MW_UNDO ) ) ); pcHLButtons->AddChild( new os::HLayoutSpacer( "", 5.0f, 5.0f ) ); pcHLButtons->AddChild( pcBDefault = new os::Button( cRect, "BDefault", MSG_MAINWND_BUTTON_DEFAULT, new os::Message( M_MW_DEFAULT ) ) ); pcHLButtons->AddChild( new os::HLayoutSpacer( "", 5.0f, 5.0f ) ); pcHLButtons->SameWidth( "BControls", "BApply", "BUndo", "BDefault", NULL ); pcHLButtons->SameHeight( "BControls", "BApply", "BUndo", "BDefault", NULL ); pcVLRoot->AddChild( pcHLButtons ); // Set root and add to window pcLRoot->SetRoot( pcVLRoot ); AddChild( pcLRoot ); // Set default button and initial focus this->SetDefaultButton( pcBApply ); // Set tab order int iTabOrder = 0; pcBDefault->SetTabOrder( iTabOrder++ ); pcBUndo->SetTabOrder( iTabOrder++ ); pcBApply->SetTabOrder( iTabOrder++ ); pcBControls->SetTabOrder( iTabOrder++ ); pcBApply->MakeFocus(); // Set default outputs os::MediaInput * pcDefaultInput = os::MediaManager::GetInstance()->GetDefaultInput( ); os::MediaOutput * pcDefaultVideo = os::MediaManager::GetInstance()->GetDefaultVideoOutput( ); os::MediaOutput * pcDefaultAudio = os::MediaManager::GetInstance()->GetDefaultAudioOutput( ); if ( pcDefaultInput ) { cCurrentInput = pcDefaultInput->GetIdentifier(); pcDefaultInput->Release(); } if ( pcDefaultAudio ) { cCurrentAudio = pcDefaultAudio->GetIdentifier(); pcDefaultAudio->Release(); } if ( pcDefaultVideo ) { cCurrentVideo = pcDefaultVideo->GetIdentifier(); pcDefaultVideo->Release(); } cUndoInput = cCurrentInput; cUndoVideo = cCurrentVideo; cUndoAudio = cCurrentAudio; // Set Icon os::Resources cCol( get_image_id() ); os::ResStream *pcStream = cCol.GetResourceStream( "icon48x48.png" ); os::BitmapImage *pcIcon = new os::BitmapImage( pcStream ); SetIcon( pcIcon->LockBitmap() ); delete( pcIcon ); // Show data ShowData(); // Select first item */ if( pcDevice->GetItemCount() > 0 ) pcDevice->SetSelection( 0 ); }
SettingsWindow::SettingsWindow( const Rect &cFrame, const String cTitle, Handler *pcParent, WebSettings *pcWebSettings, Settings *pcSettings, Settings *pcGuiSettings ) : Window( cFrame, "whisper_settings", cTitle ) { m_pcParent = pcParent; m_pcWebSettings = pcWebSettings; m_pcSettings = pcSettings; m_pcGuiSettings = pcGuiSettings; SetSizeLimits( Point( 500, 400 ), Point( 4096, 4096 ) ); Rect cBounds = GetBounds(); Rect cIconListFrame( 10, 10, 140, cBounds.Height() - 45 ); m_pcIconList = new IconList( cIconListFrame, CF_FOLLOW_TOP | CF_FOLLOW_BOTTOM, this ); AddChild( m_pcIconList ); /* The selected panel is displayed inside this FrameView */ Rect cFrameViewFrame( 150, 10, cBounds.Width() - 10, cBounds.Height() - 45 ); m_pcFrameView = new FrameView( cFrameViewFrame, "settings_window_frame", "Settings", CF_FOLLOW_ALL ); AddChild( m_pcFrameView ); /* Add panel icons & associated views */ BitmapImage *pcImage; ResStream *pcStream; Resources cRes( get_image_id() ); SettingsView *pcView; Rect cViewFrame( 10, 20, cFrameViewFrame.Width() - 10, cFrameViewFrame.Height() - 10 ); /* General */ pcImage = new BitmapImage(); pcStream = cRes.GetResourceStream( "general.png" ); pcImage->Load( pcStream ); m_pcIconList->AddIcon( pcImage, "General" ); delete( pcStream ); pcView = new GeneralView( cViewFrame, m_pcSettings, m_pcWebSettings, m_pcParent ); m_vViews.push_back( pcView ); /* Proxies */ pcImage = new BitmapImage(); pcStream = cRes.GetResourceStream( "proxy.png" ); pcImage->Load( pcStream ); m_pcIconList->AddIcon( pcImage, "Proxies" ); delete( pcStream ); pcView = new ProxyView( cViewFrame, m_pcSettings, m_pcWebSettings, m_pcParent ); m_vViews.push_back( pcView ); /* The Apply/Save/Cancel buttons live in a layoutview of their own */ Rect cButtonFrame = cBounds; cButtonFrame.top = cButtonFrame.bottom - 25; m_pcLayoutView = new LayoutView( cButtonFrame, "settings_window" ); VLayoutNode *pcNode = new VLayoutNode( "settings_window_root" ); pcNode->SetBorders( Rect( 5, 4, 5, 4 ) ); pcNode->AddChild( new VLayoutSpacer( "settings_window_v_spacer", 1.0f ) ); HLayoutNode *pcButtons = new HLayoutNode( "settings_window_buttons" ); pcButtons->AddChild( new HLayoutSpacer( "settings_window_h_spacer" ) ); Button *pcOkButton = new Button( Rect(), "settings_window_save", "Save", new Message( ID_SETTINGS_SAVE ) ); pcButtons->AddChild( pcOkButton, 0.0f ); pcButtons->AddChild( new HLayoutSpacer( "settings_window_h_spacer", 0.5f, 0.5f, pcButtons, 0.1f ) ); pcButtons->AddChild( new Button( Rect(), "settings_window_apply", "Apply", new Message( ID_SETTINGS_APPLY ) ), 0.0f ); pcButtons->AddChild( new HLayoutSpacer( "settings_window_h_spacer", 0.5f, 0.5f, pcButtons, 0.1f ) ); pcButtons->AddChild( new Button( Rect(), "settings_window_cancel", "Cancel", new Message( ID_SETTINGS_CANCEL ) ), 0.0f ); pcNode->AddChild( pcButtons ); m_pcLayoutView->SetRoot( pcNode ); AddChild( m_pcLayoutView ); /* Focus the controls */ /* XXXKV: The default button always swallows Enter, which is no use if we have a multiline TextView (E.g. the signature text). SetDefaultButton( pcOkButton ); */ /* Select first view by default */ m_pcSelected = NULL; m_pcIconList->Select( 0, true ); }