Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2004.10.31;
Скачать: CL | DM;

Вниз

WordWrap в RichEdit   Найти похожие ветки 

 
4kusNick ©   (2004-04-13 19:11) [0]

Я хотел бы узнать побольше о проблеме WordWrap. В особенности, почему эта возможность RichEdit была отключина в KOL, в отличии от VCL?


 
4kusNick ©   (2004-04-13 19:12) [1]

Отключена, грамотей. И не отключена вообще, а всего - навсего "только для чтения" - прим.авт :-)


 
Delphi5.01 ©   (2004-04-14 08:26) [2]

U mena pohoji vopros! Tolko dla VCL, do sih por ni kto ne smog otvetiti. Pochemu otkluchili (specialno pisali kod) podderjku Forn.Color u Button-a. Tak kak u BitBtn i SpeedButton eta opcia rabotaet.
Esli danni komponent ne bil v sostoianii izmenit cvet Caption-a to pochemu ne otkluchili v dialoge vibor cveta?
Voprosov mnogo a otvetov malo :-(
P.S. izvenaus za latinicu, vremeni malo!


 
Gandalf ©   (2004-04-14 14:22) [3]

1) Проблем с WordWrap - нет!
2) WordWrap - свойтво только для чтения - потому как без recreate контрола этот стиль приладить нельзя.
3) WordWrap работает ТОЛЬКО для Static (Label)
4) Для WordWrap в понимании VCL необходимо применять свойство - опцию - [eo_NoHScroll]
5) Она только для чтения, почему смотри 2)
6) Можно наворотить свой WordWrap -  для этого надо сделать свой callback. Какой конкретно зависит от версии richedit, от наличия юникода и потребностей - можно типо того...



const
 WB_CLASS_WHITESPACE=0;
 WB_CLASS_LINEBREAK=1;
 WB_CLASS_DELIMITER=2;
 WB_CLASS_NORMALCHAR=3;

 WBF_ISWHITE=0;
 WBF_BREAKAFTER=1;
 WBF_BREAKLINE=2;

WB_CLASSIFY=3;
WB_MOVEWORDLEFT=4;
WB_MOVEWORDRIGHT=5;
WB_LEFTBREAK=6;
WB_RIGHTBREAK=7;
WB_MOVEWORDPREV=4;
WB_MOVEWORDNEXT=5;
WB_PREVBREAK=6;
WB_NEXTBREAK=7;
WBF_WORDWRAP=16;
WBF_WORDBREAK=32;
WBF_OVERFLOW=64;
WBF_LEVEL1=128;
WBF_LEVEL2=256;
WBF_CUSTOM=512;

EM_GETWORDBREAKPROCEX=(WM_USER+80);
EM_SETWORDBREAKPROCEX=(WM_USER+81);

whitespace=" "#9;
linebreakers=#13#10;
delimiters="[]();:,.\"";

function isInDelimiterList(c:WideChar):Boolean;
begin
 Result:=pos(c,delimiters)>0;
end;

function EditWordBreakProcEx(pchText:PWideChar; ichCurrent, cch, code:Integer):Integer; stdcall;
var
 return:Integer;
 lRet:Integer;
 i:Integer;
 found:Boolean;
 initial_pos:Integer;
begin
 lRet:= 0 ;
 i:=0 ;
 found:= FALSE ;
 initial_pos:= ichCurrent ;

 case (code) of

 WB_LEFT:
   begin//Finds the beginning of a word to the left of the specified position.
     while (not isInDelimiterList(pchText[ichCurrent])) and ( ichCurrent>0) do
       Dec(ichCurrent);
     if(ichCurrent>0) then
        lRet:= ichCurrent +1
     else
        lRet:= -1 ;
   end;

 WB_RIGHT:
   begin
     //Finds the beginning of a word to the right of the specified position.
     while (not isInDelimiterList(pchText[ichCurrent])) and ( ichCurrent<cch) do
       ichCurrent:=ichCurrent+1 ;
     if(ichCurrent>0) then
        lRet:= ichCurrent -1
     else
        lRet:= -1 ;
   end;
 WB_ISDELIMITER:
   begin//Checks whether the character at the specified position is a delimiter.
     if( pos(pchText[0],delimiters) >0) then
     begin
       lRet:=Integer(TRUE);
     end;
   end;
  WB_CLASSIFY:
   begin //Retrieves the character class and word break flags of the character at the specified position.
     if(pos(pchText[0],whitespace)>0) then
     begin
       lRet:= WBF_ISWHITE or WB_CLASS_WHITESPACE ;
     end
     else
     if(pos(pchText[0],delimiters)>0) then
     begin
       lRet:= WBF_BREAKAFTER or WB_CLASS_DELIMITER ;
     end
     else if(pos(pchText[0],linebreakers)>0) then
     begin
       lRet:= WBF_BREAKLINE or WB_CLASS_DELIMITER ;
     end
     else
     begin
       lRet:= WB_CLASS_NORMALCHAR ;
     end;
   end ;
 WB_MOVEWORDLEFT:
   // Finds the next character that begins a word before the specified position.
   begin
     Dec(ichCurrent);
     while(isInDelimiterList(pchText[ichCurrent])) do
       Dec(ichCurrent);
     while((ichCurrent<cch) and  (not found) and (ichCurrent>=0)) do
     begin
        found:= isInDelimiterList(pchText[ichCurrent]) ;
        if found and (ichCurrent>=0) then
        begin
           lRet:= ichCurrent+1;
        end
        else
        begin
           lRet:= -1 ;//This ensures failure unless something is found.                           //Thus, if the supplied string, is exhausted,
                      //we will be called with the next bunch                                    //of characters.
           Dec(ichCurrent);
        end;
     end;
     return:=lRet;
     Result:=return;
     exit;
   end ;
 WB_MOVEWORDRIGHT:
   //Finds the next character that begins a word after the specified position.
  begin
     if( not isInDelimiterList(pchText[ichCurrent])) then
        while( (not isInDelimiterList(pchText[ichCurrent])) and (ichCurrent <cch)) do
          Inc(ichCurrent);

     while(isInDelimiterList(pchText[ichCurrent]) and (ichCurrent <cch)) do
       Inc(ichCurrent);
     if(ichCurrent<cch) then
        lRet:= ichCurrent +1
     else
        lRet:= -1 ;
     return:=lRet;
     Result:=return;
     exit;
   end;
 WB_LEFTBREAK:
   //Finds the end-of-word delimiter to the left of the specified position.
   begin
     while( not isInDelimiterList(pchText[ichCurrent])) and (ichCurrent>0) do
       Dec(ichCurrent);
     if(ichCurrent>0) then
        lRet:= ichCurrent
     else
        lRet:= -1 ;
   end;
 WB_RIGHTBREAK:
   begin//Finds the end-of-word delimiter to the left of the specified position.
     while( not isInDelimiterList(pchText[ichCurrent])) and  (ichCurrent<cch) do
       ichCurrent:=ichCurrent+1;
     if(ichCurrent>0) then
        lRet:= ichCurrent
     else
        lRet:= -1 ;
   end;
 end;
 return:=lRet;
 Result:=return;
end;

procedure TForm1.Button1Click(Sender: PObj);
begin
//  RichEdit1.Perform(EM_SETWORDBREAKPROCEX,0,Integer(@EditWordBreakProcEx));
 RichEdit1.Perform(EM_SETWORDBREAKPROC,0,Integer(@EditWordBreakPr
ocEx));
end;


-----

#) Ну нельзя менять у кнопки цвет текста - таков API. VCL *Button - сами себя рисуют - так можно.
#) А в MCK вообще у контролов не нало - левых свойств - так получилось, нет времени желания и большой необходимости - но если ты хочешь поменять - нет проблем.

ЗЫ: Еще есть умные вопросы?

ЗЗЫ: Учите мат часть...


 
4kusNick ©   (2004-04-17 19:24) [4]

2 Gandalf попробую реализовать идею.


 
4kusNick ©   (2004-04-19 21:08) [5]

Всем спасибо. Все понял.


 
4kusNick ©   (2004-04-19 21:08) [6]

Всем спасибо. Все понял.



Страницы: 1 вся ветка

Текущий архив: 2004.10.31;
Скачать: CL | DM;

Наверх




Память: 0.49 MB
Время: 0.023 c
8-1089988038
gdima
2004-07-16 18:27
2004.10.31
Video


1-1098205530
Sirruf
2004-10-19 21:05
2004.10.31
Alignment in TEdit


3-1096709878
тот же
2004-10-02 13:37
2004.10.31
Как расставить DisableControls и EnableControls


1-1098085986
Walker
2004-10-18 11:53
2004.10.31
GDI +


1-1097850659
bushmen
2004-10-15 18:30
2004.10.31
Ярдык на рабочий стол