Beispiel #1
0
static bool ChooseLanguage(wxString *value)
{
    wxArrayString langs;
    wxArrayString arr;

    {
        wxBusyCursor bcur;
        langs = wxTranslations::Get()->GetAvailableTranslations("poedit");

        arr.push_back(_("(Use default language)"));
        for (auto i : langs)
        {
            auto lang = Language::TryParse(i.ToStdWstring());
            arr.push_back(lang.DisplayNameInItself() + L"  —  " + lang.DisplayName());
        }
    }
    int choice = wxGetSingleChoiceIndex(
            _("Select your preferred language"),
            _("Language selection"),
            arr);
    if ( choice == -1 )
        return false;

    if ( choice == 0 )
        *value = "";
    else
        *value = langs[choice-1];
    return true;
}
Beispiel #2
0
status_t MSNManager::SetDisplayName(const char *displayname) {
	if (fNoticeCon) {
		fDisplayName = displayname;
		
		Command *rea = new Command("PRP");
		rea->AddParam("MFN");
		rea->AddParam(DisplayName(), true);
	
		fNoticeCon->Send(rea);
		return B_OK;
	};
	
	return B_ERROR;
};
Beispiel #3
0
void PoeditListCtrl::ReadCatalog()
{
    wxWindowUpdateLocker no_updates(this);

    // clear the list and its sort order too:
    SetItemCount(0);
    m_mapListToCatalog.clear();
    m_mapCatalogToList.clear();

    if (m_catalog == NULL)
    {
        Refresh();
        return;
    }

    auto lang = m_catalog->GetLanguage();
    auto isRTL = lang.IsRTL();
#ifdef __WXMSW__
    // a quirk of wx API: if the current locale is RTL, the meaning of L and R is reversed
    if (m_appIsRTL)
        isRTL = !isRTL;
#endif
    m_isRTL = isRTL;

    wxString langname = lang.IsValid() ? lang.DisplayName() : _("unknown language");
    wxListItem colInfo;
    colInfo.SetMask(wxLIST_MASK_TEXT);
    colInfo.SetText(wxString::Format(_(L"Translation — %s"), langname));
    colInfo.SetAlign(isRTL ? wxLIST_FORMAT_RIGHT : wxLIST_FORMAT_LEFT);
    SetColumn(1, colInfo);

    // sort catalog items, create indexes mapping
    CreateSortMap();

    // now that everything is prepared, we may set the item count
    SetItemCount(m_catalog->GetCount());

    // scroll to the top and refresh everything:
    if ( m_catalog->GetCount() )
    {
        SelectOnly(0);
        RefreshItems(0, m_catalog->GetCount()-1);
    }
    else
    {
        Refresh();
    }
}
Beispiel #4
0
wxString Language::FormatForRoundtrip() const
{
    // TODO: Can't show variants nicely yet, not standardized
    if (!Variant().empty())
        return m_code;

    wxString disp = DisplayName();
    // ICU isn't 100% reliable, some of the display names it produces
    // (e.g. "Chinese (China)" aren't in the list of known locale names
    // (here because zh-Trans is preferred to zh_CN). So make sure it can
    // be parsed back first.
    if (TryParse(disp).IsValid())
        return disp;
    else
        return m_code;
}
Beispiel #5
0
VOID    CProfileAssociationPage::UpdateDeviceListBox() {

    //  Add the associations to the list

    SendDlgItemMessage(m_hwnd, DeviceListControl, LB_RESETCONTENT, 0, 0);

    for (unsigned u = 0; u < AssociationCount(); u++ ) {
        LRESULT iItem = SendDlgItemMessage(m_hwnd, DeviceListControl, LB_ADDSTRING,
            0, (LPARAM) DisplayName(u));
        SendDlgItemMessage(m_hwnd, DeviceListControl, LB_SETITEMDATA, iItem,
            (LPARAM) Association(u));
    }

    //  If there are no associations, disable the Remove Devices button

    HWND hwndRemove = GetDlgItem(m_hwnd,RemoveButton);

    //  If there are no more devices, or all are associated, disable the Add
    //  Devices button.
    //
    //  !!! To get more performance !!!
    //
    //  EnableWindow(GetDlgItem(m_hwnd, AddButton),
    //     m_pcpTarget->DeviceCount() && m_pcpTarget->DeviceCount() > AssociationCount());
    //
    //  !!! AddButton NEVER DISABLED !!!
    //

    // If focus is on Remove, move it to Add button.

    if (GetFocus() == hwndRemove) {

        HWND hwndAdd = GetDlgItem(m_hwnd, AddButton);

        SetFocus(hwndAdd);
        SendMessage(hwndRemove, BM_SETSTYLE, BS_PUSHBUTTON, MAKELPARAM(TRUE, 0));
        SendMessage(hwndAdd, BM_SETSTYLE, BS_DEFPUSHBUTTON, MAKELPARAM(TRUE, 0));
    }

    EnableWindow(hwndRemove, !!(AssociationCount()));

    //  If there is any device, set focus to 1st entry.

    if  (SendDlgItemMessage(m_hwnd, DeviceListControl, LB_GETCOUNT, 0, 0))
        SendDlgItemMessage(m_hwnd, DeviceListControl, LB_SETCURSEL, 0, 0);
}
Beispiel #6
0
void QuickView::DisplayObject()
{
	if (m_Flags.Check(FSCROBJ_ISREDRAWING))
		return;

	m_Flags.Set(FSCROBJ_ISREDRAWING);

	if (!QView && !ProcessingPluginCommand)
		Parent()->GetAnotherPanel(this)->UpdateViewPanel();

	if (this->Destroyed())
		return;

	if (QView)
		QView->SetPosition(m_X1+1,m_Y1+1,m_X2-1,m_Y2-3);

	Box(m_X1,m_Y1,m_X2,m_Y2,colors::PaletteColorToFarColor(COL_PANELBOX),DOUBLE_BOX);
	SetScreen(m_X1+1,m_Y1+1,m_X2-1,m_Y2-1,L' ',colors::PaletteColorToFarColor(COL_PANELTEXT));
	SetColor(m_Focus ? COL_PANELSELECTEDTITLE:COL_PANELTITLE);

	string strTitle = GetTitle();
	if (!strTitle.empty())
	{
		GotoXY(m_X1+(m_X2-m_X1+1-(int)strTitle.size())/2,m_Y1);
		Text(strTitle);
	}

	DrawSeparator(m_Y2-2);
	SetColor(COL_PANELTEXT);
	GotoXY(m_X1+1,m_Y2-1);
	Global->FS << fmt::LeftAlign()<<fmt::ExactWidth(m_X2-m_X1-1)<<PointToName(strCurFileName);

	if (!strCurFileType.empty())
	{
		string strTypeText=L" ";
		strTypeText+=strCurFileType;
		strTypeText+=L" ";
		TruncStr(strTypeText,m_X2-m_X1-1);
		SetColor(COL_PANELSELECTEDINFO);
		GotoXY(m_X1+(m_X2-m_X1+1-(int)strTypeText.size())/2,m_Y2-2);
		Text(strTypeText);
	}

	if (Directory)
	{
		FormatString FString;
		string DisplayName(strCurFileName);
		TruncPathStr(DisplayName,std::max(0, m_X2-m_X1-1-StrLength(MSG(MQuickViewFolder))-5));
		FString<<MSG(MQuickViewFolder)<<L" \""<<DisplayName<<L"\"";
		SetColor(COL_PANELTEXT);
		GotoXY(m_X1+2,m_Y1+2);
		PrintText(FString);

		DWORD currAttr=os::GetFileAttributes(strCurFileName); // обламывается, если нет доступа
		if (currAttr != INVALID_FILE_ATTRIBUTES && (currAttr&FILE_ATTRIBUTE_REPARSE_POINT))
		{
			string Tmp, Target;
			DWORD ReparseTag=0;
			const wchar_t* PtrName;
			if (GetReparsePointInfo(strCurFileName, Target, &ReparseTag))
			{
				NormalizeSymlinkName(Target);
				switch(ReparseTag)
				{
				// 0xA0000003L = Directory Junction or Volume Mount Point
				case IO_REPARSE_TAG_MOUNT_POINT:
					{
						LNGID ID_Msg = MQuickViewJunction;
						bool Root;
						if(ParsePath(Target, nullptr, &Root) == PATH_VOLUMEGUID && Root)
						{
							ID_Msg=MQuickViewVolMount;
						}
						PtrName = MSG(ID_Msg);
					}
					break;
				// 0xA000000CL = Directory or File Symbolic Link
				case IO_REPARSE_TAG_SYMLINK:
					PtrName = MSG(MQuickViewSymlink);
					break;
				// 0x8000000AL = Distributed File System
				case IO_REPARSE_TAG_DFS:
					PtrName = MSG(MQuickViewDFS);
					break;
				// 0x80000012L = Distributed File System Replication
				case IO_REPARSE_TAG_DFSR:
					PtrName = MSG(MQuickViewDFSR);
					break;
				// 0xC0000004L = Hierarchical Storage Management
				case IO_REPARSE_TAG_HSM:
					PtrName = MSG(MQuickViewHSM);
					break;
				// 0x80000006L = Hierarchical Storage Management2
				case IO_REPARSE_TAG_HSM2:
					PtrName = MSG(MQuickViewHSM2);
					break;
				// 0x80000007L = Single Instance Storage
				case IO_REPARSE_TAG_SIS:
					PtrName = MSG(MQuickViewSIS);
					break;
				// 0x80000008L = Windows Imaging Format
				case IO_REPARSE_TAG_WIM:
					PtrName = MSG(MQuickViewWIM);
					break;
				// 0x80000009L = Cluster Shared Volumes
				case IO_REPARSE_TAG_CSV:
					PtrName = MSG(MQuickViewCSV);
					break;
				case IO_REPARSE_TAG_DEDUP:
					PtrName = MSG(MQuickViewDEDUP);
					break;
				case IO_REPARSE_TAG_NFS:
					PtrName = MSG(MQuickViewNFS);
					break;
				case IO_REPARSE_TAG_FILE_PLACEHOLDER:
					PtrName = MSG(MQuickViewPlaceholder);
					break;
					// 0x????????L = anything else
				default:
					if (Global->Opt->ShowUnknownReparsePoint)
					{
						Tmp = FormatString() << L":" << fmt::Radix(16) << fmt::ExactWidth(8) << fmt::FillChar(L'0') << ReparseTag;
						PtrName = Tmp.data();
					}
					else
					{
						PtrName=MSG(MQuickViewUnknownReparsePoint);
					}
				}
			}
			else
			{
				PtrName = MSG(MQuickViewUnknownReparsePoint);
				Target = MSG(MQuickViewNoData);
			}

			TruncPathStr(Target,std::max(0, m_X2-m_X1-1-StrLength(PtrName)-5));
			FString.clear();
			FString<<PtrName<<L" \""<<Target<<L"\"";
			SetColor(COL_PANELTEXT);
			GotoXY(m_X1+2,m_Y1+3);
			PrintText(FString);
		}

		if (Directory==1 || Directory==4)
		{
			const auto iColor = uncomplete_dirscan? COL_PANELHIGHLIGHTTEXT : COL_PANELINFOTEXT;
			const wchar_t *prefix = uncomplete_dirscan ? L"~" : L"";
			GotoXY(m_X1+2,m_Y1+4);
			PrintText(MSG(MQuickViewContains));
			GotoXY(m_X1+2,m_Y1+6);
			PrintText(MSG(MQuickViewFolders));
			SetColor(iColor);
			FString.clear();
			FString<<prefix<<Data.DirCount;
			PrintText(FString);
			SetColor(COL_PANELTEXT);
			GotoXY(m_X1+2,m_Y1+7);
			PrintText(MSG(MQuickViewFiles));
			SetColor(iColor);
			FString.clear();
			FString<<prefix<<Data.FileCount;
			PrintText(FString);
			SetColor(COL_PANELTEXT);
			GotoXY(m_X1+2,m_Y1+8);
			PrintText(MSG(MQuickViewBytes));
			SetColor(iColor);
			string strSize;
			InsertCommas(Data.FileSize,strSize);
			PrintText(prefix+strSize);
			SetColor(COL_PANELTEXT);
			GotoXY(m_X1+2,m_Y1+9);
			PrintText(MSG(MQuickViewAllocated));
			SetColor(iColor);
			InsertCommas(Data.AllocationSize,strSize);
			FString.clear();
			FString << prefix << strSize << L" (" << ToPercent(Data.AllocationSize,Data.FileSize) << L"%)";
			PrintText(FString);

			if (Directory!=4)
			{
				SetColor(COL_PANELTEXT);
				GotoXY(m_X1+2,m_Y1+11);
				PrintText(MSG(MQuickViewCluster));
				SetColor(iColor);
				InsertCommas(Data.ClusterSize,strSize);
				PrintText(prefix+strSize);

				SetColor(COL_PANELTEXT);
				GotoXY(m_X1+2,m_Y1+12);
				PrintText(MSG(MQuickViewSlack));
				SetColor(iColor);
				InsertCommas(Data.FilesSlack, strSize);
				FString.clear();
				FString << prefix << strSize << L" (" << ToPercent(Data.FilesSlack, Data.AllocationSize) << L"%)";
				PrintText(FString);

				SetColor(COL_PANELTEXT);
				GotoXY(m_X1+2,m_Y1+13);
				PrintText(MSG(MQuickViewMFTOverhead));
				SetColor(iColor);
				InsertCommas(Data.MFTOverhead, strSize);
				FString.clear();
				FString<<prefix<<strSize<<L" ("<<ToPercent(Data.MFTOverhead, Data.AllocationSize)<<L"%)";
				PrintText(FString);

			}
		}
	}
	else if (QView)
		QView->Show();

	m_Flags.Clear(FSCROBJ_ISREDRAWING);
}
Beispiel #7
0
std::string CQExpressionWidget::getExpression() const
{
  QString Infix;
  const QString Display(toPlainText());

  QRegExp DisplayObjectPattern(CQExpressionWidget::DisplayPattern);

  int Index = 0;
  QString::const_iterator it = Display.begin();
  QString::const_iterator end;

  while (true)
    {
      Index = DisplayObjectPattern.indexIn(Display, Index);

      if (Index < 0)
        {
          end = Display.end();
        }
      else
        {
          end = Display.begin() + Index;
        }

      // Copy the non-object part
      for (; it != end; ++it)
        {
          Infix.append(*it);
        }

      if (DisplayObjectPattern.matchedLength() < 0)
        break;

      Index += DisplayObjectPattern.matchedLength();
      it += DisplayObjectPattern.matchedLength();

      std::string DisplayName(TO_UTF8(DisplayObjectPattern.cap(1)));
      std::map< std::string, const CCopasiObject *>::const_iterator itObject = mParseList.find(DisplayName);

      if (itObject == mParseList.end() && CCopasiRootContainer::getConfiguration()->useAdvancedEditing())
        {

          // the object pattern does not match the species name if
          // the species is in a different compartment, in that case we
          // have to remove the backslash in the displayname.
          std::string::size_type bsPos = DisplayName.find("\\}");

          if (bsPos != std::string::npos)
            DisplayName.erase(bsPos, 1);

          // here we don't have an object recognized, what we ought to do is to find it in the model
          const CCopasiObject* object = findObjectByDisplayName(
                                          mpCurrentObject != NULL ? mpCurrentObject->getObjectDataModel() : &CCopasiRootContainer::getDatamodelList()->operator[](0),
                                          DisplayName);

          if (object != NULL)
            {
              const_cast<CQExpressionWidget*>(this)->mParseList[DisplayName] = object;
              itObject = mParseList.find(DisplayName);
            }
        }

      if (itObject != mParseList.end())
        Infix += "<" + FROM_UTF8(itObject->second->getCN()) + ">";
      else
        {
          Infix += "<";

          // We need to escape '\'
          std::string CN = TO_UTF8(DisplayObjectPattern.cap(1));
          std::string::const_iterator it = CN.begin();
          std::string::const_iterator end = CN.end();

          for (; it < end; ++it)
            {
              if (*it == '\\')
                {
                  ++it;
                }

              Infix += *it;
            }

          Infix += ">";
        }
    }

  return TO_UTF8(Infix);
}
Beispiel #8
0
void DeviceInfo::UpdateDevice(enum DevType aDevType, enum DevState aDevState,
        FILETIME aNow, wchar_t *aPortName, int aPortNumber, unsigned aUsbHub, unsigned aUsbPort, BOOL aUsbValid,
        wchar_t *aSerialNumber, unsigned aScanId, BOOL aIsWinSerial)
{
    // change of device type happens when installing/removing device drivers
    if (devType != aDevType) {
        BOOL nameChanged = FALSE;

#ifdef _DEBUG
        PrintDebugStatus(_T("DevType changed (%u -> %u)\n"), devType, aDevType);
#endif

        if (devPresent) {
            // update counts
            DecDeviceTypeCount();
            devType = aDevType;
            IncDeviceTypeCount();
        } else {
            devType = aDevType;
        }

        // update DeviceTracker counts, decide on notifications 
        gdevTracker->DetermineRemovalNotifications(devType, devState, DevRemoved);
        gdevTracker->DetermineArrivalNotifications(aDevType, devState);

        // rely on FindDevMatchBySernum() to enforce type change restrictions
        SetDeviceIcon();

        // update port status & icon on display
        gdevTracker->UpdateViewItemIconAndType(devImage, DevTypeName(), (LPARAM)this);

        // installing driver can add/change name
        if ((aPortName) && (!devPortName || wcscmp(devPortName, aPortName))) {
#ifdef _DEBUG
            PrintDebugStatus(_T("Adding PortName (%s)\n"), aPortName);
#endif
            ReleaseString(devPortName);

            devPortName = _wcsdup(aPortName);
            if (devPortName) {
                devPortNumber = aPortNumber;
                nameChanged = TRUE;
            }
        } else if (devPortName && !aPortName) {
#ifdef _DEBUG
            PrintDebugStatus(_T("Release portname (%s)\n"), devPortName);
#endif
            // driver uninstalled, portname removed
            ReleaseString(devPortName);
            nameChanged = TRUE;
        }

        if (nameChanged) {
            gdevTracker->UpdateViewItemPortName(DisplayName(), (LPARAM)this);
        }
    }

    // check for change of state, eg removed etc...
    UpdateDeviceState(aDevState, aNow, aScanId);


    if ((devState == DevArrived) || (devState == DevPresent)) {
        // portname has changed? eg by user in Device Manager
        if ((aPortName) && (!devPortName || wcscmp(devPortName, aPortName))) {
            ReleaseString(devPortName);

            devPortName = _wcsdup(aPortName);
            if (devPortName) {
                devPortNumber = aPortNumber;
                // NB should reorder devices to reflect updated portname
                gdevTracker->UpdateViewItemPortName(devPortName, (LPARAM)this);
            }
        }
    }

    if (aUsbValid) {
        if ((devUsbValid != aUsbValid) || (devUsbHub != aUsbHub) || (devUsbPort != aUsbPort)) {
            devUsbValid = aUsbValid;
            devUsbHub = aUsbHub;
            devUsbPort = aUsbPort;
            // update displayed usb location
            gdevTracker->UpdateViewItemLocation(LocationString(), (LPARAM)this);
        }
    }

    if (!devSerialNumber && aSerialNumber) {
        devSerialNumber = _wcsdup(aSerialNumber);
        if (devSerialNumber) {
            devIsWinSerial = aIsWinSerial;
            // NB should reorder devices to reflect updated serial number
            gdevTracker->UpdateViewItemSerialNumber(devSerialNumber, (LPARAM)this);
        }
    }

    devScanId = aScanId;
}