void GroupListEmoticons::CreateToolTips()
{
	int top = 0;

	for(int i = 0; i < num_groups; i++)
	{
		Group &group = groups[i];
		
		if (group.name[0] != '\0')
		{
			RECT rc = CalcRect(group.name, groupFont);
			top += HeightWithBorders(rc);
		}

		int index = 0;
		for (int j = group.start; j <= group.end; j++)
		{
			Emoticon *e = ssd->module->emoticons[j];
			if (e->IgnoreFor(ssd->module))
				continue;

			RECT rc = GetEmoticonRect(group, index);
			rc.top += top;
			rc.bottom += top;
			CreateEmoticonToolTip(e, rc);
			index++;
		}

		top += group.max_height * group.lines + (group.lines + 1) * BORDER;
	}
}
void CElcSkinFrameBase::DrawClientBackground(CDC* pDC)
{
	if (!m_bDrawClientBackgnd)
		return;

	CRect rcClient, rcImage;
	::GetClientRect(m_hDerive, &rcClient);

	CElcMemDC dcMem(pDC, rcClient);

	// fill background
	dcMem.FillSolidRect(rcClient, m_skin.client.crBackgnd);

	if (m_skin.client.pane.image.pImage) 
	{
		for (CClientImagePosArray::iterator it = m_arrClientImagePos.begin();
			it != m_arrClientImagePos.end();
			it ++) 
		{
			rcImage = CalcRect(&rcClient, &(it->pos.point), &(it->pos.size));
			thePainter.DrawImageGDI(dcMem.GetSafeHdc(),
				&m_skin.client.pane.image,
				rcImage,
				0,
				0,
				1,
				0);
		}
	}

	dcMem.DrawMe();
}
bool LabelControl::Init(int nfnt, char *pszLabel, char *pszFlag1, char *pszFlag2)
{
	m_nfnt = nfnt;
	char *pszT = (char *)gpbScratch + (gcbScratch / 2);
	ExpandVars(pszLabel, pszT, kcbLabelTextMax);
	m_szLabel = (char *)gmmgr.AllocPtr(strlen(pszT) + 1);
	gmmgr.WritePtr(m_szLabel, 0, pszT, strlen(pszT) + 1);

	if (strcmp(pszFlag1, "center") == 0)
		m_wf |= kfLblCenterText;
	else if (strcmp(pszFlag1, "multiline") == 0)
		m_wf |= kfLblMultiLine;
	else if (strcmp(pszFlag1, "right") == 0)
		m_wf |= kfLblRightText;

	if (strcmp(pszFlag2, "center") == 0)
		m_wf |= kfLblCenterText;
	else if (strcmp(pszFlag2, "multiline") == 0)
		m_wf |= kfLblMultiLine;
	else if (strcmp(pszFlag2, "right") == 0)
		m_wf |= kfLblRightText;
    else if (strcmp(pszFlag2, "clipvert") == 0)
        m_wf |= kfLblClipVertical;

	CalcRect();
	return true;
}
BOOL CElcSkinFrameBase::IsCtrlInPane(CWnd* pWnd)
{
	if (!m_bDrawClientBackgnd)
		return FALSE;

	if (!m_skin.client.pane.image.pImage)
		return FALSE;

	CWnd* pThis = CWnd::FromHandle(m_hDerive);
	if (!pThis)
		return FALSE;

	CRect rcThis, rcPane, rcCtrl;
	CPoint pt;

	pThis->GetClientRect(rcThis);
	pWnd->GetWindowRect(rcCtrl);
	pThis->ScreenToClient(&rcCtrl);
	pt.x = rcCtrl.left + rcCtrl.Width() / 2;
	pt.y = rcCtrl.top + rcCtrl.Height() / 2;

	for (CClientImagePosArray::iterator it = m_arrClientImagePos.begin();
		it != m_arrClientImagePos.end();
		it ++)
	{
		rcPane = CalcRect(rcThis, &(it->pos.point), &(it->pos.size));
		if (rcPane.PtInRect(pt))
			return TRUE;
	}

	return FALSE;
}
void LabelControl::SetText(const char *psz)
{
	if (psz == NULL) {
		if (m_szLabel != NULL) {
			gmmgr.FreePtr(m_szLabel);
			m_szLabel = NULL;
		}
	} else {
		if (strcmp(psz, m_szLabel) == 0)
			return;
		if (m_szLabel != NULL)
			gmmgr.FreePtr(m_szLabel);

        // Use the tail end of the scratch buffer because ExpandVars
        // (potentially) calls StringTable::GetString which reads from the
        // database, decompressing to the front of the scratch buffer as part
        // of the process.

		char *pszT = (char *)gpbScratch + (gcbScratch / 2);
		ExpandVars((char *)psz, pszT, kcbLabelTextMax);

		m_szLabel = (char *)gmmgr.AllocPtr(strlen(pszT) + 1);
		gmmgr.WritePtr(m_szLabel, 0, pszT, strlen(pszT) + 1);
	}
	CalcRect();
}
Example #6
0
void CLayoutControl::DoLayout( CWindow wndLayout, HDWP hDwp, const CRect& rcLayout )
{
	CRect rcControl;
	CWindow wndControl = CalcRect( wndLayout, rcLayout, rcControl );

	StoreNewWindowRect( wndControl, hDwp, rcControl );

	wndControl.DeferWindowPos( hDwp, NULL, RECT_BREAK(rcControl),
		SWP_NOACTIVATE | SWP_NOZORDER /*| SWP_DRAWFRAME*/ );
}
Example #7
0
void CLayoutContainer::DoLayout( CWindow wndLayout, HDWP hDwp, const CRect& rcLayout )
{
	CalcRect(wndLayout, rcLayout);

	// iterate through all layout entries
	for ( POSITION pos = m_LayoutList.GetHeadPosition(); pos != NULL; )
	{
		CLayoutNode* pNode = m_LayoutList.GetNext(pos);
		pNode->DoLayout( wndLayout, hDwp, m_rcBounds );
	}
}
Example #8
0
void
BPose::MoveTo(BPoint point, BPoseView* poseView, bool invalidate)
{
	point.x = floorf(point.x);
	point.y = floorf(point.y);

	BRect oldBounds;

	BPoint oldLocation = Location(poseView);

	ASSERT(poseView->ViewMode() != kListMode);
	if (point == oldLocation || poseView->ViewMode() == kListMode)
		return;

	if (invalidate)
		oldBounds = CalcRect(poseView);

	// might need to move a text view if we're active
	if (poseView->ActivePose() == this) {
		BView* border_view = poseView->FindView("BorderView");
		if (border_view) {
			border_view->MoveBy(point.x - oldLocation.x,
				point.y - oldLocation.y);
		}
	}

	float scale = 1.0;
	if (poseView->ViewMode() == kIconMode) {
		scale = poseView->IconSize() / 32.0;
	}
	fLocation.x = point.x / scale;
	fLocation.y = point.y / scale;

	fHasLocation = true;
	fNeedsSaveLocation = true;

	if (invalidate) {
		poseView->Invalidate(oldBounds);
		poseView->Invalidate(CalcRect(poseView));
	}
}
Example #9
0
BRect
BTextWidget::CalcClickRect(BPoint poseLoc, const BColumn *column,
	const BPoseView* view)
{
	BRect result = CalcRect(poseLoc, column, view);
	if (result.Width() < kWidthMargin) {
		// if resulting rect too narrow, make it a bit wider
		// for comfortable clicking
		if (column && column->Width() < kWidthMargin)
			result.right = result.left + column->Width();
		else
			result.right = result.left + kWidthMargin;
	}
	return result;
}
void EmoticonsSelectionLayout::GetEmoticonSize(Emoticon *e, int &width, int &height)
{
	width = 0;
	height = 0;

	if (e->img != NULL)
		e->img->Load(height, width);

	if (e->img == NULL || e->img->img == NULL)
	{
		if (e->texts.getCount() > 0)
		{
			RECT rc = CalcRect(e->texts[0]);
			height = rc.bottom - rc.top + 1;
			width = rc.right - rc.left + 1;
		}
		else
		{
			RECT rc = CalcRect(e->description);
			height = rc.bottom - rc.top + 1;
			width = rc.right - rc.left + 1;
		}
	}
}
Example #11
0
BRect
BTextWidget::ColumnRect(BPoint poseLoc, const BColumn *column,
	const BPoseView *view)
{
	if (view->ViewMode() != kListMode) {
		// ColumnRect only makes sense in list view, return
		// CalcRect otherwise
		return CalcRect(poseLoc, column, view);
	}
	BRect result;
	result.left = column->Offset() + poseLoc.x;
	result.right = result.left + column->Width();
	result.bottom = poseLoc.y + view->ListElemHeight() - 1;
	result.top = result.bottom - view->FontHeight();
	return result;
}
Example #12
0
XBOOL XHScrollBar::OnPaint(XGraphics &g)
{
	XRect rect;
	GetClientRect(rect);
	XColor c(XWindow::m_nColors[XCW_BUTTON]);
	XColor cc(c);
	cc.Bright(24);
	g.SetBackColor(cc);
	g.FillRectangle(rect);
	
	XRect r=rect;
	int pp;
	CalcRect(r,pp);
	if(m_nStatus==XS_UPPAGE&&r.left>rect.bottom)
	{
	   XColor cm(c);
	   cm.Bright(12);
	   g.SetBackColor(cm);
	   g.FillRectangle(XRect(0,0,r.left,rect.bottom));
	}
	if(m_nStatus==XS_DOWNPAGE&&r.right<rect.right-rect.bottom)
	{
	   XColor cm(c);
	   cm.Bright(12);
	   g.SetBackColor(cm);
	   g.FillRectangle(XRect(r.right,0,rect.right-rect.bottom,rect.bottom));
	}


	XColor hc(c);
	hc.Bright(10);
	XRect rl(0,0,rect.bottom,rect.bottom);
	XRect rr(rect.right-rect.bottom,0,rect.right,rect.bottom);
	g.DrawButton(rl,m_nStatus==XS_UPLINE?hc:c,XBS_BFRAME|XBS_WFRAME);
	g.DrawButton(rr,m_nStatus==XS_DOWNLINE?hc:c,XBS_BFRAME|XBS_WFRAME);

	cc=c;cc.Dark(60);
	g.DrawDirect(rl,XK_LEFT,cc);
	g.DrawDirect(rr,XK_RIGHT,cc);


	g.DrawButton(r,m_nStatus==XS_HAND?hc:c,XBS_BFRAME|XBS_WFRAME|XBS_VHAND);

	return XTRUE;
	//*/
}
void GroupListEmoticons::SetSelection(HWND hwnd, POINT p)
{
	// first find group 
	int i;
	for(i = 0; i < num_groups; i++)
	{
		Group &group = groups[i];
		if (group.top > p.y)
			break;
	}
	i--;

	Group &group = groups[i];

	p.y -= group.top;
	if (group.name[0] != '\0')
	{
		RECT rc = CalcRect(group.name, groupFont);
		p.y -= HeightWithBorders(rc);
	}

	int col;
	if (p.x % (BORDER + group.max_width) < BORDER)
		col = -1;
	else
		col = p.x / (BORDER + group.max_width);

	int line;
	if (p.y % (BORDER + group.max_height) < BORDER)
		line = -1;
	else
		line = p.y / (BORDER + group.max_height);

	int index = GetIndex(group, line, col);

	if (col >= 0 && col < group.cols && line >= 0 && line < group.lines && index <= group.end)
	{
		EmoticonsSelectionLayout::SetSelection(hwnd, index);
	}
	else
	{
		EmoticonsSelectionLayout::SetSelection(hwnd, -1);
	}
}
Example #14
0
BOOL CMainDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	SetWindowVersion();
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	CalcRect();
	SetStatusBar();
	InitPage();	
	g_pListView = &m_FileList;
	if (m_bIsWin9x)
	{
		m_wndToolBar.GetToolBarCtrl().EnableButton(ID_SCHEDULE_EDIT,FALSE); 
		EnableMenu(2,FALSE);
	}
	PostMessage(WM_COMMAND,ID_FOLDER_VIEW,0);
	return TRUE;  // return TRUE  unless you set the focus to a control
}
Example #15
0
void XHScrollBar::OnMouseDown(XPoint &pt,int iPos)
{
	if(iPos) return;
	if(m_nRange<=0) return;
	XRect r;
	GetClientRect(r);
	XRect ru(0,0,r.bottom,r.bottom);
	XRect rd(r.right-r.bottom,0,r.right,r.bottom);
	int pp;
	CalcRect(r,pp);
	m_nStatus=XS_NONE;
	if(ru.PtInRect(pt))
		m_nStatus=XS_UPLINE;
	else if(rd.PtInRect(pt))
		m_nStatus=XS_DOWNLINE;
	else if(pt.x<r.left)
	{
		m_nStatus=XS_UPPAGE;
		m_nDownPos=(pt.x-((r.left+r.right)>>1))*1000/pp+m_nPos;
	}
Example #16
0
BOOL CChart::Create(DWORD dwStyle, CRect &rect, CWnd *pParent, UINT id)
{
	//DWORD style = dwStyle & ( ~WS_BORDER ) ;
	//static CString className = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW);
	BOOL result ;
	
	result = CWnd::CreateEx(WS_EX_CLIENTEDGE | WS_EX_STATICEDGE, 
                            NULL, NULL, dwStyle, 
                            rect.left, rect.top, 
                            rect.right-rect.left, rect.bottom-rect.top,
                            pParent->GetSafeHwnd(), (HMENU)id) ;
	if( !result )
		AfxMessageBox("Error creating window");
	m_ctlRect = rect ;
	pParent->ClientToScreen(m_ctlRect) ;
	ScreenToClient(m_ctlRect) ;
	CreateFont(); // Get system font for label draw 
	bFontIsCreate = TRUE ;
	CalcRect() ;  // Compute rectangle 
	ResCalc();    // Compute resolution per dot .
	bCreated = result;
	return result ;
}
Example #17
0
void
BPose::UpdateIcon(BPoint poseLoc, BPoseView* poseView)
{
	IconCache::sIconCache->IconChanged(ResolvedModel());

	int32 iconSize = poseView->IconSizeInt();

	BRect rect;
	if (poseView->ViewMode() == kListMode) {
		rect = CalcRect(poseLoc, poseView);
		rect.left += kListOffset;
		rect.right = rect.left + iconSize;
		rect.top = rect.bottom - iconSize;
	} else {
		BPoint location = Location(poseView);
		rect.left = location.x;
		rect.top = location.y;
		rect.right = rect.left + iconSize;
		rect.bottom = rect.top + iconSize;
	}

	poseView->Invalidate(rect);
}
Example #18
0
void ZoomRect(Boolean zoomLarger,Rect *smallRect, Rect *bigRect)
{
	double firstStep,stepValue,trailer,zoomRatio;
	short i,step;
	Rect curRect;
	unsigned long ticks;
	Pattern	grayPattern; //used in carbonization
	RgnHandle rgnHandle = NewRgn();
	GrafPtr oldPort;
	Rect	tempRect1;
	
	GetPort(&oldPort);
	SetPort(GetWindowPort(gWindow));
	
	//PenPat(&qd.gray);
	PenPat(GetQDGlobalsGray(&grayPattern));
	PenMode(patXor);
	
	
	firstStep=kZoomRatio;
	for (i=0; i<kNumSteps; i++) {
		firstStep *= kZoomRatio;
	}

	if (!zoomLarger) {
		zoomRatio = 1.0/kZoomRatio;
		firstStep = 1.0-firstStep;
	}
	else
		zoomRatio = kZoomRatio;
		
	trailer = firstStep;
	stepValue = firstStep;
	for (step=0; step<(kNumSteps+kRectsVisible); step++) {
	
		// draw new frame
		
		if (step<kNumSteps) {
			stepValue /= zoomRatio;
			CalcRect(&curRect,smallRect,bigRect,stepValue);
			FrameRect(&curRect);
		}
		
		// erase old frame
		
		if (step>=kRectsVisible) {
			trailer /= zoomRatio;
			CalcRect(&curRect,smallRect,bigRect,trailer);
			FrameRect(&curRect);
		}
		QDFlushPortBuffer(GetWindowPort(gWindow), GetPortVisibleRegion(GetWindowPort(gWindow), rgnHandle));
		Delay(kDelayTicks,&ticks);
		
	}

	PenNormal();
	DisposeRgn(rgnHandle);
	smallRect->top = bigRect->top = -1;
	EraseRect(GetPortBounds(GetWindowPort(gWindow), &tempRect1));
	
	SetPort(oldPort);
}
void GroupListEmoticons::Load()
{
	selection = -1;

	// Load fonts
	groupFont = mir_font_get(_T("Emoticons"), _T("Group Name"), &groupColor);
	emoticonFont = mir_font_get(_T("Emoticons"), _T("Emoticons Text"), &emoticonColor);
	groupBkgColor = mir_color_get(_T("Emoticons"), _T("Group Background"));
	ssd->background = mir_color_get(_T("Emoticons"), _T("Emoticons Background"));

	num_groups = CountGroups();
	groups = (Group *) malloc(num_groups * sizeof(Group));

	char *current_group = ssd->module->emoticons[0]->group;

	int current_id = -1;
	int i;
	for(i = 0; i < ssd->module->emoticons.getCount(); i++)
	{
		Emoticon *e = ssd->module->emoticons[i];
		if (e->IgnoreFor(ssd->module))
			continue;

		if (stricmp(e->group, current_group) != 0 || i == 0)
		{
			if (i != 0)
				groups[current_id].end = i - 1;

			current_group = e->group;
			current_id++;

			SetGroupName(groups[current_id], current_group);
			groups[current_id].start = i;
			groups[current_id].count = 1;
		}
		else 
		{
			groups[current_id].count++;
		}
	}
	groups[current_id].end = i - 1;

	// First calc the width
	window.width = 0;
	for(i = 0; i < num_groups; i++)
	{
		Group &group = groups[i];
		GetMaxEmoticonSize(group);
		group.cols = GetNumOfCols(group.count);

		if (group.name[0] != _T('\0'))
		{
			RECT rc = CalcRect(group.name, groupFont);
			window.width = max(window.width, rc.right - rc.left + 2 * BORDER + 1);
		}

		window.width = max(window.width, group.max_width * group.cols + (group.cols + 1) * BORDER);
	}

	// Now calc the height
	window.height = 0;
	for(i = 0; i < num_groups; i++)
	{
		Group &group = groups[i];
		group.top = window.height;

		int w = window.width - BORDER;

		// Recalc the num of cols
		group.lines = GetNumOfLines(group.count, group.cols);
		
		int new_cols = w / (group.max_width + BORDER);
		int new_lines = GetNumOfLines(group.count, new_cols);
		if (new_lines < group.lines)
		{
			group.cols = new_cols;
			group.lines = new_lines;
		}


		// If there is space left, put it into the emoticons
		group.max_width += (w - group.cols * (group.max_width + BORDER)) / group.cols;

		if (group.name[0] != '\0')
		{
			RECT rc = CalcRect(group.name, groupFont);
			window.height += HeightWithBorders(rc);
		}

		window.height += group.max_height * group.lines + (group.lines + 1) * BORDER;
	}
}
void GroupListEmoticons::Draw(HDC hdc)
{
	EraseBackground(hdc);

	RECT client_rc;
	GetClientRect(hwnd, &client_rc);

	COLORREF old_text_color = SetTextColor(hdc, emoticonColor);

	int top = 0;

	for(int i = 0; i < num_groups; i++)
	{
		Group &group = groups[i];
		
		if (group.name[0] != '\0')
		{
			RECT rc = CalcRect(group.name, groupFont);
			rc.top += top + BORDER;
			rc.bottom += top + BORDER;

			int width = rc.right - rc.left;
			rc.left = client_rc.left + (client_rc.right - client_rc.left - width) / 2;
			rc.right = rc.left + width;

			RECT title_rc = client_rc;
			title_rc.top = rc.top - BORDER;
			title_rc.bottom = rc.bottom + BORDER + 1;
			HBRUSH hB = CreateSolidBrush(groupBkgColor);
			FillRect(hdc, &title_rc, hB);
			DeleteObject(hB);

			SetTextColor(hdc, groupColor);

			DrawEmoticonText(hdc, group.name, rc, groupFont);

			SetTextColor(hdc, emoticonColor);

			top += HeightWithBorders(rc);
		}

		int index = 0;
		for (int j = group.start; j <= group.end; j++)
		{	
			Emoticon *e = ssd->module->emoticons[j];
			if (e->IgnoreFor(ssd->module))
				continue;

			RECT rc = GetEmoticonRect(group, index);
			rc.top += top;
			rc.bottom += top;

			DrawEmoticon(hdc, j, rc);

			index++;
		}

		top += group.max_height * group.lines + (group.lines + 1) * BORDER;
	}

	SetTextColor(hdc, old_text_color);
}