Exemple #1
0
void Window::DrawOnRegion()
{
	if (!m_bVisible)
		return;

	TYPE_WindowColor& colors = m_pWinData->win.color;

	CRect rcTitle(CPoint(m_pWinData->win.titleX, m_pWinData->win.titleY), CSize(m_pWinData->win.titleW, m_pWinData->win.titleH));
	m_pRegion->DrawTextInBox(rcTitle, m_sTitle, colors.titleText, colors.titleBack, colors.border, 0, 1, DT_CENTER|DT_VCENTER);

	CRect rcBody(CPoint(m_pWinData->win.bodyX, m_pWinData->win.bodyY), CSize(m_pWinData->win.bodyW, m_pWinData->win.bodyH));
	m_pRegion->DrawFilledBox(rcBody, m_pWinData->win.color.bodyBack, m_pWinData->win.color.border);

	int itemsOnScreen = CalcItemsOnScreen();
	int itemHeight = CalcItemHeight();

	for (int i=0 ; i<itemsOnScreen ; i++)
	{	
		int iIndex = i + m_pWinData->startPos;
		if (iIndex >= m_pWinData->itemNum)
			break;
		int yOffs = i * itemHeight;
		CRect rcBox(CPoint(m_pWinData->win.bodyX, m_pWinData->win.bodyY + yOffs),
			CSize(m_pWinData->win.bodyW, itemHeight));
			
		m_pRegion->DrawTextInBox(rcBox, m_sItems[iIndex], colors.bodyText,
			iIndex == m_pWinData->currentPos ? colors.check : colors.bodyBack, colors.border, 0,  1, DT_LEFT|DT_VCENTER);
	}
}
Exemple #2
0
MidiInPanel::MidiInPanel( const CRect& rcSize, Editor* editor ) : 
    CViewContainer( rcSize, editor->getChildFrame(), NULL ),
    editor_( editor )
{
    setTransparency( true );
    setWantsFocus( true );

    SoundDevices* devices = editor_->getDevices();
    MidiPortMap& inPorts  = devices->midiInInfo_;

    CCoord itemHeight = 18;
    CCoord boxHeight  = min( 6*18+1, inPorts.size()*18+1 );
    CRect rcLabelPanel( 5, 0, 150, 15 );
    CRect rcBox( 25, 38, 185, 38+boxHeight );
    
    lblCaption_        = new Label( rcLabelPanel, "Midi In" );
    lblCaption_->font_ = fontPirulen9;
    addView( lblCaption_ );

    gbPorts_ = new GridBox( rcBox, getFrame(), this );
    gbPorts_->setSelectionStyle( GridBox::NoSel );
    gbPorts_->setItemHeight( itemHeight );
    gbPorts_->addColumn( 86 );
    gbPorts_->addColumn( 14 );

    for( UINT16 i=0; i<inPorts.size(); i++ )
    {
        string portName   = inPorts.getPortName( i );
        bool checked      = devices->midiInPortIsOpen( portName );
        MidiBoxItem* item = new MidiBoxItem( portName, checked );
        gbPorts_->addItem( item );
    }
    setColors();
    gbPorts_->layout();
    addView( gbPorts_ );
}
Exemple #3
0
LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
	static DWORD st = 0;
	static DWORD dt = 0;
	static DWORD update_dt = 0;
	static DWORD update_delay = 200;
	static HDC hMainDC = NULL;
	static HDC hMemDC = NULL;
	static HBITMAP hMemBitmap = NULL;
	static HBITMAP hOldMemBitmap = NULL;

	// TODO
	static Point ptMouse;
	static std::list<Rect> Cursor;
	static HBITMAP hBitmap = NULL;
	static int index = 0;
	static Rect current;
	
	if (uMsg == WM_CREATE)
	{
		Rect rc;
		::GetClientRect(hWnd, &rc);

		hMainDC = ::GetDC(hWnd);
		hMemDC = ::CreateCompatibleDC(hMainDC);
		hMemBitmap = ::CreateCompatibleBitmap(hMainDC, rc.width(), rc.height());
		hOldMemBitmap = ::Select(hMemDC, hMemBitmap);

		// TODO
		hBitmap = (HBITMAP)::LoadImage(NULL,
			_T("cursor.bmp"), IMAGE_BITMAP, 0, 0,
			LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_SHARED);

		Rect rcBox(2,2,43,45);
		for (int i = 0; i < 4; i++)
		{
			rcBox.left = rcBox.left + 44;
			rcBox.right = rcBox.right + 44;

			Cursor.push_back(rcBox);
		}

		index = 0;

		::ShowCursor(FALSE);
	
		st = ::GetTickCount();
		::SetTimer(hWnd, 0, 20, NULL);

		return 0;
	}
	else if (uMsg == WM_DESTROY)
	{
		::ShowCursor(TRUE);

		// TODO
		std::list<Rect>::iterator it;
		for (it = Cursor.begin(); it != Cursor.end(); )
		{
			it = Cursor.erase(it);
		}

		::DeleteObject(hBitmap);

		::Select(hMemDC, hOldMemBitmap);
		::DeleteObject(hMemBitmap);
		::DeleteDC(hMemDC);
		::ReleaseDC(hWnd, hMainDC);

		::KillTimer(hWnd, 0);
		::PostQuitMessage(0);
		return 0;
	}
	else if (uMsg == WM_PAINT)
	{
		Rect rc;
		::GetClientRect(hWnd, &rc);

		PAINTSTRUCT ps;
		HDC hdc = ::BeginPaint(hWnd, &ps);

		// background 
		::SetDCBrushColor(hMemDC, RGB(200,200,250));
		::FillRect(hMemDC, &rc, (HBRUSH)::GetStockObject(DC_BRUSH));

		// TODO
		HDC hBitmapDC = ::CreateCompatibleDC(hMemDC);
		HBITMAP hOldBitmap = ::Select(hBitmapDC, hBitmap);

		std::list<Rect>::iterator it = Cursor.begin();

		std::advance(it, index);

		current = *it;

		::GdiTransparentBlt(hMemDC, ptMouse.x - 20,
			ptMouse.y - 21,
			41, 43,
			hBitmapDC,
			current.left, current.top,
			current.width(), current.height(),
			RGB(255,255,255));

		::Select(hBitmapDC, hOldBitmap);

		// memory dc => real dc.
		::BitBlt(hdc, 0, 0, rc.width(), rc.height(),
			hMemDC, 0, 0, SRCCOPY);

		::EndPaint(hWnd, &ps);
		return 0;
	}
	else if (uMsg == WM_ERASEBKGND)
	{
		return 1;
	}
	else if (uMsg == WM_MOUSEMOVE)
	{
		::GetCursorPos(&ptMouse);
		ptMouse = ptMouse.ToClient(hWnd);

		Rect rc;
		::GetClientRect(hWnd, &rc);
		::InvalidateRect(hWnd, &rc, TRUE);

		return 0;
	}
	else if (uMsg == WM_TIMER)
	{
		// TODO
		if (update_dt > update_delay)
		{
			int count = update_dt/update_delay;

			index++;
			if (index >= Cursor.size())
				index = 0;

			update_dt %= update_delay;
		}
		update_dt += dt;

		dt = ::GetTickCount() - st;
		st = ::GetTickCount();

		// redraw
		Rect rc;
		::GetClientRect(hWnd, &rc);
		::InvalidateRect(hWnd, &rc, TRUE);

		return 0;
	}

	return ::DefWindowProc(hWnd,uMsg,wParam,lParam);
}
void CHTMLListCtrl::OnLButtonDown(UINT nFlags, CPoint point) 
{
	SetFocus();

	NM_HTMLLISTCTRL *pNMHDR = new NM_HTMLLISTCTRL;

	pNMHDR->hdr.code = HTMLLIST_LBUTTONDOWN;
	pNMHDR->hdr.hwndFrom = GetSafeHwnd();
	pNMHDR->hdr.idFrom = m_nControlID;

	pNMHDR->lItemData = 0;
	pNMHDR->nItemNo = -1;
	pNMHDR->sItemText = "";
	pNMHDR->bChecked = 0;
	//Send LButton down event first
	GetParent()->SendMessage(WM_NOTIFY,m_nControlID,(LPARAM)pNMHDR);

	delete pNMHDR;


	BOOL bItemSelected = FALSE;
	long selectedItemOld = m_nSelectedItem;

	POSITION pos = m_listItems.GetHeadPosition();
	for(int i = 0;i < m_listItems.GetCount();i++)
	{
		HTMLLIST_ITEM *pItem = m_listItems.GetNext(pos);
		if(pItem->rcItem.PtInRect(point))
		{
			if(m_dwExtendedStyles & HTMLLIST_STYLE_CHECKBOX)
			{
				//see if we clicked in the box
				CPoint pt = pItem->rcItem.TopLeft();
				pt.x += 3;
				pt.y += pItem->rcItem.Height() / 2 - 8;
				

				CRect rcBox(pt,CPoint(pt.x + 15,pt.y + 15));
				
				if(rcBox.PtInRect(point))
				{
					if(pItem->bChecked)
					{
						pItem->bChecked = FALSE;
					}
					else
					{
						pItem->bChecked = TRUE;
					}
					NM_HTMLLISTCTRL *pNMHDR = new NM_HTMLLISTCTRL;

					pNMHDR->hdr.code = HTMLLIST_ITEMCHECKED;
					pNMHDR->hdr.hwndFrom = GetSafeHwnd();
					pNMHDR->hdr.idFrom = m_nControlID;

					pNMHDR->lItemData = pItem->lItemData;
					pNMHDR->nItemNo = pItem->nItemNo;
					pNMHDR->sItemText = pItem->sItemText;
					pNMHDR->bChecked = pItem->bChecked;

					//Send check changed Event
					GetParent()->SendMessage(WM_NOTIFY,m_nControlID,(LPARAM)pNMHDR);
					delete pNMHDR;

					bItemSelected = TRUE;

					//	check box는 select와 독립적으로 동작.
					break;
				}
			}

			if ( m_nSelectedItem == i )
			{	//	같다면.. toggle. -->즉 deselect이다.
				NM_HTMLLISTCTRL *pNMHDR = new NM_HTMLLISTCTRL;

				pNMHDR->hdr.code = HTMLLIST_DESELECTED;
				pNMHDR->hdr.hwndFrom = GetSafeHwnd();
				pNMHDR->hdr.idFrom = m_nControlID;

				pNMHDR->lItemData = GetItemData(selectedItemOld);
				pNMHDR->nItemNo = m_nSelectedItem;
				pNMHDR->sItemText = GetItemText(selectedItemOld);
				pNMHDR->bChecked = GetItemCheck(selectedItemOld);

				//Send Selection changed Event
				GetParent()->SendMessage(WM_NOTIFY,m_nControlID,(LPARAM)pNMHDR);

				delete pNMHDR;

				m_nSelectedItem = NONE_SELECTED;
				Invalidate(FALSE);
				bItemSelected = TRUE;
			}
			else
			{	//	예전꺼 deselect. 현재꺼 select.

				//Send WM_NOTIFY msg to parent
				if ( selectedItemOld != NONE_SELECTED )
				{
					//	old
					NM_HTMLLISTCTRL *pNMHDR = new NM_HTMLLISTCTRL;

					pNMHDR->hdr.code = HTMLLIST_DESELECTED;
					pNMHDR->hdr.hwndFrom = GetSafeHwnd();
					pNMHDR->hdr.idFrom = m_nControlID;

					pNMHDR->lItemData = GetItemData(selectedItemOld);
					pNMHDR->nItemNo = selectedItemOld;
					pNMHDR->sItemText = GetItemText(selectedItemOld);
					pNMHDR->bChecked = GetItemCheck(selectedItemOld);

					//Send Selection changed Event
					GetParent()->SendMessage(WM_NOTIFY,m_nControlID,(LPARAM)pNMHDR);

					delete pNMHDR;
				}

				{
					NM_HTMLLISTCTRL *pNMHDR = new NM_HTMLLISTCTRL;

					pNMHDR->hdr.code = HTMLLIST_SELECTED;
					pNMHDR->hdr.hwndFrom = GetSafeHwnd();
					pNMHDR->hdr.idFrom = m_nControlID;

					pNMHDR->lItemData = pItem->lItemData;
					pNMHDR->nItemNo = pItem->nItemNo;
					pNMHDR->sItemText = pItem->sItemText;
					pNMHDR->bChecked = pItem->bChecked;

					//Send Selection changed Event
					GetParent()->SendMessage(WM_NOTIFY,m_nControlID,(LPARAM)pNMHDR);

					delete pNMHDR;
				}

				m_nSelectedItem = i;
				Invalidate(FALSE);
				bItemSelected = TRUE;
			}
			break;
		}
	}

	if(!bItemSelected)
	{
		if ( selectedItemOld != NONE_SELECTED )
		{
			//	old
			NM_HTMLLISTCTRL *pNMHDR = new NM_HTMLLISTCTRL;

			pNMHDR->hdr.code = HTMLLIST_DESELECTED;
			pNMHDR->hdr.hwndFrom = GetSafeHwnd();
			pNMHDR->hdr.idFrom = m_nControlID;

			pNMHDR->lItemData = GetItemData(selectedItemOld);
			pNMHDR->nItemNo = selectedItemOld;
			pNMHDR->sItemText = GetItemText(selectedItemOld);
			pNMHDR->bChecked = GetItemCheck(selectedItemOld);

			//Send Selection changed Event
			GetParent()->SendMessage(WM_NOTIFY,m_nControlID,(LPARAM)pNMHDR);

			delete pNMHDR;
		}

		m_nSelectedItem = NONE_SELECTED;
	}

	Invalidate(FALSE);

	CWnd::OnLButtonDown(nFlags, point);
}
Exemple #5
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	static DWORD st = 0;
	static DWORD dt = 0;

	if (uMsg == WM_DESTROY)
	{
		//::KillTimer(hWnd, 0);
		::PostQuitMessage(0);
		return 0;
	}
	else if (uMsg == WM_PAINT)
	{
		Rect rc;
		::GetClientRect(hWnd, &rc);

		PAINTSTRUCT ps;
		HDC hdc = ::BeginPaint(hWnd, &ps);

		// TODO
		const int size = 10;
		Rect rcBox(0,0,size,size);

		COLORREF color;

		for (int y = 0; y < rc.height(); y += rcBox.height())
		{
			BYTE r = rand()%256;
			BYTE g = rand()%256;
			BYTE b = rand()%256;

			color = RGB(r,g,b);

			for (int x = 0; x < rc.width(); x += rcBox.width())
			{
				rcBox.left = x;
				rcBox.right = rcBox.left + size;
				rcBox.top = y;
				rcBox.bottom = rcBox.top + size;

				r = min(GetRValue(color) + 10, 255);
				g = min(GetGValue(color) + 10, 255);
				b = min(GetBValue(color) + 10, 255);

				color = RGB(r,g,b);

				HBRUSH hBrush = ::CreateSolidBrush(color);
				HBRUSH hOldBrush = ::Select(hdc, hBrush);

				HPEN hPen = ::CreatePen(PS_SOLID, 1, color);
				HPEN hOldPen = ::Select(hdc, hPen);

				::Rectangle(hdc, rcBox.left, rcBox.top, rcBox.right, rcBox.bottom);

				::Select(hdc, hOldPen);
				::DeleteObject(hPen);

				::Select(hdc, hOldBrush);
				::DeleteObject(hBrush);
			}
		}


		::EndPaint(hWnd, &ps);
		return 0;
	}

	return ::DefWindowProc(hWnd,uMsg,wParam,lParam);
}