void Address::ExportHelpFile() { if (!bExportHelpFile) { char buffer[8192]; try { os::File* pcResourceFile = new os::File( m_pcPlugin->GetPath() ); os::Resources cCol( pcResourceFile ); ResStream* pcHelpStream = cCol.GetResourceStream( "address.html" ); ssize_t nSize = pcHelpStream->GetSize(); pcHelpStream->Read(buffer,nSize); delete pcHelpStream; delete pcResourceFile; File* pcFileTwo = new File("/documentation/address.html",O_CREAT | O_RDWR); pcFileTwo->Write(buffer,nSize); pcFileTwo->WriteAttr("os::MimeType",O_TRUNC,ATTR_TYPE_STRING,"text/html",0,10); delete pcFileTwo; } catch( ... ) { printf( "Address dock plug-in: Could not export help file.\n" ); } } }
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 ); }
void TFGeometry2D::computeCenterAndSortKeyPoints() { if (_keyPoints.empty()) return; cgt::vec2 cPos(0.f); cgt::vec4 cCol(0.f); for (std::vector<KeyPoint>::const_iterator it = _keyPoints.begin(); it != _keyPoints.end(); ++it) { cPos += it->_position; cCol += toVec(it->_color); } cPos /= static_cast<float>(_keyPoints.size()); cCol /= static_cast<float>(_keyPoints.size()); _center = KeyPoint(cPos, toCol(cCol)); std::sort(_keyPoints.begin(), _keyPoints.end(), KeyPointSorter(_center._position)); }
void Address::AttachedToWindow() { os::File* pcFile = new os::File( m_pcPlugin->GetPath() ); os::Resources cCol( pcFile ); os::ResStream* pcStream = cCol.GetResourceStream( "icon48x48.png" ); m_pcIcon = new os::BitmapImage( pcStream ); delete pcStream; delete pcFile; pcSettingsWindow = NULL; InitDefaultAddresses(); LoadAddresses(); LoadBuffer(); LoadSettings(); ExportHelpFile(); pcAddressDrop->SetTarget(this); }
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 ); }