⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 upseudosupport.cpp

📁 WinCVS 源码,流行的CVS客户端源码程序
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	
	if(macpp_getcmdid(inMessage, cmdid))
	{
		LWindow *wind = dynamic_cast<LWindow*>(GetOwnerHost());
		if(wind != 0L)
		{
			pane = wind->FindPaneByID(inMessage);
		
			if(pane != 0L)
			{
				int widid = SearchWidID(pane);
				
				LEditText *edit;
				LControl *control;
				LMenuController *popup;
				LScrollBar *bar;
				LSlider *slider;
				LLittleArrows *arrows;
				LCheckBoxGroupBox *groupbox;
				
				if((edit = dynamic_cast<LEditText*>(pane)) != 0L)
					UEventSendMessage(widid, EV_EDITCHANGE, cmdid, 0L);
				else if((popup = dynamic_cast<LMenuController*>(pane)) != 0L &&
					popup->GetMacMenuH() != 0L)
				{
					SInt16 item = popup->GetCurrentMenuItem();
					LStr255 pstr;
					if(item > 0)
						popup->GetMenuItemText(item, pstr);
					UStr content(pstr);
					UEventSendMessage(widid, EV_COMBO_SEL, UMAKEINT(cmdid, item - 1),
						(void *)(const char *)content);
				}
				else if((bar = dynamic_cast<LScrollBar*>(pane)) != 0L)
					UEventSendMessage(widid, EV_SCROLLCHANGE, cmdid, (void *)bar->GetValue());
				else if((slider = dynamic_cast<LSlider*>(pane)) != 0L)
					UEventSendMessage(widid, EV_SCROLLCHANGE, cmdid, (void *)slider->GetValue());
				else if((arrows = dynamic_cast<LLittleArrows*>(pane)) != 0L)
					UEventSendMessage(widid, EV_SCROLLCHANGE, cmdid, (void *)arrows->GetValue());
				else if((control = dynamic_cast<LControl*>(pane)) != 0L)
					UEventSendMessage(widid, EV_CMD, cmdid, 0L);
				else if((groupbox = dynamic_cast<LCheckBoxGroupBox*>(pane)) != 0L)
					UEventSendMessage(widid, EV_CMD, cmdid, 0L);
			}
		}
	}
	else switch (inMessage)
	{
		case msg_ScrollAction:
		{
			LScrollBar::SScrollMessage *message = static_cast<LScrollBar::SScrollMessage *>(ioParam);
			LScrollBar*	scrollBar = message->scrollBar;
			int fPageStep = 1;
			if(macpp_getcmdid(scrollBar->GetPaneID(), cmdid))
				fPageStep = GetPageValue(cmdid);
			int fButtonStep = 1;
			switch(message->hotSpot)
			{
			case kControlPageUpPart:
				scrollBar->SetValue(scrollBar->GetValue() - fPageStep);
				break;
			case kControlUpButtonPart:
				scrollBar->SetValue(scrollBar->GetValue() - fButtonStep);
				break;
			case kControlPageDownPart:
				scrollBar->SetValue(scrollBar->GetValue() + fPageStep);
				break;
			case kControlDownButtonPart:
				scrollBar->SetValue(scrollBar->GetValue() + fButtonStep);
				break;
			}
			break;
		}
		case UTextTableView_SingleClick:
		case UTextTableView_DoubleClick:
			pane = static_cast<LPane *>(ioParam);
			
			if(pane != 0L && macpp_getcmdid(pane, cmdid))
			{
				UStr name;
				int entry = 0;
				LTextTableView *table = dynamic_cast<LTextTableView *>(pane);
				if(table != 0L)
				{
					STableCell cell = table->GetFirstSelectedCell();
					if(!cell.IsNullCell())
					{
						char tmp[255];
						UInt32 ioDataSize = 255;
						table->GetCellData(cell, tmp, ioDataSize);
						name.set(tmp, ioDataSize);
						entry = cell.row;
					}
				}
				
				UEventSendMessage(SearchWidID(pane),
					inMessage == UTextTableView_SingleClick ?
					EV_LIST_SELECTING : EV_LIST_DBLCLICK, UMAKEINT(cmdid, entry - 1),
					(void *)(const char *)name);
			}
			break;
	}
}

CPseudoItem::CPseudoItem(int widid, int cmdid) : m_widid(widid), m_cmdid(cmdid), m_data(0L)
{
}

CPseudoItem::~CPseudoItem()
{
}

// this is the routine called to know what to draw within the
// table cell. See the comments in LOutlineItem.cp for more info.
void
CPseudoItem::GetDrawContentsSelf(
	const STableCell&		inCell,
	SOutlineDrawContents&	ioDrawContents)
{
	std::map<int, UStr>::iterator i = m_texts.find(inCell.col);
	if(i != m_texts.end())
	{
		ioDrawContents.outShowSelection = true;
		LStr255 pstr((*i).second);
		LString::CopyPStr(pstr, ioDrawContents.outTextString);
	}
}

// just to be cute, we'll draw an adornment (again, see the LOutlineItem.cp
// comments for more information). We'll draw a groovy gray background
void
CPseudoItem::DrawRowAdornments(
	const Rect&		inLocalRowRect )
{
	ShadeRow(UGAColorRamp::GetColor(colorRamp_White), inLocalRowRect);
	RGBColor c = UGAColorRamp::GetColor(colorRamp_Gray2);
	RGBForeColor(&c);
	MoveTo(inLocalRowRect.right, inLocalRowRect.top);
	LineTo(inLocalRowRect.right, inLocalRowRect.bottom);
}

void CPseudoItem::DrawCell(const STableCell & inCell, const Rect & inLocalCellRect)
{
	LOutlineItem::DrawCell(inCell, inLocalCellRect);
	
	RGBColor c = UGAColorRamp::GetColor(colorRamp_Gray2);
	RGBForeColor(&c);
	MoveTo(inLocalCellRect.right - 1, inLocalCellRect.top);
	LineTo(inLocalCellRect.right - 1, inLocalCellRect.bottom);
}

void CPseudoItem::SingleClick(
								const STableCell&			inCell,
								const SMouseDownEvent&		inMouseDown,
								const SOutlineDrawContents&	inDrawContents,
								Boolean						inHitText)
{
	UStr name;
	std::map<int, UStr>::iterator i = m_texts.find(inCell.col - 1);
	if(i != m_texts.end())
	{
		name = (*i).second;
	}
	UEventSendMessage(m_widid,
		EV_LIST_SELECTING, UMAKEINT(m_cmdid, inCell.row - 1),
		(void *)(const char *)name);
	
	LOutlineItem::SingleClick(inCell, inMouseDown, inDrawContents, inHitText);
}

void
CPseudoItem::DoubleClick(
	const STableCell&			inCell,
	const SMouseDownEvent&		inMouseDown,
	const SOutlineDrawContents&	inDrawContents,
	Boolean						inHitText)
{
	UStr name;
	std::map<int, UStr>::iterator i = m_texts.find(inCell.col - 1);
	if(i != m_texts.end())
	{
		name = (*i).second;
	}
	UEventSendMessage(m_widid,
		EV_LIST_DBLCLICK, UMAKEINT(m_cmdid, inCell.row - 1),
		(void *)(const char *)name);
	
	LOutlineItem::DoubleClick(inCell, inMouseDown, inDrawContents, inHitText);
}

int UPPMenu::sPPMenuWidID = -1;

UPPMenu::UPPMenu() : UMenu(::UEventGetWidID())
{
	sPPMenuWidID = GetWidID();
}

UPPMenu::~UPPMenu()
{
}

UPseudoRotButton::UPseudoRotButton(LStream *inStream, ClassIDT inImpID) : LBevelButton(inStream, inImpID), fCurrentIcon(0)
{
	ReadIconsID(inStream, fIconSuite);
	
	if(fIconSuite.size() != 0)
		DoRotate(0, false);
}

UPseudoRotButton::~UPseudoRotButton()
{
}

void UPseudoRotButton::ReadIconsID(LStream *inStream, std::vector<short> & res)
{
	LStr255 pstr;
	
	inStream->ReadPString(pstr);
	UStr str(pstr);
	const char *ptr = str;
	while(ptr != 0L)
	{
		int v;
		const char *tmp = strchr(ptr, ',');
		if(tmp != 0L)
		{
			UStr stmp;
			size_t offset = tmp - ptr;
			stmp.set(ptr, offset);
			ptr += offset + 1;
			if(sscanf(stmp, "%d", &v) == 1)
				res.push_back(v);
		}
		else
		{
			if(sscanf(ptr, "%d", &v) == 1)
				res.push_back(v);
			ptr = 0L;
		}
	}
}

void UPseudoRotButton::DoRotate(int icon, bool refresh)
{
	if(fCurrentIcon != icon && icon >= 0 && icon < fIconSuite.size())
	{
		fCurrentIcon = icon;
		ControlButtonContentInfo info;
		GetContentInfo(info);
		if(info.contentType == kControlContentCIconRes ||
			info.contentType == kControlContentIconSuiteRes ||
			info.contentType == kControlContentICONRes ||
			info.contentType == kControlContentPictRes)
		{
			info.u.resID = fIconSuite[icon];
			SetContentInfo(info);
		}
		if(refresh)
			Refresh();
	}
}

UPseudoPlaceHolder::UPseudoPlaceHolder(LStream *inStream) : LPlaceHolder(inStream),
	fCurrentView(0L), fWidid(-1)
{
	LStr255 pstr;
	inStream->ReadPString(pstr);
	*inStream >> fController;
	
	UStr str(pstr);
	const char *ptr = str;
	while(ptr != 0L)
	{
		int v;
		const char *tmp = strchr(ptr, ',');
		if(tmp != 0L)
		{
			UStr stmp;
			size_t offset = tmp - ptr;
			stmp.set(ptr, offset);
			ptr += offset + 1;
			if(sscanf(stmp, "%d", &v) == 1)
				fViewSuite.push_back(v);
		}
		else
		{
			if(sscanf(ptr, "%d", &v) == 1)
				fViewSuite.push_back(v);
			ptr = 0L;
		}
	}
}

UPseudoPlaceHolder::~UPseudoPlaceHolder()
{
}

void UPseudoPlaceHolder::DoRotate(int entry)
{
	int cmdid;
	if(macpp_getcmdid(GetPaneID(), cmdid) && entry >= 0 && entry < fViewSuite.size())
	{
		LWindow *win = macpp_findwindow(this);
		if(win == 0L)
			return;

		LView* samplePanel = UReanimator::CreateView(fViewSuite[entry],	this, win);
		if(samplePanel == 0L)
			return;
		
		InstallOccupant	(samplePanel);
		
		LView *oldView = fCurrentView;
		
		if (fCurrentView != 0L)
		{
			fCurrentView->Hide ();
			fCurrentView = nil;
		}

		Refresh();
		fCurrentView = samplePanel;
		
		if(fWidid != -1 && !gTurnOffBroadcast)
			UEventSendMessage(fWidid, EV_PAGE_CHANGED, UMAKEINT(cmdid, entry), 0L);

		if (oldView != 0L)
		{
			delete oldView;
		}

	}
}

void UPseudoPlaceHolder::ListenToMessage(MessageT inMessage, void * ioParam)
{
	if(inMessage == fController)
	{
		SInt32 currPageIndex = *static_cast<SInt32 *>(ioParam);
		DoRotate(currPageIndex - 1);
	}
}

void UPseudoPlaceHolder::FinishCreateSelf(void)
{
	DoRotate(0);

	LWindow *win = macpp_findwindow(this);
	if(win == 0L)
		return;

	LPageController *controller = dynamic_cast<LPageController*>(win->FindPaneByID(fController));
	if (controller != 0L)
	{
		controller->StartBroadcasting ();
		controller->AddListener (this);
	}
	LTabsControl *controller2 = dynamic_cast<LTabsControl*>(win->FindPaneByID(fController));
	if (controller2 != 0L)
	{
		controller2->StartBroadcasting ();
		controller2->AddListener (this);
	}
}

UPseudoPageHider::UPseudoPageHider(LStream *inStream) : LAttachment(inStream),
	fWidid(-1), fCurSel(-1), fPageCtrl(0L)
{
	SetMessage(msg_FinishCreate);
	
	LStr255 pstr;
	inStream->ReadPString(pstr);
	
	UStr str(pstr);
	const char *ptr = str;
	while(ptr != 0L)
	{
		PaneIDT paneID;
		const char *tmp = strchr(ptr, ',');
		if(tmp != 0L)
		{
			UStr stmp;
			size_t offset = tmp - ptr;
			stmp.set(ptr, offset);
			ptr += offset + 1;
			if(stmp.length() == 4)
			{
				paneID = *(PaneIDT *)(char *)stmp;
				fViewSuite.push_back(paneID);
			}
		}
		else
		{
			if(strlen(ptr) == 4)
			{
				paneID = *(PaneIDT *)ptr;
				fViewSuite.push_back(paneID);
			}
			ptr = 0L;
		}
	}
}

void	UPseudoPageHider::ExecuteSelf(
						MessageT		inMessage,
						void*			ioParam)
{
	if(inMessage == msg_FinishCreate)
	{
		LPane *pane = reinterpret_cast<LPane*>(ioParam);
		fPageCtrl = dynamic_cast<LPageController*>(pane);
		if(fPageCtrl == 0L)
		{
			UAppConsole("The UPseudoPageHider attachement does not have any LPageController to attach to.");
		}
		else
		{
			// add ourself to the broadcast so we receive the changes
			fPageCtrl->StartBroadcasting ();
			fPageCtrl->AddListener (this);
		}
	}
}

UPseudoPageHider::~UPseudoPageHider()
{
}

void UPseudoPageHider::DoRotate(int entry)
{
	if(fPageCtrl == 0L)
		return;
	
	int cmdid;
	if(macpp_getcmdid(fPageCtrl->GetPaneID(), cmdid) && entry >= 0 && entry < fViewSuite.size() &&
		entry != fCurSel)
	{
		fCurSel = entry;
		
		LWindow *win = macpp_findwindow(fPageCtrl);
		if(win == 0L)
			return;

		LPane* samplePanel;
		std::vector<PaneIDT>::iterator i;
		for(i = fViewSuite.begin(); i != fViewSuite.end(); ++i)
		{
			samplePanel = win->FindPaneByID(*i);
			if(samplePanel != 0L)
				samplePanel->Hide();
		}
		
		samplePanel = win->FindPaneByID(fViewSuite[entry]);
		if(samplePanel == 0L)
			return;
		
		samplePanel->Show();
		
		if(fWidid != -1)
			UEventSendMessage(fWidid, EV_CMD, cmdid, (void *)entry);
	}
}

void UPseudoPageHider::ListenToMessage(MessageT inMessage, void * ioParam)
{
	if(fPageCtrl != 0L && inMessage == fPageCtrl->GetPaneID())
	{
		SInt32 currPageIndex = *static_cast<SInt32 *>(ioParam);
		DoRotate(currPageIndex - 1);
	}
}

UPseudoFakePane::UPseudoFakePane(const SPaneInfo	&inPaneInfo, LPseudoWinAttachment *inAttach) :
	LPane(inPaneInfo), m_Attach(inAttach)
{
}

UPseudoFakePane::~UPseudoFakePane()
{
}

void UPseudoFakePane::ActivateSelf()
{
	UEventNotifyMessage(EV_UPDATEFOCUS, 0, dynamic_cast<LWindow *>(GetSuperView()));
}

void UPseudoFakePane::DeactivateSelf()
{
	UEventNotifyMessage(EV_UPDATEFOCUS, 1, dynamic_cast<LWindow *>(GetSuperView()));
}

void UPseudoFakePane::AdaptToSuperFrameSize(
							SInt32		inSurrWidthDelta,
							SInt32		inSurrHeightDelta,
							Boolean		inRefresh)
{
	LPane::AdaptToSuperFrameSize(inSurrWidthDelta, inSurrHeightDelta, inRefresh);
	
	m_Attach->CheckWindowSize();
}


class CDummyClass
{
public:
	CDummyClass()
	{
		RegisterClass_(UPseudoRotButton);
		RegisterClass_(UPseudoPlaceHolder);
		RegisterClass_(UPseudoPageHider);
	}
	
} sDummyStarter;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -