예제 #1
0
void TTimeTextView::MakeFocus(bool focusState)
{
	BTextView::MakeFocus(focusState);
	
	// Inform target
	if ( focusState == false)
	{
		if (m_Target)
		{
			BLooper *looper = m_Target->Looper();
			
			if ( looper->Lock() )
			{
				CheckLastEdit();
				
				for (int16 index = 1; index < 5; index++)
					ConvertToTime(index);
				
				if (m_MessageID)
				{
					BMessage *message = new BMessage(m_MessageID);
					message->AddInt32("TheTime", m_Time);
					m_Target->MessageReceived( message);
					looper->Unlock();
					delete message;
				}
			}			
		}
	}
}
예제 #2
0
void
TDeskbarMenu::DetachedFromWindow()
{
	if (fBarView != NULL) {
		BLooper* looper = fBarView->Looper();
		if (looper != NULL && looper->Lock()) {
			fBarView->DragStop();
			looper->Unlock();
		}
	}

	// don't call BNavMenu::DetachedFromWindow
	// it sets the TypesList to NULL
	BMenu::DetachedFromWindow();
}
예제 #3
0
status_t
TBarMenuTitle::Invoke(BMessage* message)
{
	TBarView* barview = dynamic_cast<TBarApp*>(be_app)->BarView();
	if (barview) {
		BLooper* looper = barview->Looper();
		if (looper->Lock()) {
			// tell barview to add the refs to the deskbar menu
			barview->HandleDeskbarMenu(NULL);
			looper->Unlock();
		}
	}

	return BMenuItem::Invoke(message);
}
예제 #4
0
bool
BMessenger::LockTarget() const
{
	BLooper* looper = NULL;
	Target(&looper);
	if (looper != NULL && looper->Lock()) {
		if (looper->fMsgPort == fPort)
			return true;

		looper->Unlock();
		return false;
	}

	return false;
}
예제 #5
0
/*
	bool IsTargetLocal() const
	@case 3			this is initialized to local target with specific handler
	@results		should return true.
 */
void TargetTester::IsTargetLocalTest3()
{
	// create looper and handler
	status_t result = B_OK;
	BLooper *looper = new BLooper;
	looper->Run();
	LooperQuitter quitter(looper);
	BHandler *handler = new BHandler;
	HandlerDeleter deleter(handler);
	CHK(looper->Lock());
	looper->AddHandler(handler);
	looper->Unlock();
	// create the messenger and do the checks
	BMessenger messenger(handler, NULL, &result);
	CHK(messenger.IsTargetLocal() == true);
}
예제 #6
0
파일: Looper.cpp 프로젝트: puckipedia/haiku
status_t
BLooper::_task0_(void* arg)
{
	BLooper* looper = (BLooper*)arg;

	PRINT(("LOOPER: _task0_()\n"));

	if (looper->Lock()) {
		PRINT(("LOOPER: looper locked\n"));
		looper->task_looper();

		delete looper;
	}

	PRINT(("LOOPER: _task0_() done: thread %ld\n", find_thread(NULL)));
	return B_OK;
}
예제 #7
0
파일: TeamMenu.cpp 프로젝트: DonCN/haiku
void
TTeamMenu::DetachedFromWindow()
{
	TBarView* barView = (dynamic_cast<TBarApp*>(be_app))->BarView();
	if (barView != NULL) {
		BLooper* looper = barView->Looper();
		if (looper != NULL && looper->Lock()) {
			barView->DragStop();
			looper->Unlock();
		}
	}

	BMenu::DetachedFromWindow();

	BMessenger self(this);
	TBarApp::Unsubscribe(self);
}
예제 #8
0
void
TWindowMenu::DetachedFromWindow()
{
	// in expando mode the teammenu will not call DragStop,
	// thus, it needs to be called from here
	TBarView *barview = (dynamic_cast<TBarApp*>(be_app))->BarView();
	if (barview && barview->Expando()) {
		BLooper *looper = barview->Looper();
		if (looper->Lock()) {
			Window()->Show();		// We changed the show level in AttachedToWindow().  Undo it.
			barview->DragStop();
			looper->Unlock();
		}
	}
	
	BMenu::DetachedFromWindow();
}
예제 #9
0
bool
BHandler::LockLooper()
{
	BLooper* looper = fLooper;
	// Locking the looper also makes sure that the looper is valid
	if (looper != NULL && looper->Lock()) {
		// Have we locked the right looper? That's as far as the
		// "pseudo-atomic" operation mentioned in the BeBook.
		if (fLooper == looper)
			return true;

		// we locked the wrong looper, bail out
		looper->Unlock();
	}

	return false;
}
예제 #10
0
CannaMethod::~CannaMethod()
{
	BLooper *looper = NULL;
	cannaLooper.Target( &looper );
	if ( looper != NULL )
	{
#ifdef DEBUG
	SERIAL_PRINT(( "CannaIM:Locking CannaLooper...\n" ));
#endif
		if ( looper->Lock() )
#ifdef DEBUG
	SERIAL_PRINT(( "CannaIM:CannaLooper locked. Calling Quit().\n" ));
#endif
			looper->Quit();
	}
	WriteSettings();
}
void ArpNotificationType::NotifyDependents(BMessage *msg, bool deliverAsynchronously)
{
	BHandler	*h;
	BLooper		*looper;
	for (long i=0; (h = (BHandler*)dependents.ItemAt(i)) != 0; i++) {
		if (((looper = h->Looper()) != 0)
				&& (looper->Lock())) {
			// FIX: need to send out the message, and let the views
			// invalidate themselves!  So be aware that the Update
			// implementation will ALWAYS be called from within this
			// loop, meaning within a lock/unlock
#if 0	// Uncomment this to debug where messages are going
printf("SENDING MESSAGE TO %s\n", h->Name());  fflush(stdout);
#endif
			h->MessageReceived(msg);
			looper->Unlock();
		}
	}
}
예제 #12
0
int32
ColorField::_UpdateThread(void *data)
{
	// initialization

	ColorField *colorField = (ColorField *)data;
	BLooper *looper = colorField->Looper();

	if (looper)
		looper->Lock();

	BBitmap* bitmap = colorField->fBgBitmap[0];
	BView* view = colorField->fBgView[0];

	port_id port = colorField->fUpdatePort;

	if (looper)
		looper->Unlock();

	// draw

	float h, s, v, r, g, b;
	int R, G, B;

	int32 msg_code;
	char msg_buffer;

	while (true) {
		port_info info;
		do {
			read_port(port, &msg_code, &msg_buffer, sizeof(msg_buffer));
			get_port_info(port, &info);
		} while (info.queue_count);

		if (looper)
			looper->Lock();
	
		uint colormode = colorField->fColorMode;
		float fixedvalue = colorField->fFixedValue;

		if (looper)
			looper->Unlock();

		bitmap->Lock();
		view->BeginLineArray(256 * 256);

		switch (colormode)
		{
			case R_SELECTED:
			{
				R = round(fixedvalue * 255);
				for (int G = 0; G < 256; ++G)
					for (int B = 0; B < 256; ++B)
						DrawColorPoint(BPoint(G, 255.0 - B), R, G, B);
				break;
			}

			case G_SELECTED:
			{
				G = round(fixedvalue * 255);
				for (int R = 0; R < 256; ++R)
					for (int B = 0; B < 256; ++B)
						DrawColorPoint(BPoint(R, 255.0 - B), R, G, B);
				break;
			}

			case B_SELECTED:
			{
				B = round(fixedvalue * 255);
				for (int R = 0; R < 256; ++R)
					for (int G = 0; G < 256; ++G)
						DrawColorPoint(BPoint(R, 255.0 - G), R, G, B);
				break;
			}

			case H_SELECTED:
			{
				h = fixedvalue;
				for (int x = 0; x < 256; ++x) {
					s = (float)x / 255.0;
					for (int y = 0; y < 256; ++y) {
						v = (float)y / 255.0;
						HSV_to_RGB(h, s, v, r, g, b);
						DrawColorPoint(BPoint(x, 255.0 - y), round(r * 255.0),
							round(g * 255.0), round(b * 255.0));
					}
				}
				break;
			}

			case S_SELECTED:
			{
				s = fixedvalue;
				for (int x = 0; x < 256; ++x) {
					h = 6.0 / 255 * x;
					for (int y = 0; y<256; ++y) {
						v = (float)y / 255.0;
						HSV_to_RGB(h, s, v, r, g, b);
						DrawColorPoint(BPoint(x, 255.0 - y), round(r * 255.0),
							round(g * 255.0), round(b * 255.0));
					}
				}
				break;
			}

			case V_SELECTED:
			{
				v = fixedvalue;
				for (int x = 0; x < 256; ++x) {
					h = 6.0 / 255 * x;
					for (int y = 0; y < 256; ++y) {
						s = (float)y / 255.0;
						HSV_to_RGB(h, s, v, r, g, b);
						DrawColorPoint(BPoint(x, 255.0 - y), round(r * 255.0),
							round(g * 255.0), round(b * 255.0));
					}
				}
				break;
			}
		}

		view->EndLineArray();
		view->Sync();

		bitmap->Unlock();

		looper = colorField->Looper();
		if (looper && looper->Lock()) {
			colorField->Update(2);
			looper->Unlock();
		}
	}

	return 0;
}