/* SwitchesEntryPanel::moveUp
 * Moves all selected animations up
 *******************************************************************/
void SwitchesEntryPanel::moveUp()
{
	// Get selected animations
	wxArrayInt selection = list_entries->selectedItems();

	// Do nothing if nothing is selected or if the
	// first selected item is at the top of the list
	if (selection.size() == 0 || selection[0] == 0)
		return;

	list_entries->enableSizeUpdate(false);

	// Go through selection
	for (unsigned a = 0; a < selection.size(); a++)
	{
		// Swap selected animation with the one above it
		switches.swapEntries(selection[a], selection[a] - 1);
		updateListItem(switches.getEntry(selection[a]), selection[a]);
		updateListItem(switches.getEntry(selection[a]-1), selection[a]-1);
	}

	// Update selection
	list_entries->clearSelection();
	for (unsigned a = 0; a < selection.size(); a++)
		list_entries->selectItem(selection[a] - 1);

	// Refresh
	list_entries->enableSizeUpdate(true);
	list_entries->EnsureVisible(selection[0] - 4);

	// Update variables
	setModified(true);
}
/* SwitchesEntryPanel::moveDown
 * Moves all selected animations down
 *******************************************************************/
void SwitchesEntryPanel::moveDown()
{
	// Get selected animations
	wxArrayInt selection = list_entries->selectedItems();

	// Do nothing if nothing is selected or if the
	// last selected item is at the end of the list
	if (selection.size() == 0 || selection.back() == list_entries->GetItemCount()-1)
		return;

	list_entries->enableSizeUpdate(false);

	// Go through selection backwards
	for (int a = selection.size()-1; a >= 0; a--)
	{
		// Swap selected animation with the one below it
		switches.swapEntries(selection[a], selection[a] + 1);
		updateListItem(switches.getEntry(selection[a]), selection[a]);
		updateListItem(switches.getEntry(selection[a]+1), selection[a]+1);
	}

	// Update selection
	list_entries->clearSelection();
	for (unsigned a = 0; a < selection.size(); a++)
		list_entries->selectItem(selection[a] + 1);

	// Refresh
	list_entries->enableSizeUpdate(true);
	list_entries->EnsureVisible(selection[selection.size() - 1] + 3);

	// Update variables
	setModified(true);
}
/* SwitchesEntryPanel::applyChanges
 * Saves changes to list
 *******************************************************************/
void SwitchesEntryPanel::applyChanges()
{
	if (se_current == NULL)
		return;

	list_entries->enableSizeUpdate(false);

	se_current->setOff(text_offname->GetValue());
	se_current->setOn(text_onname->GetValue());
	if (rbtn_shareware->GetValue())
		se_current->setType(SWCH_DEMO);
	else if (rbtn_registered->GetValue())
		se_current->setType(SWCH_FULL);
	else if (rbtn_commercial->GetValue())
		se_current->setType(SWCH_COMM);
	else se_current->setType(SWCH_STOP);

	// Find entry
	for (uint32_t a = 0; a < switches.nEntries(); a++)
	{
		if (switches.getEntry(a) == se_current)
		{
			if (se_current->getStatus() == LV_STATUS_NORMAL)
			{
				se_current->setStatus(LV_STATUS_MODIFIED);
			}
			updateListItem(se_current, a);
			break;
		}
	}
	setModified(true);
	list_entries->enableSizeUpdate(true);
}
/* TranslationEditorDialog::onRBColourSelected
 * Called when the 'colour gradient' translation type radio button is
 * selected
 *******************************************************************/
void TranslationEditorDialog::onRBColourSelected(wxCommandEvent& e)
{
	// Swap to target colour panel
	showGradientTarget();

	// If a range is selected
	int index = list_translations->GetSelection();
	if (index >= 0)
	{
		// Remove it
		translation.removeRange(index);

		// Recreate it
		translation.addRange(TRANS_COLOUR, index);
		TransRangeColour* tr = (TransRangeColour*)translation.getRange(index);
		// Origin range
		tr->setOStart(pal_canvas_original->getSelectionStart());
		tr->setOEnd(pal_canvas_original->getSelectionEnd());
		// Target colour gradient
		wxColour sc = cp_range_begin->GetColour();
		wxColour ec = cp_range_end->GetColour();
		tr->setDStart(rgba_t(sc.Red(), sc.Green(), sc.Blue()));
		tr->setDEnd(rgba_t(ec.Red(), ec.Green(), ec.Blue()));

		// Update UI
		updateListItem(index);
		openRange(index);
		updatePreviews();
	}
}
/* AnimatedEntryPanel::applyChanges
 * Saves changes to list
 *******************************************************************/
void AnimatedEntryPanel::applyChanges()
{
	if (ae_current == NULL)
		return;

	list_entries->enableSizeUpdate(false);

	ae_current->setFirst(text_firstname->GetValue());
	ae_current->setLast(text_lastname->GetValue());
	long val;
	if (text_speed->GetValue().ToLong(&val))
		ae_current->setSpeed((uint32_t) val);
	if (rbtn_texture->GetValue())
		ae_current->setType(1);
	else ae_current->setType(0);
	ae_current->setDecals(cbox_decals->GetValue());
	if (cbox_swirl->GetValue())
		ae_current->setSpeed(65536);

	// Find entry
	for (uint32_t a = 0; a < animated.nEntries(); a++)
	{
		if (animated.getEntry(a) == ae_current)
		{
			if (ae_current->getStatus() == LV_STATUS_NORMAL)
			{
				ae_current->setStatus(LV_STATUS_MODIFIED);
			}
			updateListItem(ae_current, a);
			break;
		}
	}
	list_entries->enableSizeUpdate(true);
}
/* TranslationEditorDialog::onPalTargetLeftUp
 * Called when the left mouse button is released in the target
 * palette range canvas
 *******************************************************************/
void TranslationEditorDialog::onPalTargetLeftUp(wxMouseEvent& e)
{
	// Get current translation range
	TransRange* tr = translation.getRange(list_translations->GetSelection());

	// Update its target range if it's a palette translation
	if (tr && tr->getType() == TRANS_PALETTE)
	{
		TransRangePalette* tpr = (TransRangePalette*)tr;
		if (cb_target_reverse->GetValue())
		{
			tpr->setDEnd(pal_canvas_target->getSelectionStart());
			tpr->setDStart(pal_canvas_target->getSelectionEnd());
		}
		else
		{
			tpr->setDStart(pal_canvas_target->getSelectionStart());
			tpr->setDEnd(pal_canvas_target->getSelectionEnd());
		}
	}

	// Update UI
	updateListItem(list_translations->GetSelection());
	updatePreviews();
}
/* TranslationEditorDialog::onRBDesaturateSelected
 * Called when the 'desaturated colour gradient' translation type
 * radio button is selected
 *******************************************************************/
void TranslationEditorDialog::onRBDesaturateSelected(wxCommandEvent& e)
{
	// Swap to target colour panel
	showGradientTarget();

	// If a range is selected
	int index = list_translations->GetSelection();
	if (index >= 0)
	{
		// Remove it
		translation.removeRange(index);

		// Recreate it
		translation.addRange(TRANS_DESAT, index);
		TransRangeDesat* tr = (TransRangeDesat*)translation.getRange(index);
		// Origin range
		tr->setOStart(pal_canvas_original->getSelectionStart());
		tr->setOEnd(pal_canvas_original->getSelectionEnd());
		// Target colour gradient
		wxColour sc = cp_range_begin->GetColour();
		wxColour ec = cp_range_end->GetColour();
		tr->setDStart(MathStuff::clamp(sc.Red() / 127.0f, 0, 2),
		              MathStuff::clamp(sc.Green() / 127.0f, 0, 2),
		              MathStuff::clamp(sc.Blue() / 127.0f, 0, 2));
		tr->setDEnd(MathStuff::clamp(ec.Red() / 127.0f, 0, 2),
		            MathStuff::clamp(ec.Green() / 127.0f, 0, 2),
		            MathStuff::clamp(ec.Blue() / 127.0f, 0, 2));

		// Update UI
		updateListItem(index);
		openRange(index);
		updatePreviews();
	}
}
LRESULT FulAdvancedPage::onClickedShortcuts(WORD /* wNotifyCode */, WORD wID, HWND /* hWndCtl */, BOOL& /* bHandled */) {
	if (wID == IDC_WEB_SHORTCUTS_ADD) {
		WebShortcut* ws;
		ws = new WebShortcut();
		WebShortcutsProperties wsp(wsList, ws);
		if (wsp.DoModal() == IDOK) {
			wsList.push_back(ws);
			addListItem(ws);
		} else {
			delete ws;
		}
	} else if (wID == IDC_WEB_SHORTCUTS_PROPERTIES) {
		if (ctrlWebShortcuts.GetSelectedCount() == 1) {
			int sel = ctrlWebShortcuts.GetSelectedIndex();
			WebShortcut* ws = wsList[sel];
			WebShortcutsProperties wsp(wsList, ws);
			if (wsp.DoModal() == IDOK) {
				updateListItem(sel);
			}
		}
	} else if (wID == IDC_WEB_SHORTCUTS_REMOVE) {
		if (ctrlWebShortcuts.GetSelectedCount() == 1) {
			int sel = ctrlWebShortcuts.GetSelectedIndex();
			dcassert(sel >= 0 && sel < (int)wsList.size());

			wsList.erase(find(wsList.begin(), wsList.end(), wsList[sel]));
			ctrlWebShortcuts.DeleteItem(sel);
		}
	}
	return S_OK;
}
Exemple #9
0
//This procedure uses _keyCombo as a temp. variable to store current settings which can then later be applied (by pressing OK)
void ScintillaKeyMap::applyToCurrentIndex() {
	int index = (int)::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_GETCURSEL, 0, 0);
	if(index == LB_ERR)
		return;
	setKeyComboByIndex(index, _keyCombo);
	updateListItem(index);
	::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_SETCURSEL, index, 0);

}
/* TranslationEditorDialog::onBtnDown
 * Called when the 'Move Down' button is clicked
 *******************************************************************/
void TranslationEditorDialog::onBtnDown(wxCommandEvent& e)
{
	// Get selection
	int index = list_translations->GetSelection();

	// Check selection is valid
	if (index >= (int)translation.nRanges()-1)
		return;

	// Swap item with above
	translation.swapRanges(index, index+1);
	updateListItem(index);
	updateListItem(index+1);

	// Update selection
	list_translations->SetSelection(index+1);
	openRange(index+1);

	// Update previews
	updatePreviews();
}
/* TranslationEditorDialog::onPalOriginLeftUp
 * Called when the left mouse button is released in the origin
 * palette range canvas
 *******************************************************************/
void TranslationEditorDialog::onPalOriginLeftUp(wxMouseEvent& e)
{
	// Get current translation range
	TransRange* tr = translation.getRange(list_translations->GetSelection());

	// Update its origin range
	if (tr)
	{
		tr->setOStart(pal_canvas_original->getSelectionStart());
		tr->setOEnd(pal_canvas_original->getSelectionEnd());
	}

	// Update UI
	updateListItem(list_translations->GetSelection());
	updatePreviews();
}
/* TranslationEditorDialog::onRBPaletteSelected
 * Called when the 'palette range' translation type radio button is
 * selected
 *******************************************************************/
void TranslationEditorDialog::onRBPaletteSelected(wxCommandEvent& e)
{
	// Swap to target palette panel
	showPaletteTarget();

	// If a range is selected
	int index = list_translations->GetSelection();
	if (index >= 0)
	{
		// Remove it
		translation.removeRange(index);

		// Recreate it
		translation.addRange(TRANS_PALETTE, index);
		TransRangePalette* tr = (TransRangePalette*)translation.getRange(index);
		// Origin range
		tr->setOStart(pal_canvas_original->getSelectionStart());
		tr->setOEnd(pal_canvas_original->getSelectionEnd());
		// Target range
		if (cb_target_reverse->GetValue())
		{
			tr->setDEnd(pal_canvas_target->getSelectionStart());
			tr->setDStart(pal_canvas_target->getSelectionEnd());
		}
		else
		{
			tr->setDStart(pal_canvas_target->getSelectionStart());
			tr->setDEnd(pal_canvas_target->getSelectionEnd());
		}

		// Update UI
		updateListItem(index);
		openRange(index);
		updatePreviews();
	}
}
/* TranslationEditorDialog::setEndColour
 * Sets the current translation range's destination ending colour
 * to [col]
 *******************************************************************/
void TranslationEditorDialog::setEndColour(rgba_t col)
{
	// Get currently selected translation range
	TransRange* tr = translation.getRange(list_translations->GetSelection());

	// Check its type
	if (tr->getType() == TRANS_COLOUR)
	{
		// Colour range
		TransRangeColour* tcr = (TransRangeColour*)tr;

		// Set destination end colour
		tcr->setDEnd(col);
	}
	else if (tr->getType() == TRANS_DESAT)
	{
		// Desaturated colour range
		TransRangeDesat* tdr = (TransRangeDesat*)tr;

		// Determine end colour
		float er = MathStuff::clamp(col.r / 127.0f, 0, 2);
		float eg = MathStuff::clamp(col.g / 127.0f, 0, 2);
		float eb = MathStuff::clamp(col.b / 127.0f, 0, 2);

		// Set destination end colour
		tdr->setDEnd(er, eg, eb);
	}

	// Set gradient box end colour
	gb_gradient->setEndCol(col);

	// Update UI
	gb_gradient->Refresh();
	updateListItem(list_translations->GetSelection());
	updatePreviews();
}
uint32 FolderWindow::onMessage(uint32 message, uint32 wParam, uint32 lParam)
{
    switch (message)
    {
    case WM_CONTEXTMENU:
    {
        POINT pt;
        GetCursorPos(&pt);

        int count = ListView_GetSelectedCount(list->getHandle());
        int item = ListView_GetNextItem(list->getHandle(), -1, LVNI_SELECTED);
        if (item >= 0)
        {
            int pos = list->getItemParam(item);
            while (count > 1 && item >= 0 && items[pos].type != ITEM_FOLDER &&
                    items[pos].type != ITEM_REPLAY)
            {
                item = ListView_GetNextItem(list->getHandle(), item, LVNI_SELECTED);
                pos = (item > 0 ? list->getItemParam(item) : -1);
            }

            EnableMenuItem(ctxMenu, ID_MENU_OPEN, count > 1 ? MF_GRAYED : MF_ENABLED);
            if (pos >= 0 && (items[pos].type == ITEM_FOLDER || items[pos].type == ITEM_REPLAY))
            {
                EnableMenuItem(ctxMenu, ID_MENU_BACKUP, MF_ENABLED);
                EnableMenuItem(ctxMenu, ID_MENU_COPY, MF_ENABLED);
                EnableMenuItem(ctxMenu, ID_MENU_DELETE, MF_ENABLED);
                EnableMenuItem(ctxMenu, ID_MENU_RENAME, count > 1 ? MF_GRAYED : MF_ENABLED);
            }
            else
            {
                EnableMenuItem(ctxMenu, ID_MENU_BACKUP, MF_GRAYED);
                EnableMenuItem(ctxMenu, ID_MENU_COPY, MF_GRAYED);
                EnableMenuItem(ctxMenu, ID_MENU_DELETE, MF_GRAYED);
                EnableMenuItem(ctxMenu, ID_MENU_RENAME, MF_GRAYED);
            }
        }
        else
        {
            EnableMenuItem(ctxMenu, ID_MENU_OPEN, MF_GRAYED);
            EnableMenuItem(ctxMenu, ID_MENU_BACKUP, MF_GRAYED);
            EnableMenuItem(ctxMenu, ID_MENU_COPY, MF_GRAYED);
            EnableMenuItem(ctxMenu, ID_MENU_DELETE, MF_GRAYED);
            EnableMenuItem(ctxMenu, ID_MENU_RENAME, MF_GRAYED);
        }
        ClipboardReader cbReader(CF_HDROP);
        EnableMenuItem(ctxMenu, ID_MENU_PASTE, cbReader.getData() ? MF_ENABLED : MF_GRAYED);

        int result = TrackPopupMenuEx(ctxMenu, TPM_HORIZONTAL | TPM_LEFTALIGN |
                                      TPM_RETURNCMD | TPM_NONOTIFY, pt.x, pt.y, list->getHandle(), NULL);

        switch (result)
        {
        case ID_MENU_OPEN:
        {
            NMITEMACTIVATE ia;
            memset(&ia, 0, sizeof ia);
            ia.hdr.code = LVN_ITEMACTIVATE;
            ia.hdr.hwndFrom = list->getHandle();
            ia.iItem = item;
            onMessage(WM_NOTIFY, 0, (uint32) &ia);
        }
        break;
        case ID_MENU_BACKUP:
        {
            BatchDialog batch(BatchDialog::mCopy);
            for (int item = ListView_GetNextItem(list->getHandle(), -1, LVNI_SELECTED);
                    item >= 0; item = ListView_GetNextItem(list->getHandle(), item, LVNI_SELECTED))
            {
                int pos = list->getItemParam(item);
                if (pos >= 0 && items[pos].type == ITEM_REPLAY)
                    batch.addReplay(items[pos].path);
                else if (pos >= 0 && items[pos].type == ITEM_FOLDER)
                    batch.addFolder(items[pos].path);
            }
            batch.run(list->getHandle());
        }
        break;
        case ID_MENU_COPY:
        case ID_MENU_PASTE:
        case ID_MENU_DELETE:
        case ID_MENU_RENAME:
        {
            NMLVKEYDOWN kd;
            memset(&kd, 0, sizeof kd);
            kd.hdr.code = LVN_KEYDOWN;
            kd.hdr.hwndFrom = list->getHandle();
            if (result == ID_MENU_COPY)
                kd.wVKey = 'C';
            else if (result == ID_MENU_PASTE)
                kd.wVKey = 'V';
            else if (result == ID_MENU_DELETE)
                kd.wVKey = VK_DELETE;
            else if (result == ID_MENU_RENAME)
                kd.wVKey = VK_F2;
            onMessage(WM_NOTIFY, VK_CONTROL, (uint32) &kd);
        }
        break;
        case ID_MENU_FOLDER:
        {
            String newdir = "New Folder";
            String fulldir = String::buildFullName(path, newdir);
            FileInfo fi;
            for (int num = 1; pathFileExists(fulldir); num++)
            {
                newdir = String::format("New Folder (%d)", num);
                fulldir = String::buildFullName(path, newdir);
            }
            if (CreateDirectory(fulldir, NULL))
            {
                int pos = list->addItem(newdir,
                                        getApp()->getImageLibrary()->getListIndex("IconClosedFolder"), items.length());
                ViewItem& item = items.push();
                item.path = fulldir;
                item.pos = pos;
                item.type = ITEM_FOLDER;
                ListView_EditLabel(list->getHandle(), pos);
            }
        }
        break;
        }
    }
    break;
    case WM_NOTIFY:
    {
        NMHDR* pnm = (NMHDR*) lParam;
        if (pnm->code == LVN_ITEMACTIVATE)
        {
            NMITEMACTIVATE* pia = (NMITEMACTIVATE*) pnm;
            int pos = -1;
            if (pia->iItem >= 0)
                pos = list->getItemParam(pia->iItem);
            if (pos >= 0 && pos < items.length())
            {
                if (items[pos].type == ITEM_UPFOLDER || items[pos].type == ITEM_FOLDER)
                    mainWnd->pushView(new FolderViewItem(items[pos].path));
                else if (items[pos].type == ITEM_REPLAY)
                    mainWnd->pushView(new ReplayViewItem(items[pos].path));
            }
        }
        else if (pnm->code == LVN_BEGINDRAG)
        {
            Array<String> sel;
            getSelList(sel);
            if (sel.length())
            {
                HGLOBAL data = CreateFileDrop(sel);
                if (data)
                {
                    selfDrag = true;
                    DoDragDrop(CF_HDROP, data, DROPEFFECT_MOVE | DROPEFFECT_COPY | DROPEFFECT_LINK);
                    selfDrag = false;
                }
            }
            return TRUE;
        }
        else if (pnm->code == LVN_BEGINLABELEDIT)
        {
            NMLVDISPINFO* di = (NMLVDISPINFO*) lParam;
            int pos = -1;
            if (di->item.iItem >= 0)
                pos = list->getItemParam(di->item.iItem);
            if (pos >= 0 && pos < items.length() &&
                    (items[pos].type == ITEM_FOLDER || items[pos].type == ITEM_REPLAY))
                return FALSE;
            return TRUE;
        }
        else if (pnm->code == LVN_ENDLABELEDIT)
        {
            NMLVDISPINFO* di = (NMLVDISPINFO*) lParam;
            int pos = -1;
            if (di->item.iItem >= 0)
                pos = list->getItemParam(di->item.iItem);
            if (di->item.pszText && pos >= 0 && pos < items.length() &&
                    (items[pos].type == ITEM_FOLDER || items[pos].type == ITEM_REPLAY))
            {
                String src = items[pos].path;
                String dst = String::buildFullName(String::getPath(src), di->item.pszText);
                src += '\0';
                if (items[pos].type == ITEM_REPLAY)
                    dst += ".w3g";
                dst += '\0';
                SHFILEOPSTRUCT op;
                memset(&op, 0, sizeof op);
                op.wFunc = FO_RENAME;
                op.pFrom = src;
                op.pTo = dst;
                if (SHFileOperationEx(&op) == 0)
                {
                    items[pos].path = String::buildFullName(String::getPath(items[pos].path), di->item.pszText);
                    if (items[pos].type == ITEM_REPLAY)
                        items[pos].path += ".w3g";
                    return TRUE;
                }
            }
            rebuild();
            return FALSE;
        }
        else if (pnm->code == LVN_COLUMNCLICK)
        {
            NMLISTVIEW* lv = (NMLISTVIEW*) lParam;
            bool colShow[colCount] = {true,
                                      cfg.selColumns & COL_SAVED,
                                      cfg.selColumns & COL_SIZE,
                                      cfg.selColumns & COL_NAME,
                                      cfg.selColumns & COL_RATIO,
                                      cfg.selColumns & COL_LENGTH,
                                      cfg.selColumns & COL_MODE
                                     };
            int col = lv->iSubItem;
            for (int i = 0; i < col && col < colCount - 1; i++)
                if (!colShow[i])
                    col++;
            int pos = 0;
            while (pos < colCount - 1 && cfg.colSort[pos] != col && cfg.colSort[pos] != ~col)
                pos++;
            if (pos == 0)
                cfg.colSort[0] = ~cfg.colSort[0];
            else
            {
                for (int i = pos; i > 0; i--)
                    cfg.colSort[i] = cfg.colSort[i - 1];
                cfg.colSort[0] = col;
            }
            rebuild();
        }
        else if (pnm->code == HDN_ENDDRAG)
            PostMessage(list->getHandle(), WM_POSTHEADERDRAG, 0, 0);
        else if (pnm->code == HDN_ENDTRACK)
        {
            NMHEADER* nhdr = (NMHEADER*) pnm;
            bool colShow[colCount] = {true,
                                      cfg.selColumns & COL_SAVED,
                                      cfg.selColumns & COL_SIZE,
                                      cfg.selColumns & COL_NAME,
                                      cfg.selColumns & COL_RATIO,
                                      cfg.selColumns & COL_LENGTH,
                                      cfg.selColumns & COL_MODE
                                     };
            int count = 0;
            int colUnpos[colCount];
            for (int i = 0; i < colCount; i++)
                if (colShow[i])
                    colUnpos[count++] = i;
            if (nhdr->iItem >= 0 && nhdr->iItem < count &&
                    nhdr->pitem && nhdr->pitem->mask & HDI_WIDTH)
            {
                int col = colUnpos[nhdr->iItem];
                cfg.colWidth[col] = nhdr->pitem->cxy;
            }
        }
        else if (pnm->code == LVN_KEYDOWN)
        {
            NMLVKEYDOWN* kd = (NMLVKEYDOWN*) lParam;
            bool controlKey = ((GetAsyncKeyState(VK_CONTROL) & 0x8000) || wParam == VK_CONTROL);
            if (kd->wVKey == 'C' && controlKey)
            {
                Array<String> sel;
                getSelList(sel);
                if (sel.length())
                {
                    HGLOBAL hDrop = CreateFileDrop(sel);
                    SetClipboard(CF_HDROP, hDrop);
                }
            }
            else if (kd->wVKey == 'V' && controlKey)
            {
                ClipboardReader clip(CF_HDROP);
                HGLOBAL hDrop = clip.getData();
                if (hDrop)
                    doPaste(hDrop, DROPEFFECT_COPY, path);
            }
            else if (kd->wVKey == VK_DELETE)
            {
                Array<String> sel;
                getSelList(sel);
                if (sel.length())
                {
                    char* str = FileListToString(sel);
                    SHFILEOPSTRUCT fileop;
                    memset(&fileop, 0, sizeof fileop);
                    fileop.wFunc = FO_DELETE;
                    fileop.pFrom = str;
                    SHFileOperationEx(&fileop);
                }
            }
            else if (kd->wVKey == VK_F2)
            {
                SetFocus(list->getHandle());
                int sel = ListView_GetNextItem(list->getHandle(), -1, LVNI_FOCUSED);
                if (sel < 0)
                    sel = 0;
                ListView_EditLabel(list->getHandle(), sel);
            }
        }
    }
    break;
    case WM_DRAGOVER:
    case WM_DRAGLEAVE:
    {
        LVHITTESTINFO ht;
        LVITEM lvi;
        memset(&lvi, 0, sizeof lvi);
        if (message == WM_DRAGOVER)
        {
            ht.pt.x = LOWORD(lParam);
            ht.pt.y = HIWORD(lParam);
            ListView_HitTest(list->getHandle(), &ht);
            if (ht.iItem >= 0)
            {
                lvi.iItem = ht.iItem;
                lvi.mask = LVIF_PARAM | LVIF_STATE;
                lvi.stateMask = LVIS_SELECTED;
                ListView_GetItem(list->getHandle(), &lvi);
                if (lvi.lParam < 0 || lvi.lParam >= items.length() ||
                        (items[lvi.lParam].type != ITEM_UPFOLDER && items[lvi.lParam].type != ITEM_FOLDER))
                    ht.iItem = -1;
                if (selfDrag && (lvi.state & LVIS_SELECTED))
                    ht.iItem = -1;
            }
            if (wParam && selfDrag && ht.iItem == -1 && *(DWORD*) wParam == DROPEFFECT_MOVE)
                *(DWORD*) wParam = DROPEFFECT_NONE;
        }
        else
            ht.iItem = -1;
        if (ht.iItem != list->highlight)
        {
            lvi.mask = LVIF_STATE;
            lvi.stateMask = LVIS_DROPHILITED;
            if (list->highlight >= 0)
            {
                lvi.iItem = list->highlight;
                ListView_SetItem(list->getHandle(), &lvi);
            }
            if (ht.iItem >= 0)
            {
                lvi.state = LVIS_DROPHILITED;
                lvi.iItem = ht.iItem;
                ListView_SetItem(list->getHandle(), &lvi);
            }
            list->highlight = ht.iItem;
        }
    }
    break;
    case WM_DRAGDROP:
        if (lParam == DROPEFFECT_MOVE || lParam == DROPEFFECT_COPY)
        {
            String opTo = path;
            if (list->highlight >= 0)
            {
                int param = list->getItemParam(list->highlight);
                if (param >= 0 && param < items.length() &&
                        (items[param].type == ITEM_UPFOLDER || items[param].type == ITEM_FOLDER))
                    opTo = items[param].path;
            }
            doPaste((HGLOBAL) wParam, lParam, opTo);
        }
        return 0;
    case WM_POSTHEADERDRAG:
    {
        bool colShow[colCount] = {true,
                                  cfg.selColumns & COL_SAVED,
                                  cfg.selColumns & COL_SIZE,
                                  cfg.selColumns & COL_NAME,
                                  cfg.selColumns & COL_RATIO,
                                  cfg.selColumns & COL_LENGTH,
                                  cfg.selColumns & COL_MODE
                                 };
        int count = 0;
        int colUnpos[colCount];
        for (int i = 0; i < colCount; i++)
            if (colShow[i])
                colUnpos[count++] = i;
        int colOrder[colCount];
        ListView_GetColumnOrderArray(list->getHandle(), count, colOrder);
        int pos = 0;
        for (int i = 0; i < colCount; i++)
            if (colShow[cfg.colOrder[i]])
                cfg.colOrder[i] = colUnpos[colOrder[pos++]];
    }
    break;
    case WM_REBUILDLIST:
        if (ListView_GetEditControl(list->getHandle()) == NULL)
            rebuild();
        break;
    case WM_UPDATELISTITEM:
        updateListItem(wParam, lParam);
        break;
    default:
        return M_UNHANDLED;
    }
    return 0;
}
void LLPanelNearByMedia::refreshList()
{
	bool all_items_deleted = false;
		
	if(!mMediaList)
	{
		// None of this makes any sense if the media list isn't there.
		return;
	}
	
	// Check whether the debug column has been shown/hidden.
	bool debug_info_visible = gSavedSettings.getBOOL("MediaPerformanceManagerDebug");
	if(debug_info_visible != mDebugInfoVisible)
	{
		mDebugInfoVisible = debug_info_visible;

		// Clear all items so the list gets regenerated.
		mMediaList->deleteAllItems();
		mParcelAudioItem = NULL;
		mParcelMediaItem = NULL;
		all_items_deleted = true;
		
		updateColumns();
	}
	
	refreshParcelItems();
	
	// Get the canonical list from LLViewerMedia
	LLViewerMedia::impl_list impls = LLViewerMedia::getPriorityList();
	LLViewerMedia::impl_list::iterator priority_iter;
	
	U32 enabled_count = 0;
	U32 disabled_count = 0;
	
	// iterate over the impl list, creating rows as necessary.
	for(priority_iter = impls.begin(); priority_iter != impls.end(); priority_iter++)
	{
		LLViewerMediaImpl *impl = *priority_iter;
		
		// If we just emptied out the list, every flag needs to be reset.
		if(all_items_deleted)
		{
			impl->setInNearbyMediaList(false);
		}

		if (!impl->isParcelMedia())
		{
			LLUUID media_id = impl->getMediaTextureID();
			S32 proximity = impl->getProximity();
			// This is expensive (i.e. a linear search) -- don't use it here.  We now use mInNearbyMediaList instead.
			//S32 index = mMediaList->getItemIndex(media_id);
			if (proximity < 0 || !shouldShow(impl))
			{
				if (impl->getInNearbyMediaList())
				{
					// There's a row for this impl -- remove it.
					removeListItem(media_id);
					impl->setInNearbyMediaList(false);
				}
			}
			else
			{
				if (!impl->getInNearbyMediaList())
				{
					// We don't have a row for this impl -- add one.
					addListItem(media_id);
					impl->setInNearbyMediaList(true);
				}
			}
			// Update counts
			if (impl->isMediaDisabled())
			{
				disabled_count++;
			}
			else {
				enabled_count++;
		}
	}
	}	
	mDisableAllCtrl->setEnabled((gSavedSettings.getBOOL("AudioStreamingMusic") || 
		                         gSavedSettings.getBOOL("AudioStreamingMedia")) &&
								(LLViewerMedia::isAnyMediaShowing() || 
								 LLViewerMedia::isParcelMediaPlaying() ||
								 LLViewerMedia::isParcelAudioPlaying()));

	mEnableAllCtrl->setEnabled( (gSavedSettings.getBOOL("AudioStreamingMusic") ||
								gSavedSettings.getBOOL("AudioStreamingMedia")) &&
							   (disabled_count > 0 ||
								// parcel media (if we have it, and it isn't playing, enable "start")
								(LLViewerMedia::hasParcelMedia() && ! LLViewerMedia::isParcelMediaPlaying()) ||
								// parcel audio (if we have it, and it isn't playing, enable "start")
								(LLViewerMedia::hasParcelAudio() && ! LLViewerMedia::isParcelAudioPlaying())));

	// Iterate over the rows in the control, updating ones whose impl exists, and deleting ones whose impl has gone away.
	std::vector<LLScrollListItem*> items = mMediaList->getAllData();

	for (std::vector<LLScrollListItem*>::iterator item_it = items.begin();
		item_it != items.end();
		++item_it)
	{
		LLScrollListItem* item = (*item_it);
		LLUUID row_id = item->getUUID();
		
		if (row_id != PARCEL_MEDIA_LIST_ITEM_UUID &&
			row_id != PARCEL_AUDIO_LIST_ITEM_UUID)
		{
			LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(row_id);
			if(impl)
			{
				updateListItem(item, impl);
			}
			else
			{
				// This item's impl has been deleted -- remove the row.
				// Removing the row won't throw off our iteration, since we have a local copy of the array.
				// We just need to make sure we don't access this item after the delete.
				removeListItem(row_id);
			}
		}
	}
	
	// Set the selection to whatever media impl the media focus/hover is on. 
	// This is an experiment, and can be removed by ifdefing out these 4 lines.
	LLUUID media_target = LLViewerMediaFocus::getInstance()->getControlsMediaID();
	if(media_target.notNull())
	{
		mMediaList->selectByID(media_target);
	}
}
void LLPanelNearByMedia::refreshParcelItems()
{
	//
	// First add/remove the "fake" items Parcel Media and Parcel Audio.
	// These items will have special UUIDs 
	//    PARCEL_MEDIA_LIST_ITEM_UUID
	//    PARCEL_AUDIO_LIST_ITEM_UUID
	//
	// Get the filter choice.
	const LLSD &choice_llsd = mShowCtrl->getSelectedValue();
	MediaClass choice = (MediaClass)choice_llsd.asInteger();
	// Only show "special parcel items" if "All" or "Within" filter
	// (and if media is "enabled")
	bool should_include = (choice == MEDIA_CLASS_ALL || choice == MEDIA_CLASS_WITHIN_PARCEL);
	
	// First Parcel Media: add or remove it as necessary
	if (gSavedSettings.getBOOL("AudioStreamingMedia") &&should_include && LLViewerMedia::hasParcelMedia())
	{
		// Yes, there is parcel media.
		if (NULL == mParcelMediaItem)
		{
			mParcelMediaItem = addListItem(PARCEL_MEDIA_LIST_ITEM_UUID);
			mMediaList->setNeedsSort(true);
		}
	}
	else {
		if (NULL != mParcelMediaItem) {
			removeListItem(PARCEL_MEDIA_LIST_ITEM_UUID);
			mParcelMediaItem = NULL;
			mMediaList->setNeedsSort(true);	
		}
	}
	
	// ... then update it
	if (NULL != mParcelMediaItem)
	{
		std::string name, url, tooltip;
		getNameAndUrlHelper(LLViewerParcelMedia::getParcelMedia(), name, url, "");
		if (name.empty() || name == url)
		{
			tooltip = url;
		}
		else
		{
			tooltip = name + " : " + url;
		}
		LLViewerMediaImpl *impl = LLViewerParcelMedia::getParcelMedia();
		updateListItem(mParcelMediaItem,
					   mParcelMediaName,
					   tooltip,
					   -2, // Proximity closer than anything else, before Parcel Audio
					   impl == NULL || impl->isMediaDisabled(),
					   impl != NULL && !LLViewerParcelMedia::getURL().empty(),
					   impl != NULL && impl->isMediaTimeBased() &&	impl->isMediaPlaying(),
					   MEDIA_CLASS_ALL,
					   "parcel media");
	}
	
	// Next Parcel Audio: add or remove it as necessary (don't show if disabled in prefs)
	if (should_include && LLViewerMedia::hasParcelAudio() && gSavedSettings.getBOOL("AudioStreamingMusic"))
	{
		// Yes, there is parcel audio.
		if (NULL == mParcelAudioItem)
		{
			mParcelAudioItem = addListItem(PARCEL_AUDIO_LIST_ITEM_UUID);
			mMediaList->setNeedsSort(true);
		}
	}
	else {
		if (NULL != mParcelAudioItem) {
			removeListItem(PARCEL_AUDIO_LIST_ITEM_UUID);
			mParcelAudioItem = NULL;
			mMediaList->setNeedsSort(true);
		}
	}
	
	// ... then update it
	if (NULL != mParcelAudioItem)
	{
		bool is_playing = LLViewerMedia::isParcelAudioPlaying();
	
		std::string url;
        url = LLViewerMedia::getParcelAudioURL();

		updateListItem(mParcelAudioItem,
					   mParcelAudioName,
					   url,
					   -1, // Proximity after Parcel Media, but closer than anything else
					   (!is_playing),
					   is_playing,
					   is_playing,
					   MEDIA_CLASS_ALL,
					   "parcel audio");
	}
}
void LLPanelNearByMedia::updateListItem(LLScrollListItem* item, LLViewerMediaImpl* impl)
{
	std::string item_name;
	std::string item_tooltip;		
	std::string debug_str;
	LLPanelNearByMedia::MediaClass media_class = MEDIA_CLASS_ALL;
	
	getNameAndUrlHelper(impl, item_name, item_tooltip, mEmptyNameString);
	// Focused
	if (impl->hasFocus())
	{
		media_class = MEDIA_CLASS_FOCUSED;
	}
	// Is attached to another avatar?
	else if (impl->isAttachedToAnotherAvatar())
	{
		media_class = MEDIA_CLASS_ON_OTHERS;
	}
	// Outside agent parcel
	else if (!impl->isInAgentParcel())
	{
		media_class = MEDIA_CLASS_OUTSIDE_PARCEL;
	}
	else {
		// inside parcel
		media_class = MEDIA_CLASS_WITHIN_PARCEL;
	}
	
	if(mDebugInfoVisible)
	{
		debug_str += llformat("%g/", (float)impl->getInterest());
		
		// proximity distance is actually distance squared -- display it as straight distance.
		debug_str += llformat("%g/", (F32) sqrt(impl->getProximityDistance()));
		
		//			s += llformat("%g/", (float)impl->getCPUUsage());
		//			s += llformat("%g/", (float)impl->getApproximateTextureInterest());
		debug_str += llformat("%g/", (float)(NULL == impl->getSomeObject()) ? 0.0 : impl->getSomeObject()->getPixelArea());
		
		debug_str += PRIORITYToString(impl->getPriority());
		
		if(impl->hasMedia())
		{
			debug_str += '@';
		}
		else if(impl->isPlayable())
		{
			debug_str += '+';
		}
		else if(impl->isForcedUnloaded())
		{
			debug_str += '!';
		}
	}
	
	updateListItem(item,
				   item_name,
				   item_tooltip,
				   impl->getProximity(),
				   impl->isMediaDisabled(),
				   impl->hasMedia(),
				   impl->isMediaTimeBased() &&	impl->isMediaPlaying(),
				   media_class,
				   debug_str);
}
Exemple #18
0
BOOL CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) 
{
	
	switch (Message)
	{
		case WM_INITDIALOG :
		{
			::SetDlgItemText(_hSelf, IDC_NAME_EDIT, _name);
			_keyCombo = _keyCombos[0];

			for (size_t i = 0 ; i < nrKeys ; i++)
			{
				::SendDlgItemMessage(_hSelf, IDC_KEY_COMBO, CB_ADDSTRING, 0, (LPARAM)namedKeyArray[i].name);
			}

			for(size_t i = 0; i < size; i++) {
				::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_ADDSTRING, 0, (LPARAM)toString(i).c_str());
			}
			::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_SETCURSEL, 0, 0);

			showCurrentSettings();
			validateDialog();

			goToCenter();
			return TRUE;
		}

		case WM_COMMAND : 
		{
			switch (wParam)
			{
				case IDC_CTRL_CHECK :
					_keyCombo._isCtrl = BST_CHECKED == ::SendDlgItemMessage(_hSelf, wParam, BM_GETCHECK, 0, 0);
					//applyToCurrentIndex();
					validateDialog();
					return TRUE;

				case IDC_ALT_CHECK :
					_keyCombo._isAlt = BST_CHECKED == ::SendDlgItemMessage(_hSelf, wParam, BM_GETCHECK, 0, 0);
					//applyToCurrentIndex();
					validateDialog();
					return TRUE;

				case IDC_SHIFT_CHECK :
					_keyCombo._isShift = BST_CHECKED == ::SendDlgItemMessage(_hSelf, wParam, BM_GETCHECK, 0, 0);
					//applyToCurrentIndex();
					return TRUE;

				case IDOK :
					//Cleanup
					_keyCombo._key = 0;
					_keyCombo._isCtrl = _keyCombo._isAlt = _keyCombo._isShift = false;
					::EndDialog(_hSelf, 0);
					return TRUE;

				case IDCANCEL :
					::EndDialog(_hSelf, -1);
					return TRUE;

				case IDC_BUTTON_ADD: {
					int oldsize = size;
					int res = addKeyCombo(_keyCombo);
					if (res > -1) {
						if (res == oldsize) {
							::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)toString(res).c_str());
						}else {	//update current generic_string, can happen if it was disabled
							updateListItem(res);
						}
						::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_SETCURSEL, res, 0);
					}
					showCurrentSettings();
					validateDialog();
					return TRUE; }

				case IDC_BUTTON_RMVE: {
					if (size == 1)	//cannot delete last shortcut
						return TRUE;
					int i = ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_GETCURSEL, 0, 0);
					removeKeyComboByIndex(i);
					::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_DELETESTRING, i, 0);
					if (i == (int)size)
						i = size - 1;
					::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_SETCURSEL, i, 0);
					showCurrentSettings();
					validateDialog();
					return TRUE; }

				case IDC_BUTTON_APPLY: {
					applyToCurrentIndex();
					validateDialog();
					return TRUE; }

				default:
					if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == LBN_SELCHANGE)
					{
						switch(LOWORD(wParam)) {
							case IDC_KEY_COMBO:
							{
								int i = ::SendDlgItemMessage(_hSelf, IDC_KEY_COMBO, CB_GETCURSEL, 0, 0);
								_keyCombo._key = namedKeyArray[i].id;
								//applyToCurrentIndex();
								validateDialog();
								return TRUE;
							}
							case IDC_LIST_KEYS:
							{
								showCurrentSettings();
								return TRUE;
							}
						}
					}
					return FALSE;
			}
		}
		default :
			return FALSE;
	}

	//return FALSE;
}