Recent

Author Topic: How do I implement a cross-platform caret?  (Read 9105 times)

antonio

  • Hero Member
  • *****
  • Posts: 605
How do I implement a cross-platform caret?
« on: June 24, 2007, 01:41:46 am »
I have a component where I implement a caret for a window by Windows API calls (CreateCaret, ShowCaret, etc). What should I do to make this component work on Linux?

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1927
RE: How do I implement a cross-platform caret?
« Reply #1 on: June 24, 2007, 03:10:17 am »
Why not make it a simple Fillrect basically?

antonio

  • Hero Member
  • *****
  • Posts: 605
RE: How do I implement a cross-platform caret?
« Reply #2 on: June 24, 2007, 03:49:30 am »
Drawing the caret myself? Do you think it's a good approach?

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1927
Re: RE: How do I implement a cross-platform caret?
« Reply #3 on: June 24, 2007, 05:03:10 am »
Quote from: "antonio"
Drawing the caret myself? Do you think it's a good approach?


Why not? I do this in my RichEdit thingie and I see no problems.
Invalidate just the Rect where the caret is blinking.
I can't see any "magic" in this. It's just a vertical line.

antonio

  • Hero Member
  • *****
  • Posts: 605
RE: Re: RE: How do I implement a cross-platform caret?
« Reply #4 on: June 24, 2007, 07:50:59 am »
How do you handle the selection on this control?

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1927
Re: RE: Re: RE: How do I implement a cross-platform caret?
« Reply #5 on: June 24, 2007, 11:52:20 am »
Quote from: "antonio"
How do you handle the selection on this control?


What exactly do you want to know?

antonio

  • Hero Member
  • *****
  • Posts: 605
RE: Re: RE: Re: RE: How do I implement a cross-platform car
« Reply #6 on: June 24, 2007, 05:16:36 pm »
About the algorithm. In my control, I didn't handle selection at all.

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1927
RE: Re: RE: Re: RE: How do I implement a cross-platform car
« Reply #7 on: June 24, 2007, 06:57:58 pm »
Have a look at the Synedit sources.
There the CreateCaret etc. functions from LCLIntf are used.

antonio

  • Hero Member
  • *****
  • Posts: 605
RE: Re: RE: Re: RE: How do I implement a cross-platform car
« Reply #8 on: June 24, 2007, 10:01:04 pm »
Thanks.

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2582
RE: Re: RE: Re: RE: How do I implement a cross-platform car
« Reply #9 on: June 25, 2007, 03:22:00 pm »
Indeed, in order to get synedit to work, we needed to implement our own Caret handling functions :)
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

antonio

  • Hero Member
  • *****
  • Posts: 605
RE: Re: RE: Re: RE: How do I implement a cross-platform car
« Reply #10 on: June 25, 2007, 04:10:22 pm »
Is the caret implemented in a different way to Linux and Windows?

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2582
RE: Re: RE: Re: RE: How do I implement a cross-platform car
« Reply #11 on: June 25, 2007, 04:34:44 pm »
in windows the real caret is used, in linux it is simulated. The LCLIntf winapi functions are a replacement for common used winapifunctions. On windows they are redirected tothe real winapi function, on other widgetsets they are implemented ourselves, but should behave the same.
Note that you cannot set the caret on all controls on linux.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

antonio

  • Hero Member
  • *****
  • Posts: 605
RE: Re: RE: Re: RE: How do I implement a cross-platform car
« Reply #12 on: June 25, 2007, 04:44:21 pm »
Thanks.

 

TinyPortal © 2005-2018