Exemplo n.º 1
0
//自绘界面
void CRadarMapCtrl::OnCustomDraw(CDC *pDC)
{
	DrawBg();

	DrawCoordinate();

	if(m_map_bkgrdMap.bReady)
	{
		DrawMap();
	}
	if(m_map_warningResult.objNum>0)
	{
		DrawWarningResult();
	}
	if(m_map_warningObjects.size()>0
		&& (m_state==RDPlayBack))
	{
		PlayBackWaringObject();
	}
	
	if(m_zoomInBtn != NULL)
		m_zoomInBtn->Draw(&m_dcMemory);	
	if(m_zoomOutBtn != NULL)
		m_zoomOutBtn->Draw(&m_dcMemory);
	
	DrawState(pDC);
	
	//最后统一拷贝到PDC中,双缓冲
	CRect   rect;   
	GetClientRect(&rect);   
	pDC->BitBlt(0,0,rect.Width(),rect.Height(),&m_dcMemory,0,0,SRCCOPY);

}
Exemplo n.º 2
0
///////////////////////////////////////////////
// fastuidraw::gl::detail::PainterBackendGL methods
fastuidraw::gl::detail::PainterBackendGL::
PainterBackendGL(const fastuidraw::gl::PainterEngineGL *f):
  PainterBackend(),
  m_nearest_filter_sampler(0),
  m_surface_gl(nullptr)
{
  reference_counted_ptr<PainterShaderRegistrar> reg_base(&f->painter_shader_registrar());

  FASTUIDRAWassert(reg_base.dynamic_cast_ptr<PainterShaderRegistrarGL>());
  m_reg_gl = reg_base.static_cast_ptr<PainterShaderRegistrarGL>();

  FASTUIDRAWassert(dynamic_cast<GlyphAtlasGL*>(&f->glyph_atlas()));
  m_glyph_atlas = static_cast<GlyphAtlasGL*>(&f->glyph_atlas());

  FASTUIDRAWassert(dynamic_cast<ImageAtlasGL*>(&f->image_atlas()));
  m_image_atlas = static_cast<ImageAtlasGL*>(&f->image_atlas());

  FASTUIDRAWassert(dynamic_cast<ColorStopAtlasGL*>(&f->colorstop_atlas()));
  m_colorstop_atlas = static_cast<ColorStopAtlasGL*>(&f->colorstop_atlas());

  m_binding_points.m_num_ubo_units = m_reg_gl->uber_shader_builder_params().num_ubo_units();
  m_binding_points.m_num_ssbo_units = m_reg_gl->uber_shader_builder_params().num_ssbo_units();
  m_binding_points.m_num_texture_units = m_reg_gl->uber_shader_builder_params().num_texture_units();
  m_binding_points.m_num_image_units = m_reg_gl->uber_shader_builder_params().num_image_units();

  m_binding_points.m_colorstop_atlas_binding = m_reg_gl->uber_shader_builder_params().colorstop_atlas_binding();
  m_binding_points.m_image_atlas_color_tiles_nearest_binding = m_reg_gl->uber_shader_builder_params().image_atlas_color_tiles_nearest_binding();
  m_binding_points.m_image_atlas_color_tiles_linear_binding = m_reg_gl->uber_shader_builder_params().image_atlas_color_tiles_linear_binding();
  m_binding_points.m_image_atlas_index_tiles_binding = m_reg_gl->uber_shader_builder_params().image_atlas_index_tiles_binding();
  m_binding_points.m_glyph_atlas_store_binding = m_reg_gl->uber_shader_builder_params().glyph_atlas_store_binding();
  m_binding_points.m_glyph_atlas_store_binding_fp16 = m_reg_gl->uber_shader_builder_params().glyph_atlas_store_binding_fp16x2();
  m_binding_points.m_data_store_buffer_binding = m_reg_gl->uber_shader_builder_params().data_store_buffer_binding();
  m_binding_points.m_color_interlock_image_buffer_binding = m_reg_gl->uber_shader_builder_params().color_interlock_image_buffer_binding();
  m_binding_points.m_context_texture_binding = m_reg_gl->uber_shader_builder_params().context_texture_binding();
  m_binding_points.m_coverage_buffer_texture_binding = m_reg_gl->uber_shader_builder_params().coverage_buffer_texture_binding();
  m_binding_points.m_uniforms_ubo_binding = m_reg_gl->uber_shader_builder_params().uniforms_ubo_binding();

  if (!m_reg_gl->params().use_uber_item_shader())
    {
      m_cached_item_programs = FASTUIDRAWnew PainterShaderRegistrarGL::CachedItemPrograms(m_reg_gl);
    }

  if (m_reg_gl->params().separate_program_for_discard())
    {
      m_choose_uber_program[false] = PainterEngineGL::program_without_discard;
      m_choose_uber_program[true] = PainterEngineGL::program_with_discard;
    }
  else
    {
      m_choose_uber_program[false] = m_choose_uber_program[true] = PainterEngineGL::program_all;
    }

  unsigned int num_ext(m_reg_gl->uber_shader_builder_params().number_context_textures());
  m_current_context_texture.resize(num_ext, 0u);
  m_pool = FASTUIDRAWnew painter_vao_pool(m_reg_gl->params(),
                                          m_reg_gl->tex_buffer_support(),
                                          m_binding_points.m_data_store_buffer_binding);
  m_draw_state = FASTUIDRAWnew DrawState();
}
Exemplo n.º 3
0
void ImagedButton::drawIcon(HDC* dc, RECT* imageRect, bool isPressed, bool isDisabled)
{
  DrawState(*dc, NULL, NULL, (LPARAM)*m_icon, 0,
            imageRect->left, imageRect->top,
            (imageRect->right - imageRect->left),
            (imageRect->bottom - imageRect->top), 
            (isDisabled ? DSS_DISABLED : DSS_NORMAL) | DST_ICON);
} 
Exemplo n.º 4
0
Arquivo: game.c Projeto: docwhat/cwimp
void NextPlayer() {
  Int x;
#ifdef DEBUG
  Int dd = 0;
#endif

  x = stor.currplayer;

  while(1) {
	stor.currplayer = (stor.currplayer + 1) % stor.numplayers;
	if ( x == stor.currplayer ) {
	  if ( stor.numplayers > 1 ) {
		// Only one guy hasn't lost
		//HaveWinner();
		FrmCustomAlert( calertDEBUG,
						"We have a weiner, I mean a winner!",
						"No, I'm not telling you who.",
						"ToDo: Do this correctly." );
	  }
	  break;
	}
	if ( ! stor.player[stor.currplayer].lost ) {
	  break;
	}
#ifdef DEBUG
	ErrNonFatalDisplayIf( ++dd > (MaxPlayers + 4), "NextPlayer: Had to rely on dd loop check!" );
#endif
  }
  
	DrawPlayerScore( x );
	DrawPlayerScore( stor.currplayer );

  // Clear scores
  stor.scorethisroll = stor.scorethisturn = 0;
  StayBit = false;

  // Clear cubes
  for( x = 0 ; x < NumCubes ; x++ ) {
	stor.cube[x].keep = false;
	stor.cube[x].value = 0;
  }

  stor.status = DS_NextPlayer; // Bypass StatusLine();

  if ( stor.flags & flag_NextPlayerPopUp ) {
	FrmCustomAlert( calertNEXTPLAYER,
					stor.player[stor.currplayer].name,
					" ", " ");
	DrawState();
  } else {
	DrawStatus();
  }

}
Exemplo n.º 5
0
void _draw_tabs(
		LPDRAWITEMSTRUCT itst
	)
{	
	DrawState(itst->hDC, NULL, NULL, 
		(LPARAM)NULL, 0, itst->rcItem.left, itst->rcItem.top, 0, 0, DST_PREFIXTEXT);

	DrawEdge(itst->hDC, &itst->rcItem, BDR_SUNKENOUTER, 0);


}
Exemplo n.º 6
0
/**
 * name:	PaintIcon
 * desc:	Draws the Icon of the button
 * param:	ctl			- BTNCTRL structure for the button
 *			hdcMem		- device context to draw to
 *			ccText		- character count of the text of the button
 *			rcClient	- rectangle of the whole button
 *			rcText		- rectangle of the text to draw later on
 * return:	nothing
 **/
static void __fastcall PaintIcon(BTNCTRL *ctl, HDC hdcMem, LPWORD ccText, LPRECT rcClient, LPRECT rcText)
{
    RECT rcImage;

    // draw icon on the left of the button
    if (ctl->hIcon) {
        rcImage.right = GetSystemMetrics(SM_CXSMICON);
        rcImage.bottom = GetSystemMetrics(SM_CYSMICON);
        rcImage.left = (rcClient->right - rcClient->left) / 2 - ((rcImage.right + rcText->right + (*ccText > 0 ? 4 : 0) + (ctl->arrow ? rcImage.right : 0)) / 2);
        rcImage.top = (rcClient->bottom - rcClient->top - rcImage.bottom) / 2;
        rcImage.right += rcImage.left;
        rcImage.bottom += rcImage.top;

        OffsetRect(rcText, rcImage.right + 4, 0);
        if (ctl->stateId == PBS_PRESSED)	OffsetRect(&rcImage, 1, 1);

        DrawState(hdcMem, NULL, NULL, (LPARAM)ctl->hIcon, 0,
                  rcImage.left, rcImage.top,
                  rcImage.right - rcImage.left, rcImage.bottom - rcImage.top,
                  IsWindowEnabled(ctl->hwnd) ? DST_ICON | DSS_NORMAL : DST_ICON | DSS_DISABLED);
    }

    // draw arrow on the right of the button
    if (ctl->arrow) {
        rcImage.right = GetSystemMetrics(SM_CXSMICON);
        rcImage.left = (*ccText > 0 || ctl->hIcon)
                       ? rcClient->right - GetSystemMetrics(SM_CXSMICON)
                       : (rcClient->right - rcClient->left - rcImage.right) / 2;
        rcImage.right += rcImage.left;
        rcImage.bottom = GetSystemMetrics(SM_CYSMICON);
        rcImage.top = (rcClient->bottom - rcClient->top - rcImage.bottom) / 2;
        if (ctl->stateId == PBS_PRESSED)	OffsetRect(&rcImage, 1, 1);

        DrawState(hdcMem, NULL, NULL, (LPARAM)ctl->arrow, 0,
                  rcImage.left, rcImage.top,
                  rcImage.right - rcImage.left, rcImage.bottom - rcImage.top,
                  IsWindowEnabled(ctl->hwnd) ? DST_ICON | DSS_NORMAL : DST_ICON | DSS_DISABLED);
    }
}
Exemplo n.º 7
0
void MainWnd_OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT * lpDrawItem) {
    if (lpDrawItem->itemID == -1)
        return;
    RECT rect = lpDrawItem->rcItem;
    project_t *project = project_get(lpDrawItem->itemID);
    WCHAR *name = U2W(project_name(project));
    HFONT hOldFont;

    // http://www.codeproject.com/KB/combobox/TransListBox.aspx
    switch (lpDrawItem->itemAction) {
        case ODA_SELECT:
        case ODA_DRAWENTIRE:
            if (lpDrawItem->itemState & ODS_SELECTED) {
                DrawState(lpDrawItem->hDC, NULL, NULL, (LPARAM)g_hListBoxSelectionBgBitmap, 0, rect.left, rect.top, 0, 0, DST_BITMAP);
            } else {
                RECT parentRect = rect;
                MapWindowPoints(g_hProjectListView, g_hMainWindow, (LPPOINT)&parentRect, 2);

                HDC hBitmapDC = CreateCompatibleDC(lpDrawItem->hDC);
                HBITMAP hOldBitmap = SelectBitmap(hBitmapDC, g_hMainWindowBgBitmap);
                BitBlt(lpDrawItem->hDC, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
                    hBitmapDC, parentRect.left, parentRect.top, SRCCOPY);
                SelectBitmap(hBitmapDC, hOldBitmap);
                DeleteDC(hBitmapDC);
            }
            DrawState(lpDrawItem->hDC, NULL, NULL, (LPARAM)g_hProjectIcon, 0, rect.left + 18, rect.top + 2, 0, 0, DST_ICON);
            SetTextAlign(lpDrawItem->hDC, TA_TOP | TA_LEFT);
            hOldFont = SelectFont(lpDrawItem->hDC, g_hNormalFont12);
            if (lpDrawItem->itemState & ODS_SELECTED) {
                SetTextColor(lpDrawItem->hDC, RGB(0xFF, 0xFF, 0xFF));
            } else {
                SetTextColor(lpDrawItem->hDC, RGB(0x00, 0x00, 0x00));
            }
            TextOut(lpDrawItem->hDC, rect.left + 39, rect.top + 1, name, wcslen(name));
            SelectFont(lpDrawItem->hDC, hOldFont);
    }
}
Exemplo n.º 8
0
VOID MainWindow::UpdateDisplay()
{
	HDC hdc;
	// convert display_slice to bitmap
	if(m_hbmpSlice)
		DeleteObject(m_hbmpSlice);

	m_hbmpSlice = m_Recon->GetBitmap();
	if(m_hbmpSlice)
	{
		hdc = GetDC(m_hwnd);
		DrawState(hdc,NULL,NULL,(LPARAM)m_hbmpSlice,0,400,46,0,0,DST_BITMAP);
		ReleaseDC(m_hwnd, hdc);
	}
}
Exemplo n.º 9
0
//增加一条记录,并同步显示
//Addr不能为0,Name可以为空,name为空,则不修改name
static void AddOneDevice(u8 Addr,u8 *Name)
{
	u8 i;
	u8 Len=0;
	u16 NameChk;

	if(Name!=NULL) Len=strlen((void *)Name);
	if(Len>=DEVICE_NAME_MAX_LEN) Len=DEVICE_NAME_MAX_LEN-1;
	NameChk=MakeHash33(Name,Len);

	for(i=0;i<DEVICE_INFO_MAX_CLIENT_RECORD;i++)
	{
		//对比地址或名字,如果地址相等,直接修改名字,如果名字相同,则修改地址。
		if((gpQwpVar->ClientRecord[i].Addr==Addr)||((gpQwpVar->ClientRecord[i].Addr!=0)&&(gpQwpVar->ClientRecord[i].NameChk==NameChk)))
		{//修改现成的
			gpQwpVar->ClientRecord[i].Addr=Addr;
			
			if((Name!=NULL)&&(gpQwpVar->ClientRecord[i].NameChk!=NameChk))//修改名字
			{
				MemCpy(gpQwpVar->ClientRecord[i].Name,Name,Len);
				gpQwpVar->ClientRecord[i].Name[Len]=0;
			}

			if(gpQwpVar->ClientRecord[i].IsHiLight==TRUE)
				DrawDeviceInfo(gpQwpVar->ClientRecord[i].DispIdx,Addr,gpQwpVar->ClientRecord[i].Name,HighLightDisp);
			else
				DrawDeviceInfo(gpQwpVar->ClientRecord[i].DispIdx,Addr,gpQwpVar->ClientRecord[i].Name,NormalDisp);
			break;
		}
	}

	if(i==DEVICE_INFO_MAX_CLIENT_RECORD)//not found ,add new one.
	{//建新的
		for(i=0;i<DEVICE_INFO_MAX_CLIENT_RECORD;i++)
			if(gpQwpVar->ClientRecord[i].Addr==0)
			{
				gpQwpVar->ClientRecord[i].Addr=Addr;
				MemCpy(gpQwpVar->ClientRecord[i].Name,Name,Len);
				gpQwpVar->ClientRecord[i].Name[Len]=0;
				gpQwpVar->ClientRecord[i].NameChk=MakeHash33(gpQwpVar->ClientRecord[i].Name,Len);
				gpQwpVar->ClientRecord[i].DispIdx=++gpQwpVar->NowDispNum;
				DrawDeviceInfo(gpQwpVar->ClientRecord[i].DispIdx,Addr,gpQwpVar->ClientRecord[i].Name,NormalDisp);
				break;
			}
	}	

	DrawState();//更新下状态
}
Exemplo n.º 10
0
void CCheckEngineTabDlg::OnCustomdrawList ( NMHDR* pNMHDR, LRESULT* pResult )
{
 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );

 // Take the default processing unless we set this to something else below.
 *pResult = 0;

 bool is_enabled = ::IsWindowEnabled(m_errors_list.m_hWnd);

 // If this is the beginning of the control's paint cycle, request
 // notifications for each item.
 if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
 {
  *pResult = CDRF_NOTIFYITEMDRAW;
 }
 else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
 {
  // This is the pre-paint stage for an item.  We need to make another
  // request to be notified during the post-paint stage.
  if (!is_enabled)
   pLVCD->clrText = m_gray_text_color;
  *pResult = CDRF_NOTIFYPOSTPAINT;
 }
 else if ( CDDS_ITEMPOSTPAINT == pLVCD->nmcd.dwDrawStage )
 {
  int    nItem = static_cast<int>( pLVCD->nmcd.dwItemSpec );
  LVITEM rItem;
  ZeroMemory (&rItem, sizeof(LVITEM) );
  rItem.mask  = LVIF_IMAGE | LVIF_STATE;
  rItem.iItem = nItem;
  rItem.stateMask = 0xFFFF;     // get all state flags
  m_errors_list.GetItem ( &rItem );

  CDC*  pDC = CDC::FromHandle ( pLVCD->nmcd.hdc );
  // Get the rect that holds the item's icon.
  CRect rcIcon;
  m_errors_list.GetItemRect ( nItem, &rcIcon, LVIR_BOUNDS );
  UINT nStateImageMask = rItem.state & LVIS_STATEIMAGEMASK;
  int nImage = (nStateImageMask >> 12) - 1;

  //TODO: What is the magic number - 2?
  DrawState(pDC->m_hDC,NULL,NULL,(LPARAM)m_image_list.ExtractIcon(nImage), 0,
   rcIcon.left+2, rcIcon.top, rcIcon.Width(), rcIcon.Height(),
   DST_ICON| (is_enabled ? 0 : DSS_DISABLED));

  *pResult = CDRF_DODEFAULT;
 }
Exemplo n.º 11
0
// draw_bitmap () - Draw a bitmap
void
CImageButtonWithStyle::draw_bitmap (HDC hDC, const CRect& Rect, DWORD style)
{
	HBITMAP hBitmap = GetBitmap();
	if (hBitmap == NULL)
		return;

	// determine size of bitmap image
	BITMAPINFO bmi;
	memset(&bmi, 0, sizeof (BITMAPINFO));
	bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
	GetDIBits(hDC, hBitmap, 0, 0, NULL, &bmi, DIB_RGB_COLORS);

	// determine position of top-left corner of bitmap (positioned according to style)
	int x = image_left(bmi.bmiHeader.biWidth, Rect, style);
	int y = image_top(bmi.bmiHeader.biHeight, Rect, style);

	// Draw the bitmap
	DrawState(hDC, NULL, NULL, (LPARAM) hBitmap, 0, x, y, bmi.bmiHeader.biWidth, bmi.bmiHeader.biHeight,
	          (style & WS_DISABLED) != 0 ? (DST_BITMAP | DSS_DISABLED) : (DST_BITMAP | DSS_NORMAL));
}
Exemplo n.º 12
0
void vmsUiLinkWindow::Draw(CDC *pdc)
{
	CFont *pfntOld = pdc->SelectObject (m_pfntLnk ? m_pfntLnk : vmsUiFonts::Tahoma_11underline ());
	CRect rc; getAbsolutePos (&rc);
	if (m_tstrUrl.empty () && m_uDrawTextFormat == 0)
	{
		DrawState (pdc->GetSafeHdc (), NULL, NULL, (LPARAM)m_tstrText.c_str (), 0, rc.left, rc.top,
			rc.Width (), rc.Height (), DST_TEXT | DSS_DISABLED);
	}
	else
	{
		pdc->SetTextColor (_SkinMgr.getLinkTextColor ());
		pdc->DrawText (m_tstrText.c_str (), &rc, m_uDrawTextFormat);

		if (m_uDrawTextFormat)
		{
			pdc->DrawText (m_tstrText.c_str (), &rc, m_uDrawTextFormat);
		}
	}
	pdc->SelectObject (pfntOld);
	pdc->SetTextColor (RGB (0,0,0));
}
Exemplo n.º 13
0
// draw_icon () - Draw an icon
void
CImageButtonWithStyle::draw_icon (HDC hDC, const CRect& Rect, DWORD style)
{
	HICON hIcon = GetIcon();
	if (hIcon == NULL)
		return;

	// determine size of icon image
	ICONINFO ii;
	GetIconInfo(hIcon, &ii);
	BITMAPINFO bmi;
	memset(&bmi, 0, sizeof (BITMAPINFO));
	bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
	int cx = 0;
	int cy = 0;
	if (ii.hbmColor != NULL)
	{
		// icon has separate image and mask bitmaps - use size directly
		GetDIBits(hDC, ii.hbmColor, 0, 0, NULL, &bmi, DIB_RGB_COLORS);
		cx = bmi.bmiHeader.biWidth;
		cy = bmi.bmiHeader.biHeight;
	}
	else
	{
		// icon has singel mask bitmap which is twice as high as icon
		GetDIBits(hDC, ii.hbmMask, 0, 0, NULL, &bmi, DIB_RGB_COLORS);
		cx = bmi.bmiHeader.biWidth;
		cy = bmi.bmiHeader.biHeight / 2;
	}

	// determine position of top-left corner of icon
	int x = image_left(cx, Rect, style);
	int y = image_top(cy, Rect, style);

	// Draw the icon
	DrawState(hDC, NULL, NULL, (LPARAM) hIcon, 0, x, y, cx, cy,
	          (style & WS_DISABLED) != 0 ? (DST_ICON | DSS_DISABLED) : (DST_ICON | DSS_NORMAL));
}
Exemplo n.º 14
0
//高亮一个设备
static void HighLightOneDevice(u8 Addr)
{
	u8 i;
	
	for(i=0;i<DEVICE_INFO_MAX_CLIENT_RECORD;i++)
	{
		//对比地址,如果地址相等,高亮
		if(gpQwpVar->ClientRecord[i].Addr==Addr)
		{
			gpQwpVar->ClientRecord[i].IsHiLight=TRUE;
			DrawDeviceInfo(gpQwpVar->ClientRecord[i].DispIdx,Addr,gpQwpVar->ClientRecord[i].Name,HighLightDisp);
			break;
		}
	}

	//没找到,说明有新的设备来了
	if(i==DEVICE_INFO_MAX_CLIENT_RECORD)//not found ,add new one.
	{//建新的
		AddOneDevice(Addr,NULL);
		HighLightOneDevice(Addr);
	}	

	DrawState();//更新下状态
}
Exemplo n.º 15
0
void _draw_static(
		LPDRAWITEMSTRUCT itst
	)
{
	UINT edge   = BDR_RAISEDINNER;
	UINT state  = DSS_NORMAL;
	UINT border = BF_RECT;

	DRAWTEXTPARAMS tp = { sizeof(tp) };
	WINDOWINFO wi;
	RECT rc;

	_wnd_data *gwl;
	_tab_data *tab;

	wchar_t data[MAX_PATH];
	int x = 6, y = 3;
	char curr;	

	if ( !itst ) return;
	switch ( itst->CtlType )
	{
		case ODT_LISTVIEW: _draw_listview(itst); break;
		case ODT_COMBOBOX: _draw_combobox(itst); break;
		case ODT_TAB:      _draw_tabs(itst);     break;

		case ODT_BUTTON:

        if ( itst->itemState & ODS_DISABLED ) state = DSS_DISABLED;
        if ( itst->itemState & ODS_SELECTED )
		{
			edge = BDR_SUNKENOUTER;
			x++; y++;
        }
		itst->rcItem.top++;

		GetWindowText( itst->hwndItem, data, MAX_PATH );
		GetClientRect( itst->hwndItem, &rc );

		gwl = wnd_get_long( itst->hwndItem, GWL_USERDATA );
		tab = wnd_get_long( GetParent(itst->hwndItem), GWL_USERDATA );

		curr = tab && ( tab->h_curr == itst->hwndItem );

		if ( gwl )
		{
			if ( !gwl->dlg[0] )
			{
				itst->rcItem.right  = itst->rcItem.left + 13;
				itst->rcItem.bottom = itst->rcItem.top  + 13;

				_fill( itst->hDC, &rc, _cl(COLOR_BTNFACE, FALSE) );
				_fill( itst->hDC, &itst->rcItem, /* (itst->itemState & ODS_FOCUS) ? _cl(COLOR_BTNFACE, FALSE) : */ _cl(COLOR_BTNFACE, LGHT_CLR) );

				GetWindowText(itst->hwndItem, data, MAX_PATH);
				if ( gwl->state )
				{
					ImageList_DrawEx(
						__img, 0, itst->hDC, itst->rcItem.right - 11, 2, 0, 0, CLR_NONE, GetSysColor(COLOR_BTNSHADOW), ILD_BLEND
					);
				}
				DrawEdge(
					itst->hDC, &itst->rcItem, BDR_SUNKENOUTER, border
					);
				DrawState(
					itst->hDC, NULL, NULL, (LPARAM)data, 0, itst->rcItem.right+4, 0, 0, 0, DST_PREFIXTEXT | state
					);

				if ( itst->itemState & ODS_FOCUS )
				{
					rc.bottom  = itst->rcItem.bottom - itst->rcItem.top + 2;					
					rc.left   += itst->rcItem.right + 2;

					DrawFocusRect( itst->hDC, &rc );
				}
				return;
			} else 
			{ 
				if ( curr )
				{							
					edge = BDR_SUNKENOUTER;
					x++; y++;
				} else {
					border = BF_FLAT;
				}
			}
		}

		_fill( itst->hDC, &itst->rcItem, (itst->itemState & ODS_FOCUS ) ?
			_cl( COLOR_BTNFACE, DARK_CLR ) :
			_cl( COLOR_BTNFACE, FALSE ) );

		DrawState( itst->hDC, NULL, NULL, (LPARAM)data, 0, x, y, 0, 0, DST_PREFIXTEXT | state );
		if ( itst->itemState & ODS_FOCUS )
		{
			modify_rect( rc, 1, 2, -2, -2 );
			if ( itst->itemState & ODS_SELECTED )
			{
				modify_rect( rc, 1, 1, 1, 1 );
			}
			DrawFocusRect( itst->hDC, &rc );
		}

		case ODT_STATIC:
		{
			GetWindowInfo(itst->hwndItem, &wi);
			GetWindowText(itst->hwndItem, data, MAX_PATH);

			if ( data[0] == L'#' )
			{
				GetWindowRect(GetParent(GetParent(itst->hwndItem)), &rc);

				itst->rcItem.right = rc.right - rc.left - 3;
				itst->rcItem.top = itst->rcItem.left = 1;

				_fill(itst->hDC, &itst->rcItem, _cl(COLOR_BTNSHADOW, DARK_CLR - 7));

				tp.iLeftMargin   += 10;
				itst->rcItem.top += 1;

				DrawTextEx(itst->hDC, data + 1, -1, &itst->rcItem, DT_END_ELLIPSIS, &tp);					
			}
			else 
			{
				if ( (wi.dwStyle & SS_SUNKEN) == 0 )
				{
					DrawEdge(itst->hDC, &itst->rcItem, edge, border);				
				}
			}
		}
		break;
	}
}
Exemplo n.º 16
0
int main(int argc, char* argv[])
{
	if (FSDKE_OK != FSDK_ActivateLibrary("Jl3R1DBC1qVQonaiBAq8gK7KzetXbFb4r+OF1DLzInT3KyXHvgHNLyk2Tymk5G6GBv58/Oqn+SQeOWCQfQASTV1Mcd7RQAsrmW02oOa9lhZsMockPLoEnpsH4W1I0+zmxmUwecWKEep9j4BrYhQWuiA3QcNeQO+tfyLOHASk3+M=")){
		MessageBox(0, L"Please run the License Key Wizard (Start - Luxand - FaceSDK - License Key Wizard)\n", L"Error activating FaceSDK", MB_ICONERROR | MB_OK);
        exit(-1);
    }

	FSDK_Initialize("");
		
	// creating a window
	HWND hwnd = CreateWindowEx(WS_EX_TOOLWINDOW, L"LISTBOX", L"IP Camera Face Tracking", 0, 0, 0, 0, 0, 0, 0, 0, 0); 
	HDC dc = GetDC(hwnd);
	SetWindowPos(hwnd, 0, 0, 0, 660, 540, SWP_NOZORDER|SWP_NOMOVE);
	ShowWindow(hwnd, SW_SHOW);
	RECT ClientRect;
	GetClientRect(hwnd, &ClientRect);
	HPEN hNPen = CreatePen(PS_SOLID, 1, RGB(0, 255, 0));
	HPEN hOPen = (HPEN)SelectObject(dc, hNPen);
	HBRUSH hOldBrush;
	HBRUSH hNewBrush;
	hNewBrush = (HBRUSH)GetStockObject(NULL_BRUSH);
	hOldBrush = (HBRUSH)SelectObject(dc, hNewBrush);

	HFONT myFont = CreateFont(14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, L"Microsoft Sans Serif");

	// creating input boxes 
	HWND Address = CreateWindow(L"STATIC", L"address:", WS_CHILD, 0, 0, 0, 0, hwnd, 0, 0, 0); 
	SendMessage(Address, WM_SETFONT, (WPARAM)myFont, TRUE);
	SetWindowPos(Address, 0, 5, ClientRect.bottom - 20, 40, 18, SWP_NOZORDER);
	ShowWindow(Address, SW_SHOW);

	HWND AddressBox = CreateWindow(L"EDIT", L"", WS_CHILD | WS_BORDER | ES_AUTOHSCROLL, 0, 0, 0, 0, hwnd, 0, 0, 0); 
	SendMessage(AddressBox, WM_SETFONT, (WPARAM)myFont, TRUE);
	SetWindowPos(AddressBox, 0, 45, ClientRect.bottom - 20, 360, 18, SWP_NOZORDER);
	ShowWindow(AddressBox, SW_SHOW);

	HWND User = CreateWindow(L"STATIC", L"username:"******"EDIT", L"admin", WS_CHILD | WS_BORDER | ES_AUTOHSCROLL, 0, 0, 0, 0, hwnd, 0, 0, 0); 
	SendMessage(UserBox, WM_SETFONT, (WPARAM)myFont, TRUE);
	SetWindowPos(UserBox, 0, 460, ClientRect.bottom - 20, 65, 18, SWP_NOZORDER);
	ShowWindow(UserBox, SW_SHOW);

	HWND Password = CreateWindow(L"STATIC", L"password:"******"EDIT", L"", WS_CHILD | WS_BORDER | ES_AUTOHSCROLL, 0, 0, 0, 0, hwnd, 0, 0, 0); 
	SendMessage(PasswordBox, WM_SETFONT, (WPARAM)myFont, TRUE);
	SetWindowPos(PasswordBox, 0, 580, ClientRect.bottom - 20, 65, 18, SWP_NOZORDER);
	ShowWindow(PasswordBox, SW_SHOW);

	SendMessage(hwnd, LB_ADDSTRING, 0, (LPARAM)(L"Press Esc to exit ..."));

	// creating a Tracker
	HTracker tracker = 0;
	FSDK_CreateTracker(&tracker);

	int err = 0; // set realtime face detection parameters	
	FSDK_SetTrackerMultipleParameters(tracker, "RecognizeFaces=false; DetectFacialFeatures=true; HandleArbitraryRotations=false; DetermineFaceRotationAngle=false; InternalResizeWidth=256; FaceDetectionThreshold=5;", &err);
						
	int cameraHandle = 0; 
	bool CameraOpened = false;

	MSG msg = {0};
	while (msg.message != WM_QUIT) {
		if (CameraOpened) {
			HImage imageHandle;
			int res = FSDK_GrabFrame(cameraHandle, &imageHandle);			
			if (res != FSDKE_OK) {// grab the current frame from the camera
				printf("error in FSDK_GrabFrame %d\n", res);

				if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
					TranslateMessage(&msg);   
					DispatchMessage(&msg); 
					if (msg.message == WM_KEYDOWN && msg.wParam == VK_ESCAPE) 
						break;
				}
				continue;
			}
						
			long long IDs[256];
			long long faceCount = 0;
			FSDK_FeedFrame(tracker, 0, imageHandle, &faceCount, IDs, sizeof(IDs));

			HImage resizedImageHandle;
			FSDK_CreateEmptyImage(&resizedImageHandle);

			int width;
			int height;
			FSDK_GetImageWidth(imageHandle, &width);
			FSDK_GetImageHeight(imageHandle, &height);

			float ratio = min(ClientRect.right/(float)width, (ClientRect.bottom - 40)/(float)height);
			FSDK_ResizeImage(imageHandle, ratio, resizedImageHandle);
			FSDK_FreeImage(imageHandle);

			FSDK_GetImageWidth(resizedImageHandle, &width);
			FSDK_GetImageWidth(resizedImageHandle, &height);

			HBITMAP hbitmapHandle; // to store the HBITMAP handle
			FSDK_SaveImageToHBitmap(resizedImageHandle, &hbitmapHandle);

			DrawState(dc, NULL, NULL, (LPARAM)hbitmapHandle, NULL, 0, 16, width, height, DST_BITMAP | DSS_NORMAL);
			
			for (int i = 0; i < faceCount; ++i) {
				TFacePosition facePosition;
				FSDK_GetTrackerFacePosition(tracker, 0, IDs[i], &facePosition);

				int x1 = (int)(ratio*(facePosition.xc - facePosition.w*0.6));
				int y1 = (int)(ratio*(facePosition.yc - facePosition.w*0.5));
				int x2 = (int)(ratio*(facePosition.xc + facePosition.w*0.6));
				int y2 = (int)(ratio*(facePosition.yc + facePosition.w*0.7));
				Rectangle(dc, x1, 16 + y1, x2, 16 + y2);	
			}

			Sleep(20);

			DeleteObject(hbitmapHandle); // delete the HBITMAP object
			FSDK_FreeImage(resizedImageHandle);// delete the FSDK image handle
		}

		if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
			TranslateMessage(&msg);   
			DispatchMessage(&msg); 
			if (msg.message == WM_KEYDOWN)
			{
				if (msg.wParam == VK_ESCAPE) 
					break;
				if (msg.wParam == VK_RETURN)
				{
					if (CameraOpened && FSDKE_OK != FSDK_CloseVideoCamera(cameraHandle))
					{
						MessageBox(0, L"Error closing camera", L"Error", MB_ICONERROR | MB_OK);
						return -5;
					}
					char Camera_MJPEG_URL[1024];
					SendMessageA(AddressBox, WM_GETTEXT, (WPARAM) 1024, (LPARAM) Camera_MJPEG_URL);
					char username[1024];
					SendMessageA(UserBox, WM_GETTEXT, (WPARAM) 1024, (LPARAM) username);
					char password[1024];
					SendMessageA(PasswordBox, WM_GETTEXT, (WPARAM) 1024, (LPARAM) password);
					int timeout_seconds = 30;

					printf("Trying to open the camera...\n");
					if (FSDKE_OK != FSDK_OpenIPVideoCamera(FSDK_MJPEG, Camera_MJPEG_URL, username, password, timeout_seconds, &cameraHandle)) 
					{ 
						MessageBox(0, L"Error opening IP camera", L"Error", MB_ICONERROR | MB_OK);
						return -2;
					}
					CameraOpened = true;
				}
			}
		} 
	}

	ReleaseDC(hwnd, dc);

	if (CameraOpened && FSDKE_OK != FSDK_CloseVideoCamera(cameraHandle)) {
		MessageBox(0, L"Error closing camera", L"Error", MB_ICONERROR | MB_OK);
        return -5;
	}

	FSDK_Finalize();
	return 0;
}
Exemplo n.º 17
0
static void PaintWorker(MButtonCtrl *ctl, HDC hdcPaint)
{
	if (hdcPaint) {
		HDC hdcMem;
		HBITMAP hbmMem;
		HDC hOld;
		RECT rcClient;

		GetClientRect(ctl->hwnd, &rcClient);
		hdcMem = CreateCompatibleDC(hdcPaint);
		hbmMem = CreateCompatibleBitmap(hdcPaint, rcClient.right-rcClient.left, rcClient.bottom-rcClient.top);
		hOld = ( HDC )SelectObject(hdcMem, hbmMem);

		// If its a push button, check to see if it should stay pressed
		if (ctl->pushBtn && ctl->pbState) ctl->stateId = PBS_PRESSED;

		// Draw the flat button
		if (ctl->flatBtn) {
			if (ctl->hThemeToolbar) {
				int state = IsWindowEnabled(ctl->hwnd)?(ctl->stateId==PBS_NORMAL&&ctl->defbutton?PBS_DEFAULTED:ctl->stateId):PBS_DISABLED;
				if (isThemeBackgroundPartiallyTransparent(ctl->hThemeToolbar, TP_BUTTON, TBStateConvert2Flat(state))) {
					drawThemeParentBackground(ctl->hwnd, hdcMem, &rcClient);
				}
				drawThemeBackground(ctl->hThemeToolbar, hdcMem, TP_BUTTON, TBStateConvert2Flat(state), &rcClient, &rcClient);
			}
			else {
				HBRUSH hbr;

				if (ctl->stateId==PBS_PRESSED||ctl->stateId==PBS_HOT)
					hbr = GetSysColorBrush(COLOR_3DLIGHT);
				else {
					HWND hwndParent = GetParent(ctl->hwnd);
					HDC dc = GetDC(hwndParent);
					HBRUSH oldBrush = (HBRUSH)GetCurrentObject( dc, OBJ_BRUSH );
					hbr = (HBRUSH)SendMessage(hwndParent, WM_CTLCOLORDLG, (WPARAM)dc, (LPARAM)hwndParent);
					SelectObject(dc,oldBrush);
					ReleaseDC(hwndParent,dc);
				}
				if (hbr) {
					FillRect(hdcMem, &rcClient, hbr);
					DeleteObject(hbr);
				}
				if (ctl->stateId==PBS_HOT||ctl->focus) {
					if (ctl->pbState)
						DrawEdge(hdcMem,&rcClient, EDGE_ETCHED,BF_RECT|BF_SOFT);
					else DrawEdge(hdcMem,&rcClient, BDR_RAISEDOUTER,BF_RECT|BF_SOFT|BF_FLAT);
				}
				else if (ctl->stateId==PBS_PRESSED)
					DrawEdge(hdcMem, &rcClient, BDR_SUNKENOUTER,BF_RECT|BF_SOFT);
			}
		}
		else {
			// Draw background/border
			if (ctl->hThemeButton) {
				int state = IsWindowEnabled(ctl->hwnd)?(ctl->stateId==PBS_NORMAL&&ctl->defbutton?PBS_DEFAULTED:ctl->stateId):PBS_DISABLED;
				if (isThemeBackgroundPartiallyTransparent(ctl->hThemeButton, BP_PUSHBUTTON, state)) {
					drawThemeParentBackground(ctl->hwnd, hdcMem, &rcClient);
				}
				drawThemeBackground(ctl->hThemeButton, hdcMem, BP_PUSHBUTTON, state, &rcClient, &rcClient);
			}
			else {
				UINT uState = DFCS_BUTTONPUSH|((ctl->stateId==PBS_HOT)?DFCS_HOT:0)|((ctl->stateId == PBS_PRESSED)?DFCS_PUSHED:0);
				if (ctl->defbutton&&ctl->stateId==PBS_NORMAL) uState |= DLGC_DEFPUSHBUTTON;
				DrawFrameControl(hdcMem, &rcClient, DFC_BUTTON, uState);
			}

			// Draw focus rectangle if button has focus
			if (ctl->focus) {
				RECT focusRect = rcClient;
				InflateRect(&focusRect, -3, -3);
				DrawFocusRect(hdcMem, &focusRect);
			}
		}

		// If we have an icon or a bitmap, ignore text and only draw the image on the button
		if (ctl->hIcon) {
			int ix = (rcClient.right-rcClient.left)/2 - (GetSystemMetrics(SM_CXSMICON)/2);
			int iy = (rcClient.bottom-rcClient.top)/2 - (GetSystemMetrics(SM_CYSMICON)/2);
			if (ctl->stateId == PBS_PRESSED) {
				ix++;
				iy++;
			}
			{
				HIMAGELIST hImageList;
				HICON hIconNew;

				hImageList = ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON), IsWinVerXPPlus()? ILC_COLOR32 | ILC_MASK : ILC_COLOR16 | ILC_MASK, 1, 0);
				ImageList_AddIcon(hImageList, ctl->hIcon);
				hIconNew = ImageList_GetIcon(hImageList, 0, ILD_NORMAL);
				DrawState(hdcMem,NULL,NULL,(LPARAM)hIconNew,0,ix,iy,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),IsWindowEnabled(ctl->hwnd)?DST_ICON|DSS_NORMAL:DST_ICON|DSS_DISABLED);
				ImageList_RemoveAll(hImageList);
				ImageList_Destroy(hImageList);
				DestroyIcon(hIconNew);
			}
		}
		else if (ctl->hBitmap) {
			BITMAP bminfo;
			int ix,iy;

			GetObject(ctl->hBitmap, sizeof(bminfo), &bminfo);
			ix = (rcClient.right-rcClient.left)/2 - (bminfo.bmWidth/2);
			iy = (rcClient.bottom-rcClient.top)/2 - (bminfo.bmHeight/2);
			if (ctl->stateId == PBS_PRESSED) {
				ix++;
				iy++;
			}
			DrawState(hdcMem,NULL,NULL,(LPARAM)ctl->hBitmap,0,ix,iy,bminfo.bmWidth,bminfo.bmHeight,IsWindowEnabled(ctl->hwnd)?DST_BITMAP:DST_BITMAP|DSS_DISABLED);
		}
		else if (GetWindowTextLength(ctl->hwnd)) {
			// Draw the text and optinally the arrow
			TCHAR szText[MAX_PATH];
			SIZE sz;
			RECT rcText;
			HFONT hOldFont;

			CopyRect(&rcText, &rcClient);
			GetWindowText(ctl->hwnd, szText, SIZEOF(szText));
			SetBkMode(hdcMem, TRANSPARENT);
			hOldFont = (HFONT)SelectObject(hdcMem, ctl->hFont);
			// XP w/themes doesn't used the glossy disabled text.  Is it always using COLOR_GRAYTEXT?  Seems so.
			SetTextColor(hdcMem, IsWindowEnabled(ctl->hwnd)||!ctl->hThemeButton?GetSysColor(COLOR_BTNTEXT):GetSysColor(COLOR_GRAYTEXT));
			GetTextExtentPoint32(hdcMem, szText, lstrlen(szText), &sz);
			if (ctl->cHot) {
				SIZE szHot;

				GetTextExtentPoint32 (hdcMem, _T("&"), 1, &szHot);
				sz.cx -= szHot.cx;
			}
			if (ctl->arrow) {
				DrawState(hdcMem,NULL,NULL,(LPARAM)ctl->arrow,0,rcClient.right-rcClient.left-5-GetSystemMetrics(SM_CXSMICON)+(!ctl->hThemeButton&&ctl->stateId==PBS_PRESSED?1:0),(rcClient.bottom-rcClient.top)/2-GetSystemMetrics(SM_CYSMICON)/2+(!ctl->hThemeButton&&ctl->stateId==PBS_PRESSED?1:0),GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),IsWindowEnabled(ctl->hwnd)?DST_ICON:DST_ICON|DSS_DISABLED);
			}
			SelectObject(hdcMem, ctl->hFont);
			DrawState(hdcMem,NULL,NULL,(LPARAM)szText,0,(rcText.right-rcText.left-sz.cx)/2+(!ctl->hThemeButton&&ctl->stateId==PBS_PRESSED?1:0),ctl->hThemeButton?(rcText.bottom-rcText.top-sz.cy)/2:(rcText.bottom-rcText.top-sz.cy)/2-(ctl->stateId==PBS_PRESSED?0:1),sz.cx,sz.cy,IsWindowEnabled(ctl->hwnd)||ctl->hThemeButton?DST_PREFIXTEXT|DSS_NORMAL:DST_PREFIXTEXT|DSS_DISABLED);
			SelectObject(hdcMem, hOldFont);
		}
		BitBlt(hdcPaint, 0, 0, rcClient.right-rcClient.left, rcClient.bottom-rcClient.top, hdcMem, 0, 0, SRCCOPY);
		SelectObject(hdcMem, hOld);
		DeleteObject(hbmMem);
		DeleteDC(hdcMem);

	}
}
Exemplo n.º 18
0
static Boolean MainFormHandleEvent (EventPtr e)
{
        Boolean handled = false;
        FormPtr frm;
    
        switch (e->eType) {
        case frmOpenEvent:
                frm = FrmGetActiveForm();
                DrawIntro();
                FrmDrawForm(frm);
                DrawState();  // Draw those dice!
                handled = true;
                break;

        case frmUpdateEvent:
                DrawPlayers();
                break;

        case menuEvent:
                MenuEraseStatus(NULL);

                switch(e->data.menu.itemID) {
                case MenuItem_Help:
                        FrmHelp( GenericHelp );
                        break;

                case MenuItem_About:
                        FrmAlert(About_Info);
                        break;

                case MenuItem_New:
                        DialogNewGame();
                        break;

                case MenuItem_Reset:
                        ResetCubes();
                        DrawState();
                        break;

                case MenuItem_Defaults:
                        Defaults();
                        ResetCubes();
                        DrawState();
                        break;

                case MenuItem_Variants:
                        if ( GetCurrPlayer() < 0 ) {
                                DialogVariants();
                        } else {
                                FrmAlert(NoVariants);
                        }
                        break;

                case MenuItem_Preferences:
                        DialogPreferences();
                        break;


                }
                handled = true;
                break;

        case ctlSelectEvent:
                switch(e->data.ctlSelect.controlID) {

                case btn_Stay:
                        ShowButtons(false);
                        Stay();
                        break;

                case btn_Info:
                                //FrmAlert(About_Info);
                        DialogStatus();
                        break;
		
                case btn_Roll:
                        if ( isGameOn() ) {
                                ShowButtons(false);
                                Roll();
                        } else {
                                DialogNewGame();
                        }
                        break;

                case btnTopStatus:
                        FrmHelp( TS_LastLicks );
                        break;

                }
                handled = true;
                break;

        case winExitEvent:
                if( e->data.winExit.exitWindow ==
                    (WinHandle)FrmGetFormPtr(MainForm) )
                {
                                /* Turn off animations and the AI */
                        FreezeBit = true;
                }
                break;

        case winEnterEvent:
                if (e->data.winEnter.enterWindow ==
                    (WinHandle)FrmGetFormPtr(MainForm) &&
                    e->data.winEnter.enterWindow ==
                    (WinHandle)FrmGetFirstForm ())
                {
                                /* Turn back on animations and the AI */
                        FreezeBit = false;
                }

        default:
                break;
        }

        return handled;
}
Exemplo n.º 19
0
void MainWnd_PaintContent(HWND hwnd, HDC hDC, RECT *prcPaint) {
//    DrawState(hDC, NULL, NULL, (LPARAM)g_hMainWindowBgBitmap, 0, 0, 0, 0, 0, DST_BITMAP);
    DrawState(hDC, NULL, NULL, (LPARAM)g_hProjectPaneBgBitmap, 0, kProjectPaneX, kProjectPaneY, 0, 0, DST_BITMAP);
}
Exemplo n.º 20
0
static void
button_paint_split(HWND win, button_t* button, HDC dc)
{
    RECT rect;
    RECT rect_left, rect_right;
    int state_left, state_right;
    int text_offset = 0;
    HFONT font, old_font;
    int old_bk_mode;
    COLORREF old_text_color;
    HRGN old_clip;
    HICON glyph;
    int width_right = DROPDOWN_W;

    glyph = ImageList_GetIcon(mc_bmp_glyphs, MC_BMP_GLYPH_MORE_OPTIONS, ILD_TRANSPARENT);
    GetClientRect(win, &rect);

    font = (HFONT) MC_SEND(win, WM_GETFONT, 0, 0);
    if(font == NULL)
        font = GetStockObject(SYSTEM_FONT);

    old_font = SelectObject(dc, font);
    old_bk_mode = GetBkMode(dc);
    old_text_color = GetTextColor(dc);
    old_clip = get_clip(dc);

    /* Draw what's common for left and right parts background. */
    if(!button->theme  &&  (button->style & BS_DEFPUSHBUTTON)) {
        SelectObject(dc, GetSysColorBrush(COLOR_WINDOWFRAME));
        Rectangle(dc, rect.left, rect.top, rect.right, rect.bottom);
        mc_rect_inflate(&rect, -1, -1);
        width_right--;
    }

    /* Setup subrectangles (mainpart 1 and push-down part 2) */
    mc_rect_copy(&rect_left, &rect);
    rect_left.right -= width_right;
    mc_rect_copy(&rect_right, &rect);
    rect_right.left = rect_left.right;

    /* Draw background. */
    if(button->theme) {
        UINT transparent;
        RECT tmp;

        /* Determine styles for left and right parts */
        if(button->style & WS_DISABLED) {
            state_left = state_right = PBS_DISABLED;
        } else {
            LRESULT state;

            state = MC_SEND(win, BM_GETSTATE, 0, 0);
            if(state & MC_BST_DROPDOWNPUSHED) {
                state_left = PBS_NORMAL;
                state_right = PBS_PRESSED;
            } else {
                if(state & BST_PUSHED)
                    state_left = state_right = PBS_PRESSED;
                else if(state & BST_HOT)
                    state_left = state_right = PBS_HOT;
                else if(button->style & BS_DEFPUSHBUTTON)
                    state_left = state_right = PBS_DEFAULTED;
                else
                    state_left = state_right = PBS_NORMAL;
            }
        }

        /* Handle (semi-)transparent themes. */
        transparent = 0;
        if(mcIsThemeBackgroundPartiallyTransparent(button->theme,
                    BP_PUSHBUTTON, state_left))
            transparent |= 0x1;
        if(mcIsThemeBackgroundPartiallyTransparent(button->theme,
                    BP_PUSHBUTTON, state_right))
            transparent |= 0x2;
        switch(transparent) {
            case 0x1:
                mcDrawThemeParentBackground(win, dc, &rect_left);
                break;
            case 0x2:
                mcDrawThemeParentBackground(win, dc, &rect_right);
                break;
            case 0x3:
                mcDrawThemeParentBackground(win, dc, &rect);
                break;
        }

        /* Draw backgrond. */
        mcDrawThemeBackground(button->theme, dc, BP_PUSHBUTTON, state_left, &rect, &rect_left);
        mcDrawThemeBackground(button->theme, dc, BP_PUSHBUTTON, state_right, &rect, &rect_right);

        /* Deflate both rects to content rects only */
        mcGetThemeBackgroundContentRect(button->theme, dc, BP_PUSHBUTTON, state_left, &rect_left, &tmp);
        rect_left.left = tmp.left;
        rect_left.top = tmp.top;
        rect_left.bottom = tmp.bottom;
        mcGetThemeBackgroundContentRect(button->theme, dc, BP_PUSHBUTTON, state_right, &rect_right, &tmp);
        rect_right.top = tmp.top;
        rect_right.right = tmp.right;
        rect_right.bottom = tmp.bottom;

        /* Draw delimiter of left and right parts. */
        rect_right.top += 1;
        rect_right.bottom -= 1;
        mcDrawThemeEdge(button->theme, dc, BP_PUSHBUTTON, state_right, &rect_right, BDR_SUNKEN, BF_LEFT, NULL);
        rect_right.left = tmp.left;
    } else {
        /* Determine styles for left and right parts */
        if(button->style & WS_DISABLED) {
            state_left = state_right = DFCS_INACTIVE;
        } else {
            LRESULT s = MC_SEND(win, BM_GETSTATE, 0, 0);
            if(s & MC_BST_DROPDOWNPUSHED) {
                state_left = 0;
                state_right = DFCS_PUSHED;
            } else {
                if(s & BST_PUSHED) {
                    state_left = state_right = DFCS_PUSHED;
                } else {
                    state_left = state_right = 0;
                }
            }
        }

        button_send_ctlcolorbtn(win, dc);

        /* Draw control edges */
        IntersectClipRect(dc, rect_left.left, rect_left.top, rect_left.right, rect_left.bottom);
        DrawFrameControl(dc, &rect, DFC_BUTTON, DFCS_BUTTONPUSH | state_left);
        SelectClipRgn(dc, NULL);
        IntersectClipRect(dc, rect_right.left, rect_right.top, rect_right.right, rect_right.bottom);
        DrawFrameControl(dc, &rect, DFC_BUTTON, DFCS_BUTTONPUSH | state_right);

        /* Parts which are pushed, should have the contents moved a bit */
        if(state_left == DFCS_PUSHED)
            mc_rect_offset(&rect_left, 1, 1);
        if(state_right == DFCS_PUSHED)
            mc_rect_offset(&rect_right, 1, 1);

        /* Draw delimiter */
        if(state_left == state_right) {
            DrawEdge(dc, &rect_right, BDR_SUNKENOUTER | BDR_RAISEDINNER, BF_LEFT | BF_SOFT);
        } else {
            rect_right.left--;
            DrawEdge(dc, &rect_right, BDR_SUNKENOUTER, BF_LEFT | BF_SOFT);
            rect_right.left++;
        }

        /* Adjust for the outer control edges */
        mc_rect_inflate(&rect_left, 0, -2);
        rect_left.left += 2;
        mc_rect_inflate(&rect_right, -2, -2);
    }

    /* Draw focus rectangle. */
    if((MC_SEND(win, BM_GETSTATE, 0, 0) & BST_FOCUS) && !button->hide_focus) {
        SelectClipRgn(dc, NULL);
        if(button->theme) {
            mc_rect_set(&rect, rect_left.left, rect_left.top,
                        rect_right.right - DROPDOWN_W, rect_right.bottom);
            DrawFocusRect(dc, &rect);
        } else {
            mc_rect_inflate(&rect_left, -1, -2);
            DrawFocusRect(dc, &rect_left);
            mc_rect_inflate(&rect_left, -1, -1);
        }
    }

    /* Draw glyph into the right part */
    SelectClipRgn(dc, NULL);
    IntersectClipRect(dc, rect_right.left, rect_right.top,
                          rect_right.right, rect_right.bottom);
    DrawIconEx(dc, (rect_right.right + rect_right.left - MC_BMP_GLYPH_W) / 2,
                   (rect_right.bottom + rect_right.top - MC_BMP_GLYPH_H) / 2,
                   glyph, MC_BMP_GLYPH_W, MC_BMP_GLYPH_H, 0, NULL, DI_NORMAL);

    /* Draw left part contents */
    SelectClipRgn(dc, NULL);
    IntersectClipRect(dc, rect_left.left, rect_left.top,
                          rect_left.right, rect_left.bottom);
    if(button->style & BS_ICON) {
        /* Paint (BS_SPLITBUTTON | BS_ICON). Note that this is used even on
         * Vista, as according to some my testing this style combination
         * is not supported there... */
        HICON icon;

        icon = (HICON) MC_SEND(win, BM_GETIMAGE, (WPARAM) IMAGE_ICON, (LPARAM) 0);
        if(icon != NULL) {
            SIZE size;
            UINT flags;

            mc_icon_size(icon, &size);

            flags = DST_ICON;
            if(button->style & WS_DISABLED)
                flags |= DSS_DISABLED;

            DrawState(dc, NULL, NULL, (LPARAM) icon, 0,
                      (rect_left.right + rect_left.left - size.cx) / 2,
                      (rect_left.bottom + rect_left.top - size.cy) / 2,
                      size.cx, size.cy, flags);
        }
    } else {
        /* Paint text label */
        TCHAR buffer[256];
        int n;
        UINT flags = 0;

        /* Setup flags for TextOut/mcDrawThemeText */
        switch(button->style & (BS_LEFT | BS_CENTER | BS_RIGHT)) {
            case BS_LEFT:
                flags |= DT_LEFT;
                break;
            case BS_RIGHT:
                flags |= DT_RIGHT;
                break;
            default:
                if(GetWindowLong(win, GWL_EXSTYLE) & WS_EX_RIGHT)
                    flags |= DT_RIGHT;
                else
                    flags |= DT_CENTER;
                break;
        }
        switch(button->style & (BS_TOP | BS_VCENTER | BS_BOTTOM)) {
            case BS_TOP:
                flags |= DT_TOP;
                break;
            case BS_BOTTOM:
                flags |= DT_BOTTOM;
                break;
            default:
                flags |= DT_VCENTER;
                break;
        }
        if(button->style & BS_MULTILINE)
            flags |= DT_WORDBREAK;
        else
            flags |= DT_SINGLELINE;

        if(button->hide_accel)
            flags |= DT_HIDEPREFIX;

        n = MC_SEND(win, WM_GETTEXT, MC_ARRAY_SIZE(buffer), buffer);

        if(button->theme) {
            mcDrawThemeText(button->theme, dc, BP_PUSHBUTTON,
                        state_left, buffer, n, flags, 0, &rect_left);
        } else {
            SetBkMode(dc, TRANSPARENT);
            SetTextColor(dc, GetSysColor(COLOR_BTNTEXT));
            mc_rect_offset(&rect_left, text_offset, text_offset);
            DrawText(dc, buffer, n, &rect_left, flags);
        }
    }

    SelectObject(dc, old_font);
    SetBkMode(dc, old_bk_mode);
    SetTextColor(dc, old_text_color);
    SelectObject(dc, old_clip);
}
Exemplo n.º 21
0
static void
button_paint_icon(HWND win, button_t* button, HDC dc)
{
    HICON icon;
    RECT rect;
    RECT content;
    int state;
    SIZE size;
    UINT flags;
    HFONT font, old_font;
    int old_bk_mode;
    COLORREF old_text_color;
    HRGN old_clip;

    /* When theming is not used, we keep all the work on COMCTL32 button
     * implementation. */
    MC_ASSERT(button->theme != NULL);

    GetClientRect(win, &rect);

    icon = (HICON) MC_SEND(win, BM_GETIMAGE, IMAGE_ICON, 0);
    font = (HFONT) MC_SEND(win, WM_GETFONT, 0, 0);
    if(font == NULL)
        font = GetStockObject(SYSTEM_FONT);

    old_font = SelectObject(dc, font);
    old_bk_mode = GetBkMode(dc);
    old_text_color = GetTextColor(dc);
    old_clip = get_clip(dc);

    /* Draw background */
    if(button->style & WS_DISABLED) {
        state = PBS_DISABLED;
    } else {
        LRESULT s = MC_SEND(win, BM_GETSTATE, 0, 0);
        if(s & BST_PUSHED)
            state = PBS_PRESSED;
        else if(s & BST_HOT)
            state = PBS_HOT;
        else if(button->style & BS_DEFPUSHBUTTON)
            state = PBS_DEFAULTED;
        else
            state = PBS_NORMAL;
    }
    if(mcIsThemeBackgroundPartiallyTransparent(button->theme, BP_PUSHBUTTON, state))
        mcDrawThemeParentBackground(win, dc, &rect);
    mcDrawThemeBackground(button->theme, dc, BP_PUSHBUTTON, state, &rect, &rect);

    /* Get content rectangle of the button and clip DC to it */
    mcGetThemeBackgroundContentRect(button->theme, dc, BP_PUSHBUTTON, state, &rect, &content);
    IntersectClipRect(dc, content.left, content.top, content.right, content.bottom);

    /* Draw focus rectangle */
    if(MC_SEND(win, BM_GETSTATE, 0, 0) & BST_FOCUS) {
        if(!button->hide_focus)
            DrawFocusRect(dc, &content);
    }

    /* Draw the contents (i.e. the icon) */
    if(icon != NULL) {
        mc_icon_size(icon, &size);
        flags = DST_ICON;
        if(button->style & WS_DISABLED)
            flags |= DSS_DISABLED;
        DrawState(dc, NULL, NULL, (LPARAM) icon, 0, (rect.right + rect.left - size.cx) / 2,
                  (rect.bottom + rect.top - size.cy) / 2, size.cx, size.cy, flags);
    }

    /* Revert DC into original state */
    SelectObject(dc, old_font);
    SetBkMode(dc, old_bk_mode);
    SetTextColor(dc, old_text_color);
    SelectObject(dc, old_clip);
}
Exemplo n.º 22
0
void DialogNewGame() {
    FormPtr prevForm, frm;
    UInt16 hitButton;
    Char tmpString[5];
    Char *text;
    UInt16 x;
    UInt16 num;

    // Save previous form
    prevForm = FrmGetActiveForm();
    FrmSetFocus( prevForm, noFocus );

    // Init new form
    frm = FrmInitForm( frmNewGame );

    // Set it
    FrmSetActiveForm(frm);
    FrmDrawForm(frm);

    for( x = 0; x < MaxPlayers; x++ )
    {
        tmppref[x].type = GetPlayerType( x );
        StrCopy( tmppref[x].hname, pref.player[x].hname );
        StrCopy( tmppref[x].aname, pref.player[x].aname );

        DrawUserType( x, tmppref[x].type );

        NewGameSetPlayerName( fldNGname0+x, x );
    }

    // Fill in WinScore with previous value.
    if ( pref.winscore > 9999 ) { // Sanity check...
        pref.winscore = DEFAULT_WINSCORE;
    }
    StrIToA( tmpString, pref.winscore );
    SetFieldTextFromStr( fld_winscore, tmpString );

    // Fill in Opening Roll with previous value.
    if ( pref.openingroll > pref.winscore || pref.openingroll <= 0 ) {
        // Sanity check...
        pref.openingroll = DEFAULT_OPENINGROLL;
    }
    StrIToA( tmpString, pref.openingroll );
    SetFieldTextFromStr( fld_openingroll, tmpString );

    SetFocus( fld_openingroll );

    // Set the handler
    FrmSetEventHandler(frm, DialogNewGameHandleEvent);

    hitButton = FrmDoDialog(frm);

    FrmSetFocus( frm, noFocus );

    if ( hitButton == btn_OK_frmNewGame ) {

        /* Get the score needed to win */
        pref.winscore = DEFAULT_WINSCORE;
        text = FldGetTextPtr( GetObjectPtr( fld_winscore ) );
        if ( text != NULL ) {
            num = StrAToI( text );
            if( num <= 9999 && num >= 50 ) {
                pref.winscore = num;
            }
        }

        /* Get the score needed to open game */
        pref.openingroll = DEFAULT_OPENINGROLL;
        text = FldGetTextPtr( GetObjectPtr( fld_openingroll ) );
        if ( text != NULL ) {
            num = StrAToI( text );
            if( num <= pref.winscore && num >= 0 ) {
                pref.openingroll = num;
            }
        }


        pref.totalplayers = 0;
        for( x = 0; x < MaxPlayers; x++ )
        {
            pref.player[x].type = tmppref[x].type;

            NewGameGetPlayerName( fldNGname0 + x, x );

            StrCopy( pref.player[x].hname,
                     tmppref[x].hname );
            StrCopy( pref.player[x].aname,
                     tmppref[x].aname );

            if( tmppref[x].type != PlayerNone )
            {
                pref.totalplayers++;
            }

        }

        if( pref.totalplayers > 0 )
        {
            NewGame();
        }
    }

    // Delete the form, we're not using it
    FrmDeleteForm(frm);

    // Restore previous form.
    if (prevForm) {
        FrmSetActiveForm(prevForm);
    }

    DrawState();
}
void fsODMenu::OnDrawItem(LPDRAWITEMSTRUCT pdis)
{
	CDC *dc = CDC::FromHandle (pdis->hDC);
	fsODMenuItemData* pData = (fsODMenuItemData*) pdis->itemData;
	UINT uState = pdis->itemState;
	CFont *oldfont = dc->SelectObject (pData->bBold ? &m_fontBold : &m_font);

	RECT rcItem = pdis->rcItem;
	
	RECT rcIcon = rcItem;
	rcIcon.left += 3;
	rcIcon.right = rcIcon.left + m_cxIcon;
	rcIcon.top += (rcIcon.bottom - rcIcon.top - m_cyIcon) / 2;
	rcIcon.bottom = rcIcon.top + m_cyIcon;

	RECT rcIconFrame = rcIcon;
	InflateRect (&rcIconFrame, 2, 2);

	RECT rcSel;
	
	if (pData->bMenuBar)
	{
		rcSel = pdis->rcItem;
		InflateRect (&rcSel, -1, -1);
		fsFillSolidRect (dc, &rcItem, GetSysColor (COLOR_3DFACE));
	}
	else
	{
		rcSel = rcIconFrame;
		rcSel.right = rcItem.right;
		rcSel.bottom++;
		
		fsFillSolidRect (dc, &rcItem, GetSysColor (COLOR_MENU));
		rcItem.left += m_cxIcon;
	}
	
	if (pData->strMenuText.GetLength () == 0)
	{
		RECT rect = rcItem;
		rect.left -= m_cxIcon;
		rect.top += (rect.bottom - rect.top) / 2;
		rect.bottom = rect.top+1;
		rect.right = rcItem.right;
		fsFillSolidRect (dc, &rect, GetSysColor (COLOR_GRAYTEXT));
		return;
	}

	if (uState & 0x40 )
		if (pData->bMenuBar)
			fsDrawFrame (dc, &rcSel, 1);

	if (uState & ODS_SELECTED)	
	{
		if (pData->bMenuBar)
			fsDrawPressedFrame (dc, &rcSel, 1);	
		else
		{
			
			fsFillSolidRect (dc, &rcSel, GetSysColor (COLOR_HIGHLIGHT));
		}
	}

	dc->SetBkMode (TRANSPARENT);

	if (pData->bMenuBar)
	{
		
		if (uState & ODS_GRAYED || uState & ODS_DISABLED) 
			dc->SetTextColor (GetSysColor (COLOR_GRAYTEXT));
		dc->DrawText (pData->strMenuText, &rcItem, DT_VCENTER | DT_SINGLELINE | DT_CENTER);
	}
	else
	{
		CPen pen (PS_SOLID, 1, GetSystemMetrics (COLOR_HIGHLIGHTTEXT));

		CPen *oldpen = dc->SelectObject (&pen);

		if (uState & ODS_GRAYED || uState & ODS_DISABLED) 
			dc->SetTextColor (GetSysColor (COLOR_GRAYTEXT));
		else if (uState & ODS_SELECTED)
			dc->SetTextColor (GetSysColor (COLOR_HIGHLIGHTTEXT));
		else
			dc->SetTextColor (GetSysColor (COLOR_MENUTEXT));

		

		LPCSTR pszTab = strchr (pData->strMenuText, '\t');
		int left = pszTab ? pszTab - pData->strMenuText : pData->strMenuText.GetLength ();

		rcItem.left += 9; rcItem.right -= 15;
		dc->DrawText (pData->strMenuText, left, &rcItem, DT_VCENTER | DT_SINGLELINE);

		if (pszTab)
			dc->DrawText (pszTab+1, -1, &rcItem, DT_VCENTER | DT_SINGLELINE | DT_RIGHT);

		dc->SelectObject (oldpen);
	}

	

	POINT ptIcon;
	ptIcon.x = rcIcon.left + 1;
	ptIcon.y = rcIcon.top + 1;

	RECT rcClr = pdis->rcItem;
	rcClr.right = m_cxIcon + 5;

	if (uState & ODS_CHECKED)
	{
		if (pData->iCheckImage >= 0)
		{
			fsFillSolidRect (dc, &rcClr, GetSysColor (COLOR_MENU));
			m_pImages->Draw (dc, pData->iCheckImage, ptIcon, ILD_TRANSPARENT);
		}
		else if (pData->iImage >= 0)
		{
			fsFillSolidRect (dc, &rcClr, GetSysColor (COLOR_MENU));
			
			
			rcIconFrame.right--;
			fsDrawPressedFrame (dc, &rcIconFrame, 1);
			m_pImages->Draw (dc, pData->iImage, ptIcon, ILD_TRANSPARENT);
		}
		else
		{
			CFont font;
			char check;
			int fsize;

			switch (pData->iCheckImage)
			{
				case ODMENU_CHECKIMAGE_CHECK:
				{
					DrawCheckMark (dc, rcIcon, uState & ODS_SELECTED, uState & ODS_GRAYED);
					
				}
				break;

				case ODMENU_CHECKIMAGE_RADIO:
				{
					check = 105;
					fsize = m_cyIcon;
					font.CreateFont (fsize, 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, "Marlett");
					CFont* oldfont = dc->SelectObject (&font);
					dc->DrawText (&check, 1, &rcIcon, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
					dc->SelectObject (oldfont);
				}
				break;

				default:
					return;
			}
		}
	}
	else if (pData->iImage != -1)
	{
		fsFillSolidRect (dc, &rcClr, GetSysColor (COLOR_MENU));

		if (uState & ODS_GRAYED || uState & ODS_DISABLED)
		{
			if (m_pDisImages == NULL)
			{
				HICON hI = m_pImages->ExtractIcon (pData->iImage);

				DrawState (dc->m_hDC, NULL, NULL, LPARAM (hI), 0, ptIcon.x, ptIcon.y, m_cxIcon, m_cyIcon, 
					DST_ICON | DSS_DISABLED);

				DestroyIcon (hI); 
			}
			else
				m_pDisImages->Draw (dc, pData->iImage, ptIcon, ILD_TRANSPARENT);

		}
		else
		{
			if (uState & ODS_SELECTED)
				fsDrawFrame (dc, &rcIconFrame, 1);

			m_pImages->Draw (dc, pData->iImage, ptIcon, ILD_TRANSPARENT);
		}
	}

	dc->SelectObject (oldfont);
}
Exemplo n.º 24
0
LRESULT MainWindow::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch(uMsg)
	{
	case WM_CREATE:
		CreateMainWindow();
		return 0;

	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;

	case WM_PAINT:
		{
			PAINTSTRUCT ps;
			HDC hdc = BeginPaint(m_hwnd, &ps);
			FillRect(hdc, &ps.rcPaint, (HBRUSH) (COLOR_WINDOW+1));
			if(m_hbmpSlice)
				DrawState(hdc,NULL,NULL,(LPARAM)m_hbmpSlice,0,400,46,0,0,DST_BITMAP);
			EndPaint(m_hwnd, &ps);
		}
		return 0;

	case WM_UPDATE_RECON:
		UpdateDisplay();
		SendMessage(m_hProgress, PBM_SETPOS, (WPARAM)LOWORD(wParam),NULL);
		return 0;

	case WM_RECON_COMPLETE:
		ShowWindow(m_hProgress, SW_HIDE);
		m_ReconSaved = false;
		return 0;

	case WM_COMMAND:
		if(lParam) // Control
		{
			switch(LOWORD(wParam))
			{
			case ID_RECON_DIM:
				if(HIWORD(wParam)==EN_CHANGE)
					SetDimText();
				return 0;
			case ID_LOAD_PROJ:
				if(HIWORD(wParam)==BN_CLICKED)
					OpenProjData();
				return 0;
			case ID_START_RECON:
				if(HIWORD(wParam)==BN_CLICKED)
				{
					ShowWindow(m_hProgress, SW_SHOW);
					StartReconstruction();
					return 0;
				}
			case ID_CANCEL_RECON:
				if(HIWORD(wParam)==BN_CLICKED)
				{
					m_Recon->CancelRecon();
					ShowWindow(m_hProgress, SW_HIDE);
				}
				return 0;
			case ID_SAVE_RECON:
				if(HIWORD(wParam)==BN_CLICKED)
				{
					SaveRecon();
					//SaveDicom();
				}
				return 0;
			case ID_LOAD_RECON:
				if(HIWORD(wParam)==BN_CLICKED)
					LoadRecon();
				return 0;
			case ID_REMOVE_METAL:
				if(HIWORD(wParam)==BN_CLICKED)
					RemoveMetal();
				return 0;
			}
			break;
		}
		else
		{
			switch(HIWORD(wParam))
			{
			case 0:	// Menu
				switch(LOWORD(wParam))
				{
				case IDM_OPEN:
					OpenProjData();
					return 0;
				case IDM_EXIT:
					DestroyWindow(m_hwnd);
					return 0;
				case IDM_ABOUT:
					DialogBox(GetModuleHandle(NULL),L"AboutBox",m_hwnd,(DLGPROC)AboutDlgProc);
					return 0;
				}
				break;
			case 1:		// Accelerator
				break;
			}
		}
		break;

	case WM_HSCROLL:
		if((HWND)lParam==m_hCutoff)
		{
			switch(LOWORD(wParam))
			{
			case TB_THUMBTRACK:
				if(SendMessage(m_hCutoff,TBM_GETPOS,0,0)==0)
					SendMessage(m_hCutoff,TBM_SETPOS,TRUE,1);
			}
			return 0;
		}
		break;

	case WM_CTLCOLORSTATIC: // ensures the background of the controls is drawn in white
		{
			HDC hDC = (HDC) wParam;
			SetBkColor(hDC,RGB(255,255,255));
			return (INT_PTR)m_hbrBackground;
		}

	}
	
	return DefWindowProc(m_hwnd, uMsg, wParam, lParam);

	// return TRUE;
}
Exemplo n.º 25
0
static void PaintWorker(MButtonCtrl *ctl, HDC hdcPaint)
{
	if(hdcPaint) {
		HDC 	hdcMem;
		RECT 	rcClient, rcBp;
		HFONT 	hOldFont = 0;
		int 	xOffset = 0;
		HANDLE	hbp = 0;
		GetClientRect(ctl->hwnd, &rcClient);
#ifndef _USE_D2D
		rcBp = rcClient;
		INIT_PAINT(hdcPaint, rcBp, hdcMem);
#else
		hdcMem = cfg::dat.hdcBg;
		MapWindowPoints(ctl->hwnd, pcli->hwndContactList, reinterpret_cast<POINT *>(&rcClient), 2);
#endif

		hOldFont = reinterpret_cast<HFONT>(SelectObject(hdcMem, ctl->hFont));
		// If its a push button, check to see if it should stay pressed
		if(ctl->pushBtn && ctl->pbState)
			ctl->stateId = PBS_PRESSED;

		// Draw the flat button
		if(ctl->flatBtn) {
			if(ctl->hThemeToolbar && ctl->bThemed) {
				RECT rc = rcClient;
				int state = IsWindowEnabled(ctl->hwnd) ? (ctl->stateId == PBS_NORMAL && ctl->defbutton ? PBS_DEFAULTED : ctl->stateId) : PBS_DISABLED;
				Gfx::drawBGFromSurface(ctl->hwnd, rc, hdcMem);
				if(Api::pfnIsThemeBackgroundPartiallyTransparent(ctl->hThemeToolbar, TP_BUTTON, TBStateConvert2Flat(state))) {
					Api::pfnDrawThemeParentBackground(ctl->hwnd, hdcMem, &rc);
				}
				Api::pfnDrawThemeBackground(ctl->hThemeToolbar, hdcMem, TP_BUTTON, TBStateConvert2Flat(state), &rc, &rc);
			} else {
				HBRUSH hbr;
				RECT rc = rcClient;

				if(ctl->buttonItem) {
					RECT rcParent;
					POINT pt;
					TImageItem *imgItem = ctl->stateId == PBS_HOT ? ctl->buttonItem->imgHover : (ctl->stateId == PBS_PRESSED ? ctl->buttonItem->imgPressed : ctl->buttonItem->imgNormal);
					LONG *glyphMetrics = ctl->stateId == PBS_HOT ? ctl->buttonItem->hoverGlyphMetrics : (ctl->stateId == PBS_PRESSED ? ctl->buttonItem->pressedGlyphMetrics : ctl->buttonItem->normalGlyphMetrics);
#ifndef _USE_D2D
					GetWindowRect(ctl->hwnd, &rcParent);
					pt.x = rcParent.left;
					pt.y = rcParent.top;
					ScreenToClient(pcli->hwndContactList, &pt);
					Gfx::drawBGFromSurface(ctl->hwnd, rc, hdcMem);
#endif
					if(imgItem)
						Gfx::renderSkinItem(hdcMem, &rc, imgItem);
					if(Skin::glyphItem) {
						Api::pfnAlphaBlend(hdcMem, (rc.right - glyphMetrics[2]) / 2, (rc.bottom - glyphMetrics[3]) / 2,
										   glyphMetrics[2], glyphMetrics[3], Skin::glyphItem->hdc,
										   glyphMetrics[0], glyphMetrics[1], glyphMetrics[2],
										   glyphMetrics[3], Skin::glyphItem->bf);
					}
				} else if(ctl->bSkinned) {    // skinned
					RECT rcParent;
					TStatusItem *item;
					int item_id;

					GetWindowRect(ctl->hwnd, &rcParent);

					Gfx::drawBGFromSurface(ctl->hwnd, rc, hdcMem);
					item_id = ctl->stateId == PBS_HOT ? ID_EXTBKBUTTONSMOUSEOVER : (ctl->stateId == PBS_PRESSED ? ID_EXTBKBUTTONSPRESSED : ID_EXTBKBUTTONSNPRESSED);
					item = &Skin::statusItems[item_id];
					Gfx::setTextColor(item->TEXTCOLOR);
					if(item->IGNORED)
						FillRect(hdcMem, &rc, GetSysColorBrush(COLOR_3DFACE));
					else {
						rc.top += item->MARGIN_TOP;
						rc.bottom -= item->MARGIN_BOTTOM;
						rc.left += item->MARGIN_LEFT;
						rc.right -= item->MARGIN_RIGHT;
						Gfx::renderSkinItem(hdcMem, &rc, item->imageItem);
					}
				} else {
					if(ctl->stateId == PBS_PRESSED || ctl->stateId == PBS_HOT)
						hbr = GetSysColorBrush(COLOR_3DFACE);
					else {
						HDC dc;
						HWND hwndParent;

						hwndParent = GetParent(ctl->hwnd);
						dc = GetDC(hwndParent);
						hbr = (HBRUSH) SendMessage(hwndParent, WM_CTLCOLORDLG, (WPARAM) dc, (LPARAM) hwndParent);
						ReleaseDC(hwndParent, dc);
					}
					if(hbr) {
						FillRect(hdcMem, &rc, hbr);
						DeleteObject(hbr);
					}
				}
				if(!ctl->bSkinned && ctl->buttonItem == 0) {
					if(ctl->stateId == PBS_HOT || ctl->focus) {
						if(ctl->pbState)
							DrawEdge(hdcMem, &rc, EDGE_ETCHED, BF_RECT | BF_SOFT);
						else
							DrawEdge(hdcMem, &rc, BDR_RAISEDOUTER, BF_RECT | BF_SOFT);
					} else if(ctl->stateId == PBS_PRESSED)
						DrawEdge(hdcMem, &rc, BDR_SUNKENOUTER, BF_RECT | BF_SOFT);
				}
			}
		} else {
			// Draw background/border
			if(ctl->hThemeButton && ctl->bThemed) {
				int state = IsWindowEnabled(ctl->hwnd) ? (ctl->stateId == PBS_NORMAL && ctl->defbutton ? PBS_DEFAULTED : ctl->stateId) : PBS_DISABLED;
				POINT pt;
				RECT rcParent;

				GetWindowRect(ctl->hwnd, &rcParent);
				pt.x = rcParent.left;
				pt.y = rcParent.top;
				ScreenToClient(pcli->hwndContactList, &pt);
				BitBlt(hdcMem, 0, 0, rcClient.right, rcClient.bottom, cfg::dat.hdcBg, pt.x, pt.y, SRCCOPY);

				if(Api::pfnIsThemeBackgroundPartiallyTransparent(ctl->hThemeButton, BP_PUSHBUTTON, state)) {
					Api::pfnDrawThemeParentBackground(ctl->hwnd, hdcMem, &rcClient);
				}
				Api::pfnDrawThemeBackground(ctl->hThemeButton, hdcMem, BP_PUSHBUTTON, state, &rcClient, &rcClient);
			} else {
				UINT uState = DFCS_BUTTONPUSH | ((ctl->stateId == PBS_HOT) ? DFCS_HOT : 0) | ((ctl->stateId == PBS_PRESSED) ? DFCS_PUSHED : 0);
				if(ctl->defbutton && ctl->stateId == PBS_NORMAL)
					uState |= DLGC_DEFPUSHBUTTON;
				DrawFrameControl(hdcMem, &rcClient, DFC_BUTTON, uState);
			}

			// Draw focus rectangle if button has focus
			if(ctl->focus) {
				RECT focusRect = rcClient;
				InflateRect(&focusRect, -3, -3);
				DrawFocusRect(hdcMem, &focusRect);
			}
		}

		// If we have an icon or a bitmap, ignore text and only draw the image on the button
		if(ctl->hIcon || ctl->hIconPrivate || ctl->iIcon) {
			int ix = (rcClient.right - rcClient.left) / 2 - (CXSMICON / 2);
			int iy = (rcClient.bottom - rcClient.top) / 2 - (CXSMICON / 2);
			HICON hIconNew = ctl->hIconPrivate != 0 ? ctl->hIconPrivate : ctl->hIcon;
			if(lstrlen(ctl->szText) == 0) {
				if(ctl->iIcon)
					ImageList_DrawEx(ctl->hIml, ctl->iIcon, hdcMem, ix, iy, CXSMICON, CYSMICON, CLR_NONE, CLR_NONE, ILD_NORMAL);
				else
					DrawState(hdcMem, NULL, NULL, (LPARAM) hIconNew, 0, ix, iy, CXSMICON, CYSMICON, IsWindowEnabled(ctl->hwnd) ? DST_ICON | DSS_NORMAL : DST_ICON | DSS_DISABLED);
				ctl->sLabel.cx = ctl->sLabel.cy = 0;
			} else {
				GetTextExtentPoint32(hdcMem, ctl->szText, lstrlen(ctl->szText), &ctl->sLabel);

				if(CXSMICON + ctl->sLabel.cx + 8 > rcClient.right - rcClient.left)
					ctl->sLabel.cx = (rcClient.right - rcClient.left) - CXSMICON - 8;
				else
					ctl->sLabel.cx += 4;

				ix = (rcClient.right - rcClient.left) / 2 - ((CXSMICON + ctl->sLabel.cx) / 2);
				if(ctl->iIcon)
					ImageList_DrawEx(ctl->hIml, ctl->iIcon, hdcMem, ix, iy, CXSMICON, CYSMICON, CLR_NONE, CLR_NONE, ILD_NORMAL);
				else
					DrawState(hdcMem, NULL, NULL, (LPARAM) hIconNew, 0, ix, iy, CXSMICON, CYSMICON, IsWindowEnabled(ctl->hwnd) ? DST_ICON | DSS_NORMAL : DST_ICON | DSS_DISABLED);
				xOffset = ix + CXSMICON + 4;
			}
		} else if(ctl->hBitmap) {
			BITMAP bminfo;
			int ix, iy;

			GetObject(ctl->hBitmap, sizeof(bminfo), &bminfo);
			ix = (rcClient.right - rcClient.left) / 2 - (bminfo.bmWidth / 2);
			iy = (rcClient.bottom - rcClient.top) / 2 - (bminfo.bmHeight / 2);
			if(ctl->stateId == PBS_PRESSED) {
				ix++;
				iy++;
			}
			DrawState(hdcMem, NULL, NULL, (LPARAM) ctl->hBitmap, 0, ix, iy, bminfo.bmWidth, bminfo.bmHeight, IsWindowEnabled(ctl->hwnd) ? DST_BITMAP : DST_BITMAP | DSS_DISABLED);
		}
		if(GetWindowTextLength(ctl->hwnd)) {
			// Draw the text and optinally the arrow
			RECT rcText;

			CopyRect(&rcText, &rcClient);
			SetBkMode(hdcMem, TRANSPARENT);
			if(!ctl->bSkinned)
				Gfx::setTextColor(IsWindowEnabled(ctl->hwnd) || !ctl->hThemeButton ? GetSysColor(COLOR_BTNTEXT) : GetSysColor(COLOR_GRAYTEXT));
			if(ctl->arrow) {
				DrawState(hdcMem, NULL, NULL, (LPARAM) ctl->arrow, 0, rcClient.right - rcClient.left - 5 - CXSMICON + (!ctl->hThemeButton && ctl->stateId == PBS_PRESSED ? 1 : 0), (rcClient.bottom - rcClient.top) / 2 - CYSMICON / 2 + (!ctl->hThemeButton && ctl->stateId == PBS_PRESSED ? 1 : 0), CXSMICON, CYSMICON, IsWindowEnabled(ctl->hwnd) ? DST_ICON : DST_ICON | DSS_DISABLED);
				rcText.left += (4 + CXSMICON);
			}
			if(xOffset)
				rcText.left += (4 + CXSMICON);
			Gfx::renderText(hdcMem, ctl->hThemeButton, ctl->szText, &rcText, DT_VCENTER | DT_CENTER | DT_SINGLELINE, 0);
		}
		if(hOldFont)
			SelectObject(hdcMem, hOldFont);
#ifndef _USE_D2D
		FINALIZE_PAINT(hbp, &rcBp, 0);
#endif
	}
}
Exemplo n.º 26
0
Arquivo: draw.c Projeto: docwhat/cwimp
void DialogNewGame() {
    FormPtr prevForm, frm;
    Word hitButton;
    Char tmpString[5];
    CharPtr text;
    Word  fldIndex;
    Int x;

    // Save previous form
    prevForm = FrmGetActiveForm();
    // Init new form
    frm = FrmInitForm( frmNewGame );

    // Set it
    FrmSetActiveForm(frm);
    FrmDrawForm(frm);

    // Set Controls
    // cbtnVal & pbtnVal
    stor.tmpplayers = stor.numplayers;
    stor.tmpcomputers = stor.numcomputers;
    if ( stor.numplayers > 0 ) {
        x = stor.numplayers;
    } else {
        x = 1;
    }
    CtlSetValue( GetObjectPtr( pbtnVal[x - 1] ), true );

    if ( stor.numcomputers > 0 ) {
        x = stor.numcomputers;
    } else {
        x = 0;
    }
    CtlSetValue( GetObjectPtr( cbtnVal[x] ), true );

    // Fill in WinScore with previous value.
    if ( stor.winscore > 9999 ) { // Sanity check...
        stor.winscore = 300;
    }
    StrIToA( tmpString, stor.winscore );
    SetFieldTextFromStr( fld_winscore, tmpString );
    // Set the focus to this field so the user can just start typing.
    fldIndex =  FrmGetObjectIndex(frm, fld_winscore);
    FrmSetFocus( frm, fldIndex );

    // Set the handler
    FrmSetEventHandler(frm, DialogNewGameHandleEvent);

    hitButton = FrmDoDialog(frm);

    if ( hitButton == btn_OK_frmNewGame ) {
        text = FldGetTextPtr( FrmGetObjectPtr (frm, fldIndex) );
        if ( text != NULL ) {
            stor.winscore = StrAToI( text );
        } else {
            stor.winscore = 300;
        }

        stor.numplayers = stor.tmpplayers;
        stor.numcomputers = stor.tmpcomputers;
    }

    // Delete the form, we're not using it
    FrmDeleteForm(frm);

    // Restore previous form.
    if (prevForm) {
        FrmSetActiveForm(prevForm);
    }


    if ( hitButton == btn_OK_frmNewGame ) {
        NewGame();
    }


    DrawState();
}
Exemplo n.º 27
0
/**
 * name:	PaintThemeButton
 * desc:	Draws the none themed button
 * param:	ctl			- BTNCTRL structure for the button
 *			hdcMem		- device context to draw to
 *			rcClient	- rectangle of the whole button
 * return:	nothing
 **/
static void __fastcall PaintButton(BTNCTRL *ctl, HDC hdcMem, LPRECT rcClient)
{
    RECT rcText = { 0, 0, 0, 0 };
    TCHAR szText[MAX_PATH] = { 0 };
    WORD ccText;

    // Draw the flat button
    if (ctl->dwStyle & MBS_FLAT) {
        HBRUSH hbr = NULL;

        if (ctl->stateId == PBS_PRESSED || ctl->stateId == PBS_HOT)
            hbr = GetSysColorBrush(COLOR_3DLIGHT);
        else {
            HDC dc;
            HWND hwndParent;

            hwndParent = GetParent(ctl->hwnd);
            if (dc = GetDC(hwndParent)) {
                hbr = (HBRUSH)SendMessage(hwndParent, WM_CTLCOLORDLG, (WPARAM)dc, (LPARAM)hwndParent);
                ReleaseDC(hwndParent, dc);
            }
        }
        if (hbr) {
            FillRect(hdcMem, rcClient, hbr);
            DeleteObject(hbr);
        }
        if (ctl->stateId == PBS_HOT || ctl->bFocus) {
            if (ctl->pbState) DrawEdge(hdcMem, rcClient, EDGE_ETCHED, BF_RECT | BF_SOFT);
            else DrawEdge(hdcMem, rcClient, BDR_RAISEDOUTER, BF_RECT | BF_SOFT | BF_FLAT);
        }
        else if (ctl->stateId == PBS_PRESSED)
            DrawEdge(hdcMem, rcClient, BDR_SUNKENOUTER, BF_RECT | BF_SOFT);
    }
    else {
        UINT uState = DFCS_BUTTONPUSH | ((ctl->stateId == PBS_HOT) ? DFCS_HOT : 0) | ((ctl->stateId == PBS_PRESSED) ? DFCS_PUSHED : 0);
        if (ctl->defbutton&&ctl->stateId == PBS_NORMAL) uState |= DLGC_DEFPUSHBUTTON;
        DrawFrameControl(hdcMem, rcClient, DFC_BUTTON, uState);
        // Draw focus rectangle if button has focus
        if (ctl->bFocus) {
            RECT focusRect = *rcClient;
            InflateRect(&focusRect, -3, -3);
            DrawFocusRect(hdcMem, &focusRect);
        }
    }
    // calculate text rect
    {
        SIZE	sizeText;
        HFONT	hOldFont;

        ccText = GetWindowText(ctl->hwnd, szText, _countof(szText));

        if (ccText > 0) {
            hOldFont = (HFONT)SelectObject(hdcMem, ctl->hFont);
            GetTextExtentPoint32(hdcMem, szText, ccText, &sizeText);
            if (ctl->cHot) {
                SIZE sizeHot;

                GetTextExtentPoint32A(hdcMem, "&", 1, &sizeHot);
                sizeText.cx -= sizeHot.cx;
            }
            SelectObject(hdcMem, hOldFont);

            rcText.left = (ctl->hIcon) ? 0 : (rcClient->right - rcClient->left - sizeText.cx) / 2;
            rcText.top = (rcClient->bottom - rcClient->top - sizeText.cy) / 2;
            rcText.right = rcText.left + sizeText.cx;
            rcText.bottom = rcText.top + sizeText.cy;
            if (ctl->stateId == PBS_PRESSED)
                OffsetRect(&rcText, 1, 1);
        }
    }
    PaintIcon(ctl, hdcMem, &ccText, rcClient, &rcText);

    // draw text
    if (ccText > 0) {
        HFONT hOldFont;

        hOldFont = (HFONT)SelectObject(hdcMem, ctl->hFont);

        SetBkMode(hdcMem, TRANSPARENT);
        SetTextColor(hdcMem,
                     IsWindowEnabled(ctl->hwnd) || !ctl->hThemeButton
                     ? ctl->stateId == PBS_HOT
                     ? GetSysColor(COLOR_HOTLIGHT)
                     : GetSysColor(COLOR_BTNTEXT)
                     : GetSysColor(COLOR_GRAYTEXT));

        DrawState(hdcMem, NULL, NULL, (LPARAM)szText, 0,
                  rcText.left, rcText.top, rcText.right - rcText.left, rcText.bottom - rcText.top,
                  IsWindowEnabled(ctl->hwnd) || ctl->hThemeButton ? DST_PREFIXTEXT | DSS_NORMAL : DST_PREFIXTEXT | DSS_DISABLED);
        SelectObject(hdcMem, hOldFont);
    }
}
Exemplo n.º 28
0
//发生某些事件时,会触发的函数
static SYS_MSG SystemEventHandler(SYS_EVT SysEvent ,int IntParam, void *pSysParam)
{
	switch(SysEvent)
	{
		case Sys_PreGotoPage:
			if(pSysParam!=NULL)//如果pSysParam不为空,则表示被其他页面调用,需传递数据
			{
				gpQwpSet=Q_Mallco(sizeof(QWEB_PAGE_SET));//使用QS_Mallco是为了逃避页面的堆检查机制
				MemCpy((void *)gpQwpSet,pSysParam,sizeof(QWEB_PAGE_SET));
			}
			break;
		case Sys_PageInit:		//系统每次打开这个页面,会处理这个事件			
			gpQwpVar=Q_PageMallco(sizeof(QWEB_PAGE_VARS));//在Sys_PreGotoPage中处理,并使用OS_Mallco,是为了获取到前页数据,屏蔽页面堆检查
			MemSet(gpQwpVar,0,sizeof(QWEB_PAGE_VARS));
			gpQwpVar->NowPressKey=0xff;
			if(gpQwpSet!=NULL) 
			{
				strncpy((void *)gpQwpVar->PageTitle,(void *)gpQwpSet->PageTitle,sizeof(gpQwpVar->PageTitle));
				gpQwpVar->GotoAct_List=gpQwpSet->GotoAct_List;
				strncpy((void *)gpQwpVar->GotoName_List,(void *)gpQwpSet->GotoName_List,sizeof(gpQwpVar->GotoName_List));
				gpQwpVar->GotoAct_Back=gpQwpSet->GotoAct_Back;
				strncpy((void *)gpQwpVar->GotoName_Back,(void *)gpQwpSet->GotoName_Back,sizeof(gpQwpVar->GotoName_Back));			 	
				gpQwpVar->GotoAct_Done=gpQwpSet->GotoAct_Done;
				strncpy((void *)gpQwpVar->GotoName_Done,(void *)gpQwpSet->GotoName_Done,sizeof(gpQwpVar->GotoName_Done));
			}		
		case Sys_SubPageReturn:	//如果从子页面返回,就不会触发Sys_Page_Init事件,而是Sys_SubPage_Return
			if(SysEvent==Sys_SubPageReturn) //关全局事件
			{
				Q_DisableGobalPeripEvent(Perip_QWebJoin,PeripheralsHandler);
				Q_DisableGobalPeripEvent(Perip_QWebQueryName,PeripheralsHandler);
			}
			Q_TimSet(Q_TIM1,10000,500,TRUE);//5s poll

			DrawInitBg();
			DrawState();

			//如果q网已经开启,如果是主机,应迅速建立list
			//如果q网已经开启,如果是从机,应迅速建立list
			//如果q网没开启,不动
			if(QWA_GetMyAddr()!=QW_ADDR_DEF)//q网已经启动
			{
				u8 Addr;
				u8 MyAddr=QWA_GetMyAddr();

				if(QWA_GetMyAddr()!=QW_ADDR_HOST)//自己是从机
				{
					AddOneDevice(QW_ADDR_HOST,NULL);//添加主机
				}
				
				//轮询添加在线从机
				QWA_QueryNextOnline(TRUE);
				while((Addr=QWA_QueryNextOnline(FALSE))!=0)
				{
					if(Addr!=MyAddr) 
					{
						AddOneDevice(Addr,NULL);//添加无名设备
					}
				}
			}
			if(gpQwpSet!=NULL)//保存前页数据的内存可以销毁了
			{
				Q_Free(gpQwpSet);
				gpQwpSet=NULL;
			}
			break;
		case Sys_TouchSetOk:
		case Sys_TouchSetOk_SR:
			
			break;
		case Sys_PageClean:
			Q_PageFree(gpQwpVar);
			gpQwpVar=NULL;
		case Sys_PreSubPage:
			Q_TimSet(Q_TIM1,0,0,FALSE);//stop poll
			if(SysEvent==Sys_PreSubPage)//开全局事件 
			{
				Q_EnableGobalPeripEvent(Perip_QWebJoin,PeripheralsHandler);
				Q_EnableGobalPeripEvent(Perip_QWebQueryName,PeripheralsHandler);
			}
			break;
		default:
			//需要响应的事件未定义
			Debug("%s SystemEventHandler:This System Event Handler case unfinish! SysEvent:%d\n\r",Q_GetCurrPageName(),SysEvent);
			//while(1);
	}
	
	return 0;
}
Exemplo n.º 29
0
void OSToolBarEntryIcon::render(Canvas *canvas, const RECT &ir, int hilited, int pushed) {
  DrawState(canvas->getHDC(), NULL, NULL, (long)m_icon, 0, ir.left+3, ir.top+3, 16, 16, DST_ICON|(isDisabled()?DSS_DISABLED:0));
  OSToolBarEntry::render(canvas, ir, hilited, pushed);
}
Exemplo n.º 30
0
void _draw_listview(
		LPDRAWITEMSTRUCT itst
	)
{
	DRAWTEXTPARAMS dtp         = { sizeof(dtp) };
	LVCOLUMN       lvc         = { sizeof(lvc) };
	wchar_t        s_text[200] = { 0 };
	int            cx, cy, k   = 0;
	int            offset      = 0;
	int            icon;
	BOOL           is_root;
	int            col_cnt     = Header_GetItemCount( ListView_GetHeader( itst->hwndItem ) );
	LVITEM         lvitem      = { LVIF_TEXT | LVIF_PARAM, itst->itemID, 0, 0, 0, s_text, countof(s_text) };
	COLORREF       bgcolor     = ListView_GetBkColor( itst->hwndItem );

	ListView_GetItem( itst->hwndItem, &lvitem );
	is_root = _is_root_item( lvitem.lParam );

	{
		void *user_data = wnd_get_long( __lists[HMAIN_DRIVES], GWL_USERDATA );
		if (user_data != NULL)
		{
			MessageBox( __dlg, s_text, NULL, 0 );
		}
	}

	if ( ( itst->itemState & ODS_SELECTED ) && IsWindowEnabled( itst->hwndItem ) /*&& ( lvitem.lParam != NULL )*/ ) 
	{
		if ( GetFocus( ) == itst->hwndItem )
		{
			bgcolor = CL_WHITE;
		} else {
			bgcolor = _cl( COLOR_BTNFACE, 80 );
		}
	}
	if ( is_root ) 
	{
		bgcolor = _cl( COLOR_BTNSHADOW, 60 );
	}
	if ( _is_marked_item(lvitem.lParam) ) 
	{
		bgcolor = _cl( COLOR_BTNSHADOW, 35 );
	}
	
	_fill( itst->hDC, &itst->rcItem, bgcolor );

	for ( ; k < col_cnt; k++ )
	{
		lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_IMAGE;
		ListView_GetColumn( itst->hwndItem, k, &lvc );

		itst->rcItem.left  = k ? itst->rcItem.right : 0;
		itst->rcItem.right = itst->rcItem.left + lvc.cx;

		lvitem.iItem       = itst->itemID; 
		lvitem.iSubItem    = k;

		ListView_GetItem( itst->hwndItem, &lvitem );
		dtp.iLeftMargin = dtp.iRightMargin = 5;		

		if ( (!itst->rcItem.left) && _is_icon_show( itst->hwndItem, k ) )
		{
			ImageList_GetIconSize( __dsk_img, &cx, &cy );
			offset = lvitem.lParam && !is_root ? 25 : 3;

			itst->rcItem.left += offset + cy + ( lvitem.lParam && !is_root ? 8 : 4 );
			icon = 0;

			if (! is_root ) 
			{
				if ( _is_splited_item(lvitem.lParam) ) icon = 1;
				if ( _is_cdrom_item(lvitem.lParam) )   icon = 2;
			}

			ImageList_Draw(
				__dsk_img, icon, itst->hDC, offset, itst->rcItem.top + 3, ILD_TRANSPARENT
				);
		} else 
		{
			offset = 0;
		}
		if ( offset && is_root )
		{
			DrawState(
				itst->hDC, 0, NULL, (LPARAM)s_text, 0, 
				itst->rcItem.left+5, itst->rcItem.top, 0, 0, DST_PREFIXTEXT | DSS_MONO
				);
		} else 
		{
			if ( wcslen(s_text) != 0 ) 
			{
				COLORREF text_color = GetSysColor( COLOR_WINDOWTEXT );

				if ( !_is_active_item(lvitem.lParam) )
				{
					text_color = GetSysColor( COLOR_GRAYTEXT );
				}
				SetTextColor( itst->hDC, text_color );

				if ( k >= 4 )
				{
					SelectObject( itst->hDC, __font_bold );
				}
				if ( !IsWindowEnabled( itst->hwndItem ) )
				{
					SetTextColor( itst->hDC, GetSysColor(COLOR_GRAYTEXT) );

					DrawTextEx(
						itst->hDC, s_text, -1, &itst->rcItem,
						DT_END_ELLIPSIS | ((lvc.fmt & LVCFMT_RIGHT) ? DT_RIGHT : FALSE), &dtp
						);
				} else 
				{
					DrawTextEx(
						itst->hDC, s_text, -1, &itst->rcItem,
						DT_END_ELLIPSIS | ((lvc.fmt & LVCFMT_RIGHT) ? DT_RIGHT : FALSE), &dtp
						);
					/*
					if ( GetFocus( ) == itst->hwndItem )
					{
						DrawFocusRect( itst->hDC, &itst->rcItem );
					}
					*/
				}
			}
		}
	}							
}