PARAFORMAT CAutoRichEditCtrl::GetParagraphFormat()
{
	PARAFORMAT pf;
	pf.cbSize = sizeof(PARAFORMAT);

	pf.dwMask = PFM_ALIGNMENT | PFM_NUMBERING;    	

	GetParaFormat(pf);

	return pf;
}
Ejemplo n.º 2
0
int CRichEditCtrlGS::IsJustified(void)
{ PARAFORMAT pf;
  pf.cbSize = sizeof(PARAFORMAT);
  pf.dwMask = PFM_ALIGNMENT;    

  DWORD dwSelMask = GetParaFormat(pf);
  bool bConsistent = false;    // JUSTIFIED alignment inconsistent over the whole Selection
  if( dwSelMask & PFA_JUSTIFY )// JUSTIFIED alignment consistent over the whole Selection?
    { bConsistent = true; 
    }
  if( !bConsistent )
    { return (-1); // Set Button to indeterminate
    }
  if( (pf.wAlignment & 0xFF) == PFA_JUSTIFY )
    { return(1);   // Set Button to checked
    }
  return 0;        // Set Button to unchecked
}
Ejemplo n.º 3
0
int CRichEditCtrlGS::IsBulleted(void)
{ PARAFORMAT pf;
  pf.cbSize = sizeof(PARAFORMAT);
  pf.dwMask = PFM_ALIGNMENT | PFM_NUMBERING;    

  DWORD dwSelMask = GetParaFormat(pf);
  bool bConsistent = false;      // Paragraph NUMBERING inconsistent over the whole Selection
  if( dwSelMask & PFM_NUMBERING )// Paragraph NUMBERING consistent over the whole Selection?
    { bConsistent = true; 
    }
  if( !bConsistent )
    { return (-1); // Set Button to indeterminate
    }
  if( pf.wNumbering & PFN_BULLET )
    { return(1);   // Set Button to checked
    }
  return 0;        // Set Button to unchecked
}
Ejemplo n.º 4
0
void CRichEditCtrlGS::SetBullet(void)
{ int iFormatted = IsBulleted();
  PARAFORMAT pf;
  pf.cbSize     = sizeof(PARAFORMAT);
  pf.dwMask = PFM_NUMBERING | PFM_STARTINDENT | PFM_OFFSET;
  GetParaFormat(pf);
  
  if( 1 == iFormatted )
	{ pf.wNumbering = 0;
	  pf.dxOffset = 0;
	  pf.dwMask = PFM_NUMBERING | PFM_STARTINDENT | PFM_OFFSET;
	}
  else
	{ pf.wNumbering = PFN_BULLET;
	  pf.dwMask = PFM_NUMBERING;
	  if( pf.dxOffset == 0 )
		{ pf.dxOffset = 160;
		  pf.dwMask = PFM_NUMBERING | PFM_STARTINDENT | PFM_OFFSET;
		}
	}
  SetParaFormat(pf);
}
    LONG NativeTextfieldWin::ClipXCoordToVisibleText(LONG x,
        bool is_triple_click) const
    {
        // Clip the X coordinate to the left edge of the text.  Careful:
        // PosFromChar(0) may return a negative X coordinate if the beginning of the
        // text has scrolled off the edit, so don't go past the clip rect's edge.
        PARAFORMAT2 pf2;
        GetParaFormat(pf2);
        // Calculation of the clipped coordinate is more complicated if the paragraph
        // layout is RTL layout, or if there is RTL characters inside the LTR layout
        // paragraph.
        bool ltr_text_in_ltr_layout = true;
        if((pf2.wEffects & PFE_RTLPARA) ||
            base::i18n::StringContainsStrongRTLChars(GetText()))
        {
            ltr_text_in_ltr_layout = false;
        }
        const int length = GetTextLength();
        RECT r;
        GetRect(&r);
        // The values returned by PosFromChar() seem to refer always
        // to the left edge of the character's bounding box.
        const LONG first_position_x = PosFromChar(0).x;
        LONG min_x = first_position_x;
        if(!ltr_text_in_ltr_layout)
        {
            for(int i=1; i<length; ++i)
            {
                min_x = std::min(min_x, PosFromChar(i).x);
            }
        }
        const LONG left_bound = std::max(r.left, min_x);

        // PosFromChar(length) is a phantom character past the end of the text. It is
        // not necessarily a right bound; in RTL controls it may be a left bound. So
        // treat it as a right bound only if it is to the right of the first
        // character.
        LONG right_bound = r.right;
        LONG end_position_x = PosFromChar(length).x;
        if(end_position_x >= first_position_x)
        {
            right_bound = std::min(right_bound, end_position_x); // LTR case.
        }
        // For trailing characters that are 2 pixels wide of less (like "l" in some
        // fonts), we have a problem:
        //   * Clicks on any pixel within the character will place the cursor before
        //     the character.
        //   * Clicks on the pixel just after the character will not allow triple-
        //     click to work properly (true for any last character width).
        // So, we move to the last pixel of the character when this is a
        // triple-click, and moving to one past the last pixel in all other
        // scenarios.  This way, all clicks that can move the cursor will place it at
        // the end of the text, but triple-click will still work.
        if(x < left_bound)
        {
            return (is_triple_click && ltr_text_in_ltr_layout) ? left_bound-1 :
                left_bound;
        }
        if((length==0) || (x<right_bound))
        {
            return x;
        }
        return is_triple_click ? (right_bound-1) : right_bound;
    }