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 MainWindow::Format() { /* Show Splash Screen */ Splash* pcWindow = new Splash(LoadImageFromResource("logo.png"),"Formatting...",false,0.0); pcWindow->Go(); /* Get Device */ char zDevice[24]; int nDevice = m_pcDevice_Selection->GetSelection(); if( nDevice == 0 ) { m_pcFileRequester = new os::FileRequester( os::FileRequester::LOAD_REQ, new os::Messenger( this ), zDevice, os::FileRequester::NODE_FILE, true ); m_pcFileRequester->Show(); m_pcFileRequester->MakeFocus(); printf(zDevice); } else { sprintf(zDevice, "%s", m_pcDevice_Selection->GetItem(nDevice).c_str()); } /* Get Filesystem */ int nFilesystem = m_pcFilesystem_Selection->GetSelection(); char zFilesystem[16]; sprintf(zFilesystem, "%s", m_pcFilesystem_Selection->GetItem(nFilesystem).c_str()); /* Get Volumename */ os::String cVolumename = m_pcVolumename_Text->GetValue(); char zVolumename[32]; sprintf(zVolumename, "%s", cVolumename.c_str()); /* Get Arguments */ os::String cArguments = m_pcArguments_Text->GetValue(); char zArguments[64]; sprintf(zArguments, "%s", cArguments.c_str()); /* Format */ if ( initialize_fs( zDevice, zFilesystem, zVolumename, NULL, 0 ) < 0 ) { char zError[256]; sprintf( zError, "%s", strerror(errno)); os::Alert* pcAlert = new os::Alert( "Format", zError, m_pcIcon->LockBitmap(),0, "_Ok",NULL); pcAlert->Go( new os::Invoker( 0 ) ); } /* Remove Splash Screen */ pcWindow->Quit(); }