Example #1
0
// --------------------------------------------------
void
Fonts::SetTo(BMessage *archive)
{
	BArchivable *a = Instantiate(archive);
	Fonts *f = a ? dynamic_cast<Fonts*>(a) : NULL;
	if (f) {
		const int n = Length();
		const int m = f->Length();
		for (int i = 0; i < m; i ++) {
			FontFile *font = f->At(i);
			for (int j = 0; j < n; j ++) {
				if (strcmp(font->Path(), At(j)->Path()) == 0) {
					At(j)->SetEmbed(font->Embed());
					At(j)->SetSubst(font->Subst());
					break;
				}
			}
		}
		
		font_encoding enc; 
		bool          active;
		for (int i = 0; f->GetCJKOrder(i, enc, active); i++) {
			SetCJKOrder(i, enc, active);
		}
		delete f;
	}
}
Example #2
0
BOOL CAddEdit_Attachment::OnInitDialog()
{
  CAddEdit_PropertyPage::OnInitDialog();

  // Get Add/Edit font
  Fonts *pFonts = Fonts::GetInstance();
  CFont *pFont = pFonts->GetAddEditFont();

  // Change font size of the attachment name and file name fields
  GetDlgItem(IDC_ATT_NAME)->SetFont(pFont);
  GetDlgItem(IDC_ATT_FILE)->SetFont(pFont);

  // Check initial state
  if (!M_pci()->HasAttRef()) {
    m_attType = NO_ATTACHMENT;
  } else {
    // m_attachment() set in CAddEdit_PropertySheet::SetupInitialValues()
    // If we have an attachment, load & preview
    m_AttName = M_attachment().GetTitle();
    m_AttFileName = M_attachment().GetFilePath() + M_attachment().GetFileName();

    // Get other properties
    m_csMediaType = M_attachment().GetMediaType().c_str();
    if (m_csMediaType == L"unknown") {
      m_csMediaType.LoadString(IDS_UNKNOWN);
    }

    wchar_t szFileSize[256];
    StrFormatByteSize(M_attachment().GetContentSize(), szFileSize, 256);
    m_csSize = szFileSize;

    m_csFileCTime = M_attachment().GetFileCTime().c_str();
    if (m_csFileCTime.IsEmpty())
      m_csFileCTime.LoadString(IDS_NA);

    m_csFileMTime = M_attachment().GetFileMTime().c_str();
    if (m_csFileMTime.IsEmpty())
      m_csFileMTime.LoadString(IDS_NA);

    ShowPreview();
  }

  UpdateData(FALSE);
  UpdateControls();

  m_bInitdone = true;

  return TRUE;  // return TRUE unless you set the focus to a control
}
Example #3
0
CFont *CPWListCtrl::GetFontBasedOnStatus(CItemData *pci, COLORREF &cf)
{
  if (pci == NULL)
    return NULL;

  Fonts *pFonts = Fonts::GetInstance();
  switch (pci->GetStatus()) {
    case CItemData::ES_ADDED:
    case CItemData::ES_MODIFIED:
      cf = pFonts->GetModified_Color();
      return pFonts->GetModifiedFont();
    default:
      break;
  }
  return NULL;
}
Example #4
0
BOOL CAddEdit_Basic::OnInitDialog()
{
    CAddEdit_PropertyPage::OnInitDialog();

    ModifyStyleEx(0, WS_EX_CONTROLPARENT);

    Fonts *pFonts = Fonts::GetInstance();
    pFonts->ApplyPasswordFont(GetDlgItem(IDC_PASSWORD));
    pFonts->ApplyPasswordFont(GetDlgItem(IDC_PASSWORD2));

    // Need to get change notifcations
    m_ex_notes.SetEventMask(ENM_CHANGE | m_ex_notes.GetEventMask());

    // Set plain text - not that it seems to do much!
    m_ex_notes.SetTextMode(TM_PLAINTEXT);

    PWSprefs *prefs = PWSprefs::GetInstance();

    // Set Notes font!
    if (prefs->GetPref(PWSprefs::NotesFont).empty()) {
        m_ex_notes.SetFont(pFonts->GetCurrentFont());
    } else {
        m_ex_notes.SetFont(pFonts->GetNotesFont());
    }

    if (M_uicaller() == IDS_EDITENTRY && M_protected() != 0) {
        GetDlgItem(IDC_STATIC_PROTECTED)->ShowWindow(SW_SHOW);
        m_stc_protected.SetColour(RGB(255,0,0));
    }

    if (M_uicaller() != IDS_ADDENTRY) {
        InitToolTip();

        AddTool(IDC_STATIC_GROUP,    IDS_CLICKTOCOPY);
        AddTool(IDC_STATIC_TITLE,    IDS_CLICKTOCOPY);
        AddTool(IDC_STATIC_USERNAME, IDS_CLICKTOCOPY);
        AddTool(IDC_STATIC_PASSWORD, IDS_CLICKTOCOPY);
        AddTool(IDC_STATIC_NOTES,    IDS_CLICKTOCOPY);
        AddTool(IDC_STATIC_URL,      IDS_CLICKTOCOPY);
        AddTool(IDC_STATIC_EMAIL,    IDS_CLICKTOCOPYPLUS1);
        AddTool(IDC_LAUNCH,          IDS_CLICKTOGOPLUS);
        AddTool(IDC_SENDEMAIL,       IDS_CLICKTOSEND);

        if (M_uicaller() == IDS_EDITENTRY && M_protected() != 0) {
            AddTool(IDC_STATIC_PROTECTED, IDS_UNPROTECT);
        }

        ActivateToolTip();

        m_stc_group.SetHighlight(true, CAddEdit_PropertyPage::crefWhite);
        m_stc_title.SetHighlight(true, CAddEdit_PropertyPage::crefWhite);
        m_stc_username.SetHighlight(true, CAddEdit_PropertyPage::crefWhite);
        m_stc_password.SetHighlight(true, CAddEdit_PropertyPage::crefWhite);
        m_stc_notes.SetHighlight(true, CAddEdit_PropertyPage::crefWhite);
        m_stc_URL.SetHighlight(true, CAddEdit_PropertyPage::crefWhite);
        m_stc_email.SetHighlight(true, CAddEdit_PropertyPage::crefWhite);
    }

    m_ex_group.ChangeColour();
    GetDlgItem(IDC_LAUNCH)->EnableWindow(M_URL().IsEmpty() ? FALSE : TRUE);
    GetDlgItem(IDC_SENDEMAIL)->EnableWindow(M_email().IsEmpty() ? FALSE : TRUE);

    if (M_uicaller() == IDS_VIEWENTRY ||
            (M_uicaller() == IDS_EDITENTRY && M_protected() != 0)) {
        // Change 'OK' to 'Close' and disable 'Cancel'
        // "CancelToClose" disables the System Command SC_CLOSE
        // from clicking X on PropertySheet so have implemented
        // CAddEdit_PropertySheet::OnSysCommand to deal with it.
        CancelToClose();

        // Disable Group Combo
        GetDlgItem(IDC_GROUP)->EnableWindow(FALSE);

        // Disable normal Edit controls
        GetDlgItem(IDC_TITLE)->SendMessage(EM_SETREADONLY, TRUE, 0);
        GetDlgItem(IDC_USERNAME)->SendMessage(EM_SETREADONLY, TRUE, 0);
        GetDlgItem(IDC_PASSWORD)->SendMessage(EM_SETREADONLY, TRUE, 0);
        GetDlgItem(IDC_PASSWORD2)->SendMessage(EM_SETREADONLY, TRUE, 0);
        GetDlgItem(IDC_NOTES)->SendMessage(EM_SETREADONLY, TRUE, 0);
        GetDlgItem(IDC_URL)->SendMessage(EM_SETREADONLY, TRUE, 0);
        GetDlgItem(IDC_EMAIL)->SendMessage(EM_SETREADONLY, TRUE, 0);

        // Disable Button
        GetDlgItem(IDC_GENERATEPASSWORD)->EnableWindow(FALSE);
    }

    // Populate the combo box
    m_ex_group.ResetContent(); // groups might be from a previous DB (BR 3062758)

    // The core function "GetUniqueGroups(vGroups)" returns the group list by
    // going through the entries in the database. This will not include empty
    // groups.  However, we already maintain this list in the UI to save the
    // display status, so use this instead.
    std::vector<std::wstring> vGroups;
    GetMainDlg()->GetAllGroups(vGroups);

    for (std::vector<std::wstring>::iterator iter = vGroups.begin();
            iter != vGroups.end(); ++iter) {
        m_ex_group.AddString(iter->c_str());
    }

    size_t num_unkwn(0);
    if (M_uicaller() != IDS_ADDENTRY)
        num_unkwn = M_pci()->NumberUnknownFields();

    if (num_unkwn > 0) {
        CString cs_text;
        cs_text.Format(IDS_RECORDUNKNOWNFIELDS, num_unkwn);
        GetDlgItem(IDC_RECORDUNKNOWNFIELDS)->SetWindowText(cs_text);
        GetDlgItem(IDC_RECORDUNKNOWNFIELDS)->ShowWindow(SW_SHOW);
        GetDlgItem(IDC_STATIC_RECORDUNKNOWNFIELDS)->ShowWindow(SW_SHOW);
        GetDlgItem(IDC_STATICGROUPRUNKNFLDS)->ShowWindow(SW_SHOW);
    } else {
        GetDlgItem(IDC_RECORDUNKNOWNFIELDS)->ShowWindow(SW_HIDE);
        GetDlgItem(IDC_STATIC_RECORDUNKNOWNFIELDS)->ShowWindow(SW_HIDE);
        GetDlgItem(IDC_STATICGROUPRUNKNFLDS)->ShowWindow(SW_HIDE);
    }

    // Note shortcuts have their own dialog for edit.
    CString cs_text;
    if (M_original_entrytype() == CItemData::ET_ALIASBASE ||
            M_original_entrytype() == CItemData::ET_SHORTCUTBASE) {
        // Show button to allow users to view dependents
        cs_text.LoadString(M_original_entrytype() == CItemData::ET_ALIASBASE ?
                           IDS_VIEWALIASESBTN : IDS_VIEWSHORTCUTSBTN);
        GetDlgItem(IDC_VIEWDEPENDENTS)->SetWindowText(cs_text);
        GetDlgItem(IDC_VIEWDEPENDENTS)->ShowWindow(SW_SHOW);

        cs_text.LoadString(M_original_entrytype() == CItemData::ET_ALIASBASE ?
                           IDS_ISANALIASBASE : IDS_ISASHORTCUTBASE);
        GetDlgItem(IDC_STATIC_ISANALIAS)->SetWindowText(cs_text);
        GetDlgItem(IDC_STATIC_ISANALIAS)->ShowWindow(SW_SHOW);
    } else if (M_original_entrytype() == CItemData::ET_ALIAS) {
        // Update password to alias form
        // Show text stating that it is an alias
        M_realpassword() = M_oldRealPassword() = m_password = m_password2 = M_base();
        GetDlgItem(IDC_VIEWDEPENDENTS)->ShowWindow(SW_HIDE);

        cs_text.Format(IDS_ISANALIAS, M_base());
        GetDlgItem(IDC_STATIC_ISANALIAS)->SetWindowText(cs_text);
        GetDlgItem(IDC_STATIC_ISANALIAS)->ShowWindow(SW_SHOW);
    } else if (M_original_entrytype() == CItemData::ET_NORMAL) {
        // Normal - do none of the above
        GetDlgItem(IDC_VIEWDEPENDENTS)->ShowWindow(SW_HIDE);
        GetDlgItem(IDC_STATIC_ISANALIAS)->ShowWindow(SW_HIDE);
    }

    if (prefs->GetPref(PWSprefs::ShowPWDefault)) {
        ShowPassword();
    } else {
        HidePassword();
    }

    if (prefs->GetPref(PWSprefs::ShowNotesDefault)) {
        ShowNotes();
    } else {
        HideNotes();
        m_ex_notes.EnableMenuItem(PWS_MSG_CALL_NOTESZOOMIN, false);
        m_ex_notes.EnableMenuItem(PWS_MSG_CALL_NOTESZOOMOUT, false);
    }

    CHARFORMAT cf = {0};
    cf.cbSize = sizeof(cf);

    m_ex_notes.SetSel(0, -1);
    m_ex_notes.SendMessage(EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
    m_iPointSize = cf.yHeight / 20;

    // Set initial Word Wrap
    m_ex_notes.SetTargetDevice(NULL, m_bWordWrap ? 0 : 1);
    m_ex_notes.UpdateState(PWS_MSG_EDIT_WORDWRAP, m_bWordWrap);

    UpdateData(FALSE);
    m_bInitdone = true;
    return TRUE;
}