diff options
author | handbrake <[email protected]> | 2006-01-14 13:40:38 +0000 |
---|---|---|
committer | handbrake <[email protected]> | 2006-01-14 13:40:38 +0000 |
commit | 56bb6ce496b475944bb9577c7586e84be1cb831e (patch) | |
tree | 7720c135a160a34f22ce8f1f911f350e18207eaa /beos | |
parent | d35a2a23fe450c88925128b9db7c63a5f1ed395d (diff) |
HandBrake 0.7.0
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@16 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'beos')
53 files changed, 2312 insertions, 1973 deletions
diff --git a/beos/HBApp.cpp b/beos/HBApp.cpp index add6259f2..702c74d94 100644 --- a/beos/HBApp.cpp +++ b/beos/HBApp.cpp @@ -1,5 +1,8 @@ #include "HBApp.h" -#include "HBWindow.h" +#include "MainWindow.h" +#include "ScanWindow.h" + +#include "hb.h" int main() { @@ -10,9 +13,18 @@ int main() } HBApp::HBApp() - : MApplication( "application/x-vnd.titer-handbrake" ) + : BApplication( "application/x-vnd.titer-handbrake" ) { - fWindow = new HBWindow(); + fHandle = hb_init( HB_DEBUG_ALL, 0 ); + + fMainWin = new MainWindow( fHandle ); + fScanWin = new ScanWindow( fHandle ); + fScanWin->AddToSubset( fMainWin ); + + fMainWin->Show(); + fScanWin->Show(); + + SetPulseRate( 200000 ); /* 0.2 second */ } void HBApp::MessageReceived( BMessage * message ) @@ -20,7 +32,7 @@ void HBApp::MessageReceived( BMessage * message ) switch( message->what ) { default: - MApplication::MessageReceived( message ); + BApplication::MessageReceived( message ); break; } } @@ -29,3 +41,45 @@ void HBApp::RefsReceived( BMessage * message ) { } +void HBApp::Pulse() +{ + hb_state_t s; + hb_get_state( fHandle, &s ); + + switch( s.state ) + { + case HB_STATE_IDLE: + break; + + case HB_STATE_SCANNING: + fScanWin->Update( &s ); + break; + + case HB_STATE_SCANDONE: + if( hb_list_count( hb_get_titles( fHandle ) ) ) + { + /* Success */ + fScanWin->Hide(); + fMainWin->Update( &s ); + } + else + { + /* Invalid volume */ + fScanWin->Update( &s ); + } + break; + + case HB_STATE_WORKING: + case HB_STATE_PAUSED: + case HB_STATE_WORKDONE: + fMainWin->Update( &s ); + break; + } +} + +bool HBApp::QuitRequested() +{ + hb_close( &fHandle ); + return BApplication::QuitRequested(); +} + diff --git a/beos/HBApp.h b/beos/HBApp.h index 75f3fc173..042a791b9 100644 --- a/beos/HBApp.h +++ b/beos/HBApp.h @@ -1,19 +1,27 @@ -#ifndef HB_HB_APP_H -#define HB_HB_APP_H +#ifndef HB_APP_H +#define HB_APP_H -#include "layout-all.h" +#include <Application.h> -class HBWindow; +#include "hb.h" -class HBApp : public MApplication +class MainWindow; +class ScanWindow; + +class HBApp : public BApplication { public: - HBApp(); - void MessageReceived( BMessage * message ); - void RefsReceived( BMessage * message ); + HBApp(); + void MessageReceived( BMessage * message ); + void RefsReceived( BMessage * message ); + void Pulse(); + bool QuitRequested(); private: - HBWindow * fWindow; + MainWindow * fMainWin; + ScanWindow * fScanWin; + + hb_handle_t * fHandle; }; #endif diff --git a/beos/HBWindow.cpp b/beos/HBWindow.cpp deleted file mode 100644 index 4bb51d61f..000000000 --- a/beos/HBWindow.cpp +++ /dev/null @@ -1,283 +0,0 @@ -#include "HBWindow.h" - -#include <MenuItem.h> -#include <Screen.h> - -#define SCAN_OPEN 'scop' -#define RIP_RIP 'riri' - -static void _Scanning( void * data, int title, int titleCount ) -{ - ((HBWindow*)data)->Scanning( title, titleCount ); -} -static void _ScanDone( void * data, HBList * titleList ) -{ - ((HBWindow*)data)->ScanDone( titleList ); -} -static void _Encoding( void * data, float position, int pass, - int passCount, float frameRate, - float avgFrameRate, int remainingTime ) -{ - ((HBWindow*)data)->Encoding( position, pass, passCount, frameRate, - avgFrameRate, remainingTime ); -} -static void _RipDone( void * data, int result ) -{ - ((HBWindow*)data)->RipDone( result ); -} - -HBWindow::HBWindow() - : MWindow( BRect( 0,0,10,10 ), "HandBrake " HB_VERSION, - B_TITLED_WINDOW, 0 ) -{ - /* Init libhb */ - HBCallbacks callbacks; - callbacks.data = this; - callbacks.scanning = _Scanning; - callbacks.scanDone = _ScanDone; - callbacks.encoding = _Encoding; - callbacks.ripDone = _RipDone; - - fHandle = HBInit( 1, 0 ); - HBSetCallbacks( fHandle, callbacks ); - - fScanView = new HGroup( - new Space( minimax( 10,-1,10,-1 ) ), - new VGroup( - new Space( minimax( -1,10,-1,10 ) ), - new MStringView( "Welcome to HandBrake. Select a DVD to open:" ), - new Space( minimax( -1,5,-1,5 ) ), - new HGroup( - fScanRadio = new MRadioGroup( "Detected volume:", - "DVD Folder:", 0 ), - new VGroup( - fScanDetectedPopup = new MPopup( NULL, - "/Bulk/ANGEL_SEASON2_DISC6", 0 ), - fScanFolderControl = new MTextControl( NULL, NULL ), - 0 ), - 0 ), - fScanBrowseButton = new MButton( "Browse", 12 ), - fScanStatusString = new MStringView( "" ), - fScanProgress = new MProgressBar( this ), - fScanOpenButton = new MButton( "Open", - new BMessage( SCAN_OPEN ) ), - new Space( minimax( -1,10,-1,10000 ) ), - 0 ), - new Space( minimax( 10,-1,10,-1 ) ), - 0 ); - - fScanDetectedPopup->Menu()->ItemAt(0)->SetMarked(true); - fScanProgress->ct_mpm = minimax( 0,12,10000,12 ); - - fRipView = new HGroup( - new Space( minimax( 10,-1,10,-1 ) ), - new VGroup( - new Space( minimax( -1,10,-1,10 ) ), - new MBorder( - M_LABELED_BORDER, 15, "General", - new VGroup( - fRipTitlePopup = new MPopup( "DVD title:", "dummy", 0 ), - new MPopup( "Output format:", - "MP4 file / MPEG-4 video / AAC audio", - "OGM file / MPEG-4 video / Vorbis audio", - "AVI file / MPEG-4 video / MP3 audio", - "AVI file / H264 video / MP3 audio", 0 ), - new MTextControl( "File:", "/boot/home/Desktop/Movie.mp4" ), - new MButton( "Browse" ), - 0 ) - ), - new MBorder( - M_LABELED_BORDER, 15, "Video", - new VGroup( - new MPopup( "MPEG-4 encoder:", "FFmpeg", "XviD", 0 ), - new HGroup( - new MStringView( "Bitrate:" ), - new MRadioGroup( "Custom (kbps)", "Target size (MB)", 0 ), - new VGroup( - new MTextControl( NULL, NULL ), - new MTextControl( NULL, NULL ), - 0 ), - 0 ), - new MSplitter(), - new HGroup( - new MCheckBox( "2-pass encoding" ), - new MButton( "Crop & Scale..." ), - 0 ), - 0 ) - ), - new MBorder( - M_LABELED_BORDER, 15, "Audio", - new VGroup( - fRipLanguage1Popup = new MPopup( "Language 1:", - "dummy", 0 ), - fRipLanguage2Popup = new MPopup( "Language 2 (optional):", - "dummy", 0 ), - fRipBitratePopup = new MPopup( "Bitrate (kbps):", "32", - "64", "96", "128", "160", "192", "224", "256", "288", - "320", 0 ), - 0 ) - ), - new MProgressBar( this ), - new HGroup( - new MButton( "Pause" ), - new MButton( "Rip!", new BMessage( RIP_RIP ) ), - 0 ), - new Space( minimax( -1,10,-1,10 ) ), - 0 ), - new Space( minimax( 10,-1,10,-1 ) ), - 0 ); - - fRipBitratePopup->Menu()->ItemAt(3)->SetMarked( true ); - - fLayers = new LayeredGroup( fScanView, fRipView, 0 ); - AddChild( dynamic_cast<BView*>(fLayers) ); - - /* Center the window */ - BScreen screen; - MoveTo( ( screen.Frame().Width() ) / 2, - ( screen.Frame().Height() ) / 2 ); - - Show(); -} - -bool HBWindow::QuitRequested() -{ - HBClose( &fHandle ); - be_app->PostMessage( B_QUIT_REQUESTED ); - return true; -} - -void HBWindow::MessageReceived( BMessage * message ) -{ - switch( message->what ) - { - case SCAN_OPEN: - Lock(); - /* That's ugly, but there doesn't seem to be another way */ - ((BRadioButton*)fScanRadio->ChildAt(0))->SetEnabled( false ); - ((BRadioButton*)fScanRadio->ChildAt(1))->SetEnabled( false ); - fScanDetectedPopup->SetEnabled( false ); - fScanFolderControl->SetEnabled( false ); - fScanBrowseButton->SetEnabled( false ); - fScanOpenButton->SetEnabled( false ); - fScanStatusString->SetText( "Opening device..." ); - Unlock(); - HBScanDVD( fHandle, - fScanDetectedPopup->Menu()->FindMarked()->Label(), 0 ); - break; - - case RIP_RIP: - { - HBTitle * title = (HBTitle*) HBListItemAt( fTitleList, - fRipTitlePopup->Menu()->IndexOf( - fRipTitlePopup->Menu()->FindMarked() ) ); - title->file = strdup( "/boot/home/Desktop/Movie.mp4" ); - title->twoPass = 0; - title->deinterlace = 0; - title->topCrop = title->autoTopCrop; - title->bottomCrop = title->autoBottomCrop; - title->leftCrop = title->autoLeftCrop; - title->rightCrop = title->autoRightCrop; - title->bitrate = 1024; - title->codec = HB_CODEC_FFMPEG; - title->mux = HB_MUX_MP4; - HBAudio * audio = (HBAudio*) HBListItemAt( - title->audioList, 0 ); - audio->codec = HB_CODEC_AAC; - audio->outBitrate = 128; - HBListAdd( title->ripAudioList, audio ); - HBStartRip( fHandle, title ); - break; - } - - default: - MWindow::MessageReceived( message ); - break; - } -} - -void HBWindow::Scanning( int title, int titleCount ) -{ - Lock(); - char string[1024]; memset( string, 0, 1024 ); - snprintf( string, 1023, "Scanning title %d of %d...", - title, titleCount ); - fScanStatusString->SetText( string ); - fScanProgress->SetValue( (float) title / titleCount ); - Unlock(); -} - -void HBWindow::ScanDone( HBList * titleList ) -{ -#define menu fRipTitlePopup->Menu() - Lock(); - BMenuItem * item; - while( ( item = menu->ItemAt(0) ) ) - { - menu->RemoveItem( item ); - delete item; - } - HBTitle * title; - char label[1024]; - for( int i = 0; i < HBListCount( titleList ); i++ ) - { - memset( label, 0, 1024 ); - title = (HBTitle*) HBListItemAt( titleList, i ); - snprintf( label, 1023, "%d - %02dh%02dm%02ds", title->index, - title->length / 3600, ( title->length % 3600 ) / 60, - title->length % 60 ); - menu->AddItem( new BMenuItem( label, NULL ) ); - } - menu->ItemAt(0)->SetMarked( true ); - fTitleList = titleList; - UpdateLanguages(); - fLayers->ActivateLayer( 1 ); - Unlock(); -#undef menu -} - -void HBWindow::Encoding( float position, int pass, int passCount, - float frameRate, float avgFrameRate, - int remainingTime ) -{ -} - -void HBWindow::RipDone( int result ) -{ -} - -void HBWindow::UpdateLanguages() -{ -#define menu fRipTitlePopup->Menu() - HBTitle * title = (HBTitle*) HBListItemAt( fTitleList, - menu->IndexOf( menu->FindMarked() ) ); -#undef menu - -#define menu1 fRipLanguage1Popup->Menu() -#define menu2 fRipLanguage2Popup->Menu() - BMenuItem * item; - while( ( item = menu1->ItemAt(0) ) ) - { - menu1->RemoveItem( item ); - delete item; - } - while( ( item = menu2->ItemAt(0) ) ) - { - menu2->RemoveItem( item ); - delete item; - } - - HBAudio * audio; - for( int i = 0; i < HBListCount( title->audioList ); i++ ) - { - audio = (HBAudio*) HBListItemAt( title->audioList, i ); - menu1->AddItem( new BMenuItem( audio->language, NULL ) ); - menu2->AddItem( new BMenuItem( audio->language, NULL ) ); - } - menu1->ItemAt(0)->SetMarked( true ); - menu2->AddItem( new BMenuItem( "None", NULL ) ); - menu2->ItemAt( menu2->CountItems() - 1 )->SetMarked( true ); -#undef menu1 -#undef menu2 -} - diff --git a/beos/HBWindow.h b/beos/HBWindow.h deleted file mode 100644 index 52ddfbf1b..000000000 --- a/beos/HBWindow.h +++ /dev/null @@ -1,41 +0,0 @@ -#include "layout-all.h" -#include "HandBrake.h" - -class HBWindow : public MWindow -{ - public: - HBWindow(); - bool QuitRequested(); - void MessageReceived( BMessage * message ); - - void Scanning( int title, int titleCount ); - void ScanDone( HBList * titleList ); - void Encoding( float position, int pass, int passCount, - float frameRate, float avgFrameRate, - int remainingTime ); - void RipDone( int result ); - - private: - void UpdateLanguages(); - - HBHandle * fHandle; - HBList * fTitleList; - - LayeredGroup * fLayers; - - MView * fScanView; - MRadioGroup * fScanRadio; - MPopup * fScanDetectedPopup; - MTextControl * fScanFolderControl; - MButton * fScanBrowseButton; - MStringView * fScanStatusString; - MProgressBar * fScanProgress; - MButton * fScanOpenButton; - - MView * fRipView; - MPopup * fRipTitlePopup; - MPopup * fRipLanguage1Popup; - MPopup * fRipLanguage2Popup; - MPopup * fRipBitratePopup; -}; - diff --git a/beos/MainWindow.cpp b/beos/MainWindow.cpp new file mode 100644 index 000000000..5b2741bb9 --- /dev/null +++ b/beos/MainWindow.cpp @@ -0,0 +1,986 @@ +#include <app/Application.h> +#include <interface/Box.h> +#include <interface/Button.h> +#include <interface/CheckBox.h> +#include <interface/MenuField.h> +#include <interface/MenuItem.h> +#include <interface/PopUpMenu.h> +#include <interface/RadioButton.h> +#include <interface/Screen.h> +#include <interface/Slider.h> +#include <interface/StatusBar.h> +#include <interface/StringView.h> +#include <interface/TextControl.h> +#include <storage/FilePanel.h> +#include <storage/Path.h> +#include <support/String.h> + +#include "MainWindow.h" +#include "PicWindow.h" +#include "QueueWindow.h" + +#define MSG_TITLEPOPUP 'titl' +#define MSG_CHAPTERPOPUP 'chap' +#define MSG_FORMATPOPUP 'form' +#define MSG_CODECSPOPUP 'code' +#define MSG_BROWSE 'brow' +#define MSG_QUALITYRADIO 'radi' +#define MSG_SLIDER 'slid' +#define MSG_PICSETTINGS 'pise' +#define MSG_QUEUE_ENABLE 'quen' +#define MSG_QUEUE_ADD 'quad' +#define MSG_QUEUE_SHOW 'qush' +#define MSG_PAUSE 'paus' +#define MSG_START 'star' + +static int FormatSettings[3][4] = + { { HB_MUX_MP4 | HB_VCODEC_FFMPEG | HB_ACODEC_FAAC, + HB_MUX_MP4 | HB_VCODEC_X264 | HB_ACODEC_FAAC, + 0, + 0 }, + { HB_MUX_AVI | HB_VCODEC_FFMPEG | HB_ACODEC_LAME, + HB_MUX_AVI | HB_VCODEC_FFMPEG | HB_ACODEC_AC3, + HB_MUX_AVI | HB_VCODEC_X264 | HB_ACODEC_LAME, + HB_MUX_AVI | HB_VCODEC_X264 | HB_ACODEC_AC3 }, + { HB_MUX_OGM | HB_VCODEC_FFMPEG | HB_ACODEC_VORBIS, + HB_MUX_OGM | HB_VCODEC_FFMPEG | HB_ACODEC_LAME, + 0, + 0 } }; + +MainView::MainView( hb_handle_t * handle ) + : BView( BRect( 0,0,700,475 ), NULL, B_FOLLOW_NONE, B_WILL_DRAW ) +{ + fHandle = handle; + + BRect r, b; + BBox * box; + + SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) ); + + /* Source box */ + b = Bounds(); + r = BRect( 10,10,b.right/2-5,135 ); + box = new BBox( r ); + box->SetLabel( "Source" ); + AddChild( box ); + + b = box->Bounds(); + + r = BRect( 10,15,b.right/4,35 ); + fSrcDVD1String = new BStringView( r, NULL, "DVD:" ); + box->AddChild( fSrcDVD1String ); + + r = BRect( b.right/4+1,15,b.right-10,35 ); + fSrcDVD2String = new BStringView( r, NULL, "" ); + fSrcDVD2String->SetAlignment( B_ALIGN_RIGHT ); + box->AddChild( fSrcDVD2String ); + + r = BRect( 10,40,b.right-10,60 ); + fSrcTitlePopUp = new BPopUpMenu( "" ); + fSrcTitleMenu = new BMenuField( r, NULL, "Title:", fSrcTitlePopUp, + true ); + fSrcTitleMenu->SetDivider( b.right-130 ); + box->AddChild( fSrcTitleMenu ); + + r = BRect( 10,65,b.right-120,85 ); + fSrcChapString = new BStringView( r, NULL, "Chapters:" ); + box->AddChild( fSrcChapString ); + + r = BRect( b.right-119,65,b.right-80,85 ); + fSrcChapStartPopUp = new BPopUpMenu( "" ); + fSrcChapStartMenu = new BMenuField( r, NULL, "", + fSrcChapStartPopUp, true ); + fSrcChapStartMenu->SetDivider( 0.0 ); + box->AddChild( fSrcChapStartMenu ); + + r = BRect( b.right-79,65,b.right-50,85 ); + fSrcChapToString = new BStringView( r, NULL, "to" ); + fSrcChapToString->SetAlignment( B_ALIGN_CENTER ); + box->AddChild( fSrcChapToString ); + + r = BRect( b.right-49,65,b.right-10,85 ); + fSrcChapEndPopUp = new BPopUpMenu( "" ); + fSrcChapEndMenu = new BMenuField( r, NULL, "", fSrcChapEndPopUp, + true ); + fSrcChapEndMenu->SetDivider( 0.0 ); + box->AddChild( fSrcChapEndMenu ); + + r = BRect( 10,90,b.right/2,110 ); + fSrcDur1String = new BStringView( r, NULL, "Duration:" ); + box->AddChild( fSrcDur1String ); + + r = BRect( b.right/2+1,90,b.right-10,110 ); + fSrcDur2String = new BStringView( r, NULL, "00:00:00" ); + fSrcDur2String->SetAlignment( B_ALIGN_RIGHT ); + box->AddChild( fSrcDur2String ); + + /* Destination box */ + b = Bounds(); + r = BRect( b.right/2+5,10,b.right-10,135 ); + box = new BBox( r ); + box->SetLabel( "Destination" ); + AddChild( box ); + + b = box->Bounds(); + + r = BRect( 10,15,b.right-10,35 ); + fDstFormatPopUp = new BPopUpMenu( "" ); +#define ADDITEM(a) fDstFormatPopUp->AddItem( new BMenuItem( a, \ + new BMessage( MSG_FORMATPOPUP ) ) ) + ADDITEM( "MP4 file" ); + ADDITEM( "AVI file" ); + ADDITEM( "OGM file" ); +#undef ADDITEM + fDstFormatPopUp->ItemAt( 0 )->SetMarked( true ); + fDstFormat = -1; + fDstFormatMenu = new BMenuField( r, NULL, "File format:", + fDstFormatPopUp, true ); + fDstFormatMenu->SetDivider( b.right/3 ); + box->AddChild( fDstFormatMenu ); + + r = BRect( 10,40,b.right-10,60 ); + fDstCodecsPopUp = new BPopUpMenu( "" ); + fDstCodecsMenu = new BMenuField( r, NULL, "Codecs:", + fDstCodecsPopUp, true ); + fDstCodecsMenu->SetDivider( b.right/3 ); + box->AddChild( fDstCodecsMenu ); + + r = BRect( 10,65,b.right-10,85 ); + fDstFileControl = new BTextControl( r, NULL, "File:", + "/boot/home/Desktop/Movie", new BMessage() ); + fDstFileControl->SetDivider( b.right/3 ); + box->AddChild( fDstFileControl ); + + r = BRect( b.right-90,90,b.right-10,115 ); + fBrowseButton = new BButton( r, NULL, "Browse", + new BMessage( MSG_BROWSE ) ); + box->AddChild( fBrowseButton ); + + /* Video box */ + b = Bounds(); + r = BRect( 10,145,b.right/2-5,395 ); + box = new BBox( r ); + box->SetLabel( "Video" ); + AddChild( box ); + + b = box->Bounds(); + + r = BRect( 10,15,b.right-10,35 ); + fVidRatePopUp = new BPopUpMenu( "" ); + fVidRatePopUp->AddItem( new BMenuItem( "Same as source", + new BMessage() ) ); + for( int i = 0; i < hb_video_rates_count; i++ ) + { + fVidRatePopUp->AddItem( new BMenuItem( hb_video_rates[i].string, + new BMessage() ) ); + } + fVidRatePopUp->ItemAt( 0 )->SetMarked( true ); + fVidRateMenu = new BMenuField( r, NULL, "Framerate (fps):", + fVidRatePopUp, true ); + box->AddChild( fVidRateMenu ); + + r = BRect( 10,40,b.right-10,60 ); + fVidEncoderPopUp = new BPopUpMenu( "" ); + fVidEncoderMenu = new BMenuField( r, NULL, "Encoder:", + fVidEncoderPopUp, true ); + box->AddChild( fVidEncoderMenu ); + + r = BRect( 10,65,b.right-10,85 ); + fVidQualityString = new BStringView( r, NULL, "Quality:" ); + box->AddChild( fVidQualityString ); + + r = BRect( 10,90,b.right*2/3,110); + fVidTargetRadio = new BRadioButton( r, NULL, "Target size (MB):", + new BMessage( MSG_QUALITYRADIO ) ); + box->AddChild( fVidTargetRadio ); + + r = BRect( b.right*2/3+1,90,b.right-10,110); + fVidTargetControl = new BTextControl( r, NULL, "", "700", + new BMessage() ); + fVidTargetControl->SetDivider( 0 ); + box->AddChild( fVidTargetControl ); + + r = BRect( 10,115,b.right/2,135); + fVidAverageRadio = new BRadioButton( r, NULL, "Average bitrate (kbps):", + new BMessage( MSG_QUALITYRADIO ) ); + fVidAverageRadio->SetValue( 1 ); + box->AddChild( fVidAverageRadio ); + + r = BRect( b.right*2/3+1,115,b.right-10,135); + fVidAverageControl = new BTextControl( r, NULL, "", "1000", + new BMessage() ); + fVidAverageControl->SetDivider( 0 ); + box->AddChild( fVidAverageControl ); + + r = BRect( 10,140,b.right/2,160); + fVidConstantRadio = new BRadioButton( r, NULL, "Constant quality:", + new BMessage( MSG_QUALITYRADIO ) ); + box->AddChild( fVidConstantRadio ); + + r = BRect( 20,165,b.right-10,195); + fVidConstantSlider = new BSlider( r, NULL, NULL, + new BMessage( MSG_SLIDER ), 0, 100 ); + fVidConstantSlider->SetValue( 50 ); + SliderChanged(); + box->AddChild( fVidConstantSlider ); + + r = BRect( 10,200,b.right-10,220); + fVidGrayCheck = new BCheckBox( r, NULL, "Grayscale encoding", new BMessage() ); + box->AddChild( fVidGrayCheck ); + r = BRect( 10,220,b.right-10,240); + fVidTwoPassCheck = new BCheckBox( r, NULL, "2-pass encoding", new BMessage() ); + box->AddChild( fVidTwoPassCheck ); + + /* Subtitles box */ + b = Bounds(); + r = BRect( b.right/2+5,145,b.right-10,190 ); + box = new BBox( r ); + box->SetLabel( "Subtitles" ); + AddChild( box ); + + b = box->Bounds(); + + r = BRect( 10,15,b.right-10,35 ); + fSubPopUp = new BPopUpMenu( "" ); + fSubMenu = new BMenuField( r, NULL, "Language:", + fSubPopUp, true ); + box->AddChild( fSubMenu ); + + /* Audio box */ + b = Bounds(); + r = BRect( b.right/2+5,200,b.right-10,320 ); + box = new BBox( r ); + box->SetLabel( "Audio" ); + AddChild( box ); + + b = box->Bounds(); + + r = BRect( 10,15,b.right-10,35 ); + fAudLang1PopUp = new BPopUpMenu( "" ); + fAudLang1Menu = new BMenuField( r, NULL, "Language 1:", + fAudLang1PopUp, true ); + box->AddChild( fAudLang1Menu ); + r = BRect( 10,40,b.right-10,60 ); + fAudLang2PopUp = new BPopUpMenu( "" ); + fAudLang2Menu = new BMenuField( r, NULL, "Language 2:", + fAudLang2PopUp, true ); + box->AddChild( fAudLang2Menu ); + r = BRect( 10,65,b.right-10,85 ); + fAudRatePopUp = new BPopUpMenu( "" ); + for( int i = 0; i < hb_audio_rates_count; i++ ) + { + fAudRatePopUp->AddItem( new BMenuItem( hb_audio_rates[i].string, + new BMessage ) ); + } + fAudRatePopUp->ItemAt( hb_audio_rates_default )->SetMarked( true ); + fAudRateMenu = new BMenuField( r, NULL, "Sample rate (Hz):", + fAudRatePopUp, true ); + box->AddChild( fAudRateMenu ); + r = BRect( 10,90,b.right-10,110 ); + fAudBitratePopUp = new BPopUpMenu( "" ); + for( int i = 0; i < hb_audio_bitrates_count; i++ ) + { + fAudBitratePopUp->AddItem( new BMenuItem( + hb_audio_bitrates[i].string, new BMessage ) ); + } + fAudBitratePopUp->ItemAt( + hb_audio_bitrates_default )->SetMarked( true ); + fAudBitrateMenu = new BMenuField( r, NULL, "Bitrate (kbps):", + fAudBitratePopUp, true ); + box->AddChild( fAudBitrateMenu ); + + /* Picture settings */ + b = Bounds(); + r = BRect( b.right-110,370,b.right-10,395 ); + fPictureButton = new BButton( r, NULL, "Picture settings...", + new BMessage( MSG_PICSETTINGS ) ); + AddChild( fPictureButton ); + + /* Bottom */ + r = BRect( 10,405,b.right-10,435 ); + fProgressBar = new BStatusBar( r, NULL ); + AddChild( fProgressBar ); + + r = BRect( 10,450,b.right-370,470); + fQueueCheck = new BCheckBox( r, NULL, "Enable Queue", + new BMessage( MSG_QUEUE_ENABLE ) ); + AddChild( fQueueCheck ); + + r = BRect( b.right-360,445,b.right-280,470 ); + fAddButton = new BButton( r, NULL, "Add to Queue", + new BMessage( MSG_QUEUE_ADD ) ); + + r = BRect( b.right-270,445,b.right-190,470 ); + fShowButton = new BButton( r, NULL, "Show queue", + new BMessage( MSG_QUEUE_SHOW ) ); + + r = BRect( b.right-180,445,b.right-100,470 ); + fPauseButton = new BButton( r, NULL, "Pause", + new BMessage( MSG_PAUSE ) ); + AddChild( fPauseButton ); + + r = BRect( b.right-90,445,b.right-10,470 ); + fRipButton = new BButton( r, NULL, "Rip", + new BMessage( MSG_START ) ); + AddChild( fRipButton ); + + EnableUI( false ); + fPauseButton->SetEnabled( false ); + fRipButton->SetEnabled( false ); + + FormatPopUpChanged(); + + fFilePanel = NULL; +} + +void MainView::HandleMessage( BMessage * msg ) +{ + switch( msg->what ) + { + case MSG_TITLEPOPUP: + TitlePopUpChanged(); + break; + + case MSG_CHAPTERPOPUP: + ChapterPopUpChanged(); + break; + + case MSG_FORMATPOPUP: + FormatPopUpChanged(); + break; + + case MSG_CODECSPOPUP: + CodecsPopUpChanged(); + break; + + case MSG_BROWSE: + if( !fFilePanel ) + { + fFilePanel = new BFilePanel( B_SAVE_PANEL, + new BMessenger( Window() ), NULL, 0, false ); + } + fFilePanel->Show(); + break; + + case B_SAVE_REQUESTED: + { + entry_ref ref; + BString string; + if( msg->FindRef( "directory", 0, &ref ) == B_OK && + msg->FindString( "name", &string ) == B_OK ) + { + BPath * path = new BPath( &ref ); + string.Prepend( "/" ); + string.Prepend( path->Path() ); + fDstFileControl->SetText( string.String() ); + CheckExtension(); + } + break; + } + + case MSG_QUALITYRADIO: + QualityRadioChanged(); + break; + + case MSG_SLIDER: + SliderChanged(); + break; + + case MSG_PICSETTINGS: + fPicWin = new PicWindow( fHandle, fSrcTitlePopUp->IndexOf( + fSrcTitlePopUp->FindMarked() ) ); + fPicWin->Show(); + break; + + case MSG_QUEUE_ENABLE: + if( fQueueCheck->Value() ) + { + AddChild( fAddButton ); + AddChild( fShowButton ); + } + else + { + RemoveChild( fAddButton ); + RemoveChild( fShowButton ); + } + break; + + case MSG_QUEUE_ADD: + AddJob(); + break; + + case MSG_QUEUE_SHOW: + fQueueWin = new QueueWindow( fHandle ); + fQueueWin->Show(); + break; + + case MSG_PAUSE: + fPauseButton->SetEnabled( false ); + fRipButton->SetEnabled( false ); + if( !strcmp( fPauseButton->Label(), "Resume" ) ) + { + hb_resume( fHandle ); + } + else + { + hb_pause( fHandle ); + } + break; + + case MSG_START: + { + if( !strcmp( fRipButton->Label(), "Cancel" ) ) + { + fPauseButton->SetEnabled( false ); + fRipButton->SetEnabled( false ); + hb_stop( fHandle ); + break; + } + + EnableUI( false ); + fPauseButton->SetEnabled( false ); + fRipButton->SetEnabled( false ); + + if( !fQueueCheck->Value() ) + { + AddJob(); + } + + hb_start( fHandle ); + break; + } + } +} + +void MainView::Update( hb_state_t * s ) +{ + if( !LockLooper() ) + { + fprintf( stderr, "LockLooper failed\n" ); + return; + } + + switch( s->state ) + { +#define p s->param.scandone + case HB_STATE_SCANDONE: + { + hb_list_t * list; + hb_title_t * title; + char string[1024]; + + list = hb_get_titles( fHandle ); + for( int i = 0; i < hb_list_count( list ); i++ ) + { + title = (hb_title_t *) hb_list_item( list, i ); + fSrcDVD2String->SetText( title->dvd ); + snprintf( string, 1024, "%d - %02dh%02dm%02ds", + title->index, title->hours, title->minutes, + title->seconds ); + fSrcTitlePopUp->AddItem( new BMenuItem( string, + new BMessage( MSG_TITLEPOPUP ) ) ); + } + fSrcTitlePopUp->ItemAt( 0 )->SetMarked( true ); + fSrcTitle = -1; + TitlePopUpChanged(); + + EnableUI( true ); + fRipButton->SetEnabled( true ); + fPauseButton->SetEnabled( false ); + break; + } +#undef p + +#define p s->param.working + case HB_STATE_WORKING: + { + float progress_total; + char text[1024]; + progress_total = ( p.progress + p.job_cur - 1 ) / p.job_count; + snprintf( text, 1024, "Encoding: task %d of %d, %.2f %%", + p.job_cur, p.job_count, 100.0 * p.progress ); + if( p.seconds > -1 ) + { + snprintf( text + strlen( text ), 1024 - strlen( text ), + " (%.2f fps, avg %.2f fps, ETA %02dh%02dm%02ds)", + p.rate_cur, p.rate_avg, p.hours, p.minutes, + p.seconds ); + } + fProgressBar->Update( fProgressBar->MaxValue() * + progress_total - fProgressBar->CurrentValue(), text ); + + fPauseButton->SetLabel( "Pause" ); + fPauseButton->SetEnabled( true ); + fRipButton->SetLabel( "Cancel" ); + fRipButton->SetEnabled( true ); + break; + } +#undef p + + case HB_STATE_PAUSED: + fProgressBar->Update( 0, "Paused" ); + fPauseButton->SetLabel( "Resume" ); + fPauseButton->SetEnabled( true ); + fRipButton->SetLabel( "Cancel" ); + fRipButton->SetEnabled( true ); + break; + +#define p s->param.workdone + case HB_STATE_WORKDONE: + fProgressBar->Update( - fProgressBar->CurrentValue(), + "Done." ); + EnableUI( true ); + fPauseButton->SetLabel( "Pause" ); + fPauseButton->SetEnabled( false ); + fRipButton->SetLabel( "Rip" ); + fRipButton->SetEnabled( true ); + + /* FIXME */ + hb_job_t * job; + while( ( job = hb_job( fHandle, 0 ) ) ) + { + hb_rem( fHandle, job ); + } + break; +#undef p + } + + UnlockLooper(); +} + +void MainView::EnableUI( bool b ) +{ + + rgb_color mycolor; + mycolor.red = mycolor.green = mycolor.blue = b ? 0 : 128; + mycolor.alpha = 255; + + BStringView * strings[] = + { fSrcDVD1String, fSrcDVD2String, fSrcChapString, + fSrcChapToString, fSrcDur1String, fSrcDur2String, + fVidQualityString }; + for( unsigned i = 0; i < sizeof( strings ) / sizeof( void * ); i++ ) + { + strings[i]->SetHighColor( mycolor ); + strings[i]->Invalidate(); /* Force redraw */ + } + + BMenuField * fields[] = + { fSrcTitleMenu, fSrcChapStartMenu, fSrcChapEndMenu, + fDstFormatMenu, fDstCodecsMenu, fVidRateMenu, fVidEncoderMenu, + fSubMenu, fAudLang1Menu, fAudLang2Menu, fAudRateMenu, + fAudBitrateMenu }; + for( unsigned i = 0; i < sizeof( fields ) / sizeof( void * ); i++ ) + { + fields[i]->SetEnabled( b ); + } + + BControl * controls[] = + { fDstFileControl, fBrowseButton, fVidTargetRadio, + fVidTargetControl, fVidAverageRadio, fVidAverageControl, + fVidConstantRadio, fVidConstantSlider, fVidGrayCheck, + fVidTwoPassCheck, fPictureButton }; + for( unsigned i = 0; i < sizeof( controls ) / sizeof( void * ); i++ ) + { + controls[i]->SetEnabled( b ); + } + + if( b ) + { + QualityRadioChanged(); + } +} + +void MainView::TitlePopUpChanged() +{ + int index = fSrcTitlePopUp->IndexOf( fSrcTitlePopUp->FindMarked() ); + if( index == fSrcTitle ) + { + /* No change actually */ + return; + } + fSrcTitle = index; + + /* Get a pointer to the title */ + hb_list_t * list; + hb_title_t * title; + list = hb_get_titles( fHandle ); + title = (hb_title_t *) hb_list_item( list, index ); + + char text[1024]; + BMenuItem * item; + + /* Update chapters popups */ + while( ( item = fSrcChapStartPopUp->RemoveItem( 0L ) ) ) + { + delete item; + } + while( ( item = fSrcChapEndPopUp->RemoveItem( 0L ) ) ) + { + delete item; + } + for( int i = 0; i < hb_list_count( title->list_chapter ); i++ ) + { + snprintf( text, 1024, "%d", i + 1 ); + fSrcChapStartPopUp->AddItem( new BMenuItem( text, + new BMessage( MSG_CHAPTERPOPUP ) ) ); + fSrcChapEndPopUp->AddItem( new BMenuItem( text, + new BMessage( MSG_CHAPTERPOPUP ) ) ); + } + fSrcChapStartPopUp->ItemAt( 0 )->SetMarked( true ); + fSrcChapEndPopUp->ItemAt( hb_list_count( title->list_chapter ) + - 1 )->SetMarked( true ); + ChapterPopUpChanged(); + + /* Update subtitles popup */ + hb_subtitle_t * sub; + while( ( item = fSubPopUp->RemoveItem( 0L ) ) ) + { + delete item; + } + fSubPopUp->AddItem( new BMenuItem( "None", new BMessage() ) ); + for( int i = 0; i < hb_list_count( title->list_subtitle ); i++ ) + { + sub = (hb_subtitle_t *) hb_list_item( title->list_subtitle, i ); + fSubPopUp->AddItem( new BMenuItem( sub->lang, new BMessage() ) ); + } + fSubPopUp->ItemAt( 0 )->SetMarked( true ); + + /* Update audio popups */ + hb_audio_t * audio; + while( ( item = fAudLang1PopUp->RemoveItem( 0L ) ) ) + { + delete item; + } + while( ( item = fAudLang2PopUp->RemoveItem( 0L ) ) ) + { + delete item; + } + fAudLang1PopUp->AddItem( new BMenuItem( "None", new BMessage() ) ); + fAudLang2PopUp->AddItem( new BMenuItem( "None", new BMessage() ) ); + for( int i = 0; i < hb_list_count( title->list_audio ); i++ ) + { + audio = (hb_audio_t *) hb_list_item( title->list_audio, i ); + fAudLang1PopUp->AddItem( new BMenuItem( audio->lang, new BMessage() ) ); + fAudLang2PopUp->AddItem( new BMenuItem( audio->lang, new BMessage() ) ); + } + fAudLang1PopUp->ItemAt( 1 )->SetMarked( true ); + fAudLang2PopUp->ItemAt( 0 )->SetMarked( true ); +} + +void MainView::ChapterPopUpChanged() +{ + /* Get a pointer to the title */ + hb_list_t * list; + hb_title_t * title; + list = hb_get_titles( fHandle ); + title = (hb_title_t *) hb_list_item( list, + fSrcTitlePopUp->IndexOf( fSrcTitlePopUp->FindMarked() ) ); + + hb_chapter_t * chapter; + int64_t duration = 0; + for( int i = fSrcChapStartPopUp->IndexOf( + fSrcChapStartPopUp->FindMarked() ); + i <= fSrcChapEndPopUp->IndexOf( + fSrcChapEndPopUp->FindMarked() ); + i++ ) + { + chapter = (hb_chapter_t *) hb_list_item( title->list_chapter, i ); + duration += chapter->duration; + } + duration /= 90000; /* pts -> seconds */ + + char text[1024]; + snprintf( text, sizeof(text), "%02lld:%02lld:%02lld", + duration / 3600, ( duration / 60 ) % 60, duration % 60 ); + fSrcDur2String->SetText( text ); +} + +void MainView::FormatPopUpChanged() +{ + int format; + BMenuItem * item; + + format = fDstFormatPopUp->IndexOf( fDstFormatPopUp->FindMarked() ); + if( format == fDstFormat ) + { + /* No change actually */ + CheckExtension(); + return; + } + fDstFormat = format; + + /* Empty codecs popup */ + while( ( item = fDstCodecsPopUp->RemoveItem( 0L ) ) ) + { + delete item; + } + + /* Add acceptable video codec / audio codec combinations */ +#define ADDITEM(a) \ + fDstCodecsPopUp->AddItem( new BMenuItem( a, new BMessage( MSG_CODECSPOPUP ) ) ) + switch( format ) + { + case 0: + ADDITEM( "MPEG-4 Video / AAC Audio" ); + ADDITEM( "AVC/H.264 Video / AAC Audio" ); + break; + case 1: + ADDITEM( "MPEG-4 Video / MP3 Audio" ); + ADDITEM( "MPEG-4 Video / AC-3 Audio" ); + ADDITEM( "AVC/H.264 Video / MP3 Audio" ); + ADDITEM( "AVC/H.264 Video / AC-3 Audio" ); + break; + case 2: + ADDITEM( "MPEG-4 Video / Vorbis Audio" ); + ADDITEM( "MPEG-4 Video / MP3 Audio" ); + break; + } +#undef ADDITEM + + fDstCodecsPopUp->ItemAt( 0 )->SetMarked( true ); + + CheckExtension(); + CodecsPopUpChanged(); +} + +void MainView::CodecsPopUpChanged() +{ + int format = fDstFormatPopUp->IndexOf( fDstFormatPopUp->FindMarked() ); + int codecs = fDstCodecsPopUp->IndexOf( fDstCodecsPopUp->FindMarked() ); + + BMenuItem * item; + + /* Update the encoder popup if necessary */ + if( ( FormatSettings[format][codecs] & HB_VCODEC_X264 ) && + fVidEncoderPopUp->CountItems() > 1 ) + { + /* MPEG-4 -> H.264 */ + while( ( item = fVidEncoderPopUp->RemoveItem( 0L ) ) ) + delete item; + fVidEncoderPopUp->AddItem( new BMenuItem( "x264", new BMessage() ) ); + fVidEncoderPopUp->ItemAt( 0 )->SetMarked( true ); + } + else if( ( FormatSettings[format][codecs] & HB_VCODEC_FFMPEG ) && + fVidEncoderPopUp->CountItems() < 2 ) + { + /* H.264 -> MPEG-4 */ + while( ( item = fVidEncoderPopUp->RemoveItem( 0L ) ) ) + delete item; + fVidEncoderPopUp->AddItem( new BMenuItem( "FFmpeg", new BMessage() ) ); + fVidEncoderPopUp->AddItem( new BMenuItem( "XviD", new BMessage() ) ); + fVidEncoderPopUp->ItemAt( 0 )->SetMarked( true ); + } + + if( FormatSettings[format][codecs] & HB_ACODEC_AC3 ) + { + /* AC-3 pass-through: disable samplerate and bitrate */ + fAudRatePopUp->SetEnabled( false ); + fAudBitratePopUp->SetEnabled( false ); + } + else if( fVidEncoderPopUp->IsEnabled() ) + { + fAudRatePopUp->SetEnabled( true ); + fAudBitratePopUp->SetEnabled( true ); + } +} + +void MainView::CheckExtension() +{ + char * ext = NULL; + switch( fDstFormat ) + { + case 0: + ext = ".mp4"; + break; + case 1: + ext = ".avi"; + break; + case 2: + ext = ".ogm"; + break; + } + + char newname[1024]; + const char * oldname = fDstFileControl->Text(); + memcpy( newname, oldname, strlen( oldname ) ); + if( strlen( oldname ) > 4 && + oldname[strlen( oldname ) - 4] == '.' ) + { + /* Replace extension */ + memcpy( &newname[strlen( oldname ) - 4], ext, 5 ); + } + else + { + /* Add extension */ + memcpy( &newname[strlen( oldname )], ext, 5 ); + } + fDstFileControl->SetText( newname ); +} + +void MainView::QualityRadioChanged() +{ + fVidTargetControl->SetEnabled( fVidTargetRadio->Value() ); + fVidAverageControl->SetEnabled( fVidAverageRadio->Value() ); + fVidConstantSlider->SetEnabled( fVidConstantRadio->Value() ); + fVidTwoPassCheck->SetEnabled( !fVidConstantRadio->Value() ); + if( fVidConstantRadio->Value() ) + fVidTwoPassCheck->SetValue( 0 ); +} + +void MainView::SliderChanged() +{ + char text[1024]; + snprintf( text, 1024, "Constant quality: %ld %%", + fVidConstantSlider->Value() ); + fVidConstantRadio->SetLabel( text ); +} + +void MainView::AddJob() +{ + hb_list_t * list; + hb_title_t * title; + hb_job_t * job; + list = hb_get_titles( fHandle ); + title = (hb_title_t *) hb_list_item( list, + fSrcTitlePopUp->IndexOf( fSrcTitlePopUp->FindMarked() ) ); + job = title->job; + + job->chapter_start = fSrcChapStartPopUp->IndexOf( + fSrcChapStartPopUp->FindMarked() ) + 1; + job->chapter_end = fSrcChapEndPopUp->IndexOf( + fSrcChapEndPopUp->FindMarked() ) + 1; + + int format = fDstFormatPopUp->IndexOf( + fDstFormatPopUp->FindMarked() ); + int codecs = fDstCodecsPopUp->IndexOf( + fDstCodecsPopUp->FindMarked() ); + + job->mux = FormatSettings[format][codecs] & HB_MUX_MASK; + job->vcodec = FormatSettings[format][codecs] & HB_VCODEC_MASK; + job->acodec = FormatSettings[format][codecs] & HB_ACODEC_MASK; + + if( ( job->vcodec & HB_VCODEC_FFMPEG ) && + fVidEncoderPopUp->IndexOf( + fVidEncoderPopUp->FindMarked() ) > 0 ) + { + job->vcodec = HB_VCODEC_XVID; + } + + int index; + index = fVidRatePopUp->IndexOf( + fVidRatePopUp->FindMarked() ); + if( index > 0 ) + { + job->vrate_base = hb_video_rates[index-1].rate; + } + else + { + job->vrate_base = title->rate_base; + } + + job->grayscale = fVidGrayCheck->Value(); + + job->subtitle = fSubPopUp->IndexOf( + fSubPopUp->FindMarked() ) - 1; + + job->audios[0] = fAudLang1PopUp->IndexOf( + fAudLang1PopUp->FindMarked() ) - 1; + job->audios[1] = fAudLang2PopUp->IndexOf( + fAudLang2PopUp->FindMarked() ) - 1; + job->audios[2] = -1; + + job->arate = hb_audio_rates[fAudRatePopUp->IndexOf( + fAudRatePopUp->FindMarked() )].rate; + job->abitrate = hb_audio_bitrates[fAudBitratePopUp->IndexOf( + fAudBitratePopUp->FindMarked() )].rate; + + if( fVidConstantRadio->Value() ) + { + job->vquality = 0.01 * fVidConstantSlider->Value(); + job->vbitrate = 0; + } + else if( fVidTargetRadio->Value() ) + { + job->vquality = -1.0; + job->vbitrate = hb_calc_bitrate( job, + atoi( fVidTargetControl->Text() ) ); + } + else + { + job->vquality = -1.0; + job->vbitrate = atoi( fVidAverageControl->Text() ); + } + + job->file = strdup( fDstFileControl->Text() ); + + if( fVidTwoPassCheck->Value() ) + { + job->pass = 1; + hb_add( fHandle, job ); + job->pass = 2; + hb_add( fHandle, job ); + } + else + { + job->pass = 0; + hb_add( fHandle, job ); + } +} + +MainWindow::MainWindow( hb_handle_t * handle ) + : BWindow( BRect( 0,0,10,10 ), "HandBrake " HB_VERSION, + B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE ) +{ + fHandle = handle; + + /* Add the main view */ + fView = new MainView( fHandle ); + AddChild( fView ); + + /* Resize to fit */ + ResizeTo( fView->Bounds().Width(), fView->Bounds().Height() ); + + /* Center */ + BScreen screen; + MoveTo( ( screen.Frame().Width() - fView->Bounds().Width() ) / 2, + ( screen.Frame().Height() - fView->Bounds().Height() ) / 2 ); +} + +void MainWindow::MessageReceived( BMessage * msg ) +{ + switch( msg->what ) + { + case MSG_TITLEPOPUP: + case MSG_CHAPTERPOPUP: + case MSG_FORMATPOPUP: + case MSG_CODECSPOPUP: + case MSG_BROWSE: + case MSG_QUALITYRADIO: + case MSG_SLIDER: + case MSG_PICSETTINGS: + case MSG_QUEUE_ENABLE: + case MSG_QUEUE_ADD: + case MSG_QUEUE_SHOW: + case MSG_PAUSE: + case MSG_START: + case B_SAVE_REQUESTED: + fView->HandleMessage( msg ); + break; + + default: + BWindow::MessageReceived( msg ); + break; + } +} + +bool MainWindow::QuitRequested() +{ + be_app_messenger.SendMessage( B_QUIT_REQUESTED ); + return true; +} + +void MainWindow::Update( hb_state_t * s ) +{ + fView->Update( s ); +} diff --git a/beos/MainWindow.h b/beos/MainWindow.h new file mode 100644 index 000000000..1558556f0 --- /dev/null +++ b/beos/MainWindow.h @@ -0,0 +1,121 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <interface/Window.h> +#include <interface/View.h> + +#include "hb.h" + +class BButton; +class BCheckBox; +class BMenuField; +class BPopUpMenu; +class BRadioButton; +class BSlider; +class BStatusBar; +class BStringView; +class BTextControl; +class BFilePanel; + +class PicWindow; +class QueueWindow; + +class MainView : public BView +{ + public: + MainView( hb_handle_t * handle ); + + void HandleMessage( BMessage * msg ); + void Update( hb_state_t * s ); + + private: + void EnableUI( bool ); + void TitlePopUpChanged(); + void ChapterPopUpChanged(); + void FormatPopUpChanged(); + void CodecsPopUpChanged(); + void CheckExtension(); + void QualityRadioChanged(); + void SliderChanged(); + void AddJob(); + + hb_handle_t * fHandle; + + BStringView * fSrcDVD1String; + BStringView * fSrcDVD2String; + BPopUpMenu * fSrcTitlePopUp; + BMenuField * fSrcTitleMenu; + int fSrcTitle; + BStringView * fSrcChapString; + BPopUpMenu * fSrcChapStartPopUp; + BMenuField * fSrcChapStartMenu; + BStringView * fSrcChapToString; + BPopUpMenu * fSrcChapEndPopUp; + BMenuField * fSrcChapEndMenu; + BStringView * fSrcDur1String; + BStringView * fSrcDur2String; + + BPopUpMenu * fDstFormatPopUp; + BMenuField * fDstFormatMenu; + int fDstFormat; + BPopUpMenu * fDstCodecsPopUp; + BMenuField * fDstCodecsMenu; + BTextControl * fDstFileControl; + BButton * fBrowseButton; + + BPopUpMenu * fVidRatePopUp; + BMenuField * fVidRateMenu; + BPopUpMenu * fVidEncoderPopUp; + BMenuField * fVidEncoderMenu; + BStringView * fVidQualityString; + BRadioButton * fVidTargetRadio; + BTextControl * fVidTargetControl; + BRadioButton * fVidAverageRadio; + BTextControl * fVidAverageControl; + BRadioButton * fVidConstantRadio; + BSlider * fVidConstantSlider; + BCheckBox * fVidGrayCheck; + BCheckBox * fVidTwoPassCheck; + + BPopUpMenu * fSubPopUp; + BMenuField * fSubMenu; + + BPopUpMenu * fAudLang1PopUp; + BMenuField * fAudLang1Menu; + BPopUpMenu * fAudLang2PopUp; + BMenuField * fAudLang2Menu; + BPopUpMenu * fAudRatePopUp; + BMenuField * fAudRateMenu; + BPopUpMenu * fAudBitratePopUp; + BMenuField * fAudBitrateMenu; + + BButton * fPictureButton; + + BStatusBar * fProgressBar; + BCheckBox * fQueueCheck; + BButton * fAddButton; + BButton * fShowButton; + BButton * fPauseButton; + BButton * fRipButton; + + BFilePanel * fFilePanel; + PicWindow * fPicWin; + QueueWindow * fQueueWin; +}; + +class MainWindow : public BWindow +{ + public: + MainWindow( hb_handle_t * handle ); + void MessageReceived( BMessage * msg ); + bool QuitRequested(); + + void Update( hb_state_t * s ); + + private: + MainView * fView; + + hb_handle_t * fHandle; +}; + +#endif diff --git a/beos/PicWindow.cpp b/beos/PicWindow.cpp new file mode 100644 index 000000000..6b30f27c2 --- /dev/null +++ b/beos/PicWindow.cpp @@ -0,0 +1,369 @@ +#include <app/Application.h> +#include <interface/Bitmap.h> +#include <interface/Box.h> +#include <interface/Button.h> +#include <interface/CheckBox.h> +#include <interface/RadioButton.h> +#include <interface/Screen.h> +#include <interface/StringView.h> + +#include "PicWindow.h" +#include "Stepper.h" + +#define MSG_PREV 'prev' +#define MSG_NEXT 'next' +#define MSG_CLOSE 'clos' +#define MSG_WIDTH 'widt' +#define MSG_HEIGHT 'heig' +#define MSG_RADIO 'radi' + +PicView::PicView( hb_handle_t * handle, int index ) + : BView( BRect( 0,0,10,10 ), NULL, B_FOLLOW_NONE, B_WILL_DRAW ) +{ + fHandle = handle; + + /* Get the title and the job */ + hb_list_t * list; + list = hb_get_titles( fHandle ); + fTitle = (hb_title_t *) hb_list_item( list, index ); + fJob = fTitle->job; + + /* We'll start with the first picture */ + fIndex = 0; + + /* Allocate a buffer large enough to call hb_get_preview() later */ + fRawPic = (uint8_t *) malloc( ( fTitle->width + 2 ) * + ( fTitle->height + 2 ) * 4 ); + + /* Create the RGB BBitmap we'll use to display */ + fBitmap = new BBitmap( BRect( 0, 0, fTitle->width + 1, + fTitle->height + 1 ), 0, B_RGB32 ); + + /* Now build the interface */ + BRect r, b; + BBox * box; + BButton * button; + BStringView * stringView; + + /* Resize ourselves so the picture fits just fine */ + b = fBitmap->Bounds(); + ResizeTo( b.Width()+170, b.Height()+65 ); + + /* Now build the UI around the BBitmap */ + SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) ); + + /* "Size" box */ + b = Bounds(); + r = BRect( b.right-150,10,b.right-10,105 ); + box = new BBox( r ); + box->SetLabel( "Size" ); + AddChild( box ); + + b = box->Bounds(); + + /* Width */ + r = BRect( 10,15,b.right/2,35 ); + stringView = new BStringView( r, NULL, "Width:" ); + box->AddChild( stringView ); + r = BRect( b.right/2+1,15,b.right-10,35 ); + fWidthStepper = new HBStepper( r, 16, 16, fTitle->width, + fJob->width, new BMessage( MSG_WIDTH ) ); + box->AddChild( fWidthStepper ); + + /* Height */ + r = BRect( 10,40,b.right/2,60 ); + stringView = new BStringView( r, NULL, "Height:" ); + box->AddChild( stringView ); + r = BRect( b.right/2+1,40,b.right-10,60 ); + fHeightStepper = new HBStepper( r, 16, 16, fTitle->height, + fJob->height, new BMessage( MSG_HEIGHT ) ); + box->AddChild( fHeightStepper ); + + /* Aspect ratio */ + r = BRect( 10,65,b.right-10,85 ); + fRatioCheck = new BCheckBox( r, NULL, "Keep aspect ratio", + new BMessage( MSG_WIDTH ) ); + fRatioCheck->SetValue( fJob->keep_ratio ); + box->AddChild( fRatioCheck ); + + /* "Crop" box */ + b = Bounds(); + r = BRect( b.right-150,115,b.right-10,260 ); + box = new BBox( r ); + box->SetLabel( "Crop" ); + AddChild( box ); + + b = box->Bounds(); + + /* Automatic */ + r = BRect( 10,15,b.right-10,35 ); + fAutoRadio = new BRadioButton( r, NULL, "Automatic", + new BMessage( MSG_RADIO ) ); + box->AddChild( fAutoRadio ); + + /* Custom */ + r = BRect( 10,40,b.right-10,60 ); + fCustomRadio = new BRadioButton( r, NULL, "Custom:", + new BMessage( MSG_RADIO ) ); + box->AddChild( fCustomRadio ); + float width = ( b.Width() - 30 ) / 2; + r = BRect( (b.right-width)/2,65,(b.right+width)/2,85 ); + fCropSteppers[0] = new HBStepper( r, 2, 0, fTitle->height/2-2, + fJob->crop[0], new BMessage( MSG_WIDTH ) ); + box->AddChild( fCropSteppers[0] ); + r = BRect( (b.right-width)/2,115,(b.right+width)/2,135 ); + fCropSteppers[1] = new HBStepper( r, 2, 0, fTitle->height/2-2, + fJob->crop[1], new BMessage( MSG_WIDTH ) ); + box->AddChild( fCropSteppers[1] ); + r = BRect( 10,90,10+width,110 ); + fCropSteppers[2] = new HBStepper( r, 2, 0, fTitle->width/2-2, + fJob->crop[2], new BMessage( MSG_HEIGHT ) ); + box->AddChild( fCropSteppers[2] ); + r = BRect( width+20,90,b.right-10,110 ); + fCropSteppers[3] = new HBStepper( r, 2, 0, fTitle->width/2-2, + fJob->crop[3], new BMessage( MSG_HEIGHT ) ); + box->AddChild( fCropSteppers[3] ); + + if( memcmp( fTitle->crop, fJob->crop, 4 * sizeof( int ) ) ) + { + fCustomRadio->SetValue( 1 ); + } + else + { + fAutoRadio->SetValue( 1 ); + } + + /* "Misc" box */ + b = Bounds(); + r = BRect( b.right-150,270,b.right-10,315 ); + box = new BBox( r ); + box->SetLabel( "Misc" ); + AddChild( box ); + + b = box->Bounds(); + + /* Deinterlace */ + r = BRect( 10,15,b.right-10,35 ); + fDeintCheck = new BCheckBox( r, NULL, "Deinterlace picture", + new BMessage( MSG_WIDTH ) ); + fDeintCheck->SetValue( fJob->deinterlace ); + box->AddChild( fDeintCheck ); + + b = Bounds(); + + /* Next/Prev buttons */ + r = BRect( b.right-90,325,b.right-10,350 ); + fPrevButton = new BButton( r, NULL, "Previous", + new BMessage( MSG_PREV ) ); + AddChild( fPrevButton ); + r = BRect( b.right-90,355,b.right-10,380 ); + fNextButton = new BButton( r, NULL, "Next", + new BMessage( MSG_NEXT ) ); + AddChild( fNextButton ); + + /* Info string and OK button */ + r = BRect( 10,b.bottom-30,b.right-100,b.bottom-10 ); + fInfoString = new BStringView( r, NULL, "" ); + AddChild( fInfoString ); + r = BRect( b.right-90,b.bottom-35,b.right-10,b.bottom-10 ); + button = new BButton( r, NULL, "OK", new BMessage( MSG_CLOSE ) ); + AddChild( button ); + + /* Process and draw a first picture */ + RadioChanged(); + UpdateBitmap(); +} + +PicView::~PicView() +{ + free( fRawPic ); + delete fBitmap; +} + +/************************************************************************ + * PicView::Draw + ************************************************************************ + * Calls the inherited BView::Draw, plus draws the BBitmap preview + * and the horizontal line above the info string and OK button + ***********************************************************************/ +void PicView::Draw( BRect rect ) +{ + BRect b; + + BView::Draw( rect ); + + if( LockLooper() ) + { + b = fBitmap->Bounds(); + DrawBitmap( fBitmap, BRect( 10,10,b.Width()+10,b.Height()+10 ) ); + UnlockLooper(); + } + + b = Bounds(); + SetHighColor( 128,128,128 ); + StrokeLine( BPoint( 10,b.bottom-45 ), BPoint( b.right-10,b.bottom-45 ) ); + SetHighColor( 255,255,255 ); + StrokeLine( BPoint( 10,b.bottom-44 ), BPoint( b.right-10,b.bottom-44 ) ); +} + +void PicView::HandleMessage( BMessage * msg ) +{ + switch( msg->what ) + { + case MSG_PREV: + fIndex--; + UpdateBitmap(); + break; + + case MSG_NEXT: + fIndex++; + UpdateBitmap(); + break; + + case MSG_WIDTH: + case MSG_HEIGHT: + UpdateSettings( msg->what ); + UpdateBitmap(); + break; + + case MSG_RADIO: + RadioChanged(); + break; + + } +} + +void PicView::RadioChanged() +{ + int cus = fCustomRadio->Value(); + for( int i = 0; i < 4; i++ ) + { + fCropSteppers[i]->SetEnabled( cus ); + } + if( !cus ) + { + memcpy( fJob->crop, fTitle->crop, 4 * sizeof( int ) ); + for( int i = 0; i < 4; i++ ) + { + fCropSteppers[i]->SetValue( fJob->crop[i] ); + } + UpdateSettings( MSG_WIDTH ); + UpdateBitmap(); + } +} + +void PicView::UpdateSettings( uint32 what ) +{ + fJob->width = fWidthStepper->Value(); + fJob->height = fHeightStepper->Value(); + fJob->keep_ratio = fRatioCheck->Value(); + fJob->deinterlace = fDeintCheck->Value(); + for( int i = 0; i < 4; i++ ) + { + fJob->crop[i] = fCropSteppers[i]->Value(); + } + + if( fJob->keep_ratio ) + { + if( what == MSG_WIDTH ) + { + hb_fix_aspect( fJob, HB_KEEP_WIDTH ); + if( fJob->height > fTitle->height ) + { + fJob->height = fTitle->height; + hb_fix_aspect( fJob, HB_KEEP_HEIGHT ); + } + } + else + { + hb_fix_aspect( fJob, HB_KEEP_HEIGHT ); + if( fJob->width > fTitle->width ) + { + fJob->width = fTitle->width; + hb_fix_aspect( fJob, HB_KEEP_WIDTH ); + } + } + } + + fWidthStepper->SetValue( fJob->width ); + fHeightStepper->SetValue( fJob->height ); +} + +void PicView::UpdateBitmap() +{ + /* Sanity checks */ + if( fIndex < 0 ) + { + fIndex = 0; + return; + } + if( fIndex > 9 ) + { + fIndex = 9; + return; + } + + /* Enable/disable buttons */ + fPrevButton->SetEnabled( fIndex > 0 ); + fNextButton->SetEnabled( fIndex < 9 ); + + /* Get new preview and copy it in our BBitmap */ + hb_get_preview( fHandle, fTitle, fIndex, fRawPic ); + for( int i = 0; i < fTitle->height + 2; i++ ) + { + memcpy( ( (uint8_t *) fBitmap->Bits() ) + + i * fBitmap->BytesPerRow(), + fRawPic + 4 * ( fTitle->width + 2 ) * i, + 4 * ( fTitle->width + 2 ) ); + } + + /* Update size info */ + char text[1024]; + snprintf( text, 1024, "Source: %dx%d, output: %dx%d", + fTitle->width, fTitle->height, + fJob->width, fJob->height ); + fInfoString->SetText( text ); + + /* Force redraw */ + Draw( Bounds() ); +} + +PicWindow::PicWindow( hb_handle_t * handle, int index ) + : BWindow( BRect( 0,0,10,10 ), "Picture settings", + B_FLOATING_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, + B_NOT_CLOSABLE | B_NOT_RESIZABLE | B_NOT_ZOOMABLE ) +{ + /* Add the PicView */ + fView = new PicView( handle, index ); + AddChild( fView ); + + /* Resize to fit */ + ResizeTo( fView->Bounds().Width(), fView->Bounds().Height() ); + + /* Center */ + BScreen screen; + MoveTo( ( screen.Frame().Width() - fView->Bounds().Width() ) / 2, + ( screen.Frame().Height() - fView->Bounds().Height() ) / 2 ); +} + +void PicWindow::MessageReceived( BMessage * msg ) +{ + switch( msg->what ) + { + case MSG_PREV: + case MSG_NEXT: + case MSG_WIDTH: + case MSG_HEIGHT: + case MSG_RADIO: + fView->HandleMessage( msg ); + break; + + case MSG_CLOSE: + Lock(); + Quit(); + break; + + default: + BWindow::MessageReceived( msg ); + } +} diff --git a/beos/PicWindow.h b/beos/PicWindow.h new file mode 100644 index 000000000..9fe5d3131 --- /dev/null +++ b/beos/PicWindow.h @@ -0,0 +1,54 @@ +#ifndef PICWINDOW_H +#define PICWINDOW_H + +#include <interface/Window.h> +#include <interface/View.h> + +#include "hb.h" + +class HBStepper; + +class PicView : public BView +{ + public: + PicView( hb_handle_t * handle, int index ); + ~PicView(); + void Draw( BRect rect ); + + void HandleMessage( BMessage * msg ); + + private: + void UpdateBitmap(); + void RadioChanged(); + void UpdateSettings( uint32 what ); + + hb_handle_t * fHandle; + hb_title_t * fTitle; + hb_job_t * fJob; + int fIndex; + uint8_t * fRawPic; + BBitmap * fBitmap; + + HBStepper * fWidthStepper; + HBStepper * fHeightStepper; + BCheckBox * fRatioCheck; + BRadioButton * fAutoRadio; + BRadioButton * fCustomRadio; + HBStepper * fCropSteppers[4]; + BCheckBox * fDeintCheck; + BButton * fPrevButton; + BButton * fNextButton; + BStringView * fInfoString; +}; + +class PicWindow : public BWindow +{ + public: + PicWindow( hb_handle_t * handle, int index ); + void MessageReceived( BMessage * msg ); + + private: + PicView * fView; +}; + +#endif diff --git a/beos/QueueWindow.cpp b/beos/QueueWindow.cpp new file mode 100644 index 000000000..2b0319e32 --- /dev/null +++ b/beos/QueueWindow.cpp @@ -0,0 +1,132 @@ +#include <app/Message.h> +#include <interface/Button.h> +#include <interface/Screen.h> +#include <interface/ScrollView.h> +#include <interface/StringView.h> + +#include "QueueWindow.h" + +#define MSG_REMOVE 'remo' +#define MSG_CLOSE 'clos' + +QueueView::QueueView( hb_handle_t * handle ) + : BView( BRect( 0,0,500,300 ), NULL, B_FOLLOW_NONE, B_WILL_DRAW ) +{ + fHandle = handle; + + BRect b = Bounds(), r; + + r = BRect( b.right-90,b.bottom-35,b.right-10,b.bottom-10 ); + BButton * button = new BButton( r, NULL, "Close", new BMessage( MSG_CLOSE ) ); + AddChild( button ); + + fScrollView = NULL; + UpdateQueue(); +} + +QueueView::~QueueView() +{ +} + +void QueueView::HandleMessage( BMessage * msg ) +{ + switch( msg->what ) + { + case MSG_REMOVE: + break; + } +} + +void QueueView::AddStringView( char * string, BRect * r ) +{ + BStringView * stringView; + + stringView = new BStringView( *r, NULL, string ); + fQueueView->AddChild( stringView ); + free( string ); + + r->top += 20; + r->bottom += 20; +} + +void QueueView::UpdateQueue() +{ + BRect b = Bounds(), r; + + if( fScrollView ) + { + RemoveChild( fScrollView ); + delete fScrollView; + } + + r = BRect( b.left+10,b.top+10,b.right-B_V_SCROLL_BAR_WIDTH-10,b.bottom-45 ); + fQueueView = new BView( r, NULL, B_FOLLOW_NONE, B_WILL_DRAW ); + fScrollView = new BScrollView( NULL, fQueueView, B_FOLLOW_NONE, 0, + false, true, B_FANCY_BORDER ); + AddChild( fScrollView ); + + hb_job_t * j; + hb_title_t * t; + int i; + char * s; + + b = fQueueView->Bounds(); + r = BRect( b.left+10,b.top+10,b.right-10,b.top+25 ); + + for( i = 0; i < hb_count( fHandle ); i++ ) + { + j = hb_job( fHandle, i ); + t = j->title; + + asprintf( &s, "DVD: %s", t->dvd ); + AddStringView( s, &r ); + + asprintf( &s, "Title: %d", t->index ); + AddStringView( s, &r ); + + asprintf( &s, "Chapters: %d to %d", j->chapter_start, j->chapter_end ); + AddStringView( s, &r ); + + asprintf( &s, "Pass: %d of %d", MAX( 1, j->pass ), MIN( 2, j->pass + 1 ) ); + AddStringView( s, &r ); + + asprintf( &s, "Destination: %s", j->file ); + AddStringView( s, &r ); + } +} + +QueueWindow::QueueWindow( hb_handle_t * handle ) + : BWindow( BRect( 0,0,10,10 ), "Queue", + B_FLOATING_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, + B_NOT_CLOSABLE | B_NOT_RESIZABLE | B_NOT_ZOOMABLE ) +{ + /* Add the QueueView */ + fView = new QueueView( handle ); + AddChild( fView ); + + /* Resize to fit */ + ResizeTo( fView->Bounds().Width(), fView->Bounds().Height() ); + + /* Center */ + BScreen screen; + MoveTo( ( screen.Frame().Width() - fView->Bounds().Width() ) / 2, + ( screen.Frame().Height() - fView->Bounds().Height() ) / 2 ); +} + +void QueueWindow::MessageReceived( BMessage * msg ) +{ + switch( msg->what ) + { + case MSG_REMOVE: + fView->HandleMessage( msg ); + break; + + case MSG_CLOSE: + Lock(); + Quit(); + break; + + default: + BWindow::MessageReceived( msg ); + } +} diff --git a/beos/QueueWindow.h b/beos/QueueWindow.h new file mode 100644 index 000000000..e9b86e3a7 --- /dev/null +++ b/beos/QueueWindow.h @@ -0,0 +1,38 @@ +#ifndef QUEUE_WINDOW_H +#define QUEUE_WINDOW_H + +#include <interface/Window.h> +#include <interface/View.h> + +#include "hb.h" + +class QueueView : public BView +{ + public: + QueueView( hb_handle_t * handle ); + ~QueueView(); + + void HandleMessage( BMessage * msg ); + + private: + void AddStringView( char * string, BRect * r ); + void UpdateQueue(); + + hb_handle_t * fHandle; + + BScrollView * fScrollView; + BView * fQueueView; + BButton * fCloseButton; +}; + +class QueueWindow : public BWindow +{ + public: + QueueWindow( hb_handle_t * handle ); + void MessageReceived( BMessage * msg ); + + private: + QueueView * fView; +}; + +#endif diff --git a/beos/ScanWindow.cpp b/beos/ScanWindow.cpp new file mode 100644 index 000000000..615731f11 --- /dev/null +++ b/beos/ScanWindow.cpp @@ -0,0 +1,320 @@ +#include <drivers/Drivers.h> +#include <interface/Box.h> +#include <interface/Button.h> +#include <interface/MenuField.h> +#include <interface/MenuItem.h> +#include <interface/PopUpMenu.h> +#include <interface/RadioButton.h> +#include <interface/Screen.h> +#include <interface/StatusBar.h> +#include <interface/StringView.h> +#include <interface/TextControl.h> +#include <kernel/fs_info.h> +#include <storage/FilePanel.h> +#include <storage/Path.h> +#include <storage/Query.h> +#include <storage/VolumeRoster.h> +#include <sys/ioctl.h> + +#include "ScanWindow.h" + +#define MSG_RADIO 'radi' +#define MSG_BROWSE 'brow' +#define MSG_CANCEL 'canc' +#define MSG_OPEN 'open' + +ScanView::ScanView( hb_handle_t * handle ) + : BView( BRect( 0,0,400,215 ), NULL, B_FOLLOW_NONE, B_WILL_DRAW ) +{ + fHandle = handle; + + BRect r, b; + BBox * box; + BStringView * stringView; + + SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) ); + + b = Bounds(); + + r = BRect( 10,10,b.right-10,130 ); + box = new BBox( r ); + AddChild( box ); + + b = box->Bounds(); + + r = BRect( 10,10,b.right-10,30 ); + stringView = new BStringView( r, NULL, "Select a DVD:" ); + box->AddChild( stringView ); + + r = BRect( 10,35,b.right/2,55 ); + fDetectedRadio = new BRadioButton( r, NULL, "Detected volume", + new BMessage( MSG_RADIO ) ); + box->AddChild( fDetectedRadio ); + + r = BRect( b.right/2+1,35,b.right-10,55 ); + fPopUp = new BPopUpMenu( "No volume detected" ); + fMenu = new BMenuField( r, NULL, "", fPopUp, true ); + fMenu->SetDivider( 0 ); + box->AddChild( fMenu ); + + r = BRect( 10,60,b.right/2,80 ); + fFolderRadio = new BRadioButton( r, NULL, "DVD Folder / Image", + new BMessage( MSG_RADIO ) ); + box->AddChild( fFolderRadio ); + + r = BRect( b.right/2+1,60,b.right-10,80 ); + fControl = new BTextControl( r, NULL, "", "", new BMessage() ); + fControl->SetDivider( 0 ); + box->AddChild( fControl ); + + r = BRect( b.right-90,85,b.right-10,110 ); + fBrowseButton = new BButton( r, NULL, "Browse", + new BMessage( MSG_BROWSE ) ); + box->AddChild( fBrowseButton ); + + b = Bounds(); + + r = BRect( 10,b.bottom-75,b.right-10,b.bottom-45 ); + fBar = new BStatusBar( r, NULL, NULL, NULL ); + AddChild( fBar ); + + r = BRect( b.right-180,b.bottom-35,b.right-100,b.bottom-10 ); + fCancelButton = new BButton( r, NULL, "Cancel", + new BMessage( MSG_CANCEL ) ); + AddChild( fCancelButton ); + + r = BRect( b.right-90,b.bottom-35,b.right-10,b.bottom-10 ); + fOpenButton = new BButton( r, NULL, "Open", new BMessage( MSG_OPEN ) ); + AddChild( fOpenButton ); + + DetectVolumes(); + + if( fPopUp->CountItems() > 0 ) + { + fDetectedRadio->SetValue( true ); + } + else + { + fFolderRadio->SetValue( true ); + } + RadioChanged(); + + fFilePanel = NULL; +} + +void ScanView::HandleMessage( BMessage * msg ) +{ + switch( msg->what ) + { + case MSG_RADIO: + RadioChanged(); + break; + + case MSG_BROWSE: + if( !fFilePanel ) + { + fFilePanel = new BFilePanel( B_OPEN_PANEL, + new BMessenger( Window() ), NULL, + B_FILE_NODE | B_DIRECTORY_NODE, false, NULL, NULL, + true ); + } + fFilePanel->Show(); + break; + + case B_REFS_RECEIVED: + { + entry_ref ref; + if( msg->FindRef( "refs", 0, &ref ) == B_OK ) + { + BPath * path = new BPath( &ref ); + fControl->SetText( path->Path()); + } + break; + } + + case MSG_CANCEL: + Window()->Hide(); + break; + + case MSG_OPEN: + SetEnabled( false ); + fBar->Update( - fBar->CurrentValue(), "Opening..." ); + if( fDetectedRadio->Value() && fPopUp->CountItems() > 0 ) + { + hb_scan( fHandle, fPopUp->FindMarked()->Label(), 0 ); + } + else if( fFolderRadio->Value() ) + { + hb_scan( fHandle, fControl->Text(), 0 ); + } + break; + } +} + +void ScanView::Update( hb_state_t * s ) +{ + if( !LockLooper() ) + { + return; + } + + switch( s->state ) + { +#define p s->param.scanning + case HB_STATE_SCANNING: + { + char text[1024]; + snprintf( text, 1024, "Scanning title %d of %d...", p.title_cur, + p.title_count ); + fBar->Update( fBar->MaxValue() * ( - 0.5 + p.title_cur ) / + p.title_count - fBar->CurrentValue(), text ); + break; + } +#undef p + + case HB_STATE_SCANDONE: + /* If we are still here, then no title was found */ + fBar->Update( - fBar->CurrentValue(), + "No valid title found." ); + SetEnabled( true ); + break; + } + + UnlockLooper(); +} + +void ScanView::RadioChanged() +{ + bool b = fDetectedRadio->Value(); + fMenu->SetEnabled( b ); + fControl->SetEnabled( !b ); + fBrowseButton->SetEnabled( !b ); + fOpenButton->SetEnabled( !b || ( fPopUp->CountItems() > 0 ) ); +} + +void ScanView::SetEnabled( bool b ) +{ + fDetectedRadio->SetEnabled( b ); + fMenu->SetEnabled( b ); + fFolderRadio->SetEnabled( b ); + fControl->SetEnabled( b ); + fBrowseButton->SetEnabled( b ); + fOpenButton->SetEnabled( b ); + + if( b ) + { + RadioChanged(); + } +} + +void ScanView::DetectVolumes() +{ + BVolumeRoster * roster = new BVolumeRoster(); + BVolume * volume = new BVolume(); + fs_info info; + int device; + device_geometry geometry; + + while( roster->GetNextVolume( volume ) == B_NO_ERROR ) + { + /* open() and ioctl() for more informations */ + fs_stat_dev( volume->Device(), &info ); + if( ( device = open( info.device_name, O_RDONLY ) ) < 0 ) + { + continue; + } + + if( ioctl( device, B_GET_GEOMETRY, &geometry, + sizeof( geometry ) ) < 0 ) + { + continue; + } + + /* Get the volume name */ + char volumeName[B_FILE_NAME_LENGTH]; + volume->GetName( volumeName ); + + if( volume->IsReadOnly() && geometry.device_type == B_CD ) + { + /* May be a DVD */ + fPopUp->AddItem( new BMenuItem( info.device_name, NULL ) ); + } + else if( geometry.device_type == B_DISK ) + { + /* May be a hard drive. Look for VIDEO_TS folders on it */ + BQuery * query = new BQuery(); + + if( query->SetVolume( volume ) != B_OK ) + { + delete query; + continue; + } + + if( query->SetPredicate( "name = VIDEO_TS.IFO" ) != B_OK ) + { + delete query; + continue; + } + + query->Fetch(); + + BEntry entry, parentEntry; + BPath path; + while( query->GetNextEntry( &entry ) == B_OK ) + { + entry.GetParent( &parentEntry ); + parentEntry.GetPath( &path ); + + fPopUp->AddItem( new BMenuItem( path.Path(), NULL ) ); + } + + delete query; + } + } + + if( fPopUp->CountItems() > 0 ) + { + fPopUp->ItemAt( 0 )->SetMarked( true ); + } +} + +ScanWindow::ScanWindow( hb_handle_t * handle ) + : BWindow( BRect( 0,0,10,10 ), "Scan", B_FLOATING_WINDOW_LOOK, + B_MODAL_SUBSET_WINDOW_FEEL, B_NOT_CLOSABLE | + B_NOT_RESIZABLE | B_NOT_ZOOMABLE ) +{ + /* Add the scan view */ + fView = new ScanView( handle ); + AddChild( fView ); + + /* Resize to fit */ + ResizeTo( fView->Bounds().Width(), fView->Bounds().Height() ); + + /* Center */ + BScreen screen; + MoveTo( ( screen.Frame().Width() - fView->Bounds().Width() ) / 2, + ( screen.Frame().Height() - fView->Bounds().Height() ) / 2 ); +} + +void ScanWindow::MessageReceived( BMessage * msg ) +{ + switch( msg->what ) + { + case MSG_RADIO: + case MSG_BROWSE: + case MSG_CANCEL: + case MSG_OPEN: + case B_REFS_RECEIVED: + fView->HandleMessage( msg ); + break; + + default: + BWindow::MessageReceived( msg ); + } +} + +void ScanWindow::Update( hb_state_t * s ) +{ + fView->Update( s ); +} + diff --git a/beos/ScanWindow.h b/beos/ScanWindow.h new file mode 100644 index 000000000..f46c1c14f --- /dev/null +++ b/beos/ScanWindow.h @@ -0,0 +1,56 @@ +#ifndef SCANWINDOW_H +#define SCANWINDOW_H + +#include <interface/Window.h> +#include <interface/View.h> + +#include "hb.h" + +class BButton; +class BMenuField; +class BPopUpMenu; +class BRadioButton; +class BStatusBar; +class BTextControl; + +class ScanView : public BView +{ + public: + ScanView( hb_handle_t * handle ); + + void HandleMessage( BMessage * msg ); + void Update( hb_state_t * s ); + void RadioChanged(); + void SetEnabled( bool ); + + private: + void DetectVolumes(); + + hb_handle_t * fHandle; + + BRadioButton * fDetectedRadio; + BPopUpMenu * fPopUp; + BMenuField * fMenu; + BRadioButton * fFolderRadio; + BTextControl * fControl; + BButton * fBrowseButton; + BStatusBar * fBar; + BButton * fCancelButton; + BButton * fOpenButton; + + BFilePanel * fFilePanel; +}; + +class ScanWindow : public BWindow +{ + public: + ScanWindow( hb_handle_t * handle ); + void MessageReceived( BMessage * msg ); + + void Update( hb_state_t * s ); + + private: + ScanView * fView; +}; + +#endif diff --git a/beos/Stepper.cpp b/beos/Stepper.cpp new file mode 100644 index 000000000..8f2733ac5 --- /dev/null +++ b/beos/Stepper.cpp @@ -0,0 +1,130 @@ +#include <interface/Region.h> +#include <interface/TextControl.h> +#include <interface/Window.h> + +#include "Stepper.h" + +#include <stdio.h> + +HBStepper::HBStepper( BRect rect, int step, int min, int max, int val, + BMessage * message ) + : BView( rect, NULL, B_FOLLOW_NONE, B_WILL_DRAW ) +{ + fStep = step; + fMin = min; + fMax = max; + fMessage = message; + + BRect b = Bounds(); + + fEnabled = true; + + fControl = new BTextControl( BRect( 0,1,b.Width()-14,b.Height()-1 ), + NULL, NULL, "", new BMessage() ); + fControl->SetDivider( 0.0 ); + fControl->TextView()->MakeEditable( false ); + AddChild( fControl ); + + SetValue( val ); +} + +void HBStepper::Draw( BRect rect ) +{ + /* Why do we have to do this here!? */ + fControl->TextView()->MakeEditable( false ); + fControl->TextView()->MakeSelectable( false ); + + BRect b = Bounds(); + BRegion region; + + SetHighColor( 128,128,128 ); /* Dark gray */ + region.MakeEmpty(); + region.Include( BRect( 3, 0,10, 0 ) ); + region.Include( BRect( 2, 1, 3, 1 ) ); + region.Include( BRect( 10, 1,11, 1 ) ); + region.Include( BRect( 1, 2, 2, 2 ) ); + region.Include( BRect( 11, 2,12, 2 ) ); + region.Include( BRect( 1, 2, 1,18 ) ); + region.Include( BRect( 1,10,12,10 ) ); + region.Include( BRect( 12, 2,12,18 ) ); + region.Include( BRect( 1,18, 2,18 ) ); + region.Include( BRect( 11,18,12,18 ) ); + region.Include( BRect( 2,19, 3,19 ) ); + region.Include( BRect( 10,19,11,19 ) ); + region.Include( BRect( 3,20,10,20 ) ); + region.OffsetBy( b.Width()-12,0 ); + FillRegion( ®ion ); + + SetHighColor( 0,0,0 ); /* Black */ + region.MakeEmpty(); + region.Include( BRect( 6, 4, 7, 4 ) ); + region.Include( BRect( 5, 5, 8, 6 ) ); + region.Include( BRect( 5,14, 8,15 ) ); + region.Include( BRect( 6,16, 7,16 ) ); + region.OffsetBy( b.Width()-12,0 ); + FillRegion( ®ion ); + + BView::Draw( rect ); +} + +void HBStepper::AttachedToWindow() +{ + if( Parent() ) + { + SetViewColor( Parent()->ViewColor() ); + } +} + +void HBStepper::MouseDown( BPoint point ) +{ + BRect r, b = Bounds(); + + if( !fEnabled ) + { + return; + } + + BMessenger messenger( Window() ); + + r = BRect( 2,1,11,9 ); + r.OffsetBy( b.Width()-12,0 ); + if( r.Contains( point ) ) + { + SetValue( fValue + fStep ); + messenger.SendMessage( fMessage ); + } + r.OffsetBy( 0,10 ); + if( r.Contains( point ) ) + { + SetValue( fValue - fStep ); + messenger.SendMessage( fMessage ); + } +} + +void HBStepper::SetValue( int val ) +{ + fValue = val; + if( fValue < fMin ) + { + fValue = fMin; + } + if( fValue > fMax ) + { + fValue = fMax; + } + + char text[16]; + snprintf( text, 16, "%d", fValue ); + fControl->SetText( text ); +} + +int HBStepper::Value() +{ + return fValue; +} + +void HBStepper::SetEnabled( bool e ) +{ + fEnabled = e; + fControl->SetEnabled( fEnabled ); +} diff --git a/beos/Stepper.h b/beos/Stepper.h new file mode 100644 index 000000000..2b0493f6e --- /dev/null +++ b/beos/Stepper.h @@ -0,0 +1,31 @@ +#ifndef STEPPER_H +#define STEPPER_H + +#include <interface/View.h> + +class BTextControl; + +class HBStepper : public BView +{ + public: + HBStepper( BRect rect, int step, int min, int max, int val, + BMessage * message ); + void Draw( BRect rect ); + void AttachedToWindow(); + void MouseDown( BPoint point ); + void SetValue( int val ); + int Value(); + void SetEnabled( bool e ); + + private: + int fStep; + int fMin; + int fMax; + int fValue; + BMessage * fMessage; + + bool fEnabled; + BTextControl * fControl; +}; + +#endif diff --git a/beos/liblayout/HGroup.h b/beos/liblayout/HGroup.h deleted file mode 100644 index 9eee83fea..000000000 --- a/beos/liblayout/HGroup.h +++ /dev/null @@ -1,40 +0,0 @@ - -#ifndef _HGROUP_H -#define _HGROUP_H -#include "MGroup.h" -#include <View.h> -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT HGroup : public MGroup, public BView -{ - public: HGroup(minimax mpm,MView *kid=0, ...); - HGroup(MView *kid=0, ...); - HGroup(BMessage*); - virtual ~HGroup(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - virtual minimax layoutprefs(); - virtual BRect layout(BRect rect); - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); - virtual void MouseDown(BPoint); - - private: virtual void _expansionhgroup1(); - virtual void _expansionhgroup2(); - virtual void _expansionhgroup3(); - - static int cmpkids(const void* v1,const void *v2); - int *size; - float totalweight; - int numkids; - sortstruct *childorder; - MView **mkid; - float totalminx,totalmaxx; - BRect *lastrect; - - uint32 _expansiondata[2]; -}; - -#endif diff --git a/beos/liblayout/LayeredGroup.h b/beos/liblayout/LayeredGroup.h deleted file mode 100644 index 61264ca36..000000000 --- a/beos/liblayout/LayeredGroup.h +++ /dev/null @@ -1,37 +0,0 @@ - -#ifndef _LAYEREDGROUP_H -#define _LAYEREDGROUP_H - -#include "MGroup.h" -#include <Control.h> - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT LayeredGroup : public MGroup, public BControl -{ - public: LayeredGroup(minimax mpm,MView *arg=0, ...); - LayeredGroup(MView *arg=0, ...); - LayeredGroup(BMessage*); - virtual ~LayeredGroup(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - virtual minimax layoutprefs(); - virtual BRect layout(BRect rect); - void ActivateLayer(int); - virtual void MessageReceived(BMessage *mes); - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); - - private: virtual void _expansionlayeredgroup1(); - virtual void _expansionlayeredgroup2(); - - int numkids; - int activekid; - - uint32 _expansiondata[3]; -}; - - -#endif diff --git a/beos/liblayout/MApplication.h b/beos/liblayout/MApplication.h deleted file mode 100644 index acdd13214..000000000 --- a/beos/liblayout/MApplication.h +++ /dev/null @@ -1,29 +0,0 @@ - -#ifndef _MAPPLICATION_H -#define _MAPPLICATION_H - -#include "layout.h" -#include <Application.h> - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MApplication : public BApplication -{ - public: MApplication(char *); - MApplication(BMessage*); - virtual ~MApplication(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - virtual void MessageReceived(BMessage*); - - virtual status_t GetSupportedSuites(BMessage *message); - virtual BHandler *ResolveSpecifier(BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property); - - private: - virtual void _expansionmapplication1(); - virtual void _expansionmapplication2(); - uint32 _expansiondata[4]; -}; -#endif diff --git a/beos/liblayout/MBViewWrapper.h b/beos/liblayout/MBViewWrapper.h deleted file mode 100644 index 351dfb800..000000000 --- a/beos/liblayout/MBViewWrapper.h +++ /dev/null @@ -1,30 +0,0 @@ - -#ifndef _MBVIEWWRAPPER_H -#define _MBVIEWWRAPPER_H -#include "layout.h" -#include <View.h> - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MBViewWrapper : public MView, public BView -{ - public: MBViewWrapper(BView *view, bool usepreferred=true, bool x_fixed=true, bool y_fixed=true); - MBViewWrapper(BMessage*); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - virtual ~MBViewWrapper(); - virtual minimax layoutprefs(); - virtual BRect layout(BRect rect); - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); - - private: virtual void _expansionmbviewwrapper1(); - - BView *childview; - - uint32 _expansiondata[2]; -}; - -#endif diff --git a/beos/liblayout/MBorder.h b/beos/liblayout/MBorder.h deleted file mode 100644 index 4e925ec2d..000000000 --- a/beos/liblayout/MBorder.h +++ /dev/null @@ -1,68 +0,0 @@ - -#ifndef _MBORDER_H -#define _MBORDER_H -#include "MGroup.h" - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MBorder : public MGroup, public BView -{ - public: - enum { - ROTATE_REVERSE=(int)0x80000000 - }; - - MBorder(ulong border_type,ulong spacing,char *name=NULL,MView *kid=NULL); - MBorder(BMessage*); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - ~MBorder(); - virtual minimax layoutprefs(); - virtual BRect layout(BRect rect); - virtual void Draw(BRect); - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); - virtual void FrameResized(float width, float height); - void DrawBorder(); - void SetLabel(char *); - char *Label(); - void SetHighlight(int); - void SetHighlightColors(rgb_color color1, rgb_color color2, rgb_color color3); - - private: - virtual void _expansionmborder1(); - virtual void _expansionmborder2(); - - static long _cycler(void *arg); - void Cycler(); - int highlightmode; - thread_id cycler; - - ulong bordertype; - ulong extraspacing; - ulong extralabelspacing; - char *label; - char *truncatedlabel; - - rgb_color *highlightcolors; - - uint32 _expansiondata[1]; -}; - - -enum -{ - M_NO_BORDER, - M_RAISED_BORDER, - M_DEPRESSED_BORDER, - M_LABELED_BORDER, - M_ETCHED_BORDER -}; - -enum -{ - M_SHOW_FULL_LABEL= 0x00000100 -}; -#endif diff --git a/beos/liblayout/MButton.h b/beos/liblayout/MButton.h deleted file mode 100644 index 64cd3e32b..000000000 --- a/beos/liblayout/MButton.h +++ /dev/null @@ -1,53 +0,0 @@ - -#ifndef _MBUTTON -#define _MBUTTON -#include "layout.h" -#include <Button.h> - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MButton : public MView, public BButton -{ - public: ulong ID; - - MButton(const char *label, ulong id=0,minimax size=minimax(-1,-1,1E6,1E6,1)); - MButton(const char *label, BMessage *message, BHandler *handler=NULL, minimax size=minimax(-1,-1,1E6,1E6,1)); - MButton(BMessage*); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - - virtual ~MButton(); - void SetRepeat(ulong initial_delay, ulong repeat_delay); - virtual minimax layoutprefs(); - virtual BRect layout(BRect rect); - virtual void setcolor(rgb_color, bool); - - virtual void Draw(BRect); - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); - - virtual void MouseDown(BPoint); - - private: static long _mousetracker(void *arg); - void _MouseTracker(); - thread_id mousethread; - BHandler *target; - int64 lastwhen; - ulong initialdelay; - ulong repeatdelay; - void initobject(); - ulong buttonmask; - - uint32 _expansiondata[2]; -}; - -extern const IMPEXPLIBLAYOUT char M_BUTTON_POINTER[]; -extern const IMPEXPLIBLAYOUT char M_BUTTON_ID[]; -extern const IMPEXPLIBLAYOUT char M_BUTTON_MASK[]; -extern const IMPEXPLIBLAYOUT char M_DOUBLECLICK[]; -extern const IMPEXPLIBLAYOUT char M_REPEAT[]; -extern const IMPEXPLIBLAYOUT char M_RELEASE[]; - -#endif diff --git a/beos/liblayout/MCheckBox.h b/beos/liblayout/MCheckBox.h deleted file mode 100644 index 7b39abda2..000000000 --- a/beos/liblayout/MCheckBox.h +++ /dev/null @@ -1,33 +0,0 @@ - -#ifndef _MCHECKBOX -#define _MCHECKBOX -#include "layout.h" -#include <CheckBox.h> - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MCheckBox : public MView, public BCheckBox -{ - public: MCheckBox(const char *label,ulong id=0, bool state=false); - MCheckBox(const char *label, BMessage *message, BHandler *handler=NULL, bool state=false); - MCheckBox(BMessage*); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - - virtual ~MCheckBox(); - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); - - virtual minimax layoutprefs(); - virtual BRect layout(BRect rect); - - private: BHandler *target; - uint32 _expansiondata[2]; -}; - -extern const IMPEXPLIBLAYOUT char M_CHECKBOX_POINTER[]; -extern const IMPEXPLIBLAYOUT char M_CHECKBOX_ID[]; - -#endif diff --git a/beos/liblayout/MDividable.h b/beos/liblayout/MDividable.h deleted file mode 100644 index 800772b88..000000000 --- a/beos/liblayout/MDividable.h +++ /dev/null @@ -1,35 +0,0 @@ - -// Abstract base class for an object that can be 'divided'. -// Currently this includes MTextControl and MPopup. -// The dividable class, and the global function below, is -// used to align the left half (the label) and the right -// half (data-entry/selection) of a group of MDividable's - -#ifndef _MDIVIDABLE_H -#define _MDIVIDABLE_H - -#include "layout.h" - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MDividable -{ - public: - float labelwidth; - MDividable *rolemodel; - - public: - MDividable(); -// work around my own bug... -#ifdef BUILDING_LIBLAYOUT - ~MDividable(); -#endif - void DivideSameAs(MDividable *); - virtual float LabelWidth(); -}; - -extern void IMPEXPLIBLAYOUT DivideSame(MView *, MView *, ...); - -#endif diff --git a/beos/liblayout/MDragBar.h b/beos/liblayout/MDragBar.h deleted file mode 100644 index e345668c4..000000000 --- a/beos/liblayout/MDragBar.h +++ /dev/null @@ -1,38 +0,0 @@ - -#ifndef _MDRAGBAR_H -#define _MDRAGBAR_H -#include "layout.h" -#include <Control.h> - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MDragBar : public MView, public BControl -{ - public: MDragBar(minimax size=minimax(1,1,1E6,1E6)); - MDragBar(BMessage*); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - virtual ~MDragBar(); - - virtual minimax layoutprefs(); - virtual BRect layout(BRect rect); - virtual void AttachedToWindow(); - virtual void Draw(BRect rect); - virtual void KeyDown(const char *bytes, int32 numbytes); - virtual void DetachedFromWindow(); - virtual void MouseDown(BPoint); - - private: virtual void _expansionmdragbar1(); - - thread_id mousethread; - BPoint dragpoint; - - static long _mousetracker(void *arg); - void _MouseTracker(); - - uint32 _expansiondata[2]; -}; - -#endif diff --git a/beos/liblayout/MEject.h b/beos/liblayout/MEject.h deleted file mode 100644 index a9c017346..000000000 --- a/beos/liblayout/MEject.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef _MEJECT_H -#define _MEJECT_H - -#include "MPictureButton.h" - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MEject : public MPictureButton -{ - public: MEject(BHandler *id); - MEject(BHandler *id, BMessage*); - MEject(BMessage*); - virtual ~MEject(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - - virtual void MakePictures(); -}; -extern const IMPEXPLIBLAYOUT char M_BUTTON_POINTER[]; - -#endif diff --git a/beos/liblayout/MFFWD.h b/beos/liblayout/MFFWD.h deleted file mode 100644 index 97c0d53e1..000000000 --- a/beos/liblayout/MFFWD.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _MFFWD_H -#define _MFFWD_H - -#include "MPictureButton.h" - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MFFWD : public MPictureButton -{ - public: MFFWD(BHandler *id=NULL); - MFFWD(BHandler *id, BMessage*); - MFFWD(BMessage*); - virtual ~MFFWD(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - - virtual void MakePictures(); -}; - -extern const IMPEXPLIBLAYOUT char M_BUTTON_POINTER[]; - -#endif diff --git a/beos/liblayout/MGroup.h b/beos/liblayout/MGroup.h deleted file mode 100644 index 73dcbfb9c..000000000 --- a/beos/liblayout/MGroup.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - - MGroup is an abstract class from which all groups should derive. - -*/ - -#ifndef _MGROUP_H -#define _MGROUP_H - -#include "layout.h" -#include <View.h> - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MGroup : public MView -{ - public: MGroup(); - virtual ~MGroup(); - - virtual void reloadfont(BFont *font[]); -}; - -typedef struct -{ - MView *kid; - int kidnum; -} sortstruct; - -#endif diff --git a/beos/liblayout/MListView.h b/beos/liblayout/MListView.h deleted file mode 100644 index 95c4d42ca..000000000 --- a/beos/liblayout/MListView.h +++ /dev/null @@ -1,30 +0,0 @@ - -#ifndef _MLISTVIEW_H -#define _MLISTVIEW_H -#include "layout.h" -#include <ListView.h> - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MListView : public MView, public BListView -{ - public: MListView(list_view_type type=B_SINGLE_SELECTION_LIST, - minimax size=minimax(50,50)); - MListView(BMessage*); - virtual ~MListView(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - virtual void reloadfont(BFont *font[]); - virtual minimax layoutprefs(); - virtual BRect layout(BRect rect); - virtual void MessageReceived(BMessage*); - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); - - private: virtual void _expansionmlistview1(); - uint32 _expansiondata[2]; -}; - -#endif diff --git a/beos/liblayout/MMenuBar.h b/beos/liblayout/MMenuBar.h deleted file mode 100644 index a5b061a19..000000000 --- a/beos/liblayout/MMenuBar.h +++ /dev/null @@ -1,33 +0,0 @@ - -#ifndef _MMENUBAR_H -#define _MMENUBAR_H - -#include "layout.h" -#include <MenuBar.h> - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MMenuBar: public MView, public BMenuBar -{ - public: - MMenuBar(menu_layout layout=B_ITEMS_IN_ROW); - MMenuBar(menu_layout layout, bool resizetofit); - MMenuBar(BMessage*); - virtual ~MMenuBar(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - - virtual minimax layoutprefs(); - virtual BRect layout(BRect); - virtual void reloadfont(BFont *font[]); - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); - private: - virtual void _expansionmmenubar1(); - virtual void _expansionmmenubar2(); - - uint32 _expansiondata[2]; -}; -#endif diff --git a/beos/liblayout/MOutlineListView.h b/beos/liblayout/MOutlineListView.h deleted file mode 100644 index acb00e19b..000000000 --- a/beos/liblayout/MOutlineListView.h +++ /dev/null @@ -1,32 +0,0 @@ - -#ifndef _MOUTLINELISTVIEW_H -#define _MOUTLINELISTVIEW_H -#include "layout.h" -#include <OutlineListView.h> - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MOutlineListView : public MView, public BOutlineListView -{ - public: MOutlineListView(list_view_type type=B_SINGLE_SELECTION_LIST, - minimax size=minimax(50,50)); - MOutlineListView(BMessage*); - virtual ~MOutlineListView(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - virtual void reloadfont(BFont *font[]); - virtual minimax layoutprefs(); - virtual BRect layout(BRect rect); - virtual void MessageReceived(BMessage*); - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); - - private: virtual void _expansionmoutlinelistview1(); - virtual void _expansionmoutlinelistview2(); - - uint32 _expansiondata[2]; -}; - -#endif diff --git a/beos/liblayout/MPictureButton.h b/beos/liblayout/MPictureButton.h deleted file mode 100644 index 687b5c28a..000000000 --- a/beos/liblayout/MPictureButton.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef _MPICTUREBUTTON_H -#define _MPICTUREBUTTON_H - -#include "layout.h" -#include <PictureButton.h> - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MPictureButton : public MView, public BPictureButton -{ - public: - MPictureButton(minimax size, BPicture *off, BPicture *on, - BMessage *message=NULL, BHandler *target=NULL, - uint32 behavior=B_ONE_STATE_BUTTON); - MPictureButton(BMessage *archive); - virtual ~MPictureButton(); - void SetRepeat(ulong initial_delay, ulong repeat_delay); - - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - - virtual minimax layoutprefs(); - virtual BRect layout(BRect); - virtual void setcolor(rgb_color col, bool deep=false); - virtual void MakePictures(); - - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); - virtual void MouseDown(BPoint); - - private: - virtual void _expansionmpicturebutton1(); - virtual void _expansionmpicturebutton2(); - - thread_id mousethread; - int64 lastwhen; - ulong initialdelay; - ulong repeatdelay; - ulong buttonmask; - BHandler *target; - - static long _mousetracker(void *arg); - void _MouseTracker(); - - uint32 _expansiondata[2]; -}; - -extern const IMPEXPLIBLAYOUT char M_DOUBLECLICK[]; -extern const IMPEXPLIBLAYOUT char M_BUTTON_MASK[]; -extern const IMPEXPLIBLAYOUT char M_REPEAT[]; -extern const IMPEXPLIBLAYOUT char M_RELEASE[]; - -#endif diff --git a/beos/liblayout/MPlayBW.h b/beos/liblayout/MPlayBW.h deleted file mode 100644 index 043aa46d3..000000000 --- a/beos/liblayout/MPlayBW.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef _MPLAYBW_H -#define _MPLAYBW_H - -#include "MPictureButton.h" - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MPlayBW : public MPictureButton -{ - public: MPlayBW(BHandler*); - MPlayBW(BHandler *id, BMessage*); - MPlayBW(BMessage*); - virtual ~MPlayBW(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - - virtual void MakePictures(); -}; -extern const IMPEXPLIBLAYOUT char M_BUTTON_POINTER[]; - -#endif diff --git a/beos/liblayout/MPlayFW.h b/beos/liblayout/MPlayFW.h deleted file mode 100644 index 7f847df7b..000000000 --- a/beos/liblayout/MPlayFW.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef _MPLAYFW_H -#define _MPLAYFW_H - -#include "MPictureButton.h" - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MPlayFW : public MPictureButton -{ - public: MPlayFW(BHandler*); - MPlayFW(BHandler *id, BMessage*); - MPlayFW(BMessage*); - virtual ~MPlayFW(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - virtual void MakePictures(); -}; -extern const IMPEXPLIBLAYOUT char M_BUTTON_POINTER[]; - -#endif diff --git a/beos/liblayout/MPopup.h b/beos/liblayout/MPopup.h deleted file mode 100644 index 2223664ec..000000000 --- a/beos/liblayout/MPopup.h +++ /dev/null @@ -1,45 +0,0 @@ - -#ifndef _MPOPUP_H -#define _MPOPUP_H -#include "layout.h" -#include "MDividable.h" -#include <MenuField.h> - -class BPopUpMenu; - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MPopup: - public MView, public MDividable, public BMenuField -{ - public: MPopup(char *label, char *item ...); - MPopup(char *label, BMessage*, BHandler *, char *item ...); - MPopup(BMessage*); - virtual ~MPopup(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - - virtual float LabelWidth(); - - virtual minimax layoutprefs(); - virtual BRect layout(BRect rect); - virtual void reloadfont(BFont *font[]); - void SetActive(ulong, bool send=true); - void EnableItem(ulong index, bool enabled); - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); - - private: virtual void _expansionmpopup1(); - - char *poplabel; - BHandler *target; - BPopUpMenu *popup; - - uint32 _expansiondata[2]; -}; - -extern const IMPEXPLIBLAYOUT char M_POPUP_POINTER_NAME[]; - -#endif diff --git a/beos/liblayout/MProgressBar.h b/beos/liblayout/MProgressBar.h deleted file mode 100644 index 3938c2583..000000000 --- a/beos/liblayout/MProgressBar.h +++ /dev/null @@ -1,58 +0,0 @@ - -#ifndef _MSTATUSBAR_H -#define _MSTATUSBAR_H -#include "layout.h" -#include <View.h> - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MProgressBar : public MView, public BView -{ - public: float value; - float currentwidth; - - public: MProgressBar(BHandler *, bool pulsed_updates=false); - MProgressBar(BMessage*); - virtual ~MProgressBar(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - - virtual minimax layoutprefs(); - virtual BRect layout(BRect rect); - virtual void setcolor(rgb_color,bool); - void setbarcolor(rgb_color); - rgb_color getbarcolor() {return bar_fill;}; - virtual void Draw(BRect); - virtual void Pulse(); - void Refresh(); - void SetValue(float value); - virtual void MouseDown(BPoint); - virtual void WindowActivated(bool); - virtual void FrameResized(float,float); - virtual void MessageReceived(BMessage *mes); - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); - - private: virtual void _expansionmprogressbar1(); - virtual void _expansionmprogressbar2(); - - thread_id mousethread; - static long _mousetracker(void *arg); - long mousetracker(); - - BRect lastbounds; - BHandler *target; - rgb_color bar_hi; - rgb_color bar_fill; - rgb_color bar_low; - float barwidth; - - uint32 _expansiondata[2]; -}; - -extern const IMPEXPLIBLAYOUT char M_PROGRESSBAR_FRACTION[]; - -#endif - diff --git a/beos/liblayout/MRadioGroup.h b/beos/liblayout/MRadioGroup.h deleted file mode 100644 index bb430f2da..000000000 --- a/beos/liblayout/MRadioGroup.h +++ /dev/null @@ -1,46 +0,0 @@ - -#ifndef _MRADIOGROUP_H -#define _MRADIOGROUP_H -#include "MGroup.h" -#include <RadioButton.h> - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MRadioGroup : public MGroup, public BView -{ - public: MRadioGroup(char *item ...); - MRadioGroup(BMessage *model, char *item ...); - MRadioGroup(BMessage *model, BHandler *target, char *item ...); - MRadioGroup(BMessage*); - virtual ~MRadioGroup(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - - virtual minimax layoutprefs(); - virtual BRect layout(BRect rect); - virtual void SetActive(ulong); - virtual long ActiveButton(); - virtual void reloadfont(BFont *font[]); - virtual void setcolor(rgb_color col,bool deep); - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); - - private: virtual void _expansionmradiogroup1(); - virtual void _expansionmradiogroup2(); - - ulong numradios; - BHandler *handler; - - uint32 _expansiondata[3]; -}; - -extern const IMPEXPLIBLAYOUT char M_RADIO_POINTER_NAME[]; -extern const IMPEXPLIBLAYOUT char M_RADIO_INDEX_NAME[]; - - -#endif - - - diff --git a/beos/liblayout/MRew.h b/beos/liblayout/MRew.h deleted file mode 100644 index f21683b5d..000000000 --- a/beos/liblayout/MRew.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef _MREW_H -#define _MREW_H - -#include "MPictureButton.h" - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MRew : public MPictureButton -{ - public: MRew(BHandler*); - MRew(BHandler *id, BMessage*); - MRew(BMessage*); - virtual ~MRew(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - virtual void MakePictures(); -}; -extern const IMPEXPLIBLAYOUT char M_BUTTON_POINTER[]; - -#endif diff --git a/beos/liblayout/MScrollView.h b/beos/liblayout/MScrollView.h deleted file mode 100644 index 8ba21ce0e..000000000 --- a/beos/liblayout/MScrollView.h +++ /dev/null @@ -1,39 +0,0 @@ - -#ifndef _MSCROLLVIEW_H -#define _MSCROLLVIEW_H - -#include "layout.h" -#include <ScrollView.h> - -// An MScrollView accepts another MView as its target. -// The MScrollView will display scrollbars as requested -// so that the target MView may be scrolled left/right or -// up/down. - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MScrollView: public MView, public BScrollView -{ - public: - MScrollView(MView *target, bool horizontal=false, bool vertical=false, - border_style border=B_FANCY_BORDER, minimax size=0); - MScrollView(BMessage*); - virtual ~MScrollView(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - virtual minimax layoutprefs(); - virtual BRect layout(BRect); - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); - - private: - MView *kid; - float leftinset; - float rightinset; - float topinset; - float bottominset; -}; - -#endif diff --git a/beos/liblayout/MSlider.h b/beos/liblayout/MSlider.h deleted file mode 100644 index 6e7077d3d..000000000 --- a/beos/liblayout/MSlider.h +++ /dev/null @@ -1,30 +0,0 @@ - - -#ifndef _MSLIDER_H -#define _MSLIDER_H - -#include "layout.h" -#include "Slider.h" - -class IMPEXPLIBLAYOUT MSlider: public MView, public BSlider -{ - public: - MSlider(const char *label, int32 minval, int32 maxval,int32 granularity=1, BMessage *message=NULL, BHandler *target=NULL, thumb_style ts=B_BLOCK_THUMB); - virtual ~MSlider(); - virtual void AllAttached(); - virtual void DetachedFromWindow(); - virtual void SetValue(int32 value); - void SetGranularity(int32 granul); - - virtual minimax layoutprefs(); - virtual BRect layout(BRect); - - private: - virtual void _expansionmslider1(); - virtual void _expansionmslider2(); - BHandler *target; - int32 granularity; - uint32 _expansiondata[4]; -}; - -#endif diff --git a/beos/liblayout/MSplitter.h b/beos/liblayout/MSplitter.h deleted file mode 100644 index 411c5d14f..000000000 --- a/beos/liblayout/MSplitter.h +++ /dev/null @@ -1,38 +0,0 @@ - -#ifndef _MSPLITTER_H -#define _MSPLITTER_H - -#include "layout.h" - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MSplitter : public MView, public BView -{ - public: MSplitter(); - MSplitter(bool cosmetic); - MSplitter(BMessage*); - virtual ~MSplitter(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - - virtual minimax layoutprefs(); - virtual BRect layout(BRect rect); - virtual void MouseDown(BPoint); - virtual void Draw(BRect); - virtual void MouseMoved(BPoint, ulong, const BMessage*); - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); - - private: - float siblingweight; - MView *previoussibling; - MView *nextsibling; - thread_id mousethread; - static long _mousetracker(void *); - void _MouseTracker(void); - uint32 _expansiondata[2]; -}; - -#endif diff --git a/beos/liblayout/MStop.h b/beos/liblayout/MStop.h deleted file mode 100644 index b99fc2fe4..000000000 --- a/beos/liblayout/MStop.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef _MSTOP_H -#define _MSTOP_H - -#include "MPictureButton.h" - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MStop : public MPictureButton -{ - public: MStop(BHandler*); - MStop(BHandler *id, BMessage*); - MStop(BMessage*); - virtual ~MStop(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - virtual void MakePictures(); -}; -extern const IMPEXPLIBLAYOUT char M_BUTTON_POINTER[]; - -#endif diff --git a/beos/liblayout/MStringView.h b/beos/liblayout/MStringView.h deleted file mode 100644 index 4db74452e..000000000 --- a/beos/liblayout/MStringView.h +++ /dev/null @@ -1,25 +0,0 @@ - -#ifndef _MSTRINGVIEW_H -#define _MSTRINGVIEW_H -#include "layout.h" -#include <StringView.h> - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MStringView : public MView, public BStringView -{ - public: MStringView(const char *label,alignment a=B_ALIGN_LEFT,minimax size=minimax(10,10,65536,65536,1)); - MStringView(BMessage*); - virtual ~MStringView(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - - virtual minimax layoutprefs(); - virtual BRect layout(BRect rect); - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); -}; - -#endif diff --git a/beos/liblayout/MTabView.h b/beos/liblayout/MTabView.h deleted file mode 100644 index 04c69ec59..000000000 --- a/beos/liblayout/MTabView.h +++ /dev/null @@ -1,33 +0,0 @@ - -#ifndef _MTABVIEW_H -#define _MTABVIEW_H - -#include <TabView.h> -#include "MGroup.h" - -class IMPEXPLIBLAYOUT MTab: public BTab -{ - public: - MTab(MView *view, const char *name=NULL); - MTab(BMessage *archive); - virtual ~MTab(); -}; - - -class IMPEXPLIBLAYOUT MTabView: public MGroup, public BTabView -{ - public: - MTabView(); - MTabView(BMessage *archive); - virtual void Add(MTab *tab); - virtual void Select(int32 tab); - - virtual void reloadfont(BFont *font[]); - virtual minimax layoutprefs(); - virtual BRect layout(BRect); - - private: - void LayoutCurrentTab(); -}; - -#endif diff --git a/beos/liblayout/MTextControl.h b/beos/liblayout/MTextControl.h deleted file mode 100644 index 46f1a746f..000000000 --- a/beos/liblayout/MTextControl.h +++ /dev/null @@ -1,36 +0,0 @@ - -#ifndef _MTEXTCONTROL_H -#define _MTEXTCONTROL_H -#include "layout.h" -#include "MDividable.h" -#include <TextControl.h> - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MTextControl: - public MView, public MDividable, public BTextControl -{ - public: MTextControl(char *label, char *text); - MTextControl(char *label, char *text, BMessage *mes); - MTextControl(BMessage*); - virtual ~MTextControl(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - - virtual void SetLabel(const char *); - virtual float LabelWidth(); - - virtual minimax layoutprefs(); - virtual BRect layout(BRect rect); - virtual void reloadfont(BFont *font[]); - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); - - private: float lastheight; - - uint32 _expansiondata[2]; -}; - -#endif diff --git a/beos/liblayout/MTextView.h b/beos/liblayout/MTextView.h deleted file mode 100644 index 512a85cd1..000000000 --- a/beos/liblayout/MTextView.h +++ /dev/null @@ -1,31 +0,0 @@ - -#ifndef _MTEXTVIEW_H -#define _MTEXTVIEW_H -#include "layout.h" -#include <TextView.h> - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MTextView : public MView, public BTextView -{ - public: MTextView(minimax size=0); - MTextView(BMessage*); - virtual ~MTextView(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - - virtual minimax layoutprefs(); - virtual BRect layout(BRect rect); - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); - virtual void MessageReceived(BMessage *mes); - - private: void initobject(); - static long AsyncSetTextRect(void *arg); - thread_id resizer; - uint32 _expansiondata[2]; -}; - -#endif diff --git a/beos/liblayout/MVolume.h b/beos/liblayout/MVolume.h deleted file mode 100644 index 9d70b7955..000000000 --- a/beos/liblayout/MVolume.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef _MVOLUME_H -#define _MVOLUME_H - -#include "layout.h" -#include <Control.h> - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MVolume : public MView, public BControl -{ - public: MVolume(BHandler*); - MVolume(BMessage*); - virtual ~MVolume(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - - virtual minimax layoutprefs(); - BRect layout(BRect); - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); - virtual void Draw(BRect); - virtual void DrawVolume(void); - float Volume(); - void SetVolume(float vol); - virtual void MouseDown(BPoint); - virtual void KeyDown(const char *bytes, int32 numbytes); - - private: float volume; - BHandler *target; - BPoint lastvoldot; - BPoint clickpoint; - thread_id mousethread; - bool ispressed; - // moved into private area 21-6-98 - static long _mousetracker(void *arg); - void _MouseTracker(); - // added 21-6-98 - void _PUMouseTracker(); -}; - -inline float MVolume::Volume() -{ - return volume; -} - -#endif diff --git a/beos/liblayout/MWindow.h b/beos/liblayout/MWindow.h deleted file mode 100644 index 6118f87bc..000000000 --- a/beos/liblayout/MWindow.h +++ /dev/null @@ -1,62 +0,0 @@ - -#ifndef _MWINDOW_H -#define _MWINDOW_H - -#include "layout.h" -#include <Window.h> - -class BPopUpMenu; - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT MWindow : public BWindow -{ - public: - ulong flags; - - MWindow(BRect r,const char *name,window_type type,uint32 flags, uint32 workspaces=B_CURRENT_WORKSPACE); - MWindow(BRect r,const char *name,window_look look, window_feel feel,uint32 flags, uint32 workspaces=B_CURRENT_WORKSPACE); - MWindow(BMessage*); - virtual ~MWindow(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - - virtual const BFont *getfont(fontspec font); - - virtual void MessageReceived(BMessage *message); - virtual void Show(); - virtual void RecalcSize(); - virtual void FrameResized(float width, float height); - - virtual status_t GetSupportedSuites(BMessage *message); - virtual BHandler *ResolveSpecifier(BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property); - virtual void ScreenChanged(BRect frame, color_space mode); - virtual void WorkspaceActivated(int32 workspace, bool active); - - void StartDragging(); - static long _mousetracker(void *arg); - void _MouseTracker(); - - private: - virtual void _expansionmwindow1(); - virtual void _expansionmwindow2(); - virtual void _expansionmwindow3(); - - void initobject(); - BFont **fontlist; - BRect lastrect; - BPopUpMenu *pop; - thread_id mousethread; - BPoint dragpoint; - - uint32 _expansiondata[1]; -}; - -enum { - M_WIN_AUTORESIZE =0x00000100, - M_WIN_ESCAPETOCLOSE=0x00000200 -}; - -#endif // MWINDOW_H diff --git a/beos/liblayout/PropGadget.h b/beos/liblayout/PropGadget.h deleted file mode 100644 index 81a3f1f9b..000000000 --- a/beos/liblayout/PropGadget.h +++ /dev/null @@ -1,75 +0,0 @@ - -#ifndef _PROPGADGET -#define _PROPGADGET -#include "layout.h" -#include <Control.h> -#include <Bitmap.h> - -class IMPEXPLIBLAYOUT PropGadget; - -typedef void (*propgadget_hook)(PropGadget*, void*, double, double); - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class PropGadget : public MView, public BControl -{ - public: PropGadget(double xprop, double xval, double yprop, double yval, - BBitmap *knobimage=NULL, - propgadget_hook=NULL, - void *callbackarg=NULL, - long extraspacing=0); - PropGadget(BMessage*); - virtual ~PropGadget(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - - BBitmap* Pknob; - - virtual void Draw(BRect); - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); - virtual void MouseDown(BPoint); - - void SetProportion(double, double); - void SetProportionNoDraw(double,double); - virtual void SetValues(double,double); - void SetValuesNoDraw(double,double); - virtual void FrameResized(float,float); - void ReDraw(); - inline double Hval() {return hval;} - inline double Vval() {return 1.0-vval;} - - virtual minimax layoutprefs(); - virtual BRect layout(BRect rect); - virtual void setcolor(rgb_color col, bool deep=false); - virtual void DrawContainer(BRect); - virtual void DrawKnob(BRect); - virtual void KeyDown(const char *bytes, int32 numbytes); - bool IsBusy(); - - private: virtual void _expansionpropgadget1(); - virtual void _expansionpropgadget2(); - - thread_id mousethread; - BPoint clickpoint; - BRect lastknobrect; - bool _isbusy; - bool vertical; - bool horizontal; - - double hprop; - double hval; - double vprop; - double vval; - void (*callback)(PropGadget*,void*,double,double); - void *callbackarg; - long borderspacing; - - static long _mousetracker(void *arg); - void _MouseTracker(); - - uint32 _expansiondata[2]; -}; -#endif diff --git a/beos/liblayout/Space.h b/beos/liblayout/Space.h deleted file mode 100644 index c49f6fbd2..000000000 --- a/beos/liblayout/Space.h +++ /dev/null @@ -1,22 +0,0 @@ - -#ifndef _SPACE_H -#define _SPACE_H -#include "layout.h" -#include "View.h" - -#if __POWERPC__ -#pragma simple_class_byval off -#endif -class IMPEXPLIBLAYOUT Space : public MView, public BView -{ - public: Space(); - Space(minimax); - Space(BMessage*); - virtual ~Space(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - virtual minimax layoutprefs(); - virtual BRect layout(BRect rect); -}; - -#endif diff --git a/beos/liblayout/SpinButton.h b/beos/liblayout/SpinButton.h deleted file mode 100644 index 3bb00db69..000000000 --- a/beos/liblayout/SpinButton.h +++ /dev/null @@ -1,78 +0,0 @@ - -#ifndef _SPINBUTTON_H -#define _SPINBUTTON_H - -#include <View.h> -#include "layout.h" -#include "HGroup.h" -#include "MTextControl.h" - -enum spinmode -{ - SPIN_FLOAT, - SPIN_INTEGER -}; - -class NumberTextView; -class TinyButton; -#if __POWERPC__ -#pragma warn_hidevirtual off -#endif -class IMPEXPLIBLAYOUT SpinButton: public MView, public MDividable, public BControl -{ - public: - SpinButton(const char *label,spinmode mode, BHandler *target=NULL); - virtual ~SpinButton(); - - virtual void reloadfont(BFont *font[]); - virtual minimax layoutprefs(); - virtual BRect layout(BRect); - - virtual float LabelWidth(); - - virtual void AllAttached(); - virtual void DetachedFromWindow(); - virtual void Draw(BRect); - virtual void MessageReceived(BMessage *mes); - virtual void SetEnabled(bool); - - double Increment(); - double Decrement(); - double StepSize(); - void SetStepSize(double step); - - virtual void SetValue(int32 v); - virtual void SetValue(double v); - double Value(); - double Maximum(); - void SetMaximum(double max); - double Minimum(); - void SetMinimum(double min); - const char * Format() const; - void SetFormat(const char *f); - - private: - spinmode mode; - ulong height; - TinyButton *tb1,*tb2; - NumberTextView *tv; - long lx,ly; - void NotifyWorld(BMessage *mes); - BHandler *target; - uint32 _expansiondata[4]; -}; - -enum -{ - M_SPIN_UP='!!up', - M_SPIN_DOWN='!!dn', - M_SPIN_TICK='!spn' -}; - -extern const IMPEXPLIBLAYOUT char M_RELEASE[]; - -#if __POWERPC__ -#pragma warn_hidevirtual on -#endif - -#endif diff --git a/beos/liblayout/TabGroup.h b/beos/liblayout/TabGroup.h deleted file mode 100644 index 64a2cf9cc..000000000 --- a/beos/liblayout/TabGroup.h +++ /dev/null @@ -1,46 +0,0 @@ - -#ifndef _TABGROUP_H -#define _TABGROUP_H - -#include "MGroup.h" -#include <Control.h> - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT TabGroup : public MGroup, public BControl -{ - public: TabGroup(minimax mpm,char *arg=0, ...); - TabGroup(char *arg=0, ...); - TabGroup(BMessage*); - virtual ~TabGroup(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - virtual minimax layoutprefs(); - virtual BRect layout(BRect rect); - virtual void AttachedToWindow(); - virtual void MouseDown(BPoint point); - virtual void Draw(BRect clip); - virtual void KeyDown(const char *bytes, int32 numbytes); - virtual void ActivateTab(int); - int32 ActiveTab(); - virtual void DetachedFromWindow(); - virtual void SetEnabled(bool enabled); - void SetExtraSpacing(float spacing); - float ExtraSpacing(); - - private: virtual void _expansiontabgroup1(); - virtual void _expansiontabgroup2(); - - int numkids; - int activekid; - float tabheight; - float biggesttabmin; - float fontdescent; - float extraspacing; - - uint32 _expansiondata[1]; -}; - -#endif diff --git a/beos/liblayout/VGroup.h b/beos/liblayout/VGroup.h deleted file mode 100644 index 56be070df..000000000 --- a/beos/liblayout/VGroup.h +++ /dev/null @@ -1,41 +0,0 @@ - -#ifndef _VGROUP_H -#define _VGROUP_H -#include "MGroup.h" -#include <View.h> - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -class IMPEXPLIBLAYOUT VGroup : public MGroup, public BView -{ - public: VGroup(minimax mpm,MView *kid=0, ...); - VGroup(MView *kid=0, ...); - VGroup(BMessage*); - virtual ~VGroup(); - virtual long Archive(BMessage *archive, bool deep=true) const; - static BArchivable *Instantiate(BMessage *archive); - virtual minimax layoutprefs(); - virtual BRect layout(BRect rect); - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); - virtual void MouseDown(BPoint); - - private: virtual void _expansionvgroup1(); - virtual void _expansionvgroup2(); - virtual void _expansionvgroup3(); - - static int cmpkids(const void* v1,const void *v2); - int *size; - float totalweight; - int numkids; - sortstruct *childorder; - MView **mkid; - float totalminy,totalmaxy; - BRect *lastrect; - - uint32 _expansiondata[2]; -}; - -#endif diff --git a/beos/liblayout/layout-all.h b/beos/liblayout/layout-all.h deleted file mode 100644 index b2e78df10..000000000 --- a/beos/liblayout/layout-all.h +++ /dev/null @@ -1,35 +0,0 @@ -#include "MApplication.h" -#include "MWindow.h" -#include "HGroup.h" -#include "VGroup.h" -#include "LayeredGroup.h" -#include "TabGroup.h" -#include "MBViewWrapper.h" -#include "MBorder.h" -#include "MButton.h" -#include "MCheckBox.h" -#include "MDividable.h" -#include "MDragBar.h" -#include "MEject.h" -#include "MFFWD.h" -#include "MListView.h" -#include "MMenuBar.h" -#include "MOutlineListView.h" -#include "MPictureButton.h" -#include "MPlayBW.h" -#include "MPlayFW.h" -#include "MPopup.h" -#include "MProgressBar.h" -#include "MRadioGroup.h" -#include "MRew.h" -#include "MScrollView.h" -#include "MSlider.h" -#include "MSplitter.h" -#include "MStop.h" -#include "MStringView.h" -#include "MTextControl.h" -#include "MTextView.h" -#include "MVolume.h" -#include "PropGadget.h" -#include "Space.h" -#include "SpinButton.h" diff --git a/beos/liblayout/layout.h b/beos/liblayout/layout.h deleted file mode 100644 index 772b251db..000000000 --- a/beos/liblayout/layout.h +++ /dev/null @@ -1,168 +0,0 @@ -/* - - Lowest-level classes in liblayout - - minimax, used to store information about minimum size, maximum size, and weigth of objects - - MView, a class that knows how to layout itself - -*/ - -#ifndef _LAYOUT_H -#define _LAYOUT_H - -#if __POWERPC__ -#pragma simple_class_byval off -#endif - -#include <BeBuild.h> - -#if !defined(IMPEXPLIBLAYOUT) && defined(BUILDING_LIBLAYOUT) -#define IMPEXPLIBLAYOUT _EXPORT -#else -#define IMPEXPLIBLAYOUT _IMPORT -#endif - -#include <Rect.h> -#include <GraphicsDefs.h> -#include <stdlib.h> - -class BMessage; -class BFont; - -// use macro to make code slightly more readable -#define MVPTR(x) dynamic_cast<MView*>(x) - -enum fontspec -{ - M_PLAIN_FONT=0, - M_BOLD_FONT, - M_FIXED_FONT -}; - - -// this structure is exported from liblayout, and contains the version number -struct LAYOUT_VERSION_INFO -{ - uchar major; - uchar minor; - ushort patchlevel; -}; - -extern "C" LAYOUT_VERSION_INFO IMPEXPLIBLAYOUT LIBLAYOUT_VERSION; - - -class IMPEXPLIBLAYOUT minimax // Order now, by dialing the number on your screen! -{ -struct xypair { float x,y;}; - - public: xypair mini; - xypair maxi; - float weight; - - minimax(int minx=0,int miny=0, - int maxx=10000,int maxy=10000, - float wght=1.0); -}; - -class IMPEXPLIBLAYOUT MView -{ - protected: rgb_color FILL_COLOR; - rgb_color LOW_COLOR; - rgb_color HI_COLOR; - - // helper functions for archiving/unarchiving the MView - // part of MView hybrids - status_t archive(BMessage *); - status_t unarchive(BMessage *); - - public: minimax mpm; // currently active minimax (calculated from ct_mpm and environmental constraints) - minimax ct_mpm; // size specified at construction-time - ulong flags; // various flags - // upper 16 bits are reserve for liblayout-use - // bits 8-15 are reserved for per-class liblayout-use - // bits 0-7 are available - - MView(); - virtual ~MView(); - virtual minimax layoutprefs()=0; - virtual BRect layout(BRect rect)=0; - - // reload the font from one of the fonts in the font-array - virtual void reloadfont(BFont *font[]); - // get a BFont with the required fontspec - const BFont *getfont(fontspec font); - - // set the color of the MView - virtual void setcolor(rgb_color col, bool deep=true); - // this one calls the above function - void setcolor(uchar red, uchar green, uchar blue, bool deep=true); - rgb_color getcolor(); // get the base color (what is set through setcolor() ) - - private: - virtual void _expansionmview1(); - virtual void _expansionmview2(); - virtual void _expansionmview3(); - virtual void _expansionmview4(); - - uint32 _expansiondata[4]; -}; - - -// constants used in messaging all start with a '!' -#define M_POPUP_SELECTED '!pop' -#define M_CHECKBOX_SELECTED '!chk' -#define M_BUTTON_SELECTED '!but' -#define M_RADIO_SELECTED '!rad' -#define M_PLAYBW_SELECTED '!ylp' -#define M_PLAYFW_SELECTED '!ply' -#define M_FFWD_SELECTED '!fwd' -#define M_REW_SELECTED '!rwd' -#define M_STOP_SELECTED '!stp' -#define M_VOLUME_CHANGED '!vol' -#define M_EJECT_SELECTED '!ejt' -#define M_PREV_SELECTED '!prv' -#define M_NEXT_SELECTED '!nxt' -#define M_PROGRESSBAR_CLICKED '!pbc' -#define M_PROGRESSBAR_DRAGGED '!pbd' -#define M_PROGRESSBAR_RELEASED '!pbr' -#define M_ACTIVATE_LAYER '!lyr' - -// when sent to a window, it recalculates the entire window -#define M_RECALCULATE_SIZE '!rsz' - -// font-change message is understood by MWindow and MApplication, -// but is not generated by liblayout. -#define M_FONT_CHANGED '!FNT' - -extern IMPEXPLIBLAYOUT rgb_color M_FILL_COLOR; -extern IMPEXPLIBLAYOUT rgb_color M_LOW_COLOR; -extern IMPEXPLIBLAYOUT rgb_color M_HI_COLOR; -extern IMPEXPLIBLAYOUT rgb_color BLACK_COLOR; -extern IMPEXPLIBLAYOUT rgb_color WHITE_COLOR; - -void IMPEXPLIBLAYOUT SetDefaultColors(uchar red, uchar green, uchar blue); -void IMPEXPLIBLAYOUT SetDefaultColors(rgb_color cs); - -// misc flags -// note that not all controls responds to all flags - -enum{ - M_REPORT_IMMEDIATE= 0x00010000, // report first click on control - M_REPORT_REPEAT = 0x00020000, // report if control is clicked and held - M_REPORT_RELEASE= 0x00040000, // report release of button over control - M_REPORT_RELEASE_ALWAYS= 0x00080000, // always report release of button - M_REPORT_MASK= 0x000f0000, // all of the above - - // mostly for internal use, therefore not documented (yet) - M_USE_CALCULATED_MINX= 0x00100000, - M_USE_CALCULATED_MINY= 0x00200000, - M_USE_CALCULATED_MAXX= 0x00400000, - M_USE_CALCULATED_MAXY= 0x00800000, - M_NO_X_LEFTOVERS= 0x01000000, // don't add "leftover" space to this object - M_NO_Y_LEFTOVERS= 0x02000000, // don't add "leftover" space to this object - M_NO_COLOR_CHANGES= 0x20000000, // don't listen to color-drop messages - M_NO_FONT_CHANGES= 0x40000000, // don't listen to font-change messages - M_USE_FULL_SIZE = (int) 0x80000000 // don't respect max-size (set for grouping classes) -}; - - -#endif |