Пример #1
0
status_t
GlutGameMode::Enter()
{
	display_mode* mode = _FindMatchingMode();
	if (!mode)
		return B_BAD_VALUE;

	BScreen screen;
	if (!fActive) {
		// First enter: remember this workspace original mode...
		fGameModeWorkspace = current_workspace();
		screen.GetMode(fGameModeWorkspace, &fOriginalMode);
	}

	// Don't make it new default mode for this workspace...
	status_t status = screen.SetMode(fGameModeWorkspace, mode, false);
	if (status != B_OK)
		return status;

	// Retrieve the new active display mode, which could be
	// a sligth different than the one we asked for...
	screen.GetMode(fGameModeWorkspace, &fCurrentMode);

	if (!fGameModeWindow) {
		// create a new window
		fPreviousWindow = glutGetWindow();
		fGameModeWindow = glutCreateWindow("glutGameMode");
		if (!fGameModeWindow)
			return Leave();
	} else
		// make sure it's the current window
		glutSetWindow(fGameModeWindow);

	BDirectWindow *directWindow
		= dynamic_cast<BDirectWindow*>(gState.currentWindow->Window());
	if (directWindow == NULL)
		// Hum?!
		return B_ERROR;

	// Give it some useless title, except for debugging (thread name).
	BString name;
	name << "Game Mode " << fCurrentMode.virtual_width
		<< "x" << fCurrentMode.virtual_height
		<< ":" << _GetModePixelDepth(&fCurrentMode)
		<< "@" << _GetModeRefreshRate(&fCurrentMode);

	// force the game mode window to fullscreen
	directWindow->Lock();
	directWindow->SetTitle(name.String());
	directWindow->SetFullScreen(true);
	directWindow->Unlock();

	fDisplayChanged = true;
	fActive = true;

	return B_OK;
}
Пример #2
0
void restoreWorkspaceResolution()
{
	BScreen screen;
	display_mode displayMode;

	if (screen.GetMode(&displayMode) == B_OK && memcmp(&displayMode,&gDisplayMode,sizeof(display_mode)))
		screen.SetMode(&gDisplayMode);
}
Пример #3
0
void set_display(Display* dpy) {
  static Depth dlist[1];
  static Visual vlist[1];
  static Screen slist[1];
  static char vstring[] = "libB11";
  Colormap cmap = 0;

  BRect rect;
  display_mode mode;
  BScreen screen;
  screen.GetMode(&mode);
  
  memset(slist, 0, sizeof(Screen));

  dlist[0].depth = mode.space;
  dlist[0].nvisuals = 1;
  dlist[0].visuals  = vlist;

  vlist[0].ext_data     = NULL;
  vlist[0].visualid     = 0;
  vlist[0].c_class       = TrueColor;
  vlist[0].bits_per_rgb = 24;
  vlist[0].map_entries  = 256;
  vlist[0].red_mask     = 255;
  vlist[0].green_mask   = 255 << 8;
  vlist[0].blue_mask    = 255 << 16;
  rect = screen.Frame();
  slist[0].width       = static_cast<int>(rect.right - rect.left);
  slist[0].height      = static_cast<int>(rect.bottom - rect.top);
  slist[0].mwidth      = 260;
  slist[0].mheight     = 190;
  slist[0].ndepths     = 1;
  slist[0].depths      = dlist;
  slist[0].root_depth  = mode.space;
  slist[0].root_visual = vlist;
  slist[0].default_gc  = NULL;
  slist[0].cmap        = cmap;
  slist[0].white_pixel = 0xFFFFFF;
  slist[0].black_pixel = 0;

  slist[0].display = dpy;

  dpy->ext_data            = NULL;
  dpy->fd                  = 0;
  dpy->proto_major_version = 11;
  dpy->proto_minor_version = 4;
  dpy->vendor              = vstring;
  dpy->display_name        = vstring;
  dpy->nscreens            = 1;
  dpy->screens             = slist;
  dpy->max_keycode         = 255;
  dpy->qlen                = 0;
  dpy->head = dpy->tail    = NULL;
  dpy->qfree               = NULL;

  dpy->free_funcs = (_XFreeFuncRec *)Xcalloc(1, sizeof(_XFreeFuncRec));
}
Пример #4
0
void UAE::ReadyToRun(void)
{
	{
		BScreen screen;
		screen.GetMode(&gDisplayMode);
	}

	// Start the emulation thread
	fEmulationThread = spawn_thread(EmulationThreadFunc, "UAE 68k", B_NORMAL_PRIORITY, this);
	resume_thread(fEmulationThread);
}
Пример #5
0
void AboutWindow::Show() {
	BScreen *screen = new BScreen( this );
	display_mode mode;
	screen->GetMode( &mode );
	/* we center a window */
	int32 width = (int32)( ABOUTWINDOW_RECT.right - ABOUTWINDOW_RECT.left );
	int32 height = (int32)( ABOUTWINDOW_RECT.bottom - ABOUTWINDOW_RECT.top );
	/* calculating center of a screen /2 - 1/2 of window width */
	int32 x_wind = mode.timing.h_display/2 - ( width/2 );
	/* calculating center of a screen /2 - 1/2 of window height */
	int32 y_wind = mode.timing.v_display/2 - ( height/2 );
	MoveTo( x_wind, y_wind );
	BWindow::Show();
}
/*!	\function	ColorUpdateWindow::ColorUpdateWindow
 *	\brief		Constructor.
 *	\param[in]	corner	One of the corners of the window IN SCREEN COORDINATES!
 *	\param[in]	label	Label of the color. (Usually name of the category).
 *	\param[in]	enableEditingLabel	If "true", label can be edited. If "false", it's constant.
 *	\param[in]	title			Title of the window
 *	\param[in]	defaultColor	Original color. Defaults to black.
 *	\param[in]	targetLooper	The target which receives message with the results.
 *	\param[in]	currentScreen	Defines the screen the program runs in. Usually it's
 *								B_MAIN_SCREEN_ID.
 *	\param[in]	message			The template message to be used. If this parameter is NULL,
 *								a new message is constructed.
 */
ColorUpdateWindow::ColorUpdateWindow( BPoint corner,
								  	  BString& label,
								  	  rgb_color &defaultColor,
								  	  bool enableEditingLabel,
								  	  BString title,
								      BHandler *targetHandler,
								      screen_id currentScreen,
								   	  BMessage* message )
	:
	BWindow( BRect( 100, 100, 300, 500 ),
			 title.String(),
			 B_MODAL_WINDOW,
			 B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_ASYNCHRONOUS_CONTROLS | B_WILL_ACCEPT_FIRST_CLICK ),
	originalString( label ),
	originalColor( defaultColor),
	labelView( NULL ),
	okButton( NULL ),
	revertButton( NULL ),
	messageToSend( NULL ),
	target( targetHandler ),
	dirty( false )
{
	BSize layoutSize;
	BLayoutItem* item = NULL;
	float width, height, dontCare;
	BView* background = new BView( this->Bounds(),
								   "Background",
								   B_FOLLOW_LEFT | B_FOLLOW_TOP,
								   B_FRAME_EVENTS | B_WILL_DRAW );
	if ( !background )
	{
		/* Panic! */
		exit(1);
	}
	background->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );	
	
	this->enableEditingLabel = enableEditingLabel;
	
	/* There are three parts in the interface of the control.
	 * Upmost is the label, which, according to the user's settings,
	 * can be editable or not.
	 * Next is the color control.
	 * Last is the row of two buttons, Revert and Ok.
	 */

	// Debugging
	printf( "Color Selected = %u, Color Reverted = %u.\n",
			kColorSelected,
			kColorReverted );

	// Construct background view and layout
	BGridLayout* layout = new BGridLayout( B_VERTICAL );
	if ( !layout ) { /* Panic! */ exit(1); }
	layout->SetInsets( 5, 5, 5, 5 );
	
	background->SetLayout( layout );
	this->AddChild( background );

	// Constructing the name label, editable or not.
	if ( enableEditingLabel )
	{
		labelView = new BTextControl( BRect(0, 0, 1, 1),
									  "Label",
								   	  NULL,
								   	  label.String(),
								   	  NULL );
	} else {
		labelView = new BStringView( BRect (0, 0, 1, 1),
									 "Label",
									 label.String() );
	}
	if ( !labelView )
	{
		/* Panic! */
		exit(1);
	}
	labelView->ResizeToPreferred();
	item = layout->AddView( labelView, 0, 0, 3, 1 );
	if ( !item ) { /* Panic! */ exit(1); }
	item->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_VERTICAL_CENTER ) );
//	item->SetExplicitMinSize( BSize( width, height ) );
	
	// Construct color control
	BMessage* toSend = new BMessage( kColorChanged );
	if ( !toSend ) { /* Panic! */ exit(1); }
	colorControl = new BColorControl( BPoint( 0, 0 ),
								      B_CELLS_32x8,
								      4.0,
								      "Color Control",
								      toSend );
	if ( !colorControl )
	{
		/* Panic! */
		exit(1);
	}
	colorControl->GetPreferredSize( &width, &height );
	colorControl->ResizeTo( width, height );
	colorControl->SetTarget( this );
	item = layout->AddView( colorControl, 0, 1, 3, 1 );
	if ( !item ) { /* Panic! */ exit(1); }
	item->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_TOP ) );

	// Construct last two buttons
	// Revert button
	toSend = new BMessage( kColorReverted );
	if ( !toSend ) { /* Panic! */ exit(1); }
	revertButton = new BButton( BRect( 0, 0, 1, 1),
								"Revert button",
								"Revert",
								toSend );
	if ( !revertButton ) { /* Panic! */ exit(1); }
	revertButton->ResizeToPreferred();
	
	// Ok button
	toSend = new BMessage( kColorSelected );
	if ( !toSend ) { /* Panic! */ exit(1); }
	okButton = new BButton( BRect( 0, 0, 1, 1),
						    "Ok button",
						    "Ok",
						    toSend,
						    B_FOLLOW_RIGHT | B_FOLLOW_TOP );
	if ( !okButton ) { /* Panic! */ exit(1); }
	okButton->ResizeToPreferred();
	
	// Attach the buttons to current layout
	item = layout->AddView( revertButton, 0, 2 );
	if ( ! item ) { /* Panic! */ exit(1); }
	item->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT, B_ALIGN_MIDDLE ) );
		// Note I'm skipping one cell - this is for showing current color!
	item = layout->AddView( okButton, 2, 2 );
	if ( ! item ) { /* Panic! */ exit(1); }
	item->SetExplicitAlignment( BAlignment( B_ALIGN_RIGHT, B_ALIGN_MIDDLE ) );
	
	// Make "Ok" button the default
	okButton->MakeDefault( true );
	
	// Now, find the correct place for this window. 
	// We have one of the corners from constructor, we need to position the window
	// in such manner that it will be fully visible and keep one of the corners in
	// the specified point.
	layout->Relayout( true );
	layoutSize = layout->PreferredSize();
	this->ResizeTo( layoutSize.width, layoutSize.height );
	background->ResizeTo( layoutSize.width, layoutSize.height );
	
	float windowWidth = layoutSize.width, windowHeight = layoutSize.height;
	BScreen* mainScreen = new BScreen( currentScreen ); // Get access to current screen
	display_mode currentDisplayMode;
	mainScreen->GetMode( &currentDisplayMode );		// Obtain the width and height of screen
	
	// The following booleans uniquely define where the window be located regarding
	// given corner.
	bool leftFromCorner = false, upFromCorner = false;
	
	// Check where the window should span regarding to the corner
	if ( corner.x + windowWidth >= currentDisplayMode.virtual_width )
	{
		if ( corner.x - windowWidth < 0 )
		{
			corner.x = 0;
			leftFromCorner = false;
		}
		else
		{
			leftFromCorner = true;
		}
	}
	
	if ( corner.y + windowHeight >= currentDisplayMode.virtual_height )
	{
		if ( corner.y - windowHeight < 0 )
		{
			corner.y = 0;
			upFromCorner = false;
		}
		else
		{
			upFromCorner = true;
		}	
	}
	
	// Calculate new top-left corner of the window
	if ( leftFromCorner ) 	{ corner.x -= windowWidth; }
	if ( upFromCorner )		{ corner.y -= windowHeight; }
	
	// Move the window to calculated position
	this->MoveTo( corner );
	
	// Show the window
	this->Show();
	colorControl->Invoke();
}	// <-- end of constructor for ColorUpdateWindow
Пример #7
0
void BeGadu::MessageReceived( BMessage *aMessage ) {
	switch( aMessage->what ) {
		/* sending mesgs from libgadu to network */
		case GOT_MESSAGE:
		case ADD_HANDLER:
		case DEL_HANDLER:
			BMessenger( iWindow->GetNetwork() ).SendMessage( aMessage );
			break;
		case ADD_MESSENGER:
			DEBUG_TRACE( "BeGadu::MessageReceived( ADD_MESSENGER )\n" );
			aMessage->FindMessenger( "messenger", &iMessenger );
			if( iWindow ) {
				iWindow->SetMessenger( iMessenger );
				BMessenger( iMessenger ).SendMessage( PROFILE_SELECTED );
			}
			break;
		case SET_AVAIL:
		case SET_BRB:
		case SET_INVIS:
		case SET_NOT_AVAIL:
		case SET_DESCRIPTION:
		case BEGG_ABOUT:
		case SHOW_MAIN_WINDOW:
		case CHANGE_DESCRIPTION:
		case PREFERENCES_SWITCH:
			if( iWindow )
				BMessenger( iWindow ).SendMessage( aMessage );
			break;
		case OPEN_PROFILE_WIZARD:
			{
			DEBUG_TRACE( "BeGadu::MessageReceived( OPEN_PROFILE_WIZARD )\n" );
//			if( iProfileSelector )
//				iProfileSelector = NULL;
			if( iWindow ) {
				BMessenger( iWindow ).SendMessage( new BMessage( CLOSE_MAIN_WINDOW ) );
				if( iWindow->Lock() )
					iWindow->Quit();
				iWindow = NULL;
			}
			ProfileWizard *pw = new ProfileWizard();
			pw->Show();
			break;
			}
		case CONFIG_OK:
			{
			DEBUG_TRACE( "BeGadu::MessageReceived( CONFIG_OK )\n" );
			iReadyToRun = true;
			AddDeskbarIcon();
			Profile *profile = new Profile();
			int ret = profile->Load( iLastProfile );
			if( ret != 0 ) {
				delete profile;
				BMessenger( be_app ).SendMessage( new BMessage( PROFILE_SELECT ) );
				break;
			}
			if( strcmp( profile->GetProfilePassword(), "" ) != 0 ) {
				BResources res;
				BRoster roster;
				entry_ref ref;
				BFile resfile;
				roster.FindApp( APP_MIME, &ref );
				resfile.SetTo( &ref, B_READ_ONLY );
				res.SetTo( &resfile );
				BScreen *screen = new BScreen( B_MAIN_SCREEN_ID );
				display_mode mode;
				screen->GetMode( &mode );
//				int32 width = 250;
//				int32 height = 110; // 70
//				int32 x_wind = mode.timing.h_display / 2 - ( width / 2);
//				int32 y_wind = mode.timing.v_display / 2 - ( height / 2 );
//				int32 new_width = x_wind + width;	// x 2
//				int32 new_height = y_wind + height;		// x 2
				BMessenger( iMessenger ).SendMessage( new BMessage( PROFILE_NOT_SELECTED ) );
//				iProfileSelector = new ProfileSelector( iLastProfile, BRect( x_wind, y_wind, new_width, new_height ), &res );
//				if( iProfileSelector->LockLooper() ) {
//					iProfileSelector->Show();
//					iProfileSelector->UnlockLooper();
//				}
			} else {
				BMessenger( iMessenger ).SendMessage( new BMessage( PROFILE_SELECTED ) );
				iWindow = new MainWindow( iLastProfile );
				if( !iHideAtStart ) {
					if( iWindow->LockLooper() ) {
						iWindow->Show();
						iWindow->UnlockLooper();
					}
				} else {
					if( iWindow->LockLooper() ) {
						iWindow->Show();
						iWindow->Hide();
						iWindow->UnlockLooper();
					}
				}
			}
			break;
			}
		case PROFILE_CREATED:
			DEBUG_TRACE( "BeGadu::MessageReceived( PROFILE_CREATED )\n" );
			iReadyToRun = true;
			AddDeskbarIcon();
			aMessage->FindString( "ProfileName", iLastProfile );
			fprintf( stderr, _T("Setting last profile to %s\n"), iLastProfile->String() );
			iFirstRun = false;
			BMessenger( iMessenger ).SendMessage( new BMessage( PROFILE_SELECTED ) );
			iWindow = new MainWindow( iLastProfile );
			if( iWindow->LockLooper() ) {
				if( iWindow->IsHidden() )
					iWindow->Show();
				else
					iWindow->Activate();
				iWindow->UnlockLooper();
			}
			break;
		case PROFILE_SELECT:
			DEBUG_TRACE( "BeGadu::MessageReceived( PROFILE_SELECT )\n" );
//			if( iProfileSelector )
//				iProfileSelector->Activate();
//			else
				{
				BResources res;
				BRoster roster;
				entry_ref ref;
				BFile resfile;
				roster.FindApp( APP_MIME, &ref );
				resfile.SetTo( &ref, B_READ_ONLY );
				res.SetTo( &resfile );
				BScreen *screen = new BScreen( B_MAIN_SCREEN_ID );
				display_mode mode;
				screen->GetMode( &mode );
//				int32 width = 250;
//				int32 height = 110; // 70
//				int32 x_wind = mode.timing.h_display / 2 - ( width / 2);
//				int32 y_wind = mode.timing.v_display / 2 - ( height / 2 );
//				int32 new_width = x_wind + width;	// x 2
//				int32 new_height = y_wind + height;		// x 2
				BMessenger( iMessenger ).SendMessage( new BMessage( PROFILE_NOT_SELECTED ) );
//				iProfileSelector = new ProfileSelector( iLastProfile, BRect( x_wind, y_wind, new_width, new_height ), &res );
//				if( iProfileSelector->LockLooper() ) {
//					iProfileSelector->Show();
//					iProfileSelector->UnlockLooper();
//				}
			}
			break;
		case PROFILE_SWITCH:
			{
			DEBUG_TRACE( "BeGadu::MessageReceived( PROFILE_SWITCH )\n" );
			if( iWindow ) {
				BMessenger( iWindow ).SendMessage( new BMessage( CLOSE_MAIN_WINDOW ) );
				if( iWindow->Lock() )
					iWindow->Quit();
				iWindow = NULL;
			}
			Profile* profile = new Profile();
			BString* name = new BString( "" );
			aMessage->FindString( "iProfileName", name );
			int ret = profile->Load( name );
			if( ret != 0 ) {
				delete profile;
				BMessenger( this ).SendMessage( new BMessage( PROFILE_SELECT ) );
				break;
			}
			// XXX loaded profile password empty?
			if( strcmp( profile->GetProfilePassword(), "" ) == 0 ) {
				BMessenger( iMessenger ).SendMessage( new BMessage( PROFILE_SELECTED ) );
				iWindow = new MainWindow( iLastProfile );
//				iWindow = new MainWindow( name );
				if( iWindow->LockLooper() ) {
					iWindow->Show();
					iWindow->UnlockLooper();
				}
			} else {
			// XXX what's that for?
				BResources res;
				BRoster roster;
				entry_ref ref;
				BFile resfile;
				roster.FindApp( APP_MIME, &ref );
				resfile.SetTo( &ref, B_READ_ONLY );
				res.SetTo( &resfile );
				BScreen *screen = new BScreen( B_MAIN_SCREEN_ID );
				display_mode mode;
				screen->GetMode( &mode );
//				int32 width = 250;
//				int32 height = 110; // 70
//				int32 x_wind = mode.timing.h_display / 2 - ( width / 2);
//				int32 y_wind = mode.timing.v_display / 2 - ( height / 2 );
//				int32 new_width = x_wind + width;	// x 2
//				int32 new_height = y_wind + height;		// x 2
				BMessenger( iMessenger ).SendMessage( new BMessage( PROFILE_NOT_SELECTED ) );
//				iProfileSelector = new ProfileSelector( name, BRect( x_wind, y_wind, new_width, new_height ), &res );
//				if( iProfileSelector->LockLooper() ) {
//					iProfileSelector->Show();
//					iProfileSelector->UnlockLooper();
//				}
			}
			break;
			}
		case PROFILE_SELECTED:
			{
			DEBUG_TRACE( "BeGadu::MessageReceived( PROFILE_SELECTED )\n" );
//			if( iProfileSelector )
//				iProfileSelector = NULL;
			BString *profile = new BString( "" );
			aMessage->FindString( "iProfileName", profile );
			BMessenger( iMessenger ).SendMessage( new BMessage( PROFILE_SELECTED ) );
			iWindow = new MainWindow( profile );
			if( !iHideAtStart ) {
				if( iWindow->LockLooper() ) {
					iWindow->Show();
					iWindow->UnlockLooper();
				}
			} else {
				if( iWindow->LockLooper() ) {
					iWindow->Show();
					iWindow->Hide();
					iWindow->UnlockLooper();
				}
			}
			break;
			}
		case PROFILE_NOT_SELECTED:
			DEBUG_TRACE( "BeGadu::MessageReceived( PROFILE_NOT_SELECTED )\n" );
//			if( iProfileSelector )
//				iProfileSelector = NULL;
			BMessenger( iMessenger ).SendMessage( new BMessage( PROFILE_NOT_SELECTED ) );
			break;
		case BEGG_QUIT:
			DEBUG_TRACE( "BeGadu::MessageReceived( BEGG_QUIT )\n" );
			if( iWindow )
				BMessenger( iWindow ).SendMessage( aMessage );
			else
				BMessenger( be_app ).SendMessage( B_QUIT_REQUESTED );
			break;
		default:
			BApplication::MessageReceived( aMessage );
			break;
		}
}
Пример #8
0
Preferences::Preferences( Profile* aProfile, MainWindow* aWindow, BRect aRect, BResources* aRes ) : BWindow( aRect, PREFERENCES_NAME, B_FLOATING_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS )
	{

	BScreen *screen = new BScreen( this );
	display_mode mode;
	screen->GetMode( &mode );
	int32 width = 500;
	int32 height = 420;
	int32 x_wind = mode.timing.h_display / 2 - ( width / 2);
	int32 y_wind = mode.timing.v_display / 2 - ( height / 2 );
	delete screen;

	MoveTo(x_wind,y_wind);
	ResizeTo(width,height);
	SetTitle(_T(PREFERENCES_NAME));

	iProfile = aProfile;
	iWindow = aWindow;
	iResources = aRes;
	BRect r = Bounds();

	iLogoView = new BitmapView( BRect( r.left , r.top,
									   r.left + 600, r.top + 150 ),
									   "logo", aRes );
	AddChild( iLogoView );
	
	r.left = 20;
	r.top = 100;
	r.right = r.left + 250;
	r.bottom = r.top + 25;
	iNumberControl = new BTextControl( r, "iNumberControl", "Numer GG:", "0", NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE );
	AddChild( iNumberControl );
	r.left = 20;
	r.right = r.left + 250;
	r.top = 130;
	r.bottom = r.top + 25;
	iPasswordControl = new BTextControl( r, "iPasswordControl", "Haslo:", "", NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE );
	AddChild( iPasswordControl );
	r = Bounds();
	BButton *przycisk;
    przycisk = new BButton( BRect( r.left + 360, r.bottom - 30,
    							   r.left + 440, r.bottom - 5),
    							   "przycisk ok", "Ok",
    							   new BMessage( PREFERENCES_OK ) );
    przycisk->MakeDefault(true);
    AddChild(przycisk);
    
    przycisk = new BButton( BRect( r.left + 270, r.bottom - 30,
    							   r.left + 350, r.bottom - 5),
    							   "przycisk anuluj", "Anuluj",
    							   new BMessage( PREFERENCES_CANCEL ) );
    AddChild(przycisk);

	/* pobieramy aktualna konfiguracje */

    if( iNumberControl->LockLooper() )
    	{
		BString a;
		a << (int32) iProfile->GetUIN();
        iNumberControl->SetText( a.String() );
        iPasswordControl->SetText( iProfile->GetPassword() );
		fprintf( stderr, "numer: %s\nhaslo: %s\n", a.String(), iProfile->GetPassword() );
        iNumberControl->UnlockLooper();
    	}
	}
Пример #9
0
Description::Description( MainWindow* aWindow, BRect aRect, BResources* aRes )
	: BWindow( aRect,
			   "",
			   B_FLOATING_WINDOW,
			   B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS )
	{
	BScreen *screen = new BScreen( this );
	display_mode mode;
	screen->GetMode( &mode );
	delete screen;

	int32 width = 250;
	int32 height = 140;
	int32 x_wind = mode.timing.h_display / 2 - ( width / 2);
	int32 y_wind = mode.timing.v_display / 2 - ( height / 2 );
	MoveTo(x_wind,y_wind);
	ResizeTo(width,height);

	SetTitle( _T( DESCRIPTION_NAME ) );
	iWindow = aWindow;
	iResources = aRes;

	BRect r = Bounds();
	r.left = 5;
	r.right = r.right - 5;
	r.top = 5;
	r.bottom = r.bottom - 40;
	iBox = new BBox( r, "Description box" );

	r = iBox->Bounds();
	r.left = 3;
	r.right = r.left + 25;
	r.top = 3;
	r.bottom = r.bottom - 3;
	iIconsView = new IconsView( r, iResources );
	iBox->AddChild( iIconsView );
	AddChild( iBox );

	r = iBox->Bounds();
	r.left = r.left + 30;
	r.right = r.left + 15;
	r.top = 7;
	r.bottom = r.top + 12;
	iAvail = new BRadioButton( r, "AvailDesc", "", new BMessage( SET_AVAIL ) );
	iBox->AddChild( iAvail );

	r = iBox->Bounds();
	r.left = r.left + 30;
	r.right = r.left + 15;
	r.top = 27;
	r.bottom = r.top + 12;
	iBusy = new BRadioButton( r, "BusyDesc", "", new BMessage( SET_BRB ) );
	iBox->AddChild( iBusy );

	r = iBox->Bounds();
	r.left = r.left + 30;
	r.right = r.left + 15;
	r.top = 47;
	r.bottom = r.top + 12;
	iInvisible = new BRadioButton( r, "InvisibleDesc", "", new BMessage( SET_INVIS ) );
	iBox->AddChild( iInvisible );

	r = iBox->Bounds();
	r.left = r.left + 30;
	r.right = r.left + 15;
	r.top = 67;
	r.bottom = r.top + 12;
	iNotAvail = new BRadioButton( r, "NotAvailDesc", "", new BMessage( SET_NOT_AVAIL ) );
	iBox->AddChild( iNotAvail );

	r = iBox->Bounds();
	r.left = r.left + 50;
	r.right = r.right - 3;
	r.top = r.top + 3;
	r.bottom = r.bottom - 3;
	BRect t = iBox->Bounds();
	t.right = t.right - 60;
	iDescription = new BTextView( r, "DescriptionTextView", t, B_FOLLOW_ALL, B_WILL_DRAW );
	iDescription->SetMaxBytes( 160 );
	iBox->AddChild( iDescription );

	r = Bounds();
	r.left = r.right - 140;
	r.right = r.right - 75;
	r.top = r.bottom - 30;
	r.bottom = -5;
	BButton *button;
    button = new BButton( r, "change button", _T("Change"), new BMessage( DESCRIPTION_OK ) );
    button->MakeDefault( true );
    AddChild( button );

    r = Bounds();
	r.left = r.right - 65;
	r.right = r.right -5;
	r.top = r.bottom - 30;
	r.bottom = -5;

    button = new BButton( r, "cancel button", _T("Cancel"), new BMessage( DESCRIPTION_CANCEL ) );
    AddChild( button );

	/* setting current settings */
	int status = iWindow->GetNetwork()->Status();
	if( status == GG_STATUS_AVAIL || status == GG_STATUS_AVAIL_DESCR )
		{
		iStatus = GG_STATUS_AVAIL_DESCR;
		iAvail->SetValue( B_CONTROL_ON );
		}
	else if( status == GG_STATUS_BUSY || status == GG_STATUS_BUSY_DESCR )
		{
		iStatus = GG_STATUS_BUSY_DESCR;
		iBusy->SetValue( B_CONTROL_ON );
		}
	else if( status == GG_STATUS_INVISIBLE || status == GG_STATUS_INVISIBLE_DESCR )
		{
		iStatus = GG_STATUS_INVISIBLE_DESCR;
		iInvisible->SetValue( B_CONTROL_ON );
		}
	else if( status == GG_STATUS_NOT_AVAIL || status == GG_STATUS_NOT_AVAIL_DESCR )
		{
		iStatus = GG_STATUS_NOT_AVAIL_DESCR;
		iNotAvail->SetValue( B_CONTROL_ON );
		}
	BString *description = fromISO2(iWindow->GetNetwork()->iDescription->String());
	iDescription->SetText( description->String(), description->Length() );
	delete description;
}