Ejemplo n.º 1
0
void  widgets::update_record_in_the_tree(
        async::key_type const&  key,
        async::cached_resource_info const&  old_info,
        async::cached_resource_info const&  new_info,
        bool const  is_just_being_loaded
        )
{
    TMPROF_BLOCK();

    QTreeWidgetItem*  data_type_node = nullptr;
    {
        auto const  items = findItems(QString(key.get_data_type_name().c_str()), Qt::MatchFlag::MatchExactly, 0);
        INVARIANT(items.size() == 1);
        data_type_node = items.front();
    }
    QTreeWidgetItem*  uid_node = nullptr;
    {
        std::string const  uid = get_tree_resource_uid(key);
        for (int i = 0, n = data_type_node->childCount(); i != n; ++i)
        {
            auto const  item = data_type_node->child(i);
            std::string const  item_name = qtgl::to_string(item->text(0));
            if (item_name == uid)
            {
                uid_node = item;
                break;
            }
        }
        INVARIANT(uid_node != nullptr);
    }

    uid_node->setIcon(0, *choose_icon(new_info.get_load_state(), is_just_being_loaded));
    if (qtgl::to_string(uid_node->text(0)) != key.get_unique_id())
    {
        std::string const  item_refs_name = qtgl::to_string(uid_node->text(1));
        int const  old_num_refs = std::atoi(item_refs_name.c_str());
        int const  new_num_refs = old_num_refs + ((int)new_info.get_ref_count() - (int)old_info.get_ref_count());
        uid_node->setText(1, QString(std::to_string(new_num_refs).c_str()));
    }
    else
    {
        uid_node->setText(1, QString(std::to_string(new_info.get_ref_count()).c_str()));
    }
    if (new_info.get_error_message().empty())
        uid_node->setToolTip(0, "");
    else
        uid_node->setToolTip(0, QString(new_info.get_error_message().c_str()));

    std::string const  item_refs_name = qtgl::to_string(data_type_node->text(1));
    int const  old_num_refs = std::atoi(item_refs_name.c_str());
    int const  new_num_refs = old_num_refs + ((int)new_info.get_ref_count() - (int)old_info.get_ref_count());
    data_type_node->setText(1, QString(std::to_string(new_num_refs).c_str()));
}
Ejemplo n.º 2
0
void config_read()
{
	char *p,*ip;

	GetModuleFileName(hMainInstance,ini_file,sizeof(ini_file));
	strcpy_s(text_file,sizeof(text_file),ini_file);
	p=ini_file+strlen(ini_file); ip=p;
	while (p >= ini_file && *p != '.') p--;
	strcpy_s(++p,ip-p+1,"ini");
	p=text_file+strlen(text_file); ip=p;
	while (p >= text_file && *p != '.') p--;
	strcpy_s(++p,ip-p+1,"rtf");
	RI(config_x);
	RI(config_y);
	RI(config_w);
	RI(config_h);
	RI(config_border);
	RI(config_color);
	RI(config_bcolor1);
	RI(config_bcolor2);
	RI(config_icon);
	choose_icon(config_icon);
}
Ejemplo n.º 3
0
static void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
	LOGFONT lf={0,};
	CHOOSEFONT cf={sizeof(cf),hwnd,0,&lf,0,
		CF_EFFECTS|CF_SCREENFONTS|CF_INITTOLOGFONTSTRUCT,
		0,};
	CHARFORMAT fmt={sizeof(fmt),};
	CHOOSECOLOR cs;

    switch (id)
	{
		case IDM_ABOUT:
			MessageBox(hwnd,"Sex v0.1\n"
				            "Copyright (C) 1998, Nullsoft Inc.","About sex",MB_OK);
		return;
		case IDM_PASTE:
            SendMessage(hwnd_rich, WM_PASTE, 0, 0);
		return;
		case IDM_COPY:
            SendMessage(hwnd_rich, WM_COPY, 0, 0);
        return;
		case IDM_CUT:
            SendMessage(hwnd_rich, WM_CUT, 0, 0);
        return;
		case IDM_CLOSE:
			SendMessage(hwnd,WM_CLOSE,0,0);
		return;
		case IDM_QUIT:
			DestroyWindow(hwnd);
		return;
		case IDM_FONT:
			{
				get_font (&lf, &fmt, &cf);
				
				if (ChooseFont(&cf))
				{
                    set_font (&lf, &fmt, &cf, FALSE, FALSE, FALSE, FALSE, FALSE);
				}
			}
		return;
		case IDM_BGCOLOR:
			{
				if (choose_color(&cs, hwnd))
				{
					config_color=cs.rgbResult;
					config_write();
					SendMessage(hwnd_rich,EM_SETBKGNDCOLOR,FALSE,config_color);
				}
			}
		return;
        case IDM_FGCOLOR:
            {
				get_font (&lf, &fmt, &cf);

				if (choose_color(&cs, hwnd))
				{
                    set_font (&lf, &fmt, &cf, FALSE, FALSE, FALSE, TRUE, cs.rgbResult);
                }
            }
		return;
        case IDM_UNDERLINE:
            {
				get_font (&lf, &fmt, &cf);

                set_font (&lf, &fmt, &cf, FALSE, FALSE, TRUE, FALSE, 0);
            }
		return;
        case IDM_ITALIC:
            {
				get_font (&lf, &fmt, &cf);

                set_font (&lf, &fmt, &cf, FALSE, TRUE, FALSE, FALSE, 0);
            }
		return;
        case IDM_BOLD:
            {
				get_font (&lf, &fmt, &cf);

                set_font (&lf, &fmt, &cf, TRUE, FALSE, FALSE, FALSE, 0);
            }
		return;
        case IDM_WORDWRAP:
            {
                if (word_wrap)
                {
                    ModifyStyle(hwnd_rich, 0 ,WS_HSCROLL|ES_AUTOHSCROLL,  0 );
                    word_wrap = 0;
                }
                else
                {
                    ModifyStyle(hwnd_rich, WS_HSCROLL|ES_AUTOHSCROLL, 0 , 0 );
                    word_wrap = 1;
                }
            }
		return;
        case IDM_REDL:
            {
                if (config_icon != 1)
                {
					choose_icon(1);
					change_icon(hwnd);
                }
            }
		return;
        case IDM_BLUEL:
            {
                if (config_icon != 2)
                {
					choose_icon(2);
					change_icon(hwnd);
                }
            }
		return;
        case IDM_BLACKL:
            {
                if (config_icon != 3)
                {
					choose_icon(3);
					change_icon(hwnd);
                }
            }
		return;
        case IDM_BLUER:
            {
                if (config_icon != 4)
                {
					choose_icon(4);
					change_icon(hwnd);
                }
            }
		return;
    }
}
Ejemplo n.º 4
0
void  widgets::insert_record_to_the_tree(
        async::key_type const&  key,
        async::cached_resource_info const&  info,
        bool const  is_just_being_loaded
        )
{
    TMPROF_BLOCK();

    QTreeWidgetItem*  data_type_node = nullptr;
    {
        auto const  items = findItems(QString(key.get_data_type_name().c_str()), Qt::MatchFlag::MatchExactly, 0);
        if (items.empty())
        {
            std::unique_ptr<QTreeWidgetItem>  tree_node(new QTreeWidgetItem);
            tree_node->setText(0, QString(key.get_data_type_name().c_str()));
            tree_node->setIcon(0, m_icon_data_type);
            tree_node->setText(1, QString("0"));
            addTopLevelItem(tree_node.get());
            data_type_node = tree_node.release();
        }
        else
        {
            INVARIANT(items.size() == 1);
            data_type_node = items.front();
        }
    }
    QTreeWidgetItem*  uid_node = nullptr;
    {
        std::string const  uid = get_tree_resource_uid(key);
        for (int i = 0, n = data_type_node->childCount(); i != n; ++i)
        {
            auto const  item = data_type_node->child(i);
            std::string const  item_name = qtgl::to_string(item->text(0));
            if (item_name == uid)
            {
                uid_node = item;
                break;
            }
        }
    }
    if (uid_node == nullptr)
    {
        std::unique_ptr<QTreeWidgetItem>  tree_node(new QTreeWidgetItem);
        tree_node->setText(0, QString(get_tree_resource_uid(key).c_str()));
        tree_node->setText(1, QString(std::to_string(info.get_ref_count()).c_str()));
        data_type_node->addChild(tree_node.get());
        uid_node = tree_node.release();
    }
    else
    {
        std::string const  item_refs_name = qtgl::to_string(uid_node->text(1));
        int const  old_num_refs = std::atoi(item_refs_name.c_str());
        uid_node->setText(1, QString(std::to_string(old_num_refs + info.get_ref_count()).c_str()));
    }
    uid_node->setIcon(0, *choose_icon(info.get_load_state(), is_just_being_loaded));
    if (info.get_error_message().empty())
        uid_node->setToolTip(0, "");
    else
        uid_node->setToolTip(0, QString(info.get_error_message().c_str()));

    std::string const  item_refs_name = qtgl::to_string(data_type_node->text(1));
    int const  old_num_refs = std::atoi(item_refs_name.c_str());
    data_type_node->setText(1, QString(std::to_string(old_num_refs + info.get_ref_count()).c_str()));
}