예제 #1
0
파일: palette.cpp 프로젝트: CyberShadow/FAR
palette::palette():
	SizeArrayPalette(ARRAYSIZE(Init)),
	CurrentPalette(CurrentPaletteData),
	DefaultPalette(DefaultPaletteData),
	BlackPalette(BlackPaletteData),
	PaletteChanged(false)
{
	for(size_t i = 0; i < SizeArrayPalette; ++i)
	{
		Colors::ConsoleColorToFarColor(Init[i].DefaultIndex, DefaultPalette[i]);
		Colors::ConsoleColorToFarColor(Init[i].MonoIndex, BlackPalette[i]);
	}
	MAKE_TRANSPARENT(DefaultPalette[COL_PANELTEXT-COL_FIRSTPALETTECOLOR].BackgroundColor);
	MAKE_TRANSPARENT(DefaultPalette[COL_PANELSELECTEDTEXT-COL_FIRSTPALETTECOLOR].BackgroundColor);
	memcpy(CurrentPalette, DefaultPalette, SizeArrayPalette*sizeof(FarColor));
}
예제 #2
0
static void ApplyDefaultStartingColors(HighlightDataColor *Colors)
{
	for (int j=0; j<2; j++)
		for (int i=0; i<4; i++)
		{
			MAKE_OPAQUE(Colors->Color[j][i].ForegroundColor);
			MAKE_TRANSPARENT(Colors->Color[j][i].BackgroundColor);
		}

	Colors->MarkChar=0x00FF0000;
}
예제 #3
0
intptr_t WINAPI FileFilterConfigDlgProc(HANDLE hDlg,intptr_t Msg,intptr_t Param1,void* Param2)
{
    switch (Msg)
    {
    case DN_INITDIALOG:
    {
        FilterDlgRelativeDateItemsUpdate(hDlg, false);
        return TRUE;
    }
    case DN_BTNCLICK:
    {
        if (Param1==ID_FF_CURRENT || Param1==ID_FF_BLANK) //Current и Blank
        {
            FILETIME ft;
            string strDate, strTime;

            if (Param1==ID_FF_CURRENT)
            {
                GetSystemTimeAsFileTime(&ft);
                ConvertDate(ft,strDate,strTime,12,FALSE,FALSE,2);
            }
            else
            {
                strDate.Clear();
                strTime.Clear();
            }

            SendDlgMessage(hDlg,DM_ENABLEREDRAW,FALSE,0);
            int relative = (int)SendDlgMessage(hDlg,DM_GETCHECK,ID_FF_DATERELATIVE,0);
            int db = relative ? ID_FF_DAYSBEFOREEDIT : ID_FF_DATEBEFOREEDIT;
            int da = relative ? ID_FF_DAYSAFTEREDIT  : ID_FF_DATEAFTEREDIT;
            SendDlgMessage(hDlg,DM_SETTEXTPTR,da,const_cast<wchar_t*>(strDate.CPtr()));
            SendDlgMessage(hDlg,DM_SETTEXTPTR,ID_FF_TIMEAFTEREDIT,const_cast<wchar_t*>(strTime.CPtr()));
            SendDlgMessage(hDlg,DM_SETTEXTPTR,db,const_cast<wchar_t*>(strDate.CPtr()));
            SendDlgMessage(hDlg,DM_SETTEXTPTR,ID_FF_TIMEBEFOREEDIT,const_cast<wchar_t*>(strTime.CPtr()));
            SendDlgMessage(hDlg,DM_SETFOCUS,da,0);
            COORD r;
            r.X=r.Y=0;
            SendDlgMessage(hDlg,DM_SETCURSORPOS,da,&r);
            SendDlgMessage(hDlg,DM_ENABLEREDRAW,TRUE,0);
            break;
        }
        else if (Param1==ID_FF_RESET) // Reset
        {
            SendDlgMessage(hDlg,DM_ENABLEREDRAW,FALSE,0);
            intptr_t ColorConfig = SendDlgMessage(hDlg, DM_GETDLGDATA, 0, 0);
            SendDlgMessage(hDlg,DM_SETTEXTPTR,ID_FF_MASKEDIT,const_cast<wchar_t*>(L"*"));
            SendDlgMessage(hDlg,DM_SETTEXTPTR,ID_FF_SIZEFROMEDIT,nullptr);
            SendDlgMessage(hDlg,DM_SETTEXTPTR,ID_FF_SIZETOEDIT,nullptr);

            for (int I=ID_FF_READONLY; I <= ID_FF_VIRTUAL; ++I)
            {
                SendDlgMessage(hDlg,DM_SETCHECK,I,ToPtr(BSTATE_3STATE));
            }

            if (!ColorConfig)
                SendDlgMessage(hDlg,DM_SETCHECK,ID_FF_DIRECTORY,ToPtr(BSTATE_UNCHECKED));

            FarListPos LPos= {sizeof(FarListPos)};
            SendDlgMessage(hDlg,DM_LISTSETCURPOS,ID_FF_DATETYPE,&LPos);
            SendDlgMessage(hDlg,DM_SETCHECK,ID_FF_MATCHMASK,ToPtr(BSTATE_CHECKED));
            SendDlgMessage(hDlg,DM_SETCHECK,ID_FF_MATCHSIZE,ToPtr(BSTATE_UNCHECKED));
            SendDlgMessage(hDlg,DM_SETCHECK,ID_FF_HARDLINKS,ToPtr(BSTATE_UNCHECKED));
            SendDlgMessage(hDlg,DM_SETCHECK,ID_FF_MATCHDATE,ToPtr(BSTATE_UNCHECKED));
            SendDlgMessage(hDlg,DM_SETCHECK,ID_FF_DATERELATIVE,ToPtr(BSTATE_UNCHECKED));
            FilterDlgRelativeDateItemsUpdate(hDlg, true);
            SendDlgMessage(hDlg,DM_SETCHECK,ID_FF_MATCHATTRIBUTES,ToPtr(ColorConfig?BSTATE_UNCHECKED:BSTATE_CHECKED));
            SendDlgMessage(hDlg,DM_ENABLEREDRAW,TRUE,0);
            break;
        }
        else if (Param1==ID_FF_MAKETRANSPARENT)
        {
            HighlightDataColor *Colors = (HighlightDataColor *) SendDlgMessage(hDlg, DM_GETDLGDATA, 0, 0);

            for (int i=0; i<2; i++)
                for (int j=0; j<4; j++)
                {
                    MAKE_TRANSPARENT(Colors->Color[i][j].ForegroundColor);
                    MAKE_TRANSPARENT(Colors->Color[i][j].BackgroundColor);
                }

            SendDlgMessage(hDlg,DM_SETCHECK,ID_HER_MARKTRANSPARENT,ToPtr(BSTATE_CHECKED));
            break;
        }
        else if (Param1==ID_FF_DATERELATIVE)
        {
            FilterDlgRelativeDateItemsUpdate(hDlg, true);
            break;
        }
    }
    case DN_CONTROLINPUT:

        if ((Msg==DN_BTNCLICK && Param1 >= ID_HER_NORMALFILE && Param1 <= ID_HER_SELECTEDCURSORMARKING)
                || (Msg==DN_CONTROLINPUT && Param1==ID_HER_COLOREXAMPLE && ((INPUT_RECORD *)Param2)->EventType == MOUSE_EVENT && ((INPUT_RECORD *)Param2)->Event.MouseEvent.dwButtonState==FROM_LEFT_1ST_BUTTON_PRESSED))
        {
            HighlightDataColor *EditData = (HighlightDataColor *) SendDlgMessage(hDlg, DM_GETDLGDATA, 0, 0);

            if (Msg==DN_CONTROLINPUT)
            {
                Param1 = ID_HER_NORMALFILE + ((INPUT_RECORD *)Param2)->Event.MouseEvent.dwMousePosition.Y*2;

                if (((INPUT_RECORD *)Param2)->Event.MouseEvent.dwMousePosition.X==1 && (EditData->MarkChar&0x0000FFFF))
                    Param1 = ID_HER_NORMALMARKING + ((INPUT_RECORD *)Param2)->Event.MouseEvent.dwMousePosition.Y*2;
            }

            //Color[0=file, 1=mark][0=normal,1=selected,2=undercursor,3=selectedundercursor]
            FarColor Color=EditData->Color[(Param1-ID_HER_NORMALFILE)&1][(Param1-ID_HER_NORMALFILE)/2];
            Global->Console->GetColorDialog(Color,true,true);
            EditData->Color[(Param1-ID_HER_NORMALFILE)&1][(Param1-ID_HER_NORMALFILE)/2]=Color;

            size_t Size = SendDlgMessage(hDlg,DM_GETDLGITEM,ID_HER_COLOREXAMPLE,0);
            FarGetDialogItem gdi = {sizeof(FarGetDialogItem), Size, static_cast<FarDialogItem*>(xf_malloc(Size))};
            SendDlgMessage(hDlg,DM_GETDLGITEM,ID_HER_COLOREXAMPLE,&gdi);
            //MarkChar это FIXEDIT размером в 1 символ
            wchar_t MarkChar[2];
            FarDialogItemData item= {sizeof(FarDialogItemData),1,MarkChar};
            SendDlgMessage(hDlg,DM_GETTEXT,ID_HER_MARKEDIT,&item);
            EditData->MarkChar=*MarkChar;
            HighlightDlgUpdateUserControl(gdi.Item->VBuf,*EditData);
            SendDlgMessage(hDlg,DM_SETDLGITEM,ID_HER_COLOREXAMPLE,gdi.Item);
            xf_free(gdi.Item);
            return TRUE;
        }

        break;
    case DN_EDITCHANGE:

        if (Param1 == ID_HER_MARKEDIT)
        {
            HighlightDataColor *EditData = (HighlightDataColor *) SendDlgMessage(hDlg, DM_GETDLGDATA, 0, 0);
            size_t Size = SendDlgMessage(hDlg,DM_GETDLGITEM,ID_HER_COLOREXAMPLE,0);
            FarGetDialogItem gdi = {sizeof(FarGetDialogItem), Size, static_cast<FarDialogItem*>(xf_malloc(Size))};
            SendDlgMessage(hDlg,DM_GETDLGITEM,ID_HER_COLOREXAMPLE,&gdi);
            //MarkChar это FIXEDIT размером в 1 символ
            wchar_t MarkChar[2];
            FarDialogItemData item= {sizeof(FarDialogItemData),1,MarkChar};
            SendDlgMessage(hDlg,DM_GETTEXT,ID_HER_MARKEDIT,&item);
            EditData->MarkChar=*MarkChar;
            HighlightDlgUpdateUserControl(gdi.Item->VBuf,*EditData);
            SendDlgMessage(hDlg,DM_SETDLGITEM,ID_HER_COLOREXAMPLE,gdi.Item);
            xf_free(gdi.Item);
            return TRUE;
        }

        break;
    case DN_CLOSE:

        if (Param1 == ID_FF_OK && SendDlgMessage(hDlg,DM_GETCHECK,ID_FF_MATCHSIZE,0))
        {
            string strTemp;
            FarDialogItemData item = {sizeof(FarDialogItemData)};
            item.PtrLength = SendDlgMessage(hDlg,DM_GETTEXT,ID_FF_SIZEFROMEDIT,0);
            item.PtrData = strTemp.GetBuffer(item.PtrLength+1);
            SendDlgMessage(hDlg,DM_GETTEXT,ID_FF_SIZEFROMEDIT,&item);
            bool bTemp = !*item.PtrData || CheckFileSizeStringFormat(item.PtrData);
            item.PtrLength = SendDlgMessage(hDlg,DM_GETTEXT,ID_FF_SIZETOEDIT,0);
            item.PtrData = strTemp.GetBuffer(item.PtrLength+1);
            SendDlgMessage(hDlg,DM_GETTEXT,ID_FF_SIZETOEDIT,&item);
            bTemp = bTemp && (!*item.PtrData || CheckFileSizeStringFormat(item.PtrData));

            if (!bTemp)
            {
                intptr_t ColorConfig = SendDlgMessage(hDlg, DM_GETDLGDATA, 0, 0);
                Message(MSG_WARNING,1,ColorConfig?MSG(MFileHilightTitle):MSG(MFileFilterTitle),MSG(MBadFileSizeFormat),MSG(MOk));
                return FALSE;
            }
        }

        break;
    default:
        break;
    }

    return DefDlgProc(hDlg,Msg,Param1,Param2);
}
예제 #4
0
AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstStart)
:
	QDialog(parent),
	ui(new Ui::AboutDialog),
	m_settings(settings),
	m_initFlags(new QMap<QWidget*,bool>),
	m_disque(NULL),
	m_disqueTimer(NULL),
	m_rotateNext(false),
	m_lastTab(0)
{
	//Init the dialog, from the .ui file
	ui->setupUi(this);
	setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
	resize(this->minimumSize());
	
	//Disable "X" button
	if(firstStart)
	{
		MUtils::GUI::enable_close_button(this, false);
	}

	//Init images
	for(int i = 0; i < 4; i++)
	{
		m_cartoon[i] = NULL;
	}

	//Init tab widget
	connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));

	//Make transparent
	const type_info &styleType = typeid(*qApp->style());
	if((typeid(QWindowsVistaStyle) == styleType) || (typeid(QWindowsXPStyle) == styleType))
	{
		MAKE_TRANSPARENT(ui->infoScrollArea);
		MAKE_TRANSPARENT(ui->contributorsScrollArea);
		MAKE_TRANSPARENT(ui->softwareScrollArea);
		MAKE_TRANSPARENT(ui->licenseScrollArea);
	}

	//Show about dialog for the first time?
	if(!firstStart)
	{
		ui->acceptButton->hide();
		ui->declineButton->hide();
		ui->aboutQtButton->show();
		ui->closeButton->show();

		QPixmap disque(":/images/Disque.png");
		m_disque = new QLabel(this, Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
		m_disque->resize(disque.size());
		m_disque->setStyleSheet("background:transparent;");
		m_disque->setAttribute(Qt::WA_TranslucentBackground);
		m_disque->setPixmap(disque);
		m_disque->setCursor(QCursor(Qt::PointingHandCursor));
		m_disque->installEventFilter(this);

		connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), this, SLOT(geometryUpdated()));
		geometryUpdated();

		m_discOpacity = 0.01;
		m_disquePos.setX(static_cast<int>(MUtils::next_rand_u32() % static_cast<unsigned int>(m_disqueBound.right()  - disque.width()  - m_disqueBound.left())) + m_disqueBound.left());
		m_disquePos.setY(static_cast<int>(MUtils::next_rand_u32() % static_cast<unsigned int>(m_disqueBound.bottom() - disque.height() - m_disqueBound.top()))  + m_disqueBound.top());
		m_disqueFlags[0] = (MUtils::next_rand_u32() > (UINT_MAX/2));
		m_disqueFlags[1] = (MUtils::next_rand_u32() > (UINT_MAX/2));
		m_disque->move(m_disquePos);
		m_disque->setWindowOpacity(m_discOpacity);
		m_disque->show();

		m_disqueTimer = new QTimer;
		connect(m_disqueTimer, SIGNAL(timeout()), this, SLOT(moveDisque()));
		m_disqueTimer->start(10);

		connect(ui->aboutQtButton, SIGNAL(clicked()), this, SLOT(showAboutQt()));
	}
예제 #5
0
static void SetHighlighting(bool DeleteOld = false, HierarchicalConfig *ExternCfg = nullptr)
{
	unsigned __int64 root;
	HierarchicalConfig *cfg = ExternCfg?ExternCfg:CreateHighlightConfig();

	if (DeleteOld)
	{
		root = cfg->GetKeyID(0, HighlightKeyName);
		if (root)
			cfg->DeleteKeyTree(root);
	}

	if (!cfg->GetKeyID(0, HighlightKeyName))
	{
		root = cfg->CreateKey(0,HighlightKeyName);
		if (root)
		{
			static const wchar_t *Masks[]=
			{
				/* 0 */ L"*.*",
				/* 1 */ L"<arc>",
				/* 2 */ L"<temp>",
				/* $ 25.09.2001  IS
					Эта маска для каталогов: обрабатывать все каталоги, кроме тех, что
					являются родительскими (их имена - две точки).
				*/
				/* 3 */ L"*.*|..", // маска для каталогов
				/* 4 */ L"..",     // такие каталоги окрашивать как простые файлы
				/* 5 */ L"<exec>",
			};
			static struct DefaultData
			{
				const wchar_t *Mask;
				int IgnoreMask;
				DWORD IncludeAttr;
				BYTE InitNC;
				BYTE InitCC;
				FarColor NormalColor;
				FarColor CursorColor;
			}


			StdHighlightData[]=
			{
				/* 0 */{Masks[0], 0, 0x0002, 0x13, 0x38},
				/* 1 */{Masks[0], 0, 0x0004, 0x13, 0x38},
				/* 2 */{Masks[3], 0, 0x0010, 0x1F, 0x3F},
				/* 3 */{Masks[4], 0, 0x0010, 0x00, 0x00},
				/* 4 */{Masks[5], 0, 0x0000, 0x1A, 0x3A},
				/* 5 */{Masks[1], 0, 0x0000, 0x1D, 0x3D},
				/* 6 */{Masks[2], 0, 0x0000, 0x16, 0x36},
				// это настройка для каталогов на тех панелях, которые должны раскрашиваться
				// без учета масок (например, список хостов в "far navigator")
				/* 7 */{Masks[0], 1, 0x0010, 0x1F, 0x3F},
			};

			for (size_t I=0; I < ARRAYSIZE(StdHighlightData); I++)
			{
				Colors::ConsoleColorToFarColor(StdHighlightData[I].InitNC, StdHighlightData[I].NormalColor);
				MAKE_TRANSPARENT(StdHighlightData[I].NormalColor.BackgroundColor);
				Colors::ConsoleColorToFarColor(StdHighlightData[I].InitCC, StdHighlightData[I].CursorColor);
				MAKE_TRANSPARENT(StdHighlightData[I].CursorColor.BackgroundColor);

				unsigned __int64 key = cfg->CreateKey(root, FormatString() << L"Group" << I);
				if (!key)
					break;
				cfg->SetValue(key,HLS.Mask,StdHighlightData[I].Mask);
				cfg->SetValue(key,HLS.IgnoreMask,StdHighlightData[I].IgnoreMask);
				cfg->SetValue(key,HLS.IncludeAttributes,StdHighlightData[I].IncludeAttr);

				cfg->SetValue(key,HLS.NormalColor, &StdHighlightData[I].NormalColor, sizeof(FarColor));
				cfg->SetValue(key,HLS.CursorColor, &StdHighlightData[I].CursorColor, sizeof(FarColor));

				const FarColor DefaultColor = {FCF_FG_4BIT|FCF_BG_4BIT, 0xff000000, 0x00000000};
				cfg->SetValue(key,HLS.SelectedColor, &DefaultColor, sizeof(FarColor));
				cfg->SetValue(key,HLS.SelectedCursorColor, &DefaultColor, sizeof(FarColor));
				cfg->SetValue(key,HLS.MarkCharNormalColor, &DefaultColor, sizeof(FarColor));
				cfg->SetValue(key,HLS.MarkCharSelectedColor, &DefaultColor, sizeof(FarColor));
				cfg->SetValue(key,HLS.MarkCharCursorColor, &DefaultColor, sizeof(FarColor));
				cfg->SetValue(key,HLS.MarkCharSelectedCursorColor, &DefaultColor, sizeof(FarColor));
			}
		}
	}

	if (cfg!=ExternCfg)
	{
		delete cfg;
	}
}