Пример #1
0
void CCherryComboBox::OnMouseLeave()
{
	COMBOBOXINFO comboBoxInfo = { sizeof(COMBOBOXINFO) };
	GetComboBoxInfo(&comboBoxInfo);

	// 버튼이 눌린 상태면
	if (/* comboBoxInfo.stateButton == STATE_SYSTEM_PRESSED || */ !m_bDropDown)
	{
		// Normal
		m_pCurrentImage = &m_images[STATUS_NORMAL];
	}

	if (m_bTracking)
	{
		TRACKMOUSEEVENT trackMouseEvent;
		trackMouseEvent.cbSize = sizeof(TRACKMOUSEEVENT);
		trackMouseEvent.dwFlags = TME_CANCEL;
		trackMouseEvent.hwndTrack = GetSafeHwnd();
		trackMouseEvent.dwHoverTime = 1;
		_TrackMouseEvent(&trackMouseEvent);

		m_bTracking = FALSE;
	}

	m_bHover = FALSE;
	SetCurrentFont(GetNormalFont());

	if (m_bEnableHoverHandCursor)
		SetClassLong(GetSafeHwnd(), GCL_HCURSOR, (LONG)AfxGetApp()->LoadStandardCursor(IDC_ARROW));

	Invalidate(FALSE);

	CComboBox::OnMouseLeave();
}
Пример #2
0
CHERRY_RET CCherryComboBox::Create(LPCTSTR lpszImagePath, DWORD dwCherryStyle, DWORD dwStyle, const CCherryRect &cherryRect, CWnd *pParentWnd, UINT nID)
{
	CHERRY_RET cherryRet = CCherryException::ERROR_CHERRY_SUCCESS;

	try
	{
		dwStyle |= CBS_DROPDOWNLIST | CBS_HASSTRINGS;

		if (!CComboBox::Create(dwStyle, cherryRect, pParentWnd, nID))
			throw CCherryException::ERROR_COMBOBOX_CREATE_FAIL;

		if (NULL == m_font.CreateFont(15, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET
			, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, DEFAULT_FONT_NAME))
			throw CCherryException::ERROR_COMBOBOX_CREATE_FAIL;

		SetFont(&m_font);

		// CCherryComboBox 전용 스타일 bit 플래그
		ModifyCherryStyle(0, dwCherryStyle);

		// 기본 왼쪽, 세로 중앙 정렬
		GetNormalFont()->SetFontStyle(STYLE_VCENTER);
		GetHoverFont()->SetFontStyle(STYLE_VCENTER);
		GetDownFont()->SetFontStyle(STYLE_VCENTER);
		GetDisableFont()->SetFontStyle(STYLE_VCENTER);

		// 기본 비활성화 텍스트 속성
		COLORREF disableColor = GetSysColor(COLOR_GRAYTEXT);
		GetDisableFont()->SetFontColor(Color(GetRValue(disableColor), GetGValue(disableColor), GetBValue(disableColor)));

		cherryRet = SetImage(lpszImagePath);
	}
	catch (const CHERRY_RET &errorRet)
	{
		cherryRet = errorRet;
	}

	return cherryRet;
}
Пример #3
0
bool nGraphics::InitGraphics()
{
	// Create our base direct3d object
	m_pDirect3D = Direct3DCreate9(D3D_SDK_VERSION);
	if(!m_pDirect3D)
	{
		nMainFrame::LastError("Failed to create direct3d 9, directx 9 not installed?");
		return TraceRet(__FUNCTION__" Failed to create direct3d 9, directx 9 not installed?\n",false);
	}

	// Check if the device support's the caps we will use
	if(!ValidateDevice())
		return false;

	// Get the desktop's display mode
	D3DDISPLAYMODE displayMode;
	if(FAILED(m_pDirect3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &displayMode)))
	{
		nMainFrame::LastError("Failed to get current display adapter mode.");
		return TraceRet(__FUNCTION__" Failed to get current display adapter mode.\n",false);
	}

	// The struct that describes our direct3d device
    ZeroMemory(&m_PresentParameters,sizeof(m_PresentParameters));
	
	m_Fullscreen = !nGetInstance()->GetCommandLineVar("-windowed",SETTINGS_WINDOWED).asBool();

    m_PresentParameters.Windowed               = !m_Fullscreen;
	m_PresentParameters.SwapEffect             = D3DSWAPEFFECT_DISCARD;
	m_PresentParameters.BackBufferFormat       = D3DFMT_X8R8G8B8;
    m_PresentParameters.EnableAutoDepthStencil = TRUE;
    m_PresentParameters.AutoDepthStencilFormat = D3DFMT_D24S8;

	// Check if we should use fsaa
	if(nGetInstance()->GetCommandLineVar("-fsaa",SETTINGS_FSAA).asBool())
	{
		unsigned long samples = 0;

		// Check if multisampling is supported and enable it if it is
		if(SUCCEEDED(m_pDirect3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,m_PresentParameters.BackBufferFormat,!m_Fullscreen,D3DMULTISAMPLE_NONMASKABLE,&samples)))
		{
			m_PresentParameters.MultiSampleQuality	 = samples-1;
			m_PresentParameters.MultiSampleType		 = D3DMULTISAMPLE_NONMASKABLE;

			Trace(__FUNCTION__" Using %dx multisampling.\n",samples-1);
		}
	}

	// Check if we should display in fullscreen
	if(m_Fullscreen)
	{
		m_PresentParameters.BackBufferWidth	 = displayMode.Width;
		m_PresentParameters.BackBufferHeight = displayMode.Height;
	}
	else
	{
		nRect rect;
		GetClientRect(nGetInstance()->GetWindowHandle(),(LPRECT)&rect);
		
		m_PresentParameters.BackBufferWidth = rect.GetWidth();
		m_PresentParameters.BackBufferHeight = rect.GetHeight();
	}
	
	// Check if we shouldn't use vsync
	if(!nGetInstance()->GetCommandLineVar("-vsync",SETTINGS_VSYNC).asBool())
		m_PresentParameters.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

	Trace(__FUNCTION__" Display mode %dx%d.\n",m_PresentParameters.BackBufferWidth,m_PresentParameters.BackBufferHeight);

	// Now create our direct3d device from the base direct3d object
	HRESULT hr = m_pDirect3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,nGetInstance()->GetWindowHandle(),D3DCREATE_SOFTWARE_VERTEXPROCESSING,&m_PresentParameters,&m_pDevice);
	if(FAILED(hr))
		return TraceRet(__FUNCTION__" Failed to create the device.\n",false);

	// Turn on color dithering
	hr = m_pDevice->SetRenderState(D3DRS_DITHERENABLE,TRUE);
	if(FAILED(hr))
		Trace(__FUNCTION__" Display adapter doesn't support color dithering, using default.\n");

	// Turn off culling
	m_pDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_NONE);

	// Enable anisotropic filtering if fsaa is enabled
	//if(flags & RECFLAG_FSAA)
	//	EnableAnisotropic(m_p3DDevice);

	// Create our line drawing object
	hr = D3DXCreateLine(m_pDevice, &m_pLine);
	if(FAILED(hr))
	{
		nMainFrame::LastError("Failed to create line drawing object.");
		return TraceRet(__FUNCTION__" Failed to create line drawing object.\n",false);
	}
	
	// Don't use gl lines
	m_pLine->SetGLLines(false);

	// Init our font
	hr = D3DXCreateFont(m_pDevice,SETTINGS_FONTHEIGHT,0,FW_BOLD,0,FALSE,DEFAULT_CHARSET,OUT_TT_PRECIS,6/*CLEARTYPE_QUALITY*/,DEFAULT_PITCH,SETTINGS_FONTNAME,&m_pFontBold);
	if(FAILED(hr))
	{
		nMainFrame::LastError("Failed to create font. Font not found?");
		return TraceRet(__FUNCTION__" Failed to create font. Font not found?",false);
	}

	// Init our thin font
	hr = D3DXCreateFont(m_pDevice,SETTINGS_FONTHEIGHT,0,FW_NORMAL,0,FALSE,DEFAULT_CHARSET,OUT_TT_PRECIS,6/*CLEARTYPE_QUALITY*/,DEFAULT_PITCH,SETTINGS_FONTNAME,&m_pFontNormal);
	if(FAILED(hr))
	{
		nMainFrame::LastError("Failed to create bold font. Font not found?");
		return TraceRet(__FUNCTION__" Failed to create bold font. Font not found?",false);
	}
	
	// Get the font sizes
	nRect fontSize;
	GetTextRect(GetBoldFont(),"str",&fontSize,NULL);
	m_BoldFontHeight = fontSize.GetHeight();
	GetTextRect(GetNormalFont(),"str",&fontSize,NULL);
	m_NormalFontHeight = fontSize.GetHeight();

	// Create our sprite drawing object
	hr = D3DXCreateSprite(m_pDevice, &m_pSprite);
	if(FAILED(hr))
	{
		nMainFrame::LastError("Failed to create sprite.");
		return TraceRet(__FUNCTION__" Failed to create sprite.\n",false);
	}

	// Turn on texture filtering
	m_pDevice->SetSamplerState(0,D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	m_pDevice->SetSamplerState(0,D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	m_pDevice->SetSamplerState(1,D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	m_pDevice->SetSamplerState(1,D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	m_pDevice->SetSamplerState(2,D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	m_pDevice->SetSamplerState(2,D3DSAMP_MINFILTER, D3DTEXF_LINEAR);

	return true;
}