diff options
Diffstat (limited to 'beos')
51 files changed, 1973 insertions, 1577 deletions
diff --git a/beos/HBApp.cpp b/beos/HBApp.cpp index 52afce815..add6259f2 100644 --- a/beos/HBApp.cpp +++ b/beos/HBApp.cpp @@ -1,57 +1,31 @@ -/* $Id: HBApp.cpp,v 1.1.1.1 2003/11/03 12:03:51 titer Exp $ - - This file is part of the HandBrake source code. - Homepage: <http://handbrake.m0k.org/>. - It may be used under the terms of the GNU General Public License. */ - -#include <signal.h> - #include "HBApp.h" -#include "MainWindow.h" - -void SigHandler( int signal ) -{ - /* Ugly way to exit cleanly when hitting Ctrl-C */ - ((HBApp*) be_app)->fWindow->PostMessage( B_QUIT_REQUESTED ); -} +#include "HBWindow.h" int main() { - signal( SIGINT, SigHandler ); - signal( SIGHUP, SigHandler ); - signal( SIGQUIT, SigHandler ); - - /* Run the BApplication */ HBApp * app = new HBApp(); app->Run(); delete app; return 0; } -/* Constructor */ HBApp::HBApp() - : BApplication("application/x-vnd.titer-handbrake" ) + : MApplication( "application/x-vnd.titer-handbrake" ) { - fWindow = new MainWindow(); - fWindow->Show(); + fWindow = new HBWindow(); } void HBApp::MessageReceived( BMessage * message ) { switch( message->what ) { - case B_SAVE_REQUESTED: - fWindow->PostMessage( message ); - break; - default: - BApplication::MessageReceived( message ); + MApplication::MessageReceived( message ); break; } } void HBApp::RefsReceived( BMessage * message ) { - fWindow->PostMessage( message ); } diff --git a/beos/HBApp.h b/beos/HBApp.h index fb5c41c38..75f3fc173 100644 --- a/beos/HBApp.h +++ b/beos/HBApp.h @@ -1,24 +1,20 @@ -/* $Id: HBApp.h,v 1.1.1.1 2003/11/03 12:03:51 titer Exp $ - - This file is part of the HandBrake source code. - Homepage: <http://handbrake.m0k.org/>. - It may be used under the terms of the GNU General Public License. */ - #ifndef HB_HB_APP_H #define HB_HB_APP_H -#include <Application.h> +#include "layout-all.h" -class MainWindow; +class HBWindow; -class HBApp : public BApplication +class HBApp : public MApplication { public: - HBApp(); - void MessageReceived( BMessage * message ); - void RefsReceived( BMessage * message ); + HBApp(); + void MessageReceived( BMessage * message ); + void RefsReceived( BMessage * message ); - MainWindow * fWindow; + private: + HBWindow * fWindow; }; #endif + diff --git a/beos/HBWindow.cpp b/beos/HBWindow.cpp new file mode 100644 index 000000000..4bb51d61f --- /dev/null +++ b/beos/HBWindow.cpp @@ -0,0 +1,283 @@ +#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 new file mode 100644 index 000000000..52ddfbf1b --- /dev/null +++ b/beos/HBWindow.h @@ -0,0 +1,41 @@ +#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 deleted file mode 100644 index 53ea7fcfe..000000000 --- a/beos/MainWindow.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* $Id: MainWindow.cpp,v 1.4 2003/11/09 21:35:06 titer Exp $ - - This file is part of the HandBrake source code. - Homepage: <http://handbrake.m0k.org/>. - It may be used under the terms of the GNU General Public License. */ - -#include <Alert.h> -#include <Application.h> -#include <Screen.h> - -#include "MainWindow.h" -#include "ScanView.h" -#include "RipView.h" - -MainWindow::MainWindow() - : BWindow( BRect( 0,0,10,10 ), "HandBrake " VERSION, B_TITLED_WINDOW, - B_NOT_RESIZABLE | B_NOT_ZOOMABLE ) -{ - fHandle = HBInit( 1, 0 ); - - /* Add the scan view */ - fScanView = new ScanView( fHandle ); - fRipView = new RipView( fHandle ); - AddChild( fScanView ); - - /* Resize to fit */ - ResizeTo( fScanView->Bounds().Width(), fScanView->Bounds().Height() ); - - BScreen screen; - MoveTo( ( screen.Frame().Width() - fRipView->Bounds().Width() ) / 2, - ( screen.Frame().Height() - fRipView->Bounds().Height() ) / 2 ); - - /* Update the interface */ - fDie = false; - fUpdateThread = spawn_thread( (int32 (*)(void *)) UpdateInterface, - "interface", B_DISPLAY_PRIORITY, this ); - resume_thread( fUpdateThread ); -} - -bool MainWindow::QuitRequested() -{ - /* Clean up */ - fDie = true; - long exit_value; - wait_for_thread( fUpdateThread, &exit_value ); - HBClose( &fHandle ); - - /* Stop the application */ - be_app->PostMessage( B_QUIT_REQUESTED ); - return true; -} - -void MainWindow::MessageReceived( BMessage * message ) -{ - switch( message->what ) - { - case B_ABOUT_REQUESTED: - { - BAlert * alert; - alert = new BAlert( "About HandBrake", - "HandBrake " VERSION "\n\n" - "by Eric Petit <[email protected]>\n" - "Homepage : <http://handbrake.m0k.org/>\n\n" - "No, you don't want to know where this stupid app " - "name comes from.\n\n" - "Thanks to BGA for pointing out very cool bugs ;)", - "Woot !" ); - alert->Go( NULL ); - break; - } - - case B_REFS_RECEIVED: - case SCAN_RADIO: - case SCAN_BROWSE_BUTTON: - case SCAN_OPEN: - fScanView->MessageReceived( message ); - break; - - case B_SAVE_REQUESTED: - case RIP_TITLE_POPUP: - case RIP_BITRATE_RADIO: - case RIP_TARGET_CONTROL: - case RIP_CROP_BUTTON: - case RIP_BROWSE_BUTTON: - case RIP_SUSPEND_BUTTON: - case RIP_RIP_BUTTON: - fRipView->MessageReceived( message ); - break; - - default: - BWindow::MessageReceived( message ); - break; - } -} - -void MainWindow::UpdateInterface( MainWindow * _this ) -{ - uint64_t time; - int64_t wait; - - while( !_this->fDie ) - { - /* Update every 0.1 sec */ - time = system_time(); - - _this->_UpdateInterface(); - - wait = 100000 - ( system_time() - time ); - if( wait > 0 ) - { - snooze( wait ); - } - } -} - -void MainWindow::_UpdateInterface() -{ - if( !Lock() ) - { - fprintf( stderr, "Lock() failed\n" ); - return; - } - - int modeChanged; - HBStatus status; - - modeChanged = HBGetStatus( fHandle, &status ); - - switch( status.mode ) - { - case HB_MODE_UNDEF: - case HB_MODE_NEED_DEVICE: - break; - - case HB_MODE_SCANNING: - case HB_MODE_INVALID_DEVICE: - fScanView->UpdateIntf( status, modeChanged ); - break; - - case HB_MODE_READY_TO_RIP: - if( !modeChanged ) - break; - - RemoveChild( fScanView ); - ResizeTo( fRipView->Bounds().Width(), - fRipView->Bounds().Height() ); - AddChild( fRipView ); - fRipView->UpdateIntf( status, modeChanged ); - break; - - case HB_MODE_ENCODING: - case HB_MODE_PAUSED: - case HB_MODE_DONE: - case HB_MODE_CANCELED: - case HB_MODE_ERROR: - fRipView->UpdateIntf( status, modeChanged ); - break; - - default: - break; - } - - Unlock(); -} - diff --git a/beos/MainWindow.h b/beos/MainWindow.h deleted file mode 100644 index 5e50775bc..000000000 --- a/beos/MainWindow.h +++ /dev/null @@ -1,36 +0,0 @@ -/* $Id: MainWindow.h,v 1.1.1.1 2003/11/03 12:03:51 titer Exp $ - - This file is part of the HandBrake source code. - Homepage: <http://handbrake.m0k.org/>. - It may be used under the terms of the GNU General Public License. */ - - -#ifndef HB_MAIN_WINDOW_H -#define HB_MAIN_WINDOW_H - -#include <Window.h> -class ScanView; -class RipView; - -#include "HandBrake.h" - -class MainWindow : public BWindow -{ - public: - MainWindow(); - virtual bool QuitRequested(); - virtual void MessageReceived( BMessage * message ); - - private: - static void UpdateInterface( MainWindow * _this ); - void _UpdateInterface(); - - HBHandle * fHandle; - int fUpdateThread; - volatile bool fDie; - - ScanView * fScanView; - RipView * fRipView; -}; - -#endif diff --git a/beos/PictureWin.cpp b/beos/PictureWin.cpp deleted file mode 100644 index 5667dbc3e..000000000 --- a/beos/PictureWin.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/* $Id: PictureWin.cpp,v 1.2 2003/11/06 14:36:54 titer Exp $ - - This file is part of the HandBrake source code. - Homepage: <http://handbrake.m0k.org/>. - It may be used under the terms of the GNU General Public License. */ - -#include <Bitmap.h> -#include <Box.h> -#include <Button.h> -#include <CheckBox.h> -#include <Screen.h> -#include <Slider.h> - -#include "PictureWin.h" - -#define UPDATE_BITMAP 'upbi' - -/* Handy way to access HBTitle members */ -#define fInWidth fTitle->inWidth -#define fInHeight fTitle->inHeight -#define fPixelWidth fTitle->pixelWidth -#define fPixelHeight fTitle->pixelHeight -#define fDeinterlace fTitle->deinterlace -#define fOutWidth fTitle->outWidth -#define fOutHeight fTitle->outHeight -#define fOutWidthMax fTitle->outWidthMax -#define fOutHeightMax fTitle->outHeightMax -#define fTopCrop fTitle->topCrop -#define fBottomCrop fTitle->bottomCrop -#define fLeftCrop fTitle->leftCrop -#define fRightCrop fTitle->rightCrop - -HBPictureView::HBPictureView( BRect rect, BBitmap * bitmap ) - : BView( rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW ) -{ - fBitmap = bitmap; -} - -void HBPictureView::Draw( BRect rect ) -{ - if( LockLooper() ) - { - DrawBitmap( fBitmap, Bounds() ); - UnlockLooper(); - } - else - { - fprintf( stderr, "LockLooper() failed\n" ); - } - - BView::Draw( rect ); -} - - -/* Constructor */ -HBPictureWin::HBPictureWin( HBHandle * handle, HBTitle * title ) - : BWindow( BRect( 0, 0, 0, 0 ), "Picture settings", - B_FLOATING_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, - B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_CLOSABLE ) -{ - fHandle = handle; - fTitle = title; - - /* Resize & center */ - ResizeTo( fOutWidthMax + 40, fOutHeightMax + 280 ); - BScreen screen; - MoveTo( ( screen.Frame().Width() - Frame().Width() ) / 2, - ( screen.Frame().Height() - Frame().Height() ) / 2 ); - - /* Build the GUI */ - BRect r; - - /* Add a background view */ - BView * view; - view = new BView( Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW ); - view->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) ); - AddChild( view ); - - /* First box : picture + slider */ - r = BRect( 10, 10, fOutWidthMax + 31, fOutHeightMax + 60 ); - BBox * pictureBox; - pictureBox = new BBox( r, NULL ); - pictureBox->SetLabel( "Preview" ); - - /* Leave a one-pixel margin to draw the white line around the picture */ - fBitmap = new BBitmap( BRect( 0, 0, fOutWidthMax + 1, - fOutHeightMax + 1 ), 0, B_RGB32 ); - - /* Picture view */ - r = BRect( 10, 15, fOutWidthMax + 11, fOutHeightMax + 16 ); - fPictureView = new HBPictureView( r, fBitmap ); - pictureBox->AddChild( fPictureView ); - - /* Slider */ - r = BRect( 10, fOutHeightMax + 25, fOutWidthMax + 11, - fOutHeightMax + 55 ); - fPictureSlider = new BSlider( r, NULL, NULL, - new BMessage( UPDATE_BITMAP ), 0, 9 ); - pictureBox->AddChild( fPictureSlider ); - - view->AddChild( pictureBox ); - - /* Second box : scale & crop settings */ - r = BRect( 10, fOutHeightMax + 75, fOutWidthMax + 31, - fOutHeightMax + 235 ); - BBox * settingsBox; - settingsBox = new BBox( r, NULL ); - settingsBox->SetLabel( "Settings" ); - - r = BRect( 10, 15, fOutWidthMax + 11, 30 ); - fDeinterlaceCheck = new BCheckBox( r, NULL, "Deinterlace", - new BMessage( UPDATE_BITMAP ) ); - fDeinterlaceCheck->SetValue( fDeinterlace ? 1 : 0 ); - settingsBox->AddChild( fDeinterlaceCheck ); - - r = BRect( 10, 40, fOutWidthMax + 11, 70 ); - fWidthSlider = new BSlider( r, NULL, "Picture size", - new BMessage( UPDATE_BITMAP ), - 1, fOutWidthMax / 16, - B_TRIANGLE_THUMB ); - fWidthSlider->SetValue( fOutWidth / 16 ); - settingsBox->AddChild( fWidthSlider ); - - r = BRect( 10, 80, ( fOutWidthMax / 2 ) + 5, 110 ); - fTopCropSlider = new BSlider( r, NULL, "Top cropping", - new BMessage( UPDATE_BITMAP ), - 0, fInHeight / 4, - B_TRIANGLE_THUMB ); - fTopCropSlider->SetValue( fTopCrop / 2 ); - settingsBox->AddChild( fTopCropSlider ); - - r = BRect( ( fOutWidthMax / 2 ) + 15, 80, fOutWidthMax + 11, 110 ); - fBottomCropSlider = new BSlider( r, NULL, "Bottom cropping", - new BMessage( UPDATE_BITMAP ), - 0, fInHeight / 4, - B_TRIANGLE_THUMB ); - fBottomCropSlider->SetValue( fBottomCrop / 2 ); - settingsBox->AddChild( fBottomCropSlider ); - - r = BRect( 10, 120, ( fOutWidthMax / 2 ) + 5, 150 ); - fLeftCropSlider = new BSlider( r, NULL, "Left cropping", - new BMessage( UPDATE_BITMAP ), - 0, fInWidth / 4, - B_TRIANGLE_THUMB ); - fLeftCropSlider->SetValue( fLeftCrop / 2 ); - settingsBox->AddChild( fLeftCropSlider ); - - r = BRect( ( fOutWidthMax / 2 ) + 15, 120, fOutWidthMax + 11, 150 ); - fRightCropSlider = new BSlider( r, NULL, "Right cropping", - new BMessage( UPDATE_BITMAP ), - 0, fInWidth / 4, - B_TRIANGLE_THUMB ); - fRightCropSlider->SetValue( fRightCrop / 2 ); - settingsBox->AddChild( fRightCropSlider ); - - view->AddChild( settingsBox ); - - /* "Close" button */ - r = BRect( fOutWidthMax - 49, fOutHeightMax + 245, - fOutWidthMax + 31, fOutHeightMax + 270 ); - BButton * button = new BButton( r, NULL, "OK", - new BMessage( B_QUIT_REQUESTED ) ); - view->AddChild( button ); - - UpdateBitmap( 0 ); -} - -void HBPictureWin::MessageReceived( BMessage * message ) -{ - switch( message->what ) - { - case UPDATE_BITMAP: - UpdateBitmap( fPictureSlider->Value() ); - fPictureView->Draw( fPictureView->Bounds() ); - break; - - default: - BWindow::MessageReceived( message ); - } -} - -void HBPictureWin::UpdateBitmap( int image ) -{ - fOutWidth = 16 * fWidthSlider->Value(); - fTopCrop = 2 * fTopCropSlider->Value(); - fBottomCrop = 2 * fBottomCropSlider->Value(); - fLeftCrop = 2 * fLeftCropSlider->Value(); - fRightCrop = 2 * fRightCropSlider->Value(); - fDeinterlace = ( fDeinterlaceCheck->Value() != 0 ); - - uint8_t * preview = HBGetPreview( fHandle, fTitle, image ); - for( int i = 0; i < fOutHeightMax + 2; i++ ) - { - memcpy( ((uint8_t*) fBitmap->Bits()) + - i * fBitmap->BytesPerRow(), - preview + 4 * ( fOutWidthMax + 2 ) * i, - 4 * ( fOutWidthMax + 2 ) ); - } - free( preview ); - - if( !Lock() ) - { - fprintf( stderr, "Lock() failed\n" ); - return; - } - - char label[128]; - - memset( label, 0, 128 ); - snprintf( label, 128, "Picture size : %d x %d", - fOutWidth, fOutHeight ); - fWidthSlider->SetValue( fOutWidth / 16 ); - fWidthSlider->SetLabel( label ); - - memset( label, 0, 128 ); - snprintf( label, 128, "Top cropping : %d", fTopCrop ); - fTopCropSlider->SetLabel( label ); - - memset( label, 0, 128 ); - snprintf( label, 128, "Bottom cropping : %d", fBottomCrop ); - fBottomCropSlider->SetLabel( label ); - - memset( label, 0, 128 ); - snprintf( label, 128, "Left cropping : %d", fLeftCrop ); - fLeftCropSlider->SetLabel( label ); - - memset( label, 0, 128 ); - snprintf( label, 128, "Right cropping : %d", fRightCrop ); - fRightCropSlider->SetLabel( label ); - - Unlock(); -} diff --git a/beos/PictureWin.h b/beos/PictureWin.h deleted file mode 100644 index 265eb8ad0..000000000 --- a/beos/PictureWin.h +++ /dev/null @@ -1,52 +0,0 @@ -/* $Id: PictureWin.h,v 1.1.1.1 2003/11/03 12:03:51 titer Exp $ - - This file is part of the HandBrake source code. - Homepage: <http://handbrake.m0k.org/>. - It may be used under the terms of the GNU General Public License. */ - -#ifndef HB_PICTURE_WIN_H -#define HB_PICTURE_WIN_H - -#include <View.h> -#include <Window.h> -class BSlider; -class BCheckBox; - -#include "HandBrake.h" - -class HBPictureView : public BView -{ - public: - HBPictureView::HBPictureView( BRect rect, BBitmap * bitmap ); - virtual void Draw( BRect rect ); - - private: - BBitmap * fBitmap; -}; - -class HBPictureWin : public BWindow -{ - public: - HBPictureWin( HBHandle * handle, HBTitle * title ); - virtual void MessageReceived( BMessage * message ); - - void UpdateBitmap( int which ); - - - private: - HBHandle * fHandle; - HBTitle * fTitle; - - /* GUI */ - HBPictureView * fPictureView; - BSlider * fPictureSlider; - BBitmap * fBitmap; - BSlider * fWidthSlider; - BSlider * fTopCropSlider; - BSlider * fBottomCropSlider; - BSlider * fLeftCropSlider; - BSlider * fRightCropSlider; - BCheckBox * fDeinterlaceCheck; -}; - -#endif diff --git a/beos/RipView.cpp b/beos/RipView.cpp deleted file mode 100644 index 0d1e787ab..000000000 --- a/beos/RipView.cpp +++ /dev/null @@ -1,638 +0,0 @@ -/* $Id: RipView.cpp,v 1.4 2003/11/09 21:35:06 titer Exp $ - - This file is part of the HandBrake source code. - Homepage: <http://handbrake.m0k.org/>. - It may be used under the terms of the GNU General Public License. */ - -#include <Box.h> -#include <Button.h> -#include <CheckBox.h> -#include <FilePanel.h> -#include <MenuField.h> -#include <MenuItem.h> -#include <Path.h> -#include <PopUpMenu.h> -#include <RadioButton.h> -#include <StatusBar.h> -#include <String.h> -#include <TextControl.h> - -#include "RipView.h" -#include "PictureWin.h" - -#define DEFAULT_FILE "/boot/home/Desktop/Movie.avi" - -RipView::RipView( HBHandle * handle ) - : BView( BRect( 0,0,400,480 ), NULL, B_FOLLOW_ALL, B_WILL_DRAW ) -{ - fHandle = handle; - - BRect r; - SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) ); - - /* Video box */ - r = BRect( 10, 10, Bounds().Width() - 10, 160 ); - fVideoBox = new BBox( r ); - fVideoBox->SetLabel( "Video" ); - AddChild( fVideoBox ); - - /* Title */ - r = BRect( 10, 15, fVideoBox->Bounds().Width() - 10, 35 ); - fTitlePopUp = new BPopUpMenu( "" ); - fTitleField = new BMenuField( r, NULL, "Title:", - fTitlePopUp, true ); - fVideoBox->AddChild( fTitleField ); - - /* Video codec */ - r = BRect( 10, 40, fVideoBox->Bounds().Width() - 10, 60 ); - fVideoCodecPopUp = new BPopUpMenu( "" ); - fVideoCodecField = new BMenuField( r, NULL, "Codec:", - fVideoCodecPopUp, true ); - fVideoBox->AddChild( fVideoCodecField ); - - /* Video bitrate */ - r = BRect( 10, 65, fVideoBox->Bounds().Width() / 2, 85 ); - fCustomBitrateRadio = - new BRadioButton( r, NULL, "Custom bitrate (kbps)", - new BMessage( RIP_BITRATE_RADIO ) ); - fCustomBitrateRadio->SetValue( 1 ); - fVideoBox->AddChild( fCustomBitrateRadio ); - r = BRect( fVideoBox->Bounds().Width() - 80, 65, - fVideoBox->Bounds().Width() - 10, 85 ); - fCustomBitrateControl = new BTextControl( r, NULL, NULL, "1024", NULL ); - fCustomBitrateControl->SetDivider( 0 ); - fVideoBox->AddChild( fCustomBitrateControl ); - r = BRect( 10, 90, fVideoBox->Bounds().Width() / 2, 110 ); - fTargetSizeRadio = - new BRadioButton( r, NULL, "Target size (MB)", - new BMessage( RIP_BITRATE_RADIO ) ); - fVideoBox->AddChild( fTargetSizeRadio ); - r = BRect( fVideoBox->Bounds().Width() - 80, 90, - fVideoBox->Bounds().Width() - 10, 110 ); - fTargetSizeControl = new BTextControl( r, NULL, NULL, "700", NULL ); - fTargetSizeControl->SetDivider( 0 ); - fTargetSizeControl->SetEnabled( false ); - fTargetSizeControl->SetModificationMessage( - new BMessage( RIP_TARGET_CONTROL ) ); - fVideoBox->AddChild( fTargetSizeControl ); - - /* 2-pass */ - r = BRect( 10, 125, fVideoBox->Bounds().Width() / 2, 140 ); - fTwoPassCheck = new BCheckBox( r, NULL, "2-pass encoding", NULL ); - fVideoBox->AddChild( fTwoPassCheck ); - - /* Crop */ - r = BRect( fVideoBox->Bounds().Width() - 120, 120, - fVideoBox->Bounds().Width() - 10, 140 ); - fCropButton = new BButton( r, NULL, "Crop & Scale...", - new BMessage( RIP_CROP_BUTTON ) ); - fVideoBox->AddChild( fCropButton ); - - /* Audio box */ - r = BRect( 10, 170, Bounds().Width() - 10, 290 ); - fAudioBox = new BBox( r ); - fAudioBox->SetLabel( "Audio" ); - AddChild( fAudioBox ); - - /* Language */ - r = BRect( 10, 15, fAudioBox->Bounds().Width() - 10, 35 ); - fLanguagePopUp = new BPopUpMenu( "" ); - fLanguageField = new BMenuField( r, NULL, "Language:", - fLanguagePopUp, true ); - fAudioBox->AddChild( fLanguageField ); - - /* Secondary language */ - r = BRect( 10, 40, fAudioBox->Bounds().Width() - 10, 60 ); - fSecondaryLanguagePopUp = new BPopUpMenu( "" ); - fSecondaryLanguageField = new BMenuField( r, NULL, "Secondary language:", - fSecondaryLanguagePopUp, true ); - fAudioBox->AddChild( fSecondaryLanguageField ); - - /* Audio codec */ - r = BRect( 10, 65, fAudioBox->Bounds().Width() - 10, 85 ); - fAudioCodecPopUp = new BPopUpMenu( "" ); - fAudioCodecField = new BMenuField( r, NULL, "Codec:", - fAudioCodecPopUp, true ); - fAudioBox->AddChild( fAudioCodecField ); - - /* Audio bitrate */ - r = BRect( 10, 90, fAudioBox->Bounds().Width() - 10, 110 ); - fAudioBitratePopUp = new BPopUpMenu( "" ); - fAudioBitrateField = new BMenuField( r, NULL, "Bitrate:", - fAudioBitratePopUp, true ); - fAudioBox->AddChild( fAudioBitrateField ); - - /* Destination box */ - r = BRect( 10, 300, Bounds().Width() - 10, 395 ); - fDestinationBox = new BBox( r ); - fDestinationBox->SetLabel( "Destination" ); - AddChild( fDestinationBox ); - - /* File format */ - r = BRect( 10, 15, fDestinationBox->Bounds().Width() - 10, 35 ); - fFileFormatPopUp = new BPopUpMenu( "" ); - fFileFormatField = new BMenuField( r, NULL, "File format:", - fFileFormatPopUp, true ); - fDestinationBox->AddChild( fFileFormatField ); - - /* File location */ - r = BRect( 10, 40, fDestinationBox->Bounds().Width() - 10, 60 ); - fFileControl = new BTextControl( r, NULL, "Location:", - DEFAULT_FILE, NULL ); - fFileControl->SetDivider( 100 ); - fDestinationBox->AddChild( fFileControl ); - - /* Browse button */ - r = BRect( fDestinationBox->Bounds().Width() - 80, 65, - fDestinationBox->Bounds().Width() - 10, 85 ); - fFileButton = new BButton( r, NULL, "Browse...", - new BMessage( RIP_BROWSE_BUTTON ) ); - fDestinationBox->AddChild( fFileButton ); - - fFilePanel = new BFilePanel( B_SAVE_PANEL, NULL, NULL, 0, false ); - - /* Status bar */ - r = BRect( 10, 405, Bounds().Width() - 10, 435 ); - fStatusBar = new BStatusBar( r, NULL ); - AddChild( fStatusBar ); - - /* Suspend/Rip buttons */ - r = BRect( Bounds().Width() - 180, 445, - Bounds().Width() - 100, 465 ); - fSuspendButton = new BButton( r, NULL, "Suspend", - new BMessage( RIP_SUSPEND_BUTTON ) ); - fSuspendButton->SetEnabled( false ); - AddChild( fSuspendButton ); - r = BRect( Bounds().Width() - 90, 445, - Bounds().Width() - 10, 465 ); - fStartButton = new BButton( r, NULL, "Rip !", - new BMessage( RIP_RIP_BUTTON ) ); - fStartButton->MakeDefault( true ); - AddChild( fStartButton ); - - /* Fill popups */ - fVideoCodecPopUp->AddItem( new BMenuItem( "MPEG-4 (Ffmpeg)", NULL ) ); - fVideoCodecPopUp->AddItem( new BMenuItem( "MPEG-4 (XviD)", NULL ) ); - fVideoCodecPopUp->ItemAt( 0 )->SetMarked( true ); - fAudioCodecPopUp->AddItem( new BMenuItem( "MP3", NULL ) ); - fAudioCodecPopUp->ItemAt( 0 )->SetMarked( true ); - fAudioBitratePopUp->AddItem( - new BMenuItem( "32", new BMessage( RIP_TARGET_CONTROL ) ) ); - fAudioBitratePopUp->AddItem( - new BMenuItem( "64", new BMessage( RIP_TARGET_CONTROL ) ) ); - fAudioBitratePopUp->AddItem( - new BMenuItem( "96", new BMessage( RIP_TARGET_CONTROL ) ) ); - fAudioBitratePopUp->AddItem( - new BMenuItem( "128", new BMessage( RIP_TARGET_CONTROL ) ) ); - fAudioBitratePopUp->AddItem( - new BMenuItem( "160", new BMessage( RIP_TARGET_CONTROL ) ) ); - fAudioBitratePopUp->AddItem( - new BMenuItem( "192", new BMessage( RIP_TARGET_CONTROL ) ) ); - fAudioBitratePopUp->AddItem( - new BMenuItem( "224", new BMessage( RIP_TARGET_CONTROL ) ) ); - fAudioBitratePopUp->AddItem( - new BMenuItem( "256", new BMessage( RIP_TARGET_CONTROL ) ) ); - fAudioBitratePopUp->AddItem( - new BMenuItem( "288", new BMessage( RIP_TARGET_CONTROL ) ) ); - fAudioBitratePopUp->AddItem( - new BMenuItem( "320", new BMessage( RIP_TARGET_CONTROL ) ) ); - fAudioBitratePopUp->ItemAt( 3 )->SetMarked( true ); - fFileFormatPopUp->AddItem( new BMenuItem( "AVI", NULL ) ); - fFileFormatPopUp->ItemAt( 0 )->SetMarked( true ); -} - -void RipView::MessageReceived( BMessage * message ) -{ - switch( message->what ) - { - case RIP_TITLE_POPUP: - { - int index = fTitlePopUp->IndexOf( fTitlePopUp->FindMarked() ); - HBTitle * title = (HBTitle*) HBListItemAt( fTitleList, index ); - - /* Empty current popups */ - BMenuItem * item; - while( ( item = fLanguagePopUp->ItemAt( 0 ) ) ) - { - fLanguagePopUp->RemoveItem( item ); - delete item; - } - while( ( item = fSecondaryLanguagePopUp->ItemAt( 0 ) ) ) - { - fSecondaryLanguagePopUp->RemoveItem( item ); - delete item; - } - - /* Show new languages */ - HBAudio * audio; - for( int i = 0; i < HBListCountItems( title->audioList ); i++ ) - { - audio = (HBAudio*) HBListItemAt( title->audioList, i ); - fLanguagePopUp->AddItem( - new BMenuItem( audio->language, NULL ) ); - fSecondaryLanguagePopUp->AddItem( - new BMenuItem( audio->language, - new BMessage( RIP_TARGET_CONTROL ) ) ); - } - fLanguagePopUp->ItemAt( 0 )->SetMarked( true ); - fSecondaryLanguagePopUp->AddItem( new BMenuItem( "None", - new BMessage( RIP_TARGET_CONTROL ) ) ); - fSecondaryLanguagePopUp->ItemAt( - fSecondaryLanguagePopUp->CountItems() - 1 )->SetMarked( true ); - - fSecondaryLanguageField->SetEnabled( - ( HBListCountItems( title->audioList ) > 1 ) ); - - break; - } - - case RIP_BITRATE_RADIO: - { - if( fCustomBitrateRadio->Value() ) - { - fCustomBitrateControl->SetEnabled( true ); - fTargetSizeControl->SetEnabled( false ); - } - else - { - fCustomBitrateControl->SetEnabled( false ); - fTargetSizeControl->SetEnabled( true ); - Window()->PostMessage( RIP_TARGET_CONTROL ); - } - break; - } - - case RIP_TARGET_CONTROL: - { - if( !fTargetSizeRadio->Value() ) - { - break; - } - - int64_t available; - int index = fTitlePopUp->IndexOf( fTitlePopUp->FindMarked() ); - HBTitle * title = (HBTitle*) HBListItemAt( fTitleList, index ); - - available = (int64_t) 1024 * 1024 * - atoi( fTargetSizeControl->Text() ); - - /* AVI headers */ - available -= 2048; - - /* Video chunk headers (8 bytes / frame) and - and index (16 bytes / frame) */ - available -= 24 * title->length * title->rate / - title->rateBase; - - /* Audio tracks */ - available -= - ( strcmp( fSecondaryLanguagePopUp->FindMarked()->Label(), - "None" ) ? 2 : 1 ) * - ( title->length * - atoi( fAudioBitratePopUp->FindMarked()->Label() ) * 128 + - 24 * title->length * 44100 / 1152 ); - - char string[1024]; memset( string, 0, 1024 ); - if( available < 0 ) - { - sprintf( string, "0" ); - } - else - { - sprintf( string, "%lld", available / - ( 128 * title->length ) ); - } - fCustomBitrateControl->SetText( string ); - break; - } - - case RIP_CROP_BUTTON: - { - int index = fTitlePopUp->IndexOf( fTitlePopUp->FindMarked() ); - HBTitle * title = (HBTitle*) HBListItemAt( fTitleList, index ); - - HBPictureWin * win; - win = new HBPictureWin( fHandle, title ); - win->Show(); - break; - } - - case RIP_BROWSE_BUTTON: - { - fFilePanel->Show(); - } - - case B_SAVE_REQUESTED: - { - entry_ref ref; - BString string; - if( message->FindRef( "directory", 0, &ref ) == B_OK && - message->FindString( "name", &string ) == B_OK ) - { - BPath * path = new BPath( &ref ); - string.Prepend( "/" ); - string.Prepend( path->Path() ); - fFileControl->SetText( string.String() ); - } - break; - } - - case RIP_SUSPEND_BUTTON: - { - if( strcmp( fSuspendButton->Label(), "Suspend" ) ) - { - HBResumeRip( fHandle ); - } - else - { - HBPauseRip( fHandle ); - } - - break; - } - - case RIP_RIP_BUTTON: - { - if( strcmp( fStartButton->Label(), "Rip !" ) ) - { - HBStopRip( fHandle ); - } - else - { - int index; - - /* Get asked title & languages */ - index = fTitlePopUp->IndexOf( fTitlePopUp->FindMarked() ); - HBTitle * title = (HBTitle*) HBListItemAt( fTitleList, index ); - index = fLanguagePopUp->IndexOf( fLanguagePopUp->FindMarked() ); - HBAudio * audio1 = - (HBAudio*) HBListItemAt( title->audioList, index ); - index = fSecondaryLanguagePopUp->IndexOf( - fSecondaryLanguagePopUp->FindMarked() ); - HBAudio * audio2 = - (HBAudio*) HBListItemAt( title->audioList, index ); - - /* Use user settings */ - title->file = strdup( fFileControl->Text() ); - title->bitrate = atoi( fCustomBitrateControl->Text() ); - title->twoPass = ( fTwoPassCheck->Value() != 0 ); - title->codec = fVideoCodecPopUp->IndexOf( - fVideoCodecPopUp->FindMarked() ) ? HB_CODEC_XVID : - HB_CODEC_FFMPEG; - audio1->outBitrate = - atoi( fAudioBitratePopUp->FindMarked()->Label() ); - if( audio2 ) - { - audio2->outBitrate = - atoi( fAudioBitratePopUp->FindMarked()->Label() ); - } - - /* Let libhb do the job */ - HBStartRip( fHandle, title, audio1, audio2 ); - } - break; - } - - default: - BView::MessageReceived( message ); - break; - } -} - -void RipView::UpdateIntf( HBStatus status, int modeChanged ) -{ - switch( status.mode ) - { - case HB_MODE_READY_TO_RIP: - { - if( !modeChanged ) - break; - - fTitleList = status.titleList; - - HBTitle * title; - for( int i = 0; i < HBListCountItems( fTitleList ); i++ ) - { - title = (HBTitle*) HBListItemAt( fTitleList, i ); - char string[1024]; memset( string, 0, 1024 ); - sprintf( string, "%d - %02dh%02dm%02ds", - title->index, title->length / 3600, - ( title->length % 3600 ) / 60, - title->length % 60 ); - fTitlePopUp->AddItem( - new BMenuItem( string, new BMessage( RIP_TITLE_POPUP ) ) ); - } - fTitlePopUp->ItemAt( 0 )->SetMarked( true ); - Window()->PostMessage( RIP_TITLE_POPUP ); - break; - } - - case HB_MODE_ENCODING: - { - if( modeChanged ) - { - fTitleField->SetEnabled( false ); - fVideoCodecField->SetEnabled( false ); - fCustomBitrateRadio->SetEnabled( false ); - fCustomBitrateControl->SetEnabled( false ); - fTargetSizeRadio->SetEnabled( false ); - fTargetSizeControl->SetEnabled( false ); - fTwoPassCheck->SetEnabled( false ); - fCropButton->SetEnabled( false ); - fLanguageField->SetEnabled( false ); - fSecondaryLanguageField->SetEnabled( false ); - fAudioCodecField->SetEnabled( false ); - fAudioBitrateField->SetEnabled( false ); - fFileFormatField->SetEnabled( false ); - fFileControl->SetEnabled( false ); - fFileButton->SetEnabled( false ); - fSuspendButton->SetLabel( "Suspend" ); - fSuspendButton->SetEnabled( true ); - fStartButton->SetLabel( "Cancel" ); - fStartButton->SetEnabled( true ); - } - - if( !status.position ) - { - fStatusBar->Update( - fStatusBar->CurrentValue(), - "Starting..." ); - } - else - { - char string[1024]; memset( string, 0, 1024 ); - sprintf( string, "Encoding: %.2f %% (%.2f fps, " - "%02dh%02dm%02ds remaining)", - 100 * status.position, - status.frameRate, - status.remainingTime / 3600, - ( status.remainingTime % 3600 ) / 60, - status.remainingTime % 60 ); - fStatusBar->Update( 100 * status.position - - fStatusBar->CurrentValue(), - string ); - } - break; - } - - case HB_MODE_PAUSED: - { - if( modeChanged ) - { - fTitleField->SetEnabled( false ); - fVideoCodecField->SetEnabled( false ); - fCustomBitrateRadio->SetEnabled( false ); - fCustomBitrateControl->SetEnabled( false ); - fTargetSizeRadio->SetEnabled( false ); - fTargetSizeControl->SetEnabled( false ); - fTwoPassCheck->SetEnabled( false ); - fCropButton->SetEnabled( false ); - fLanguageField->SetEnabled( false ); - fSecondaryLanguageField->SetEnabled( false ); - fAudioCodecField->SetEnabled( false ); - fAudioBitrateField->SetEnabled( false ); - fFileFormatField->SetEnabled( false ); - fFileControl->SetEnabled( false ); - fFileButton->SetEnabled( false ); - fSuspendButton->SetLabel( "Resume" ); - fSuspendButton->SetEnabled( true ); - fStartButton->SetLabel( "Cancel" ); - fStartButton->SetEnabled( true ); - } - - fStatusBar->Update( 100 * status.position - - fStatusBar->CurrentValue(), "Suspended" ); - break; - } - - case HB_MODE_STOPPING: - { - if( modeChanged ) - { - fTitleField->SetEnabled( false ); - fVideoCodecField->SetEnabled( false ); - fCustomBitrateRadio->SetEnabled( false ); - fCustomBitrateControl->SetEnabled( false ); - fTargetSizeRadio->SetEnabled( false ); - fTargetSizeControl->SetEnabled( false ); - fTwoPassCheck->SetEnabled( false ); - fCropButton->SetEnabled( false ); - fLanguageField->SetEnabled( false ); - fSecondaryLanguageField->SetEnabled( false ); - fAudioCodecField->SetEnabled( false ); - fAudioBitrateField->SetEnabled( false ); - fFileFormatField->SetEnabled( false ); - fFileControl->SetEnabled( false ); - fFileButton->SetEnabled( false ); - fSuspendButton->SetLabel( "Suspend" ); - fSuspendButton->SetEnabled( false ); - fStartButton->SetLabel( "Cancel" ); - fStartButton->SetEnabled( false ); - } - - fStatusBar->Update( - fStatusBar->CurrentValue(), - "Stopping..." ); - break; - } - - case HB_MODE_DONE: - { - if( modeChanged ) - { - fTitleField->SetEnabled( true ); - fVideoCodecField->SetEnabled( true ); - fCustomBitrateRadio->SetEnabled( true ); - fCustomBitrateControl->SetEnabled( - fCustomBitrateRadio->Value() ); - fTargetSizeRadio->SetEnabled( true ); - fTargetSizeControl->SetEnabled( fTargetSizeRadio->Value() ); - fTwoPassCheck->SetEnabled( true ); - fCropButton->SetEnabled( true ); - fLanguageField->SetEnabled( true ); - fSecondaryLanguageField->SetEnabled( - ( fSecondaryLanguagePopUp->CountItems() > 2 ) ); - fAudioCodecField->SetEnabled( true ); - fAudioBitrateField->SetEnabled( true ); - fFileFormatField->SetEnabled( true ); - fFileControl->SetEnabled( true ); - fFileButton->SetEnabled( true ); - - fSuspendButton->SetLabel( "Suspend" ); - fSuspendButton->SetEnabled( false ); - fStartButton->SetLabel( "Rip !" ); - fStartButton->SetEnabled( true ); - } - - fStatusBar->Update( 100.0 - fStatusBar->CurrentValue(), - "Done." ); - break; - } - - case HB_MODE_CANCELED: - { - if( modeChanged ) - { - fTitleField->SetEnabled( true ); - fVideoCodecField->SetEnabled( true ); - fCustomBitrateRadio->SetEnabled( true ); - fCustomBitrateControl->SetEnabled( - fCustomBitrateRadio->Value() ); - fTargetSizeRadio->SetEnabled( true ); - fTargetSizeControl->SetEnabled( fTargetSizeRadio->Value() ); - fTwoPassCheck->SetEnabled( true ); - fCropButton->SetEnabled( true ); - fLanguageField->SetEnabled( true ); - fSecondaryLanguageField->SetEnabled( - ( fSecondaryLanguagePopUp->CountItems() > 2 ) ); - fAudioCodecField->SetEnabled( true ); - fAudioBitrateField->SetEnabled( true ); - fFileFormatField->SetEnabled( true ); - fFileControl->SetEnabled( true ); - fFileButton->SetEnabled( true ); - fSuspendButton->SetLabel( "Suspend" ); - fSuspendButton->SetEnabled( false ); - fStartButton->SetLabel( "Rip !" ); - fStartButton->SetEnabled( true ); - } - - fStatusBar->Update( - fStatusBar->CurrentValue(), - "Canceled." ); - break; - } - - case HB_MODE_ERROR: - { - if( modeChanged ) - { - fTitleField->SetEnabled( true ); - fVideoCodecField->SetEnabled( true ); - fCustomBitrateRadio->SetEnabled( true ); - fCustomBitrateControl->SetEnabled( - fCustomBitrateRadio->Value() ); - fTargetSizeRadio->SetEnabled( true ); - fTargetSizeControl->SetEnabled( fTargetSizeRadio->Value() ); - fTwoPassCheck->SetEnabled( true ); - fCropButton->SetEnabled( true ); - fLanguageField->SetEnabled( true ); - fSecondaryLanguageField->SetEnabled( - ( fSecondaryLanguagePopUp->CountItems() > 2 ) ); - fAudioCodecField->SetEnabled( true ); - fAudioBitrateField->SetEnabled( true ); - fFileFormatField->SetEnabled( true ); - fFileControl->SetEnabled( true ); - fFileButton->SetEnabled( true ); - fSuspendButton->SetLabel( "Suspend" ); - fSuspendButton->SetEnabled( false ); - fStartButton->SetLabel( "Rip !" ); - fStartButton->SetEnabled( true ); - } - - fStatusBar->Update( - fStatusBar->CurrentValue(), - "Error." ); - break; - } - - default: - break; - } -} - diff --git a/beos/RipView.h b/beos/RipView.h deleted file mode 100644 index 1036e9261..000000000 --- a/beos/RipView.h +++ /dev/null @@ -1,77 +0,0 @@ -/* $Id: RipView.h,v 1.4 2003/11/09 21:35:06 titer Exp $ - - This file is part of the HandBrake source code. - Homepage: <http://handbrake.m0k.org/>. - It may be used under the terms of the GNU General Public License. */ - - -#ifndef HB_RIP_VIEW_H -#define HB_RIP_VIEW_H - -#include <View.h> -class BBox; -class BButton; -class BCheckBox; -class BFilePanel; -class BMenuField; -class BPopUpMenu; -class BRadioButton; -class BStatusBar; -class BTextControl; - -#include "HandBrake.h" - -#define RIP_TITLE_POPUP 'rtip' -#define RIP_BITRATE_RADIO 'rbir' -#define RIP_TARGET_CONTROL 'rtac' -#define RIP_CROP_BUTTON 'rcrb' -#define RIP_BROWSE_BUTTON 'rbrb' -#define RIP_SUSPEND_BUTTON 'rsub' -#define RIP_RIP_BUTTON 'rrib' - -class RipView : public BView -{ - public: - RipView( HBHandle * handle ); - void MessageReceived( BMessage * message ); - void UpdateIntf( HBStatus status, int modeChanged ); - - private: - HBHandle * fHandle; - HBList * fTitleList; - - BBox * fVideoBox; - BPopUpMenu * fTitlePopUp; - BMenuField * fTitleField; - BPopUpMenu * fVideoCodecPopUp; - BMenuField * fVideoCodecField; - BRadioButton * fCustomBitrateRadio; - BTextControl * fCustomBitrateControl; - BRadioButton * fTargetSizeRadio; - BTextControl * fTargetSizeControl; - BCheckBox * fTwoPassCheck; - BButton * fCropButton; - - BBox * fAudioBox; - BPopUpMenu * fLanguagePopUp; - BMenuField * fLanguageField; - BPopUpMenu * fSecondaryLanguagePopUp; - BMenuField * fSecondaryLanguageField; - BPopUpMenu * fAudioCodecPopUp; - BMenuField * fAudioCodecField; - BPopUpMenu * fAudioBitratePopUp; - BMenuField * fAudioBitrateField; - - BBox * fDestinationBox; - BPopUpMenu * fFileFormatPopUp; - BMenuField * fFileFormatField; - BTextControl * fFileControl; - BButton * fFileButton; - BFilePanel * fFilePanel; - - BStatusBar * fStatusBar; - BButton * fSuspendButton; - BButton * fStartButton; -}; - -#endif diff --git a/beos/ScanView.cpp b/beos/ScanView.cpp deleted file mode 100644 index 24c66db7f..000000000 --- a/beos/ScanView.cpp +++ /dev/null @@ -1,286 +0,0 @@ -/* $Id: ScanView.cpp,v 1.2 2003/11/06 14:36:54 titer Exp $ - - This file is part of the HandBrake source code. - Homepage: <http://handbrake.m0k.org/>. - It may be used under the terms of the GNU General Public License. */ - -#include <fs_info.h> -#include <sys/ioctl.h> -#include <Box.h> -#include <Button.h> -#include <Directory.h> -#include <Drivers.h> -#include <FilePanel.h> -#include <MenuField.h> -#include <MenuItem.h> -#include <Path.h> -#include <PopUpMenu.h> -#include <Query.h> -#include <RadioButton.h> -#include <StringView.h> -#include <TextControl.h> -#include <VolumeRoster.h> - -#include "ScanView.h" - -ScanView::ScanView( HBHandle * handle ) - : BView( BRect( 0,0,400,190 ), NULL, B_FOLLOW_ALL, B_WILL_DRAW ) -{ - fHandle = handle; - - BRect r; - SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) ); - - r = BRect( 10, 10, Bounds().Width() - 10, 115 ); - BBox * box = new BBox( r ); - box->SetLabel( "Select source:" ); - AddChild( box ); - - r = BRect( 10, 15, box->Bounds().Width() / 2, 35 ); - fRadioDetected = new BRadioButton( r, NULL, "Detected volume:", - new BMessage( SCAN_RADIO ) ); - box->AddChild( fRadioDetected ); - - r = BRect( box->Bounds().Width() / 2, 15, - box->Bounds().Width() - 10, 35 ); - fPopUp = new BPopUpMenu( "" ); - fField = new BMenuField( r, NULL, NULL, fPopUp, true ); - fField->SetDivider( 0 ); - box->AddChild( fField ); - - r = BRect( 10, 45, box->Bounds().Width() / 3, 65 ); - fRadioFolder = new BRadioButton( r, NULL, "DVD folder:", - new BMessage( SCAN_RADIO ) ); - box->AddChild( fRadioFolder ); - - r = BRect( box->Bounds().Width() / 3, 45, - box->Bounds().Width() - 10, 65 ); - fFolderControl = new BTextControl( r, NULL, NULL, NULL, NULL ); - box->AddChild( fFolderControl ); - - r = BRect( box->Bounds().Width() - 80, 70, - box->Bounds().Width() - 10, 95 ); - fBrowseButton = new BButton( r, NULL, "Browse...", - new BMessage( SCAN_BROWSE_BUTTON ) ); - box->AddChild( fBrowseButton ); - - fFilePanel = new BFilePanel( B_OPEN_PANEL, NULL, - NULL, B_DIRECTORY_NODE ); - - r = BRect( 10, 125, Bounds().Width() - 10, 145 ); - fStatusString = new BStringView( r, NULL, NULL ); - AddChild( fStatusString ); - - r = BRect( Bounds().Width() - 70, 155, - Bounds().Width() - 10, 175 ); - fOpenButton = new BButton( r, NULL, "Open", new BMessage( SCAN_OPEN ) ); - fOpenButton->MakeDefault( true ); - AddChild( fOpenButton ); - - DetectVolumes(); -} - -void ScanView::MessageReceived( BMessage * message ) -{ - switch( message->what ) - { - case SCAN_RADIO: - { - if( fRadioDetected->Value() ) - { - fField->SetEnabled( true ); - fFolderControl->SetEnabled( false ); - fBrowseButton->SetEnabled( false ); - fOpenButton->SetEnabled( fPopUp->CountItems() > 0 ); - } - else - { - fField->SetEnabled( false ); - fFolderControl->SetEnabled( true ); - fBrowseButton->SetEnabled( true ); - fOpenButton->SetEnabled( true ); - } - break; - } - - case SCAN_BROWSE_BUTTON: - { - fFilePanel->Show(); - break; - } - - case B_REFS_RECEIVED: - { - entry_ref ref; - if( message->FindRef( "refs", 0, &ref ) == B_OK ) - { - BPath * path = new BPath( &ref ); - fFolderControl->SetText( path->Path() ); - } - break; - } - - case SCAN_OPEN: - { - if( fRadioDetected->Value() ) - { - HBScanDevice( fHandle, - (char*) fPopUp->FindMarked()->Label(), - 0 ); - } - else - { - HBScanDevice( fHandle, - (char*) fFolderControl->Text(), 0 ); - } - break; - } - - default: - BView::MessageReceived( message ); - } -} - -void ScanView::UpdateIntf( HBStatus status, int modeChanged ) -{ - switch( status.mode ) - { - case HB_MODE_SCANNING: - { - if( modeChanged ) - { - fRadioDetected->SetEnabled( false ); - fRadioFolder->SetEnabled( false ); - fField->SetEnabled( false ); - fFolderControl->SetEnabled( false ); - fBrowseButton->SetEnabled( false ); - fOpenButton->SetEnabled( false ); - } - - char string[1024]; memset( string, 0, 1024 ); - if( !status.scannedTitle ) - { - sprintf( string, "Opening device..." ); - } - else - { - sprintf( string, "Scanning title %d...", - status.scannedTitle ); - } - fStatusString->SetText( string ); - break; - } - - case HB_MODE_INVALID_DEVICE: - { - if( !modeChanged ) - break; - - fRadioDetected->SetEnabled( true ); - fRadioFolder->SetEnabled( true ); - - if( fRadioDetected->Value() ) - { - fField->SetEnabled( true ); - fFolderControl->SetEnabled( false ); - fBrowseButton->SetEnabled( false ); - fOpenButton->SetEnabled( fPopUp->CountItems() > 0 ); - } - else - { - fField->SetEnabled( false ); - fFolderControl->SetEnabled( true ); - fBrowseButton->SetEnabled( true ); - fOpenButton->SetEnabled( true ); - } - - fStatusString->SetText( "Invalid volume." ); - break; - } - - default: - break; - } -} - -void ScanView::DetectVolumes() -{ - BVolumeRoster * roster = new BVolumeRoster(); - BVolume * volume = new BVolume(); - fs_info info; - int device; - device_geometry geometry; - - /* Parse mounted volumes */ - 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.BUP" ) != 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 ); - fRadioDetected->SetValue( true ); - fFolderControl->SetEnabled( false ); - fBrowseButton->SetEnabled( false ); - } - else - { - fRadioFolder->SetValue( true ); - fField->SetEnabled( false ); - } -} - diff --git a/beos/ScanView.h b/beos/ScanView.h deleted file mode 100644 index 11ed342cc..000000000 --- a/beos/ScanView.h +++ /dev/null @@ -1,48 +0,0 @@ -/* $Id: ScanView.h,v 1.2 2003/11/06 14:36:54 titer Exp $ - - This file is part of the HandBrake source code. - Homepage: <http://handbrake.m0k.org/>. - It may be used under the terms of the GNU General Public License. */ - -#ifndef HB_SCAN_VIEW_H -#define HB_SCAN_VIEW_H - -#include <View.h> -class BButton; -class BFilePanel; -class BMenuField; -class BPopUpMenu; -class BRadioButton; -class BStringView; -class BTextControl; - -#include "HandBrake.h" - -#define SCAN_RADIO 'scra' -#define SCAN_BROWSE_BUTTON 'sbrb' -#define SCAN_OPEN 'scop' - -class ScanView : public BView -{ - public: - ScanView( HBHandle * handle ); - void MessageReceived( BMessage * message ); - void UpdateIntf( HBStatus status, int modeChanged ); - - private: - void DetectVolumes(); - - HBHandle * fHandle; - - BRadioButton * fRadioDetected; - BRadioButton * fRadioFolder; - BMenuField * fField; - BPopUpMenu * fPopUp; - BTextControl * fFolderControl; - BButton * fBrowseButton; - BFilePanel * fFilePanel; - BStringView * fStatusString; - BButton * fOpenButton; -}; - -#endif diff --git a/beos/liblayout/HGroup.h b/beos/liblayout/HGroup.h new file mode 100644 index 000000000..9eee83fea --- /dev/null +++ b/beos/liblayout/HGroup.h @@ -0,0 +1,40 @@ + +#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 new file mode 100644 index 000000000..61264ca36 --- /dev/null +++ b/beos/liblayout/LayeredGroup.h @@ -0,0 +1,37 @@ + +#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 new file mode 100644 index 000000000..acdd13214 --- /dev/null +++ b/beos/liblayout/MApplication.h @@ -0,0 +1,29 @@ + +#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 new file mode 100644 index 000000000..351dfb800 --- /dev/null +++ b/beos/liblayout/MBViewWrapper.h @@ -0,0 +1,30 @@ + +#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 new file mode 100644 index 000000000..4e925ec2d --- /dev/null +++ b/beos/liblayout/MBorder.h @@ -0,0 +1,68 @@ + +#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 new file mode 100644 index 000000000..64cd3e32b --- /dev/null +++ b/beos/liblayout/MButton.h @@ -0,0 +1,53 @@ + +#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 new file mode 100644 index 000000000..7b39abda2 --- /dev/null +++ b/beos/liblayout/MCheckBox.h @@ -0,0 +1,33 @@ + +#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 new file mode 100644 index 000000000..800772b88 --- /dev/null +++ b/beos/liblayout/MDividable.h @@ -0,0 +1,35 @@ + +// 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 new file mode 100644 index 000000000..e345668c4 --- /dev/null +++ b/beos/liblayout/MDragBar.h @@ -0,0 +1,38 @@ + +#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 new file mode 100644 index 000000000..a9c017346 --- /dev/null +++ b/beos/liblayout/MEject.h @@ -0,0 +1,23 @@ +#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 new file mode 100644 index 000000000..97c0d53e1 --- /dev/null +++ b/beos/liblayout/MFFWD.h @@ -0,0 +1,24 @@ +#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 new file mode 100644 index 000000000..73dcbfb9c --- /dev/null +++ b/beos/liblayout/MGroup.h @@ -0,0 +1,31 @@ +/* + + 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 new file mode 100644 index 000000000..95c4d42ca --- /dev/null +++ b/beos/liblayout/MListView.h @@ -0,0 +1,30 @@ + +#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 new file mode 100644 index 000000000..a5b061a19 --- /dev/null +++ b/beos/liblayout/MMenuBar.h @@ -0,0 +1,33 @@ + +#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 new file mode 100644 index 000000000..acb00e19b --- /dev/null +++ b/beos/liblayout/MOutlineListView.h @@ -0,0 +1,32 @@ + +#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 new file mode 100644 index 000000000..687b5c28a --- /dev/null +++ b/beos/liblayout/MPictureButton.h @@ -0,0 +1,55 @@ +#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 new file mode 100644 index 000000000..043aa46d3 --- /dev/null +++ b/beos/liblayout/MPlayBW.h @@ -0,0 +1,23 @@ +#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 new file mode 100644 index 000000000..7f847df7b --- /dev/null +++ b/beos/liblayout/MPlayFW.h @@ -0,0 +1,22 @@ +#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 new file mode 100644 index 000000000..2223664ec --- /dev/null +++ b/beos/liblayout/MPopup.h @@ -0,0 +1,45 @@ + +#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 new file mode 100644 index 000000000..3938c2583 --- /dev/null +++ b/beos/liblayout/MProgressBar.h @@ -0,0 +1,58 @@ + +#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 new file mode 100644 index 000000000..bb430f2da --- /dev/null +++ b/beos/liblayout/MRadioGroup.h @@ -0,0 +1,46 @@ + +#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 new file mode 100644 index 000000000..f21683b5d --- /dev/null +++ b/beos/liblayout/MRew.h @@ -0,0 +1,22 @@ +#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 new file mode 100644 index 000000000..8ba21ce0e --- /dev/null +++ b/beos/liblayout/MScrollView.h @@ -0,0 +1,39 @@ + +#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 new file mode 100644 index 000000000..6e7077d3d --- /dev/null +++ b/beos/liblayout/MSlider.h @@ -0,0 +1,30 @@ + + +#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 new file mode 100644 index 000000000..411c5d14f --- /dev/null +++ b/beos/liblayout/MSplitter.h @@ -0,0 +1,38 @@ + +#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 new file mode 100644 index 000000000..b99fc2fe4 --- /dev/null +++ b/beos/liblayout/MStop.h @@ -0,0 +1,22 @@ +#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 new file mode 100644 index 000000000..4db74452e --- /dev/null +++ b/beos/liblayout/MStringView.h @@ -0,0 +1,25 @@ + +#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 new file mode 100644 index 000000000..04c69ec59 --- /dev/null +++ b/beos/liblayout/MTabView.h @@ -0,0 +1,33 @@ + +#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 new file mode 100644 index 000000000..46f1a746f --- /dev/null +++ b/beos/liblayout/MTextControl.h @@ -0,0 +1,36 @@ + +#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 new file mode 100644 index 000000000..512a85cd1 --- /dev/null +++ b/beos/liblayout/MTextView.h @@ -0,0 +1,31 @@ + +#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 new file mode 100644 index 000000000..9d70b7955 --- /dev/null +++ b/beos/liblayout/MVolume.h @@ -0,0 +1,48 @@ +#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 new file mode 100644 index 000000000..6118f87bc --- /dev/null +++ b/beos/liblayout/MWindow.h @@ -0,0 +1,62 @@ + +#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 new file mode 100644 index 000000000..81a3f1f9b --- /dev/null +++ b/beos/liblayout/PropGadget.h @@ -0,0 +1,75 @@ + +#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 new file mode 100644 index 000000000..c49f6fbd2 --- /dev/null +++ b/beos/liblayout/Space.h @@ -0,0 +1,22 @@ + +#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 new file mode 100644 index 000000000..3bb00db69 --- /dev/null +++ b/beos/liblayout/SpinButton.h @@ -0,0 +1,78 @@ + +#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 new file mode 100644 index 000000000..64a2cf9cc --- /dev/null +++ b/beos/liblayout/TabGroup.h @@ -0,0 +1,46 @@ + +#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 new file mode 100644 index 000000000..56be070df --- /dev/null +++ b/beos/liblayout/VGroup.h @@ -0,0 +1,41 @@ + +#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 new file mode 100644 index 000000000..b2e78df10 --- /dev/null +++ b/beos/liblayout/layout-all.h @@ -0,0 +1,35 @@ +#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 new file mode 100644 index 000000000..772b251db --- /dev/null +++ b/beos/liblayout/layout.h @@ -0,0 +1,168 @@ +/* + + 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 |