Пример #1
0
void QHaikuCursor::changeCursor(QCursor *windowCursor, QWindow *window)
{
    if (!window)
        return;

    BWindow *haikuWindow = reinterpret_cast<BWindow*>(window->winId());

    // We expect that every BWindow has exactly one BView as child,
    // so we can use CurrentFocus to retrieve it and call SetViewCursor
    // to change the cursor for the whole window.
    if (!windowCursor) {
        BView *view = haikuWindow->CurrentFocus();
        if (view) {
            view->SetViewCursor(B_CURSOR_SYSTEM_DEFAULT);
        }
    } else {
        const Qt::CursorShape shape = windowCursor->shape();
        if (!m_cursors.contains(shape))
            m_cursors.insert(shape, new BCursor(m_cursorIds.value(shape)));

        BView *view = haikuWindow->CurrentFocus();
        if (view) {
            view->LockLooper();
            view->SetViewCursor(m_cursors.value(shape));
            view->UnlockLooper();
        }
    }
}
Пример #2
0
void SetKeyWindow::MessageReceived(BMessage* msg){
	switch(msg->what){
	case SET:
		key = control1->GetKey();
		mod = control1->GetMod();
		key2 = control2->GetKey();
		mod2 = control2->GetMod();
		KeyBind.Install(menu, KeyBind.GetID(index), key, mod, key2, mod2, message);
		parent->LockLooper();
		parent->Pulse();
		parent->UnlockLooper();
		Quit();
		break;
	
	case CLEAR1:
		mod = key = 0;
		control1->SetBinding(key,mod);
		break;
		
	case CLEAR2:
		mod2 = key2 = 0;
		control2->SetBinding(key2,mod2);
		break;
		
	default:
		BWindow::MessageReceived(msg);
	}
}
status_t
MakeScreenshot(BBitmap **here)
{
	status_t err;
	BScreen bs;
	BWindow *win;
	BBitmap *shot;
	BBitmap *scaledBmp = NULL;
	be_app->Lock();
	win = be_app->WindowAt(0);
	if (win) {
		win->Lock();
		win->Hide();
		win->Unlock();
	}
	snooze(500000);
	err = bs.GetBitmap(&shot);
	if (!err) {
		BRect scaledBounds(0,0,640-1,480-1);
		scaledBmp = new BBitmap(scaledBounds, B_BITMAP_ACCEPTS_VIEWS, B_RGB32/*shot->ColorSpace()*/);
		err = scaledBmp->InitCheck();
		if (!err) {
			err = ENOSYS;
#ifdef B_ZETA_VERSION
			err = ScaleBitmap(*shot, *scaledBmp);
#endif
			if (err) {
				// filtered scaling didn't work, do it manually
				BView *v = new BView(scaledBounds, "scaleview", B_FOLLOW_NONE, 0);
				scaledBmp->AddChild(v);
				v->LockLooper();
				v->DrawBitmap(shot);
				v->Sync();
				v->UnlockLooper();
				scaledBmp->RemoveChild(v);
				delete v;
				err = B_OK;
			}
		}
		delete shot;
	}

	if (win) {
		win->Lock();
		win->Show();
		win->Unlock();
	}
	be_app->Unlock();
	
	if (err)
		return err;
	
	*here = scaledBmp;

	return B_OK;
}
Пример #4
0
void BWebPage::paint(BRect rect, bool immediate)
{
	if (fLayoutingView || !rect.IsValid())
		return;
    // Block any drawing as long as the BWebView is hidden
    // (should be extended to when the containing BWebWindow is not
    // currently on screen either...)
    if (!fPageVisible) {
        fPageDirty = true;
        return;
    }

    // NOTE: fMainFrame can be 0 because init() eventually ends up calling
    // paint()! BWebFrame seems to cause an initial page to be loaded, maybe
    // this ought to be avoided also for start-up speed reasons!
    if (!fMainFrame)
        return;
    WebCore::Frame* frame = fMainFrame->Frame();
    WebCore::FrameView* view = frame->view();

    if (!view || !frame->contentRenderer())
        return;

	// Since calling layoutIfNeededRecursive can cycle back into paint(),
	// call this method before locking the window and before holding the
	// offscreen view lock.
	fLayoutingView = true;
	view->layout(true);
	fLayoutingView = false;

    if (!fWebView->LockLooper())
        return;
    BView* offscreenView = fWebView->OffscreenView();

    // Lock the offscreen bitmap while we still have the
    // window locked. This cannot deadlock and makes sure
    // the window is not deleting the offscreen view right
    // after we unlock it and before locking the bitmap.
    if (!offscreenView->LockLooper()) {
    	fWebView->UnlockLooper();
    	return;
    }
    fWebView->UnlockLooper();

    if (!rect.IsValid())
        rect = offscreenView->Bounds();
    BRegion region(rect);
    internalPaint(offscreenView, view, &region);

    offscreenView->UnlockLooper();

    fPageDirty = false;

    // Notify the window that it can now pull the bitmap in its own thread
    fWebView->SetOffscreenViewClean(rect, immediate);
}
Пример #5
0
void EventHandler::focusDocumentView()
{
    BView* view = m_frame->view()->platformWidget();
    if (view && view->LockLooperWithTimeout(5000) == B_OK) {
        view->MakeFocus(true);
        view->UnlockLooper();
    }

    Page* page = m_frame->page();
    if (page)
        page->focusController()->setFocusedFrame(m_frame);
}
Пример #6
0
void
KeyboardLayoutView::Draw(BRect updateRect)
{
	if (fOldSize != BSize(Bounds().Width(), Bounds().Height())) {
		_InitOffscreen();
		_LayoutKeyboard();
	}

	BView* view;
	if (fOffscreenBitmap != NULL) {
		view = fOffscreenView;
		view->LockLooper();
	} else
		view = this;

	// Draw background

	if (Parent())
		view->SetLowColor(Parent()->ViewColor());
	else
		view->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	view->FillRect(updateRect, B_SOLID_LOW);

	// Draw keys

	for (int32 i = 0; i < fLayout->CountKeys(); i++) {
		Key* key = fLayout->KeyAt(i);

		_DrawKey(view, updateRect, key, _FrameFor(key),
			_IsKeyPressed(key->code));
	}

	// Draw LED indicators

	for (int32 i = 0; i < fLayout->CountIndicators(); i++) {
		Indicator* indicator = fLayout->IndicatorAt(i);

		_DrawIndicator(view, updateRect, indicator, _FrameFor(indicator->frame),
			(fModifiers & indicator->modifier) != 0);
	}

	if (fOffscreenBitmap != NULL) {
		view->Sync();
		view->UnlockLooper();

		DrawBitmapAsync(fOffscreenBitmap, BPoint(0, 0));
	}
}
Пример #7
0
//-------------------------------------------------------------------------
void nsFilePicker::InitNative(nsIWidget *aParent,
                              const nsAString& aTitle,
                              PRInt16 aMode)
{
	mParentWindow = 0;

  BView *view = (BView *) aParent->GetNativeData(NS_NATIVE_WIDGET);
  if (view && view->LockLooper()) {
    mParentWindow = view->Window();
    view->UnlockLooper();
  }

	mTitle.Assign(aTitle);
	mMode = aMode;
}
Пример #8
0
void PrefWindow::MessageReceived(BMessage *message){
	BView *tmpV;
	int32 k;

	switch (message->what){
	case QUIT:
		Hide();
		break;
	
	case CHANGE_LANGUAGE:
		tmpV = ChildAt(0);
		if (tmpV != NULL){
			tmpV->RemoveSelf();
			delete tmpV;
		}
		BLayoutBuilder::Group<>(this)
		.AddGroup(B_VERTICAL, B_USE_DEFAULT_SPACING)
			.Add(new PrefView());
		break;
	
	case SET_FACTORY:
		k = (new BAlert(NULL,Language.get("FACTORY_SURE"),Language.get("APPLY"),Language.get("CANCEL")))->Go();
		if (k==0){
			Prefs.FactorySettings();
			KeyBind.InstallDefaults();
			tmpV = FindView("Prefs color");
			if (tmpV != NULL){
				PostMessage(COLOR_SELECT, tmpV);
			}
			tmpV = FindView("Prefs keys");
			if (tmpV != NULL){
				tmpV->LockLooper();
				tmpV->Pulse();
				tmpV->UnlockLooper();
			}else{
				be_app->PostMessage(CHANGE_LANGUAGE);
			}
			Pool.sample_view_dirty = true;	// update the sample-view
			Pool.update_draw_cache = true;	// update the draw cache
			Pool.update_index = true;		// update the index cache
			Pool.RedrawWindow();
		}
		break;

	default:
		BWindow::MessageReceived(message);
	}
}
Пример #9
0
BListView* iuphaikuGetListView(BView* view)
{
  // TODO maybe it is easier to get ScrollBar->Target ?
  BListView* listview = dynamic_cast<BListView*>(view);
  if(!listview)
  {
	BView* previous = view;
	previous->LockLooper();
	view = view->ChildAt(0);
	previous->UnlockLooper();
	while(view && !listview)
	{
      listview = dynamic_cast<BListView*>(view);
	  view = view->NextSibling();
	}
  }

  return listview;
}
Пример #10
0
void
BSlider::AttachedToWindow()
{
	ResizeToPreferred();

#if USE_OFF_SCREEN_VIEW
	BRect bounds(Bounds());

	if (!fOffScreenView) {
		fOffScreenView = new BView(bounds, "", B_FOLLOW_ALL, B_WILL_DRAW);

		BFont font;
		GetFont(&font);
		fOffScreenView->SetFont(&font);
	}

	if (!fOffScreenBits) {
		fOffScreenBits = new BBitmap(bounds, B_RGBA32, true, false);

		if (fOffScreenBits && fOffScreenView)
			fOffScreenBits->AddChild(fOffScreenView);

	} else if (fOffScreenView)
		fOffScreenBits->AddChild(fOffScreenView);
#endif // USE_OFF_SCREEN_VIEW

	BControl::AttachedToWindow();

	BView* view = OffscreenView();
	if (view && view->LockLooper()) {
		view->SetViewColor(B_TRANSPARENT_COLOR);
		view->SetLowColor(LowColor());
		view->UnlockLooper();
	}

	int32 value = Value();
	SetValue(value);
		// makes sure the value is within valid bounds
	_SetLocationForValue(Value());
		// makes sure the location is correct
	UpdateTextChanged();
}
Пример #11
0
void
SetKeyWindow::MessageReceived(BMessage* msg)
{
	switch(msg->what) {
		case SET:
		{
			KeyBind* key = new KeyBind();
	
			key->key = control1->GetKey();
			key->mod = control1->GetMod();
			key->altKey = control2->GetKey();
			key->altMod = control2->GetMod();
			key->label = gKeyBind->GetLabel(index);
			key->message = MessageBuilder(message);
			key->isMenuItem = menu;
	
			gKeyBind->AddKeyBind(key);
	
			if (parent->LockLooper()) {
				parent->Pulse();
				parent->UnlockLooper();
			}
			Quit();
			break;
		}

		case CLEAR1:
			mod = key = 0;
			control1->SetBinding(key,mod);
			break;
			
		case CLEAR2:
			mod2 = key2 = 0;
			control2->SetBinding(key2,mod2);
			break;
			
		default:
			BWindow::MessageReceived(msg);
	}
}
Пример #12
0
void wxStatusBarBeOS::DrawStatusBar()
{

	int i=0;
	int leftPos=0;
	wxArrayInt widthsAbs;
	wxString text;

	m_view->Clear();
	BRect bounds(m_view->bounds());
	BView * drawview = m_view->GetBack();
	if(drawview->LockLooper())
	{	
		rgb_color clr;
		drawview->PushState();
		clr = drawview->ViewColor();
		clr.red-=50; clr.green-=50; clr.blue-=50;
		drawview->SetHighColor(clr);
		drawview->StrokeLine(BPoint(bounds.left, bounds.top), BPoint(bounds.right, bounds.top));
		clr.red+=100; clr.green+=100; clr.blue+=100;
		drawview->SetHighColor(clr);
		drawview->StrokeLine(BPoint(bounds.left, bounds.top+1), BPoint(bounds.right, bounds.top+1));
		drawview->PopState();
		
		if(m_nFields>0)
			widthsAbs = CalculateAbsWidths(bounds.IntegerWidth() - 2*(m_nFields - 1));
		
		drawview->SetDrawingMode(B_OP_OVER);
		for(i=0;i<m_nFields;i++)
		{
			text = GetStatusBufferText(i);
			drawview->DrawString(text, BPoint(leftPos, bounds.bottom-2));
			leftPos+=widthsAbs[i]+2;
		}
		
		drawview->UnlockLooper();
	}
	m_view->flush();
}
Пример #13
0
void
SetKeyWindow::MessageReceived(BMessage* msg)
{
	switch(msg->what) {
		case SET:
		{
			KeyBind* key = new KeyBind();
	
			key->key = control1->GetKey();
			key->mod = control1->GetMod();
			key->label = FaberShortcut::KeyBindAt(index)->label;
			key->message = FaberShortcut::KeyBindAt(index)->message;
			key->itemType = FaberShortcut::KeyBindAt(index)->itemType;
			
	
			FaberShortcut::AddKeyBind(key);
	
			if (parent->LockLooper()) {
				parent->Pulse();
				parent->UnlockLooper();
			}
			Quit();
			break;
		}

		case CLEAR1:
			mod = key = 0;
			control1->SetBinding(key,mod);
			break;
			
		case CLEAR2:
			mod2 = key2 = 0;
			control2->SetBinding(key2,mod2);
			break;
			
		default:
			BWindow::MessageReceived(msg);
	}
}