Recent

Author Topic: TRxDBLookupCombo missing OnPaint event  (Read 8667 times)

lainz

  • Hero Member
  • *****
  • Posts: 4449
    • https://lainz.github.io/
TRxDBLookupCombo missing OnPaint event
« on: February 01, 2018, 02:10:21 pm »
Hi, I need to style this component: TRxDBLookupCombo, but it lacks of a working OnPaint event, one for the list items and one for the combo itself.

To the author:
- Notice when adding OnPaint event we must have access to private stuff that is accessed actually on the Paint event, that stuff should be changed to protected so our custom descendants can override Paint and do it well. Or create a custom paint event for this, and feed the things we need to have, like these:

* Assigned(FDataField) and FDataField.IsNull
* AText:=FEmptyValue
* AText:=FValuesList[FLookupDisplayIndex]

I need to style them to match the OS ComboBox, unfortunatelly, the Lazarus DB aware combobox does not work with the code I'm using, and I need to use your nice component! But does not look like the rest of the application: for that I'm asking for this feature.

Also please update the version in the Online Package Manager, that is the tool I use for your components download and installation.

Thanks!

Edit: As in the PM I sent you, if you need help doing this stuff, I can help.
« Last Edit: February 01, 2018, 02:14:11 pm by lainz »

alexs75

  • Full Member
  • ***
  • Posts: 112
Re: TRxDBLookupCombo missing OnPaint event
« Reply #1 on: February 01, 2018, 02:33:28 pm »
I can implement OnPaint - but can you better tell me how to draw more correctly with themes?

lainz

  • Hero Member
  • *****
  • Posts: 4449
    • https://lainz.github.io/
Re: TRxDBLookupCombo missing OnPaint event
« Reply #2 on: February 01, 2018, 02:50:56 pm »
I can implement OnPaint - but can you better tell me how to draw more correctly with themes?

Yes, I will build a demo and attach here.

Edit: Done! On Windows 10 looks fine. But the idea of how to draw with themes is here.
« Last Edit: February 01, 2018, 03:56:43 pm by lainz »

lainz

  • Hero Member
  • *****
  • Posts: 4449
    • https://lainz.github.io/
Re: TRxDBLookupCombo missing OnPaint event
« Reply #3 on: February 01, 2018, 03:41:53 pm »
Windows 7, almost fine.

Maybe changing the clipping rect (1 px left and 2 px right) we can have it perfectly drawn.

Ubuntu 17, almost fine =)

Again the problem is in the arrow, and also the focus, instead of using "hot" state we should use "focused" state for Ubuntu ( I can't find the focused element details? ).
« Last Edit: February 01, 2018, 04:10:47 pm by lainz »

lainz

  • Hero Member
  • *****
  • Posts: 4449
    • https://lainz.github.io/
Re: TRxDBLookupCombo missing OnPaint event
« Reply #4 on: February 01, 2018, 05:01:20 pm »
macOS, thanks for the screenshot @esvignolo

Well, what is happening here is that the arrow must be drawn entirely, like the whole combobox area.

I don't have a mac to test, but is simple to fix, just draw the arrow in the entire space: in other words change the entire combobox to be the arrow.

Maybe the same happens on linux..
« Last Edit: February 01, 2018, 05:02:54 pm by lainz »

alexs75

  • Full Member
  • ***
  • Posts: 112
Re: TRxDBLookupCombo missing OnPaint event
« Reply #5 on: February 02, 2018, 07:20:40 am »
Thanks for the code.
Have questions:
1. This solution is suitable only for the csDropDownList style. Any ideas for csDropDown?
2. How can I find out the height of ComboBox1 for the current theme?

lainz

  • Hero Member
  • *****
  • Posts: 4449
    • https://lainz.github.io/
Re: TRxDBLookupCombo missing OnPaint event
« Reply #6 on: February 02, 2018, 12:23:35 pm »
Hi, I will investigate today, If I can find an answer for both questions I will share.

Edit: About the Height, what I found is this code

Code: Pascal  [Select][+][-]
  1. Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges
http://lazarus-ccr.sourceforge.net/docs/lcl/lclintf/getsystemmetrics.html

Basically the height is the Font.Height plus the borders.

About the style, I can find that is like the style of a TEdit, so use these:

Code: Pascal  [Select][+][-]
  1. // 'Edit' theme data
  2.   TThemedEdit = (
  3.     teEditDontCare,
  4.     teEditRoot,
  5.     teEditTextNormal, teEditTextHot, teEditTextSelected, teEditTextDisabled, teEditTextFocused, teEditTextReadOnly, teEditTextAssist,
  6.     teEditCaret
  7.   );

On mac you just should use tcDropDownButtonNormal to get the csDropDown style, I can't test it, I even installed the cross compilers but nothing =(
On Windows and Linux try with TEdit styles.
« Last Edit: February 02, 2018, 01:35:04 pm by lainz »

alexs75

  • Full Member
  • ***
  • Posts: 112
Re: TRxDBLookupCombo missing OnPaint event
« Reply #7 on: February 02, 2018, 01:58:40 pm »
1. Test code:
  Edit3.Height
   and
  LCLIntf.GetSystemMetrics(SM_CYEDGE) * 2 + Canvas.TextHeight('Wg')

height not equal
 
2. TThemedEdit - not implemented

I'm planed make new property - Style
rxcsDropDownList - you code for display data
rxcsDropDown (default) - my old code


lainz

  • Hero Member
  • *****
  • Posts: 4449
    • https://lainz.github.io/
Re: TRxDBLookupCombo missing OnPaint event
« Reply #8 on: February 02, 2018, 02:02:52 pm »
Ok, that's fine. Thanks for your time!

alexs75

  • Full Member
  • ***
  • Posts: 112
Re: TRxDBLookupCombo missing OnPaint event
« Reply #9 on: February 05, 2018, 02:55:53 pm »
Done
See rev. 6177.

lainz

  • Hero Member
  • *****
  • Posts: 4449
    • https://lainz.github.io/
Re: TRxDBLookupCombo missing OnPaint event
« Reply #10 on: February 05, 2018, 03:43:05 pm »
Done
See rev. 6177.

Thankyou. Please you can upload this to Online Package Manager?

giuian

  • Newbie
  • Posts: 2
Re: TRxDBLookupCombo missing OnPaint event
« Reply #11 on: February 06, 2018, 01:03:32 pm »
Excuse me, i am unable to install rx package from OPM.
I got 'rxlookup.pas(1533,10) Error: Identifier not found "MouseInClient"'
Lazarus 1.8 not trunk fresh install.

Edit: i have changed MouseInClient with MouseEntered, now compile, but does it work the same?
MouseInclient it is not implemented in in 1.8 stable??
Sorry for my english...

lainz

  • Hero Member
  • *****
  • Posts: 4449
    • https://lainz.github.io/
Re: TRxDBLookupCombo missing OnPaint event
« Reply #12 on: February 06, 2018, 04:10:08 pm »
@alexs75, the mac button looks not quite right, the arrow is somewhat stretched at the right, like in the image I posted. Do you have a mac to test?

Of course the code I provided is the fault, but I don't have a mac to fix it for you.
« Last Edit: February 06, 2018, 04:40:21 pm by lainz »

alexs75

  • Full Member
  • ***
  • Posts: 112
Re: TRxDBLookupCombo missing OnPaint event
« Reply #13 on: February 07, 2018, 07:13:31 am »
1. How to download a package in OPM - I do not know yet.
2. Compilation in LAz 1.8 fixed.
3. I do not have a Mac. If it is not difficult - register on the bugtracker the error of displaying themes for Mac.

balazsszekely

  • Guest
Re: TRxDBLookupCombo missing OnPaint event
« Reply #14 on: February 07, 2018, 07:56:39 am »
@alexs75
Quote
1. How to download a package in OPM - I do not know yet.
Please read this: http://wiki.freepascal.org/Online_Package_Manager
Quote
2. Compilation in LAz 1.8 fixed.
Thanks. I updated in OPM.

 

TinyPortal © 2005-2018