예제 #1
0
void
APRView::MessageReceived(BMessage *msg)
{
	if (msg->WasDropped()) {
		rgb_color* color = NULL;
		ssize_t size = 0;

		if (msg->FindData("RGBColor", (type_code)'RGBC', (const void**)&color,
				&size) == B_OK) {
			_SetCurrentColor(*color);

			Window()->PostMessage(kMsgUpdate);
		}
	}

	switch (msg->what) {
		case UPDATE_COLOR:
		{
			// Received from the color fPicker when its color changes
			rgb_color color = fPicker->ValueAsColor();
			_SetCurrentColor(color);

			Window()->PostMessage(kMsgUpdate);
			break;
		}

		case ATTRIBUTE_CHOSEN:
		{
			// Received when the user chooses a GUI fAttribute from the list

			ColorWhichItem* item = (ColorWhichItem*)
				fAttrList->ItemAt(fAttrList->CurrentSelection());
			if (item == NULL)
				break;

			fWhich = item->ColorWhich();
			rgb_color color = ui_color(fWhich);
			_SetCurrentColor(color);
			break;
		}

		default:
			BView::MessageReceived(msg);
			break;
	}
}
예제 #2
0
파일: APRView.cpp 프로젝트: mmanley/Antares
void
APRView::MessageReceived(BMessage *msg)
{
	if (msg->WasDropped()) {
		rgb_color *color;
		ssize_t size;

		if (msg->FindData("RGBColor", (type_code)'RGBC', (const void**)&color,
				&size) == B_OK) {
			SetCurrentColor(*color);
		}
	}

	switch (msg->what) {
		case DECORATOR_CHANGED:
		{
			int32 index = fDecorMenu->IndexOf(fDecorMenu->FindMarked());
			#ifdef ANTARES_TARGET_PLATFORM_ANTARES
			if (index >= 0)
				BPrivate::set_decorator(index);
			#endif
			break;
		}
		case UPDATE_COLOR:
		{
			// Received from the color fPicker when its color changes
			rgb_color color = fPicker->ValueAsColor();
			SetCurrentColor(color);	
			
			Window()->PostMessage(kMsgUpdate);
			break;
		}
		case ATTRIBUTE_CHOSEN:
		{
			// Received when the user chooses a GUI fAttribute from the list

			ColorWhichItem *item = (ColorWhichItem*)
				fAttrList->ItemAt(fAttrList->CurrentSelection());
			if (item == NULL)
				break;

			fWhich = item->ColorWhich();
			rgb_color color = fCurrentSet.GetColor(fWhich);
			SetCurrentColor(color);

			Window()->PostMessage(kMsgUpdate);
			break;
		}
		case REVERT_SETTINGS:
		{
			fCurrentSet = fPrevSet;

			UpdateControls();
			UpdateAllColors();

			Window()->PostMessage(kMsgUpdate);
			break;
		}
		case DEFAULT_SETTINGS:
		{
			fCurrentSet = ColorSet::DefaultColorSet();

			UpdateControls();
			UpdateAllColors();

			if (fDecorMenu) {
				BMenuItem *item = fDecorMenu->FindItem("Default");
				if (item) {
					item->SetMarked(true);
					#ifdef ANTARES_TARGET_PLATFORM_ANTARES
					BPrivate::set_decorator(fDecorMenu->IndexOf(item));
					#endif
				}
			}
			Window()->PostMessage(kMsgUpdate);
			break;
		}
		default:
			BView::MessageReceived(msg);
			break;
	}
}