trichview.com

trichview.support




TAB, an alternative idea (long)


Return to index


Author

Message

Stef Mientki

Posted: 12/14/2003 21:14:13


hi All,


Because implementing of tabs will be not before second half of 2004,

I've been looking for an alternative.


Although I would love to have tabs,

I might even not be able to use then :-(

Most of the documents my richview handles are html pages,

and as far as I know, html doesn't support tabs.

So there's my second reason to look for an alternative.


For readonly RichViews, or documents generated by the program, there's

no problem, I can just use tables with invisible borders.

Problems starts when I want to use a not-readonly richviewedit,

in that case I want to jump to the next cell (which the tabcharacter

already does) and at the end of the table I want to add new rows.

(btw, I also don't need the way of dragging all the contents after the

cursor to the next tab)

Problem is how to detect the TAB-character (in my case I'm satisfied

with the Enter-key as navigator).


Although basically the alternative works (for me),

it doesn't work always, so there are some bugs.

Maybe there are other ideas, or maybe there are some experts on the list

who can improve the code.


The basic idea is to use a table with (almost) unvisible gridlines:

   table := TRVTableItemInfo.CreateEx(3,3,RVE.RVData);

   table.BestWidth :=-100;

   table.Color := clNone;

   table.BorderStyle := rvtbColor;

   table.CellBorderStyle := rvtbColor;

   table.BorderWidth := 0;

   table.BorderVSpacing := 0;

   table.BorderHSpacing := 0;

   table.CellBorderWidth := 0;

   table.CellPadding := 0;

   table.CellVSpacing := 0;

   table.CellHSpacing := 0;

   table.VRuleWidth := 0;

   table.HRuleWidth := 0;


Wheter in editing mode or the readonly viewing mode,

the gridlines are drawn or not

   RichViewTableGridStyle:=psdot;

or

   RichViewTableGridStyle:=psclear;


Now in the keydownmode fetch the tab key, navigate to the next cell and

if at the end of the table, create an extra tablerow.

(Because I want to use the numerical keypad, the ENTER key is used as

the tabcharacter key, so onkeydown will not do for the tab-key, maybe

use keypress ??)


procedure TForm1.RVEKeyDown(Sender: TObject; var Key: Word;

   Shift: TShiftState);

(*******************************************************************************

******************************************************************************)

var

   col     :integer;

item: TCustomRVItemInfo;

   row     :integer;

   RVE_top :TCustomRichViewEdit;

   table   :TRVTableItemInfo;

     RVEx: TCustomRichViewEdit;

     ItemNo: Integer;

     Data: Integer;

begin

   //return is handled as tab-character

   if (key=vk_return) and (shift=[]) then

   begin

     RVE_top :=RVE.TopLevelEditor;

     if(RVE.GetItemStyle(RVE.CurItemNo)=rvsTable) and

       (RVE_top.GetItemStyle(RVE_top.CurItemNo)<>rvsTable) then

     begin

       table:=TRVTableItemInfo(RVE.GetItem(RVE.CurItemNo));

       table.GetEditedCell(row,col);

       memo1.lines.add(inttostr(col)+'/'+inttostr(row));

       if col>=table.Rows[0].Count-1 then

       begin

         if row>=table.Rows.Count-1 then

         begin

           //why do I need RVEx here ??

           if RVE.CanChange and

              RVE.GetCurrentItemEx(TRVTableItemInfo,RVEx, item) then

           begin

             //why do I need to fetch table and itemno again here ??

             table := TRVTableItemInfo(item);

             ItemNo :=RVEx.GetItemNo(table);

             RVEx.BeginItemModify(ItemNo, Data);

               table.InsertRowsBelow(1);

             RVEx.EndItemModify(ItemNo, Data);

             RVEx.Change;

           //is this allowed here, or should I use postmessage

             table.EditCell(row+1,0);

           end;

         end

         else table.EditCell(row+1,0);

       end

       else table.EditCell(row,col+1);

       key:=0;

     end;



Stef Mientki





Powered by ABC Amber Outlook Express Converter