2002-11-24 00:26:55 +00:00
#include <Alert.h>
2002-07-09 12:24:59 +00:00
#include <Application.h>
#include <Button.h>
2002-11-24 00:26:55 +00:00
#include <InterfaceDefs.h>
#include <Menu.h>
#include <MenuItem.h>
#include <Messenger.h>
2002-07-09 12:24:59 +00:00
#include <String.h>
#include <Screen.h>
2002-11-24 00:26:55 +00:00
#include <Window.h>
#include <math.h>
2002-07-09 12:24:59 +00:00
#include <cstring>
#include <cstdlib>
2002-11-27 15:45:32 +00:00
#include <cstdio>
2002-07-09 12:24:59 +00:00
#include "ScreenWindow.h"
#include "ScreenDrawView.h"
#include "ScreenView.h"
#include "AlertWindow.h"
#include "Constants.h"
2002-11-24 00:26:55 +00:00
#include "Utility.h"
2002-07-09 12:24:59 +00:00
ScreenWindow :: ScreenWindow ( ScreenSettings * Settings )
: BWindow ( Settings -> WindowFrame (), "Screen" , B_TITLED_WINDOW , B_NOT_RESIZABLE | B_NOT_ZOOMABLE , B_ALL_WORKSPACES )
{
2002-11-24 00:26:55 +00:00
BRect frame ( Bounds ());
BScreen screen ( B_MAIN_SCREEN_ID );
if ( ! screen . IsValid ()) {
//What could we do?
//debugger() ?
}
screen . GetModeList ( & fSupportedModes , & fTotalModes );
2002-07-09 12:24:59 +00:00
fScreenView = new ScreenView ( frame , "ScreenView" );
AddChild ( fScreenView );
fSettings = Settings ;
BRect ScreenBoxRect ;
BRect ScreenDrawViewRect ;
BRect ControlsBoxRect ;
BRect WorkspaceMenuRect ;
BRect WorkspaceCountMenuRect ;
BRect ControlMenuRect ;
BRect ButtonRect ;
ScreenBoxRect . Set ( 11.0 , 18.0 , 153.0 , 155.0 );
fScreenBox = new BBox ( ScreenBoxRect );
fScreenBox -> SetBorder ( B_FANCY_BORDER );
ScreenDrawViewRect . Set ( 20.0 , 16.0 , 122.0 , 93.0 );
fScreenDrawView = new ScreenDrawView ( ScreenDrawViewRect , "ScreenDrawView" );
BString String ;
String << count_workspaces ();
fWorkspaceCountMenu = new BPopUpMenu ( String . String (), true , true );
2002-11-24 00:26:55 +00:00
for ( int32 Count = 1 ; Count <= 32 ; Count ++ )
2002-07-09 12:24:59 +00:00
{
String . Truncate ( 0 );
String << Count ;
fWorkspaceCountMenu -> AddItem ( new BMenuItem ( String . String (), new BMessage ( POP_WORKSPACE_CHANGED_MSG )));
}
String . Truncate ( 0 );
String << count_workspaces ();
BMenuItem * Marked = fWorkspaceCountMenu -> FindItem ( String . String ());
Marked -> SetMarked ( true );
WorkspaceCountMenuRect . Set ( 7.0 , 107.0 , 135.0 , 127.0 );
fWorkspaceCountField = new BMenuField ( WorkspaceCountMenuRect , "WorkspaceCountMenu" , "Workspace count:" , fWorkspaceCountMenu , true );
fWorkspaceCountField -> SetDivider ( 91.0 );
fScreenBox -> AddChild ( fScreenDrawView );
fScreenBox -> AddChild ( fWorkspaceCountField );
fScreenView -> AddChild ( fScreenBox );
fWorkspaceMenu = new BPopUpMenu ( "Current Workspace" , true , true );
fAllWorkspacesItem = new BMenuItem ( "All Workspaces" , new BMessage ( WORKSPACE_CHECK_MSG ));
fWorkspaceMenu -> AddItem ( fAllWorkspacesItem );
fCurrentWorkspaceItem = new BMenuItem ( "Current Workspace" , new BMessage ( WORKSPACE_CHECK_MSG ));
fCurrentWorkspaceItem -> SetMarked ( true );
fWorkspaceMenu -> AddItem ( fCurrentWorkspaceItem );
WorkspaceMenuRect . Set ( 0.0 , 0.0 , 132.0 , 18.0 );
fWorkspaceField = new BMenuField ( WorkspaceMenuRect , "WorkspaceMenu" , NULL , fWorkspaceMenu , true );
ControlsBoxRect . Set ( 164.0 , 7.0 , 345.0 , 155.0 );
fControlsBox = new BBox ( ControlsBoxRect );
fControlsBox -> SetBorder ( B_FANCY_BORDER );
fControlsBox -> SetLabel ( fWorkspaceField );
ButtonRect . Set ( 88.0 , 114.0 , 200.0 , 150.0 );
fApplyButton = new BButton ( ButtonRect , "ApplyButton" , "Apply" ,
new BMessage ( BUTTON_APPLY_MSG ));
fApplyButton -> AttachedToWindow ();
fApplyButton -> ResizeToPreferred ();
fApplyButton -> SetEnabled ( false );
fControlsBox -> AddChild ( fApplyButton );
fResolutionMenu = new BPopUpMenu ( "640 x 480" , true , true );
2002-11-24 00:26:55 +00:00
for ( uint32 c = 0 ; c < fTotalModes ; c ++ ) {
BString mode ;
mode << ( int32 ) fSupportedModes [ c ]. virtual_width << " x " << ( int32 ) fSupportedModes [ c ]. virtual_height ;
if ( ! fResolutionMenu -> FindItem ( mode . String ()))
fResolutionMenu -> AddItem ( new BMenuItem ( mode . String (),
new BMessage ( POP_RESOLUTION_MSG )));
}
2002-07-09 12:24:59 +00:00
ControlMenuRect . Set ( 33.0 , 30.0 , 171.0 , 48.0 );
fResolutionField = new BMenuField ( ControlMenuRect , "ResolutionMenu" , "Resolution:" , fResolutionMenu , true );
2002-11-27 14:41:16 +00:00
Marked = fResolutionMenu -> ItemAt ( 0 );
2002-07-09 12:24:59 +00:00
Marked -> SetMarked ( true );
fResolutionField -> SetDivider ( 55.0 );
fControlsBox -> AddChild ( fResolutionField );
fColorsMenu = new BPopUpMenu ( "8 Bits/Pixel" , true , true );
2002-12-04 14:26:01 +00:00
// Get the supported colorspaces
for ( uint32 c = 0 ; c < fTotalModes ; c ++ ) {
BString colorSpace ;
switch ( fSupportedModes [ c ]. space ) {
case B_CMAP8 :
colorSpace = "8 Bits/Pixel" ;
break ;
case B_RGB15 :
colorSpace = "15 Bits/Pixel" ;
break ;
case B_RGB16 :
colorSpace = "16 Bits/Pixel" ;
break ;
case B_RGB32 :
colorSpace = "32 Bits/Pixel" ;
break ;
}
if ( ! fColorsMenu -> FindItem ( colorSpace . String ()))
fColorsMenu -> AddItem ( new BMenuItem ( colorSpace . String (),
new BMessage ( POP_COLORS_MSG )));
}
2002-07-09 12:24:59 +00:00
ControlMenuRect . Set ( 50.0 , 58.0 , 171.0 , 76.0 );
fColorsField = new BMenuField ( ControlMenuRect , "ColorsMenu" , "Colors:" , fColorsMenu , true );
2002-12-04 14:26:01 +00:00
Marked = fColorsMenu -> ItemAt ( 0 );
2002-07-09 12:24:59 +00:00
Marked -> SetMarked ( true );
fColorsField -> SetDivider ( 38.0 );
2002-11-24 00:26:55 +00:00
fControlsBox -> AddChild ( fColorsField );
2002-07-09 12:24:59 +00:00
fRefreshMenu = new BPopUpMenu ( "60 Hz" , true , true );
fRefreshMenu -> AddItem ( new BMenuItem ( "56 Hz" , new BMessage ( POP_REFRESH_MSG )));
fRefreshMenu -> AddItem ( new BMenuItem ( "60 Hz" , new BMessage ( POP_REFRESH_MSG )));
fRefreshMenu -> AddItem ( new BMenuItem ( "70 Hz" , new BMessage ( POP_REFRESH_MSG )));
fRefreshMenu -> AddItem ( new BMenuItem ( "72 Hz" , new BMessage ( POP_REFRESH_MSG )));
fRefreshMenu -> AddItem ( new BMenuItem ( "75 Hz" , new BMessage ( POP_REFRESH_MSG )));
fRefreshMenu -> AddItem ( new BMenuItem ( "Other..." , new BMessage ( POP_OTHER_REFRESH_MSG )));
2002-12-04 14:26:01 +00:00
2002-07-09 12:24:59 +00:00
ControlMenuRect . Set ( 19.0 , 86.0 , 171.0 , 104.0 );
fRefreshField = new BMenuField ( ControlMenuRect , "RefreshMenu" , "Refresh Rate:" , fRefreshMenu , true );
Marked = fRefreshMenu -> FindItem ( "60 Hz" );
Marked -> SetMarked ( true );
fRefreshField -> SetDivider ( 69.0 );
fControlsBox -> AddChild ( fRefreshField );
fScreenView -> AddChild ( fControlsBox );
ButtonRect . Set ( 10.0 , 167 , 100.0 , 200.0 );
fDefaultsButton = new BButton ( ButtonRect , "DefaultsButton" , "Defaults" ,
2002-11-24 00:26:55 +00:00
new BMessage ( BUTTON_DEFAULTS_MSG ));
2002-07-09 12:24:59 +00:00
fDefaultsButton -> AttachedToWindow ();
fDefaultsButton -> ResizeToPreferred ();
fScreenView -> AddChild ( fDefaultsButton );
ButtonRect . Set ( 95.0 , 167 , 160.0 , 200.0 );
fRevertButton = new BButton ( ButtonRect , "RevertButton" , "Revert" ,
2002-11-24 00:26:55 +00:00
new BMessage ( BUTTON_REVERT_MSG ));
2002-07-09 12:24:59 +00:00
fRevertButton -> AttachedToWindow ();
fRevertButton -> ResizeToPreferred ();
fRevertButton -> SetEnabled ( false );
fScreenView -> AddChild ( fRevertButton );
2002-11-24 00:26:55 +00:00
2002-07-09 12:24:59 +00:00
display_mode mode ;
2002-11-24 00:26:55 +00:00
screen . GetMode ( & mode );
2002-07-09 12:24:59 +00:00
fInitialMode = mode ;
String . Truncate ( 0 );
2002-11-24 00:26:55 +00:00
String << ( uint32 ) mode . virtual_width << " x " << ( uint32 ) mode . virtual_height ;
2002-07-09 12:24:59 +00:00
Marked = fResolutionMenu -> FindItem ( String . String ());
Marked -> SetMarked ( true );
fInitialResolution = Marked ;
2002-11-24 00:26:55 +00:00
if ( mode . space == B_CMAP8 ){
2002-07-09 12:24:59 +00:00
Marked = fColorsMenu -> FindItem ( "8 Bits/Pixel" );
Marked -> SetMarked ( true );
2002-11-24 00:26:55 +00:00
} else if ( mode . space == B_RGB15 ) {
2002-07-09 12:24:59 +00:00
Marked = fColorsMenu -> FindItem ( "15 Bits/Pixel" );
Marked -> SetMarked ( true );
2002-11-24 00:26:55 +00:00
} else if ( mode . space == B_RGB16 ) {
2002-07-09 12:24:59 +00:00
Marked = fColorsMenu -> FindItem ( "16 Bits/Pixel" );
Marked -> SetMarked ( true );
2002-11-24 00:26:55 +00:00
} else if ( mode . space == B_RGB32 ) {
2002-07-09 12:24:59 +00:00
Marked = fColorsMenu -> FindItem ( "32 Bits/Pixel" );
Marked -> SetMarked ( true );
}
fInitialColors = Marked ;
String . Truncate ( 0 );
2002-11-24 00:26:55 +00:00
float total_size = mode . timing . h_total * mode . timing . v_total ;
2002-07-09 12:24:59 +00:00
2002-11-24 00:26:55 +00:00
fInitialRefreshN = round (( mode . timing . pixel_clock * 1000 ) / total_size , 1 );
2002-07-09 12:24:59 +00:00
fCustomRefresh = fInitialRefreshN ;
2002-11-24 00:26:55 +00:00
String << fInitialRefreshN << " Hz" ;
2002-07-09 12:24:59 +00:00
Marked = fRefreshMenu -> FindItem ( String . String ());
2002-12-04 14:26:01 +00:00
if ( Marked != NULL ) {
Marked -> SetMarked ( true );
2002-07-09 12:24:59 +00:00
fInitialRefresh = Marked ;
2002-12-04 14:26:01 +00:00
} else {
BMenuItem * Other = fRefreshMenu -> FindItem ( "Other..." );
2002-07-09 12:24:59 +00:00
String . Truncate ( 0 );
2002-11-24 00:26:55 +00:00
String << fInitialRefreshN ;
2002-07-09 12:24:59 +00:00
2002-12-04 14:26:01 +00:00
int32 point = String . FindFirst ( '.' );
String . Truncate ( point + 2 );
2002-07-09 12:24:59 +00:00
String << " Hz/Other..." ;
Other -> SetLabel ( String . String ());
Other -> SetMarked ( true );
2002-12-04 14:26:01 +00:00
point = String . FindFirst ( '/' );
String . Truncate ( point );
2002-07-09 12:24:59 +00:00
fRefreshMenu -> Superitem () -> SetLabel ( String . String ());
fInitialRefresh = Other ;
}
Show ();
}
ScreenWindow ::~ ScreenWindow ()
{
delete fSettings ;
2002-11-24 00:26:55 +00:00
delete [] fSupportedModes ;
2002-07-09 12:24:59 +00:00
}
2002-11-24 00:26:55 +00:00
bool
ScreenWindow :: QuitRequested ()
2002-07-09 12:24:59 +00:00
{
be_app -> PostMessage ( B_QUIT_REQUESTED );
2002-11-24 00:26:55 +00:00
return BWindow :: QuitRequested ();
2002-07-09 12:24:59 +00:00
}
2002-11-24 00:26:55 +00:00
void
ScreenWindow :: FrameMoved ( BPoint position )
2002-07-09 12:24:59 +00:00
{
fSettings -> SetWindowFrame ( Frame ());
}
2002-11-24 00:26:55 +00:00
void
ScreenWindow :: ScreenChanged ( BRect frame , color_space mode )
2002-07-09 12:24:59 +00:00
{
if ( frame . right <= Frame (). right
&& frame . bottom <= Frame (). bottom )
MoveTo ((( frame . right / 2 ) - 178 ), (( frame . right / 2 ) - 101 ));
}
2002-11-24 00:26:55 +00:00
void
ScreenWindow :: WorkspaceActivated ( int32 ws , bool state )
2002-07-09 12:24:59 +00:00
{
PostMessage ( new BMessage ( UPDATE_DESKTOP_COLOR_MSG ), fScreenDrawView );
}
2002-11-24 00:26:55 +00:00
void
ScreenWindow :: CheckApplyEnabled ()
2002-07-09 12:24:59 +00:00
{
int equals = 0 ;
if ( fResolutionMenu -> FindMarked () == fInitialResolution )
2002-11-24 00:26:55 +00:00
equals ++ ;
2002-07-09 12:24:59 +00:00
else
2002-11-24 00:26:55 +00:00
equals -- ;
2002-07-09 12:24:59 +00:00
if ( fColorsMenu -> FindMarked () == fInitialColors )
2002-11-24 00:26:55 +00:00
equals ++ ;
2002-07-09 12:24:59 +00:00
else
2002-11-24 00:26:55 +00:00
equals -- ;
2002-07-09 12:24:59 +00:00
if ( fRefreshMenu -> FindMarked () == fInitialRefresh )
2002-11-24 00:26:55 +00:00
equals ++ ;
2002-07-09 12:24:59 +00:00
else
2002-11-24 00:26:55 +00:00
equals -- ;
2002-12-04 14:26:01 +00:00
if ( equals != 3 ) {
2002-07-09 12:24:59 +00:00
fApplyButton -> SetEnabled ( true );
fRevertButton -> SetEnabled ( true );
2002-11-24 00:26:55 +00:00
} else {
2002-07-09 12:24:59 +00:00
fApplyButton -> SetEnabled ( false );
fRevertButton -> SetEnabled ( false );
}
}
2002-11-24 00:26:55 +00:00
void
ScreenWindow :: MessageReceived ( BMessage * message )
2002-07-09 12:24:59 +00:00
{
switch ( message -> what )
{
case WORKSPACE_CHECK_MSG :
{
fApplyButton -> SetEnabled ( true );
break ;
}
case POP_WORKSPACE_CHANGED_MSG :
{
BMenuItem * Item = fWorkspaceCountMenu -> FindMarked ();
set_workspace_count ( fWorkspaceCountMenu -> IndexOf ( Item ) + 1 );
break ;
}
case POP_RESOLUTION_MSG :
{
CheckApplyEnabled ();
BMessage * Message = new BMessage ( UPDATE_DESKTOP_MSG );
2002-11-24 00:26:55 +00:00
const char * Resolution = fResolutionMenu -> FindMarked () -> Label ();
2002-07-09 12:24:59 +00:00
Message -> AddString ( "resolution" , Resolution );
PostMessage ( Message , fScreenDrawView );
break ;
}
case POP_COLORS_MSG :
{
CheckApplyEnabled ();
break ;
}
case POP_REFRESH_MSG :
{
CheckApplyEnabled ();
break ;
}
case POP_OTHER_REFRESH_MSG :
{
CheckApplyEnabled ();
2002-11-24 00:26:55 +00:00
int32 value = ( int32 )( fCustomRefresh * 10 );
fRefreshWindow = new RefreshWindow ( BRect (( Frame (). left + 201.0 ),
( Frame (). top + 34.0 ), ( Frame (). left + 509.0 ),
( Frame (). top + 169.0 )), value );
2002-07-09 12:24:59 +00:00
BMenuItem * Other = fRefreshMenu -> FindItem ( POP_OTHER_REFRESH_MSG );
BString String ;
String << Other -> Label ();
2002-11-26 06:21:36 +00:00
int32 point = String . FindFirst ( 'z' );
String . Truncate ( point + 1 );
2002-07-09 12:24:59 +00:00
fRefreshMenu -> Superitem () -> SetLabel ( String . String ());
break ;
}
case BUTTON_DEFAULTS_MSG :
{
2002-11-27 14:41:16 +00:00
fResolutionMenu -> ItemAt ( 0 ) -> SetMarked ( true );
2002-07-09 12:24:59 +00:00
fColorsMenu -> FindItem ( "8 Bits/Pixel" ) -> SetMarked ( true );
fRefreshMenu -> FindItem ( "60 Hz" ) -> SetMarked ( true );
CheckApplyEnabled ();
break ;
}
case BUTTON_REVERT_MSG :
2002-11-27 15:45:32 +00:00
case SET_INITIAL_MODE_MSG :
2002-07-09 12:24:59 +00:00
{
fInitialResolution -> SetMarked ( true );
fInitialColors -> SetMarked ( true );
fInitialRefresh -> SetMarked ( true );
CheckApplyEnabled ();
BMenuItem * Other = fRefreshMenu -> FindItem ( POP_OTHER_REFRESH_MSG );
if ( fInitialRefresh == Other )
{
2002-11-26 06:21:36 +00:00
BString string ;
2002-11-24 00:26:55 +00:00
string << fInitialRefreshN ;
2002-11-26 06:21:36 +00:00
int32 point = string . FindFirst ( '.' );
string . Truncate ( point + 2 );
2002-07-09 12:24:59 +00:00
2002-11-24 00:26:55 +00:00
string << " Hz/Other..." ;
2002-07-09 12:24:59 +00:00
2002-11-24 00:26:55 +00:00
fRefreshMenu -> FindItem ( POP_OTHER_REFRESH_MSG ) -> SetLabel ( string . String ());
2002-07-09 12:24:59 +00:00
2002-11-26 06:21:36 +00:00
point = string . FindFirst ( '/' );
string . Truncate ( point );
2002-07-09 12:24:59 +00:00
2002-11-24 00:26:55 +00:00
fRefreshMenu -> Superitem () -> SetLabel ( string . String ());
2002-07-09 12:24:59 +00:00
}
2002-11-27 15:45:32 +00:00
if ( message -> what == SET_INITIAL_MODE_MSG )
{
BScreen screen ( B_MAIN_SCREEN_ID );
if ( ! screen . IsValid ())
break ;
screen . SetMode ( & fInitialMode );
}
2002-07-09 12:24:59 +00:00
break ;
}
case BUTTON_APPLY_MSG :
{
2002-11-24 00:26:55 +00:00
BScreen screen ( B_MAIN_SCREEN_ID );
2002-07-09 12:24:59 +00:00
2002-11-24 00:26:55 +00:00
if ( ! screen . IsValid ())
break ;
2002-07-09 12:24:59 +00:00
2002-11-24 00:26:55 +00:00
display_mode * mode = NULL ;
BString string ;
int32 height ;
int32 width ;
float refresh ;
BString menuLabel = fResolutionMenu -> FindMarked () -> Label ();
int32 space = menuLabel . FindFirst ( ' ' );
menuLabel . MoveInto ( string , 0 , space );
2002-11-26 06:21:36 +00:00
menuLabel . Remove ( 0 , 3 );
2002-11-24 00:26:55 +00:00
width = atoi ( string . String ());
height = atoi ( menuLabel . String ());
2002-11-26 06:21:36 +00:00
if ( fRefreshMenu -> FindMarked () == fRefreshMenu -> FindItem ( POP_OTHER_REFRESH_MSG ))
refresh = fCustomRefresh ;
else
refresh = atof ( fRefreshMenu -> FindMarked () -> Label ());
2002-11-24 00:26:55 +00:00
for ( uint32 c = 0 ; c < fTotalModes ; c ++ )
2002-07-09 12:24:59 +00:00
{
2002-11-24 00:26:55 +00:00
if (( fSupportedModes [ c ]. virtual_width == width )
&& ( fSupportedModes [ c ]. virtual_height == height ))
2002-07-09 12:24:59 +00:00
2002-11-24 00:26:55 +00:00
mode = & fSupportedModes [ c ];
2002-07-09 12:24:59 +00:00
}
2002-11-26 06:21:36 +00:00
mode -> timing . pixel_clock = ( uint32 )(( mode -> timing . h_total * mode -> timing . v_total ) * refresh / 1000 );
2002-07-09 12:24:59 +00:00
if ( fColorsMenu -> FindMarked () == fColorsMenu -> FindItem ( "8 Bits/Pixel" ))
{
mode -> space = B_CMAP8 ;
}
else if ( fColorsMenu -> FindMarked () == fColorsMenu -> FindItem ( "15 Bits/Pixel" ))
{
mode -> space = B_RGB15 ;
}
else if ( fColorsMenu -> FindMarked () == fColorsMenu -> FindItem ( "16 Bits/Pixel" ))
{
mode -> space = B_RGB16 ;
}
else if ( fColorsMenu -> FindMarked () == fColorsMenu -> FindItem ( "32 Bits/Pixel" ))
{
mode -> space = B_RGB32 ;
}
mode -> h_display_start = 0 ;
mode -> v_display_start = 0 ;
if ( fWorkspaceMenu -> FindMarked () == fWorkspaceMenu -> FindItem ( "All Workspaces" ))
2002-11-26 06:21:36 +00:00
{
2002-12-04 14:26:01 +00:00
BAlert * WorkspacesAlert = new BAlert ( "WorkspacesAlert" , "Change all workspaces? \n This action cannot be reverted" , "Okay" , "Cancel" , NULL , B_WIDTH_AS_USUAL , B_WARNING_ALERT );
2002-11-26 06:21:36 +00:00
int32 button = WorkspacesAlert -> Go ();
2002-07-09 12:24:59 +00:00
if ( button == 1 )
break ;
2002-11-24 00:26:55 +00:00
int32 old = current_workspace ();
int32 totalWorkspaces = count_workspaces ();
2002-07-09 12:24:59 +00:00
2002-11-24 00:26:55 +00:00
for ( int32 count = 0 ; count < totalWorkspaces ; count ++ )
2002-07-09 12:24:59 +00:00
{
activate_workspace ( count );
2002-12-04 14:26:01 +00:00
screen . SetMode ( mode , true );
2002-07-09 12:24:59 +00:00
}
activate_workspace ( old );
}
else
2002-11-24 00:26:55 +00:00
screen . SetMode ( mode );
2002-07-09 12:24:59 +00:00
2002-11-24 00:26:55 +00:00
BRect Rect ( 100.0 , 100.0 , 400.0 , 193.0 );
2002-07-09 12:24:59 +00:00
2002-11-24 00:26:55 +00:00
Rect . left = ( screen . Frame (). right / 2 ) - 150 ;
Rect . top = ( screen . Frame (). bottom / 2 ) - 42 ;
2002-07-09 12:24:59 +00:00
Rect . right = Rect . left + 300.0 ;
Rect . bottom = Rect . top + 93.0 ;
2002-12-04 14:26:01 +00:00
new AlertWindow ( Rect );
2002-11-24 00:26:55 +00:00
fApplyButton -> SetEnabled ( false );
2002-07-09 12:24:59 +00:00
break ;
}
case SET_CUSTOM_REFRESH_MSG :
{
message -> FindFloat ( "refresh" , & fCustomRefresh );
BMenuItem * Other = fRefreshMenu -> FindItem ( POP_OTHER_REFRESH_MSG );
Other -> SetMarked ( true );
2002-11-26 06:21:36 +00:00
BString String ;
2002-07-09 12:24:59 +00:00
String << fCustomRefresh ;
2002-11-26 06:21:36 +00:00
int32 point = String . FindFirst ( '.' );
String . Truncate ( point + 2 );
2002-07-09 12:24:59 +00:00
String << " Hz/Other..." ;
fRefreshMenu -> FindItem ( POP_OTHER_REFRESH_MSG ) -> SetLabel ( String . String ());
2002-11-27 15:45:32 +00:00
point = String . FindFirst ( '/' );
String . Truncate ( point );
2002-07-09 12:24:59 +00:00
fRefreshMenu -> Superitem () -> SetLabel ( String . String ());
if ( fCustomRefresh != fInitialRefreshN )
{
fApplyButton -> SetEnabled ( true );
fRevertButton -> SetEnabled ( true );
}
break ;
}
case MAKE_INITIAL_MSG :
{
2002-11-27 14:41:16 +00:00
BScreen screen ( B_MAIN_SCREEN_ID );
if ( ! screen . IsValid ())
break ;
display_mode mode ;
2002-11-24 00:26:55 +00:00
screen . GetMode ( & mode );
2002-12-04 14:26:01 +00:00
screen . SetMode ( & mode , true );
2002-07-09 12:24:59 +00:00
fInitialRefreshN = fCustomRefresh ;
fInitialResolution = fResolutionMenu -> FindMarked ();
fInitialColors = fColorsMenu -> FindMarked ();
fInitialRefresh = fRefreshMenu -> FindMarked ();
fInitialMode = mode ;
break ;
}
default :
2002-11-24 00:26:55 +00:00
BWindow :: MessageReceived ( message );
2002-07-09 12:24:59 +00:00
break ;
}
}