コード例 #1
0
ファイル: MlxLib.cpp プロジェクト: Geod24/Nibbler
void	MlxLib::draw_square(int x_origine, int y_origine, int color)
{
  x_origine *= _sqsize;
  y_origine *= _sqsize;
  for (int y = y_origine; y < (y_origine + _sqsize); y++) {
    for (int x = x_origine; x < (x_origine + _sqsize); x++) {
      pixel_to_image(x, y, TCOLOR(color));
    }
  }
}
コード例 #2
0
ファイル: DeskCalendar.c プロジェクト: heicks/T-Clock
LRESULT CALLBACK Window_Calendar(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch(uMsg) {
	case WM_CREATE:{
		int iMonths,iMonthsPast;
		DWORD dwCalStyle;
		RECT rc; HWND hCal;
		size_t idx;
		size_t dirty = 0;
		
		iMonths = api.GetIntEx(L"Calendar", L"ViewMonths", 3);
		iMonthsPast = api.GetIntEx(L"Calendar", L"ViewMonthsPast", 1);
		
		if(api.GetInt(L"Calendar", L"ShowDayOfYear", 1)) {
			wchar_t szTitle[32];
			GetDayOfYearTitle(szTitle,iMonths);
			SetWindowText(hwnd,szTitle);
		}
		
		dwCalStyle = WS_CHILD|WS_VISIBLE;
		if(api.GetInt(L"Calendar",L"ShowWeekNums",0))
			dwCalStyle|=MCS_WEEKNUMBERS;
		
		hCal = CreateWindowEx(0, MONTHCAL_CLASS, L"", dwCalStyle, 0,0,0,0, hwnd, NULL, NULL, NULL);
		if(!hCal) return -1;
		
		for(idx=0; idx<CALENDAR_COLOR_NUM; ++idx){
			unsigned color = api.GetInt(L"Calendar", g_calendar_color[idx].reg, TCOLOR(TCOLOR_DEFAULT));
			if(color != TCOLOR(TCOLOR_DEFAULT)){
				dirty |= (1<<idx);
				MonthCal_SetColor(hCal, g_calendar_color[idx].mcsc, api.GetColor(color,0));
			}
		}
		if(dirty&~1)
			SetXPWindowTheme(hCal, NULL, L"");
		
		MonthCal_GetMinReqRect(hCal,&rc);//size for a single month
		if(iMonths>1){
			#define CALBORDER 4
			#define CALTODAYTEXTHEIGHT 13
			rc.right+=CALBORDER;
			rc.bottom-=CALTODAYTEXTHEIGHT;
			if(api.OS == TOS_2000){
				rc.right+=2;
				rc.bottom+=2;
			}
			switch(iMonths){
			/*case 1:*/ case 2: case 3:
			case 4: case 5:
				rc.right*=iMonths;
				break;
			case 6:
				rc.bottom*=3;
				/* fall through */
			case 7: case 8:
				rc.right*=2;
				if(iMonths!=6) rc.bottom*=4;
				break;
			case 9:
				rc.bottom*=3;
			case 11: case 12:
				rc.right*=3;
				if(iMonths!=9) rc.bottom*=4;
				break;
			case 10:
				rc.right*=5;
				rc.bottom*=2;
				break;
			}
			rc.right-=CALBORDER;
			rc.bottom+=CALTODAYTEXTHEIGHT;
			if(api.OS >= TOS_VISTA)
				MonthCal_SizeRectToMin(hCal,&rc);//removes some empty space.. (eg at 4 months)
		}else{
			if(rc.right<(LONG)MonthCal_GetMaxTodayWidth(hCal))
				rc.right=MonthCal_GetMaxTodayWidth(hCal);
		}
		SetWindowPos(hCal,HWND_TOP,0,0,rc.right,rc.bottom,SWP_NOZORDER|SWP_NOACTIVATE);
		if(iMonthsPast){
			SYSTEMTIME st,stnew; MonthCal_GetCurSel(hCal,&st); stnew=st;
			stnew.wDay=1;
			if(iMonthsPast>=stnew.wMonth){ --stnew.wYear; stnew.wMonth+=12; }
			stnew.wMonth-=(short)iMonthsPast;
			if(stnew.wMonth>12){ ++stnew.wYear; stnew.wMonth-=12; }  // in case iMonthsPast is negative
			MonthCal_SetCurSel(hCal,&stnew);
			MonthCal_SetCurSel(hCal,&st);
		}
		SetFocus(hCal);
		AdjustWindowRectEx(&rc,WS_CAPTION|WS_POPUP|WS_SYSMENU|WS_VISIBLE,FALSE,0);
		SetWindowPos(hwnd,HWND_TOP,0,0, rc.right-rc.left,rc.bottom-rc.top, SWP_NOMOVE);//force to be on top
		if(m_bTopMost)
			SetWindowPos(hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
		api.PositionWindow(hwnd, (api.OS<TOS_WIN10 && api.OS>=TOS_WIN7 ? 11 : 0));
		if(m_bAutoClose && GetForegroundWindow()!=hwnd)
			PostMessage(hwnd,WM_CLOSE,0,0);
		return 0;}
	case WM_ACTIVATE:
		if(!m_bTopMost){
			if(LOWORD(wParam)==WA_ACTIVE || LOWORD(wParam)==WA_CLICKACTIVE){
				SetWindowPos(hwnd,HWND_TOPMOST_nowarn,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
			}else{
				SetWindowPos(hwnd,HWND_NOTOPMOST_nowarn,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
				// actually it should be lParam, but that's "always" NULL for other process' windows
				SetWindowPos(GetForegroundWindow(),HWND_TOP,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
			}
		}
		if(m_bAutoClose){
			if(LOWORD(wParam)!=WA_ACTIVE && LOWORD(wParam)!=WA_CLICKACTIVE){
				PostMessage(hwnd,WM_CLOSE,0,0);//adds a little more delay which is good
			}
		}
		break;
	case WM_DESTROY:
		Sleep(50);//we needed more delay... 50ms looks good (to allow T-Clock's FindWindow to work) 100ms is slower then Vista's native calendar
		PostQuitMessage(0);
		break;
	}
	return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
コード例 #3
0
ファイル: PageMisc.c プロジェクト: White-Tiger/T-Clock
static void OnInit(HWND hDlg);
static void OnApply(HWND hDlg);

#define SendPSChanged(hDlg) SendMessage(GetParent(hDlg),PSM_CHANGED,(WPARAM)(hDlg),0)

#include "../common/calendar.inc"
typedef struct{
	const wchar_t* name;
	COLORREF color[GROUP_CALENDAR_COLOR_NUM];
} CalendarPreset;

#define CALENDAR_PRESETS 3
static CalendarPreset m_calendar_preset[CALENDAR_PRESETS] = {
	{L"Preset: default", {0}},
	{L"Preset: high contrast", {0x000000, 0xFFFFFF, 0x000000, 0x000000, 0xF28E28, 0xEB00DD}},
	{L"Preset: theme colored", {TCOLOR(TCOLOR_THEME), 0x000000, TCOLOR(TCOLOR_THEME), 0x000000, 0x808080, 0x808080}},
};
static char m_calendar_dirty;

static INT_PTR CALLBACK Window_CalendarColorConfigDlg(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam){
	switch(msg){
	case WM_INITDIALOG:{
		ColorBox colors[6];
		HWND calendar = GetDlgItem(hDlg, IDC_CAL_PREVIEW);
		HWND preset_cb = GetDlgItem(hDlg, IDC_CAL_PRESET);
		int idx;
		m_calendar_dirty = 0;
		for(idx=0; idx<GROUP_CALENDAR_COLOR_NUM; ++idx){
			unsigned color_id = GROUP_CALENDAR_COLOR + (idx * 2);
			colors[idx].hwnd = GetDlgItem(hDlg, color_id);
			colors[idx].color = api.GetInt(L"Calendar", g_calendar_color[idx].reg, TCOLOR(TCOLOR_DEFAULT));
コード例 #4
0
ファイル: PageMisc.c プロジェクト: White-Tiger/T-Clock
static INT_PTR CALLBACK Window_CalendarColorConfigDlg(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam){
	switch(msg){
	case WM_INITDIALOG:{
		ColorBox colors[6];
		HWND calendar = GetDlgItem(hDlg, IDC_CAL_PREVIEW);
		HWND preset_cb = GetDlgItem(hDlg, IDC_CAL_PRESET);
		int idx;
		m_calendar_dirty = 0;
		for(idx=0; idx<GROUP_CALENDAR_COLOR_NUM; ++idx){
			unsigned color_id = GROUP_CALENDAR_COLOR + (idx * 2);
			colors[idx].hwnd = GetDlgItem(hDlg, color_id);
			colors[idx].color = api.GetInt(L"Calendar", g_calendar_color[idx].reg, TCOLOR(TCOLOR_DEFAULT));
			m_calendar_preset[0].color[idx] = (COLORREF)MonthCal_GetColor(calendar, g_calendar_color[idx].mcsc);
			if(colors[idx].color != TCOLOR(TCOLOR_DEFAULT)){
				m_calendar_dirty |= (1<<idx);
				MonthCal_SetColor(calendar, g_calendar_color[idx].mcsc, api.GetColor(colors[idx].color,0));
			}
		}
		ColorBox_Setup(colors, 6);
		for(idx=0; idx<CALENDAR_PRESETS; ++idx)
			ComboBox_AddString(preset_cb, m_calendar_preset[idx].name);
		ComboBox_AddString(preset_cb, L"custom colors");
		m_calendar_dirty ^= 1; // toggle bit to force refresh
		SendMessage(hDlg, WM_COMMAND, MAKEWPARAM(IDC_CAL_OUTER,CBN_SELCHANGE), (LPARAM)GetDlgItem(hDlg,IDC_CAL_OUTER));
		return TRUE;}
	case WM_MEASUREITEM:
		return ColorBox_OnMeasureItem(wParam, lParam);
	case WM_DRAWITEM:
		return ColorBox_OnDrawItem(wParam, lParam);
	case WM_COMMAND:{
		unsigned control_id = LOWORD(wParam);
		unsigned control_notify = HIWORD(wParam);
		switch(control_id){
		case IDC_CAL_PREVIEW:
			break;
		case IDC_CAL_PRESET:{
			HWND calendar = GetDlgItem(hDlg, IDC_CAL_PREVIEW);
			HWND preset_cb = GetDlgItem(hDlg, IDC_CAL_PRESET);
			int preset = ComboBox_GetCurSel(preset_cb);
			int idx;
			if(preset == CALENDAR_PRESETS)
				break;
			for(idx=0; idx<GROUP_CALENDAR_COLOR_NUM; ++idx){
				unsigned color_id = GROUP_CALENDAR_COLOR + (idx * 2);
				HWND color_cb = GetDlgItem(hDlg, color_id);
				if(preset == 0)
					ColorBox_SetColor(color_cb, TCOLOR(TCOLOR_DEFAULT));
				else
					ColorBox_SetColor(color_cb, m_calendar_preset[preset].color[idx]);
				MonthCal_SetColor(calendar, g_calendar_color[idx].mcsc, api.GetColor(m_calendar_preset[preset].color[idx],0));
			}
			if(preset == 0)
				m_calendar_dirty = 0;
			else
				m_calendar_dirty = 0x01|0x02|0x04|0x08|0x10|0x20;
			SetXPWindowTheme(GetDlgItem(hDlg,IDC_CAL_PREVIEW), NULL, (m_calendar_dirty ? L"" : NULL));
			break;}
		case IDC_CAL_OUTER: case IDC_CAL_FORE: case IDC_CAL_BACK: case IDC_CAL_TITLE: case IDC_CAL_TITLE_BG: case IDC_CAL_TRAIL:
			if(control_notify == CBN_SELCHANGE){
				unsigned id = (control_id - GROUP_CALENDAR_COLOR) / 2;
				unsigned color = ColorBox_GetColorRaw((HWND)lParam);
				char dirty = m_calendar_dirty;
				if(color == TCOLOR(TCOLOR_DEFAULT))
					dirty &= ~(1<<id);
				else
					dirty |= 1<<id;
				if(dirty != m_calendar_dirty){
					m_calendar_dirty = dirty;
					SetXPWindowTheme(GetDlgItem(hDlg,IDC_CAL_PREVIEW), NULL, (dirty&~1 ? L"" : NULL));
				}
				ComboBox_SetCurSel(GetDlgItem(hDlg,IDC_CAL_PRESET), (dirty ? CALENDAR_PRESETS : 0));
				if(color == TCOLOR(TCOLOR_DEFAULT))
					color = m_calendar_preset[0].color[id];
				else
					color = api.GetColor(color, 0);
				MonthCal_SetColor(GetDlgItem(hDlg,IDC_CAL_PREVIEW), g_calendar_color[id].mcsc, color);
			}
			break;
		case IDOK:
			{int idx;
			for(idx=0; idx<GROUP_CALENDAR_COLOR_NUM; ++idx){
				unsigned color_id = GROUP_CALENDAR_COLOR + (idx * 2);
				HWND color_cb = GetDlgItem(hDlg, color_id);
				api.SetInt(L"Calendar", g_calendar_color[idx].reg, ColorBox_GetColorRaw(color_cb));
			}}
			/* fall through */
		case IDCANCEL:
			EndDialog(hDlg, control_id);
			break;
		default:
			ColorBox_ChooseColor((HWND)lParam);
		}
		return TRUE;}
	}
	return FALSE;
}
コード例 #5
0
ファイル: pagecolor.c プロジェクト: heicks/T-Clock
/*------------------------------------------------
  Initialize
--------------------------------------------------*/
void OnInit(HWND hDlg)
{
	ColorBox colors[2];
	HWND quality_cb = GetDlgItem(hDlg, IDC_FONTQUAL);
	HDC hdc;
	LOGFONT logfont;
	HFONT hfont;
	m_transition=-1; // start transition lock
	// setting of "background" and "text"
	colors[0].hwnd = GetDlgItem(hDlg, IDC_COLFORE);
	colors[0].color = api.GetInt(L"Clock",L"ForeColor",TCOLOR(TCOLOR_DEFAULT));
	colors[1].hwnd = GetDlgItem(hDlg, IDC_COLBACK);
	colors[1].color = api.GetInt(L"Clock",L"BackColor",TCOLOR(TCOLOR_DEFAULT));
	ColorBox_Setup(colors, 2);
	
	// if color depth is 256 or less
	hdc = CreateICA("DISPLAY", NULL, NULL, NULL);
	if(GetDeviceCaps(hdc, BITSPIXEL) <= 8) {
		EnableDlgItem(hDlg, IDC_COLFORE_BTN, FALSE);
		EnableDlgItem(hDlg, IDC_COLBACK_BTN, FALSE);
	}
	DeleteDC(hdc);
	
	InitComboFont(hDlg);
	
	SetComboFontSize(hDlg, TRUE);
	
	
	CheckDlgButton(hDlg, IDC_BOLD, api.GetInt(L"Clock", L"Bold", 0));
	CheckDlgButton(hDlg, IDC_ITALIC, api.GetInt(L"Clock", L"Italic", 0));
	
	hfont = (HFONT)SendMessage(hDlg, WM_GETFONT, 0, 0);
	GetObject(hfont, sizeof(LOGFONT), &logfont);
	logfont.lfWeight = FW_BOLD;
	hfont = CreateFontIndirect(&logfont);
	SendDlgItemMessage(hDlg, IDC_BOLD, WM_SETFONT, (WPARAM)hfont, 0);
	
	logfont.lfWeight = FW_NORMAL;
	logfont.lfItalic = 1;
	hfont = CreateFontIndirect(&logfont);
	SendDlgItemMessage(hDlg, IDC_ITALIC, WM_SETFONT, (WPARAM)hfont, 0);
	
	SendDlgItemMessage(hDlg, IDC_SPINCHEIGHT, UDM_SETRANGE32, (WPARAM)-999,999);
	SendDlgItemMessage(hDlg, IDC_SPINCHEIGHT, UDM_SETPOS32, 0, api.GetInt(L"Clock", L"ClockHeight", 0));
	
	SendDlgItemMessage(hDlg, IDC_SPINCWIDTH, UDM_SETRANGE32, (WPARAM)-999,999);
	SendDlgItemMessage(hDlg, IDC_SPINCWIDTH, UDM_SETPOS32, 0, api.GetInt(L"Clock", L"ClockWidth", 0));
	
	SendDlgItemMessage(hDlg, IDC_SPINLHEIGHT, UDM_SETRANGE32, (WPARAM)-64,64);
	SendDlgItemMessage(hDlg, IDC_SPINLHEIGHT, UDM_SETPOS32, 0, api.GetInt(L"Clock", L"LineHeight", 0));
	
	SendDlgItemMessage(hDlg, IDC_SPINVPOS, UDM_SETRANGE32, (WPARAM)-200,200);
	SendDlgItemMessage(hDlg, IDC_SPINVPOS, UDM_SETPOS32, 0, api.GetInt(L"Clock", L"VertPos", 0));
	
	SendDlgItemMessage(hDlg, IDC_SPINHPOS, UDM_SETRANGE32, (WPARAM)-200,200);
	SendDlgItemMessage(hDlg, IDC_SPINHPOS, UDM_SETPOS32, 0, api.GetInt(L"Clock", L"HorizPos", 0));
	
	SendDlgItemMessage(hDlg, IDC_SPINANGLE, UDM_SETRANGE32, (WPARAM)-360,360);
	SendDlgItemMessage(hDlg, IDC_SPINANGLE, UDM_SETPOS32, 0, api.GetInt(L"Clock", L"Angle", 0));
	
	SendDlgItemMessage(hDlg, IDC_SPINALPHA, UDM_SETRANGE32, 0,100);
	SendDlgItemMessage(hDlg, IDC_SPINALPHA, UDM_SETPOS32, 0, api.GetInt(L"Taskbar", L"AlphaTaskbar", 0));
	
	ComboBox_AddString(quality_cb, L"Default");            // 0 = DEFAULT_QUALITY
	ComboBox_AddString(quality_cb, L"Draft");              // 1 = DRAFT_QUALITY
	ComboBox_AddString(quality_cb, L"Proof");              // 2 = PROOF_QUALITY
	ComboBox_AddString(quality_cb, L"NonAntiAliased");     // 3 = NONANTIALIASED_QUALITY
	ComboBox_AddString(quality_cb, L"AntiAliased (Win7)"); // 4 = ANTIALIASED_QUALITY
	ComboBox_AddString(quality_cb, L"ClearType (WinXP+)"); // 5 = CLEARTYPE_QUALITY
	ComboBox_AddString(quality_cb, L"ClearType Natural");  // 6 = CLEARTYPE_NATURAL_QUALITY
	ComboBox_SetCurSel(quality_cb,api.GetInt(L"Clock",L"FontQuality",CLEARTYPE_QUALITY));
	m_transition=0; // end transition lock, ready to go
}