View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0003917 | JEDI VCL | 00 JVCL Components | public | 2006-09-20 09:27 | 2007-06-19 03:54 |
Reporter | ZENsan | Assigned To | obones | ||
Priority | normal | Severity | feature | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | Daily / GIT | ||||
Target Version | Fixed in Version | 3.34 | |||
Summary | 0003917: State and AllowGreyed properties for TJvXPCheckbox... | ||||
Description | State and AllowGreyed properties for TJvXPCheckbox... Is it possible? | ||||
Tags | No tags attached. | ||||
|
I believe the AllowGreyed is only used when a checkbox component is DB aware,where the value is null, isn't it? So it wouldn't apply to this componente, that is either checked or not, right? Or do you want to display it greyed if the component's property enable = false? And the 'state' property you mention, what values would it have? Are you sure it's not the 'checked' property with a different name? Take a look at line 395 of jvXpCheckCtrls.pas, see if you can't add something to that code yourself, it doesn't look too complicated. (I just don't have the time) The JEDI appreciate any help/code from new users, you can contribute by trying some coding yourself and posting back here. In case you do change this component's code, you will need to: Open and recompile(build All) ($Jedi)\jvcl\packages\JvStdCtrlsD7R.dpk and Open and recompile(build All) ($Jedi)\jvcl\packages\JvStdCtrlsD7D.dpk Cheers |
|
Ok, I will try to add it myself. Checked - filter some values Unchecked - filter other values Greyed - do not filter anything This is why I want State property. |
2006-09-26 00:31
|
Checkbox_with_state_and_allowgrayed.zip (15,977 bytes) |
|
Here is updated source file. Unit JvXPCheckCtrls.pas: Added property AllowGrayed: Boolean; property State: TJvXLCheckBoxState; All this properties works interactively one with other. Demo program is included. Only problem - you may need to update bitmap in resources of package. I erases 4 dots in angles of square (fro cbGrayed state) beacase if I save all black square then nothing is drawed. |
|
And also I don't know how is better - save TCheckBoxState type or invent new TJVXpCheckBoxState.. I thnk may be better is to save old type for compatibility... |
|
Maybe something like that: TJVXPCheckBoxState = (jvcbUnchecked, jvcbChecked, jvcbGrayed); |
2006-09-26 08:39
|
JvXPCheckCtrls.patch.zip (5,174 bytes) |
|
There is WinMerge patch file for unit. But Bitmap and reources I haven't touched. |
|
Well done! But... I found 2 bugs in your SetState procedure. The 1st is that you 1st set the new state (FState := Value), and then you check if FState <> Value to actually do some work, which means it never does anything, only sets the value,as that condition is always false. The 2nd is that your fAllowGrayed wasn't being checked, so even if that was false, you would set FState = value, therefore it would be painted as grayed. This is the fix to those: procedure TJvXPCustomCheckControl.SetState(const Value: TJvXPCheckBoxState); begin if FState <> Value then begin if (not FAllowGrayed) and (Value=cbGrayed) then FState := cbUnchecked else FState := Value; if FState = cbChecked then FChecked := True else FChecked := False; LockedInvalidate; end; end; And another thing: I don't think you got the right bitmap to the grayed state. I couldn't actually see any checkbox grayed by Windows itself, so I created one artificially, with a TMS component. It seems to me that the grayed bitmap should be completely square, without the round corners that you used. See my attached jpg. If you agree with me, can you update your JvXPCore.res file and attach it here? Then we have the color problem. The only color available from jvXPCore.pas for the checkbox is the enabled one, does anyone know what is the constant for the disabled one, as it's brighter then the enabled, or where to lookup to find the right value? If you see the next lines just after loading the bitmap from the resource, you see this: if Theme = WindowsXP then JvXPColorizeBitmap(Bitmap, dxColor_Chk_Enb_NmSymb_WXP) where obviously we need to check now if FState = Grayed then (...) where we need to find out and create the disabled color constant. BTW, I liked the idea of your TJvXPCheckBoxState being a replica of TCheckBoxState, as it keeps it easy to typecast and there is no need to include StdCtrls in the uses clauses. Cheers, Alex |
2006-09-27 04:37
|
AlexUnit1.zip (1,009 bytes) |
2006-09-27 04:39
|
|
|
I also edited the unit1.pas (.dfm) from your demo project, so it is easier to follow how the component is behaving. They are in AlexUnit1.zip. |
|
About first bug - thanks, I forget to remove this line when copying part of code :) I also changed SetState as follows - I think is better Value := FState but not to reset state to Unchecked: procedure TJvXPCustomCheckControl.SetState(const Value: TJvXPCheckBoxState); begin if FState <> Value then begin if (not FAllowGrayed) and (Value=jvcbGrayed) then Value := FState; if FState = jvcbChecked then FChecked := True else FChecked := False; LockedInvalidate; end; end; Type: TJvXPCheckBoxState = (jvcbUnchecked, jvcbChecked, jvcbGrayed); |
2006-09-28 09:03
|
|
|
And you have never seen that type of checkbox state in Windows :)? |
|
And what are you talking about Color? Why disabled? Simply another bitmap.. Or maybe I don't understand something.. Sorry if my answers are late - I am working and doing this in work time :) |
|
Sorry - I have some differences between that old and new version of my Units, so there is my little mistake: if (not FAllowGrayed) and (Value=jvcbGrayed) then Exit;//Value := FState;compilation error because const.. |
|
Well, the component objective is to mimic the visual aspects of Windows XP, right? So it has to be as close to the ones drawn natively by Windows itself, not by my application or yours or anyone's, just like you showed in your .png. Considering that a grayed checkbox got that name because originally in the other Windows versions it was gray, and not pure black (as in the checked state), we need to find out what is the correct color of a grayed checkbox in XP, as ironically, it's now green! My whole point is: it's clearly a different color then the checked state, it's lighter, we need to know what RGB values that lighter green has. I assume there has to be a table somewhere (MSDN?) specifying the color exact RGB values, but if we can't find it, we will have to use a capture screen tool to find out manually to include it in jvCore.pas. Now, just to let you know why I'm insisting in fixing this component instead of using the TMS or any other 3rd party components that I already paid for: the Jedi ones are the only ones that work in Windows 2000 (and probably 9x, but I never tested) and in XP even if you disable the Themes service. So your applications (at least these components) are ALWAYS displayed identically across all plataforms, and make a notable difference when put side by side with any other app in W2K, for example. |
|
Just a side note: Please provide a patch file made with TortoiseSVN and only that one. One question: Why create a new type for the state of the checkbox when one already exists for regular checkboxes? TCheckBoxState defined in StdCtrls.pas |
|
This is good because you do not need to include StdCtrls in this unit. |
|
To me it is not. And the XPCtrls package already requires the StdCtrls package anyway. So please do not duplicate this type. |
2006-09-29 08:42
|
JvXPCheckCtrls29.09.zip (3,779 bytes) |
|
I have to agree with Obones, because it's descendent of jvComponents, StdCtrls is already included, whether we want it or not. |
|
I removed new type from unit, included StdCtrls and made some omproveemnts. I didn't find anything about how to determine color of check mark programmatically. I think better is to use as you said - screen capture method. |
|
I created the color I believe is the right one, dxColor_Chk_Enb_GraSymb_WXP = TColor($0071C671); Then added the code to use it: ~line 460 IF FState = cbChecked THEN Bitmap.LoadFromResourceName(HInstance, 'JvXPCheckboxCHECKBOX') ELSE Bitmap.LoadFromResourceName(HInstance, 'JvXPCheckboxCHECKBOXGRAY'); IF Theme = WindowsXP THEN -> IF FState = cbChecked THEN JvXPColorizeBitmap(Bitmap, dxColor_Chk_Enb_NmSymb_WXP) -> ELSE -> JvXPColorizeBitmap(Bitmap, dxColor_Chk_Enb_GraSymb_WXP) ELSE IF (dsClicked IN DrawState) AND (dsHighlight IN DrawState) THEN JvXPColorizeBitmap(Bitmap, clWhite); But for some reason, JvXPColorizeBitmap() always paints it in a dark gray, as like it's failing to apply the new color, any ideas? Interesting enough, if you just change the color to a lower level of R and B, like $0041C641, it works. Try yourself, just replace even the current Checked enabled color to the one I mentioned and you will see. |
|
anudedeus, can you provide the files you modified ? |
2006-10-10 05:40
|
axp_TJvXpCheckbox.zip (2,339 bytes) |
|
Ok, changes are uploaded. 2 patch files and 1 .res file. The bitmap for the grayed state has to be 256 colors to work fine, and cannot be transparent. Because of that, I decided to increase the original JvXPCheckboxCHECKBOX resource from jvXpCore.res to 256 colors as well, so they have both same format/number of colors. The final result is really good. |
|
So, is everything alright with my latest files (axp_TJvXpCheckbox.zip)? |
|
Well, thanks for the res file, but what I need are the BMP files because the res file is generated from the BMP and .RC files present in the images folder. |
2006-11-01 07:49
|
axp_CheckBox_bmps.zip (1,236 bytes) |
|
Ok, bmps are now uploaded. Note that it includes the new JVXPCHECKBOXCHECKBOXGRAY.bmp and the modified (superVga) version of the previous JVXPCHECKBOXCHECKBOX.bmp. |
|
So when it will be in release? |
|
This is now in SVN. Next time please respect the coding style and use TortoiseSVN to create the patch files. Thanks. |
Date Modified | Username | Field | Change |
---|---|---|---|
2006-09-20 09:27 | ZENsan | New Issue | |
2006-09-22 10:28 | anudedeus | Note Added: 0010154 | |
2006-09-22 11:38 | ZENsan | Note Added: 0010155 | |
2006-09-26 00:31 | ZENsan | File Added: Checkbox_with_state_and_allowgrayed.zip | |
2006-09-26 00:33 | ZENsan | Note Added: 0010174 | |
2006-09-26 00:37 | ZENsan | Note Added: 0010175 | |
2006-09-26 00:40 | ZENsan | Note Added: 0010176 | |
2006-09-26 08:39 | ZENsan | File Added: JvXPCheckCtrls.patch.zip | |
2006-09-26 08:40 | ZENsan | Note Added: 0010187 | |
2006-09-26 08:40 | ZENsan | Note Edited: 0010187 | |
2006-09-27 04:34 | anudedeus | Note Added: 0010195 | |
2006-09-27 04:37 | anudedeus | File Added: AlexUnit1.zip | |
2006-09-27 04:39 | anudedeus | File Added: JediChkBox1.jpg | |
2006-09-27 04:42 | anudedeus | Note Added: 0010196 | |
2006-09-28 09:02 | ZENsan | Note Added: 0010201 | |
2006-09-28 09:03 | ZENsan | File Added: Windows Grayed checkbox!.png | |
2006-09-28 09:04 | ZENsan | Note Added: 0010202 | |
2006-09-28 09:12 | ZENsan | Note Added: 0010203 | |
2006-09-28 09:54 | ZENsan | Note Added: 0010206 | |
2006-09-28 11:45 | anudedeus | Note Added: 0010209 | |
2006-09-28 11:56 | anudedeus | Note Edited: 0010209 | |
2006-09-29 07:20 | obones | Note Added: 0010245 | |
2006-09-29 07:20 | obones | Status | new => confirmed |
2006-09-29 07:56 | ZENsan | Note Added: 0010253 | |
2006-09-29 08:07 | obones | Note Added: 0010256 | |
2006-09-29 08:42 | ZENsan | File Added: JvXPCheckCtrls29.09.zip | |
2006-09-29 08:44 | anudedeus | Note Added: 0010258 | |
2006-09-29 08:45 | ZENsan | Note Added: 0010259 | |
2006-09-29 10:00 | anudedeus | Note Added: 0010260 | |
2006-10-06 03:01 | obones | Note Added: 0010304 | |
2006-10-10 05:40 | anudedeus | File Added: axp_TJvXpCheckbox.zip | |
2006-10-10 05:44 | anudedeus | Note Added: 0010339 | |
2006-10-23 10:41 | anudedeus | Note Added: 0010383 | |
2006-11-01 06:52 | obones | Note Added: 0010402 | |
2006-11-01 07:49 | anudedeus | File Added: axp_CheckBox_bmps.zip | |
2006-11-01 07:51 | anudedeus | Note Added: 0010405 | |
2006-11-16 07:46 | ZENsan | Note Added: 0010438 | |
2007-06-19 03:53 | obones | Status | confirmed => resolved |
2007-06-19 03:53 | obones | Fixed in Version | => Daily / SVN |
2007-06-19 03:53 | obones | Resolution | open => fixed |
2007-06-19 03:53 | obones | Assigned To | => obones |
2007-06-19 03:53 | obones | Note Added: 0013400 |