Exemple #1
0
void OnMenuFind(WindowInfo *win)
{
    if (win->IsChm()) {
        win->dm->AsChmEngine()->FindInCurrentPage();
        return;
    }

    if (!win->IsDocLoaded() || !NeedsFindUI(win))
        return;

    // copy any selected text to the find bar, if it's still empty
    if (win->dm->textSelection->result.len > 0 &&
        Edit_GetTextLength(win->hwndFindBox) == 0) {
        ScopedMem<WCHAR> selection(win->dm->textSelection->ExtractText(L" "));
        str::NormalizeWS(selection);
        if (!str::IsEmpty(selection.Get())) {
            win::SetText(win->hwndFindBox, selection);
            Edit_SetModify(win->hwndFindBox, TRUE);
        }
    }

    // Don't show a dialog if we don't have to - use the Toolbar instead
    if (gGlobalPrefs->toolbarVisible && !win->fullScreen && !win->presentation) {
        if (GetFocus() == win->hwndFindBox)
            SendMessage(win->hwndFindBox, WM_SETFOCUS, 0, 0);
        else
            SetFocus(win->hwndFindBox);
        return;
    }

    ScopedMem<WCHAR> previousFind(win::GetText(win->hwndFindBox));
    WORD state = (WORD)SendMessage(win->hwndToolbar, TB_GETSTATE, IDM_FIND_MATCH, 0);
    bool matchCase = (state & TBSTATE_CHECKED) != 0;

    ScopedMem<WCHAR> findString(Dialog_Find(win->hwndFrame, previousFind, &matchCase));
    if (!findString)
        return;

    win::SetText(win->hwndFindBox, findString);
    Edit_SetModify(win->hwndFindBox, TRUE);

    bool matchCaseChanged = matchCase != (0 != (state & TBSTATE_CHECKED));
    if (matchCaseChanged) {
        if (matchCase)
            state |= TBSTATE_CHECKED;
        else
            state &= ~TBSTATE_CHECKED;
        SendMessage(win->hwndToolbar, TB_SETSTATE, IDM_FIND_MATCH, state);
        win->dm->textSearch->SetSensitive(matchCase);
    }

    FindTextOnThread(win);
}
Exemple #2
0
void CPathEditWnd::Init( CPathEditUI* pOwner )
{
	m_pOwner = pOwner;
	RECT rcPos = CalPos();
	UINT uStyle = WS_CHILD | ES_AUTOHSCROLL;
	if( m_pOwner->IsPasswordMode() ) uStyle |= ES_PASSWORD;
	Create(m_pOwner->GetManager()->GetPaintWindow(), NULL, uStyle, 0, rcPos);
	HFONT hFont=NULL;
	int iFontIndex=m_pOwner->GetFont();
	if (iFontIndex!=-1)
		hFont=m_pOwner->GetManager()->GetFont(iFontIndex);
	if (hFont==NULL)
		hFont=m_pOwner->GetManager()->GetDefaultFontInfo()->hFont;

	SetWindowFont(m_hWnd, hFont, TRUE);
	Edit_LimitText(m_hWnd, m_pOwner->GetMaxChar());
	if( m_pOwner->IsPasswordMode() ) Edit_SetPasswordChar(m_hWnd, m_pOwner->GetPasswordChar());
	Edit_SetText(m_hWnd, m_pOwner->GetText());
	Edit_SetModify(m_hWnd, FALSE);
	SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELPARAM(0, 0));
	Edit_Enable(m_hWnd, m_pOwner->IsEnabled() == true);
	Edit_SetReadOnly(m_hWnd, m_pOwner->IsReadOnly() == true);
	//Styls
	LONG styleValue = ::GetWindowLong(m_hWnd, GWL_STYLE);
	styleValue |= pOwner->GetWindowStyls();
	::SetWindowLong(GetHWND(), GWL_STYLE, styleValue);
	::ShowWindow(m_hWnd, SW_SHOWNOACTIVATE);
	::SetFocus(m_hWnd);
	m_bInit = true;    
}
Exemple #3
0
void CEditWnd::Init(CEditUI* pOwner)
{
    m_pOwner = pOwner;
    RECT rcPos = CalPos();
    UINT uStyle = WS_CHILD | ES_AUTOHSCROLL;

    if (m_pOwner->IsPasswordMode()) uStyle |= ES_PASSWORD;
    
	Create(m_pOwner->GetManager()->GetPaintWindow(), NULL, uStyle, 0, rcPos);
    SetWindowFont(m_hWnd, m_pOwner->GetManager()->GetFontInfo(m_pOwner->GetFont())->hFont, TRUE);
    Edit_LimitText(m_hWnd, m_pOwner->GetMaxChar());
    
	if (m_pOwner->IsPasswordMode()) Edit_SetPasswordChar(m_hWnd, m_pOwner->GetPasswordChar());
    
	Edit_SetText(m_hWnd, m_pOwner->GetText());
    Edit_SetModify(m_hWnd, FALSE);
    
	SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELPARAM(0, 0));
    Edit_Enable(m_hWnd, m_pOwner->IsEnabled() == true);
    Edit_SetReadOnly(m_hWnd, m_pOwner->IsReadOnly() == true);
    
	::ShowWindow(m_hWnd, SW_SHOWNOACTIVATE);
    ::SetFocus(m_hWnd);
    m_bInit = true;
}
Exemple #4
0
void OnMenuFindMatchCase(WindowInfo *win)
{
    if (!win->IsDocLoaded() || !NeedsFindUI(win))
        return;
    WORD state = (WORD)SendMessage(win->hwndToolbar, TB_GETSTATE, IDM_FIND_MATCH, 0);
    win->dm->textSearch->SetSensitive((state & TBSTATE_CHECKED) != 0);
    Edit_SetModify(win->hwndFindBox, TRUE);
}
Exemple #5
0
static BOOL CALLBACK NotepadMainWndFindProc(HWND hWnd, LPARAM lParam)
{
  lParam = 0;
  hWnd = GetWindow(hWnd, GW_CHILD);
  if(!hWnd)
    return FALSE;
  ClipGetHtml((void(*)(PCSTR, PVOID))ParseForLinks, hWnd);
  Edit_SetModify(hWnd, TRUE);
  return FALSE;
}
Exemple #6
0
void CMultiLineEditWnd::Init(CMultiLineEditUI* pOwner)
{
   RECT rcPos = pOwner->GetPos();
   ::InflateRect(&rcPos, -1, -3);
   Create(pOwner->m_pManager->GetPaintWindow(), NULL, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL, 0, rcPos);
   SetWindowFont(m_hWnd, pOwner->m_pManager->GetThemeFont(UIFONT_NORMAL), TRUE);
   Edit_SetText(m_hWnd, pOwner->m_sText);
   Edit_SetModify(m_hWnd, FALSE);
   SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELPARAM(2, 2));
   Edit_SetReadOnly(m_hWnd, pOwner->IsReadOnly() == true);
   Edit_Enable(m_hWnd, pOwner->IsEnabled() == true);
   if( pOwner->IsVisible() ) ::ShowWindow(m_hWnd, SW_SHOWNOACTIVATE);
   m_pOwner = pOwner;
}
Exemple #7
0
void CSingleLineEditWnd::Init(CSingleLineEditUI* pOwner)
{
   CRect rcPos = pOwner->GetPos();
   rcPos.Deflate(1, 3);
   Create(pOwner->GetManager()->GetPaintWindow(), NULL, WS_CHILD | pOwner->m_uEditStyle, 0, rcPos);
   SetWindowFont(m_hWnd, pOwner->GetManager()->GetThemeFont(UIFONT_NORMAL), TRUE);
   Edit_SetText(m_hWnd, pOwner->GetText());
   Edit_SetModify(m_hWnd, FALSE);
   SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELPARAM(2, 2));
   Edit_SetSel(m_hWnd, 0, -1);
   Edit_Enable(m_hWnd, pOwner->IsEnabled() == true);
   Edit_SetReadOnly(m_hWnd, pOwner->IsReadOnly() == true);
   ::ShowWindow(m_hWnd, SW_SHOWNOACTIVATE);
   ::SetFocus(m_hWnd);
   m_pOwner = pOwner;
}
Exemple #8
0
void FindTextOnThread(WindowInfo* win, TextSearchDirection direction, bool FAYT)
{
    AbortFinding(win, true);

    FindThreadData *ftd = new FindThreadData(*win, direction, win->hwndFindBox);
    Edit_SetModify(win->hwndFindBox, FALSE);

    if (str::IsEmpty(ftd->text.Get())) {
        delete ftd;
        return;
    }

    ftd->ShowUI(!FAYT);
    win->findThread = NULL;
    win->findThread = CreateThread(NULL, 0, FindThread, ftd, 0, 0);
}
void CMultiLineEditWnd::Init(CMultiLineEditUI* pOwner)
{
    CRect rcPos = pOwner->GetPos();
#if 1
    Create(pOwner->m_pCanvas->GetHWND(), NULL, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | ES_MULTILINE | WS_VSCROLL | ES_AUTOVSCROLL, 0, rcPos);
#else
    Create(pOwner->m_pManager->GetPaintWindow(), NULL, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | ES_MULTILINE | WS_VSCROLL | ES_AUTOVSCROLL, 0, rcPos);
#endif
    SetWindowFont(m_hWnd, pOwner->GetManager()->GetDefaultFont(), TRUE);
    Edit_SetText(m_hWnd, pOwner->m_sText);
    Edit_SetModify(m_hWnd, FALSE);
    SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELPARAM(2, 2));
    Edit_SetReadOnly(m_hWnd, pOwner->IsReadOnly() == true);
    Edit_Enable(m_hWnd, pOwner->IsEnabled() == true);
    if( pOwner->IsVisible() ) ::ShowWindow(m_hWnd, SW_SHOWNOACTIVATE);
    m_pOwner = pOwner;
}
Exemple #10
0
void OnMenuFindSel(WindowInfo *win, TextSearchDirection direction)
{
    if (!win->IsDocLoaded() || !NeedsFindUI(win) || win->IsChm())
        return;
    if (!win->selectionOnPage || 0 == win->dm->textSelection->result.len)
        return;

    ScopedMem<WCHAR> selection(win->dm->textSelection->ExtractText(L" "));
    str::NormalizeWS(selection);
    if (str::IsEmpty(selection.Get()))
        return;

    win::SetText(win->hwndFindBox, selection);
    AbortFinding(win); // cancel FAYT
    Edit_SetModify(win->hwndFindBox, FALSE);
    win->dm->textSearch->SetLastResult(win->dm->textSelection);

    FindTextOnThread(win, direction);
}
Exemple #11
0
static void FixTextLineEndings(
  HWND hEditWnd)
  {  
   long sel;
   size_t i, textLength;
   int originalStart, originalEnd;
   char *fullText;
   char lastCharIsLineFeed = FALSE;
   
   /*==============================*/
   /* Save the original selection. */
   /*==============================*/

   sel = SendMessage(hEditWnd,EM_GETSEL,0,0);
   originalStart = (int) LOWORD(sel);
   originalEnd = (int) HIWORD(sel);

   /*==========================*/
   /* Get all of the text data */
   /*==========================*/
   
   textLength = (size_t) SendMessage(hEditWnd,WM_GETTEXTLENGTH,0,0);
   fullText = (char *) malloc(textLength+1);
   if (fullText == NULL )
     { return; }

   SendMessage(hEditWnd,WM_GETTEXT,textLength+1,(LPARAM) fullText);

   /*===============================*/
   /* Insert carriage returns and   */
   /* line feeds where appropriate. */
   /*===============================*/

   for (i = textLength - 1; i > 0; i--)
     {
      if ((fullText[i] == '\r') &&
          (! lastCharIsLineFeed))
        {
         SendMessage(hEditWnd,EM_SETSEL,(WPARAM) i+1,i+1);   
         SendMessage(hEditWnd,EM_REPLACESEL,0,(LPARAM) "\n");
        }
      else if ((fullText[i] != '\r') &&
               lastCharIsLineFeed)
        {       
         SendMessage(hEditWnd,EM_SETSEL,(WPARAM) i+1,i+1);   
         SendMessage(hEditWnd,EM_REPLACESEL,0,(LPARAM) "\r");
        }
         
      if (fullText[i] == '\n')
        { lastCharIsLineFeed = TRUE; }
      else
        { lastCharIsLineFeed = FALSE; }
        
      if (i == 0) break;
     }
     
   if (lastCharIsLineFeed)
     {
      SendMessage(hEditWnd,EM_SETSEL,(WPARAM) 0,0);   
      SendMessage(hEditWnd,EM_REPLACESEL,0,(LPARAM) "\r");
     }

   /*===================*/
   /* Release the text. */
   /*===================*/
   
   free(fullText);
   
   /*=================================*/
   /* Restore the original selection. */
   /*=================================*/

   SendMessage(hEditWnd,EM_SETSEL,(WPARAM) originalStart,originalEnd);
   
   Edit_SetModify(hEditWnd,FALSE);
  }