[Lazarus] OT: Happy new year

ik idokan at gmail.com
Sat Jan 2 12:39:12 CET 2010


Happy new year to everyone.

   I´m having some troubles when using other compiler messages files to compile Lazarus or 
when using fpc compiled with other message file language than english.
   The fact is that Lazarus IDE has some pieces of code with embedded strings constants. 
   I thought the most common way to solve problems like this was to declare an identifier to it and
moving it to resourcestring header (or file, i.e. LazarusIDEstrconsts)


*** The question is : What should be moved or not moved there ???? ***


Other situation occurs with constant string in logic, like this example from msgview.pp


procedure TMessagesView.MessageViewDrawItem(Sender: TCustomTreeView;
  Node: TTreeNode; State: TCustomDrawState; Stage: TCustomDrawStage;
  var PaintImages, DefaultDraw: Boolean);
var
  TheText: string;
  ARect: TRect;

const
->  cHint         = 'Hint: User defined:';
->  cNote         = 'Note: User defined:';
->  cWarning      = 'Warning: User defined:';
  clMsgHint     = clBlue;
  clMsgNote     = clGreen;
  clMsgWarning  = clRed;
  cLeftSpacer   = 0;
  
  procedure ChangeFontColor(c: TColor);
[-] ...
  end;
  
begin
  if Stage<>cdPostPaint then exit;
  // a paint means, something has changed (scrolling, expand, collapse, resize, ...)
  Changed;

  //DebugLn(['TMessagesView.MessageViewDrawItem Index=',Node.Index,' Count=',MessageTreeView.Items.Count,' TheText="',TheText,'"']);

  { Only use custom colors if not selected, otherwise it is difficult to read }
  if not (cdsSelected in State)
  then begin
->    TheText := Node.Text;
->    if Pos(cNote, TheText) > 0 then
->      ChangeFontColor(clMsgNote)
->    else if Pos(cHint, TheText) > 0 then
->      ChangeFontColor(clMsgHint)
->    else if Pos(cWarning, TheText) > 0 then
->      ChangeFontColor(clMsgWarning);
  end;
end;


   If i use other language the code above will not work, since messages are translated.

   I´m trying to figure how to solve this one, but before start sending patches maybe should be wise to
hear what others have to say.
   Maybe we get some guidelines on how to proceed in such situations.

Regards,

Marcelo.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20100101/27d4578b/attachment-0004.html>


More information about the Lazarus mailing list