ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 How to draw rating stars?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
skippix Posted - Feb 15 2021 : 19:04:27
I have a table with filenames and rating 0-5. I can load the TImageEnMView from the table, but I'd like to mimic this to show the stars.



Any suggestions, code snippets, or examples would be greatly appreciated!

Skip
3   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Feb 25 2021 : 15:34:48
Nice work, Skip. It looks really good.

Nigel
Xequte Software
www.imageen.com
skippix Posted - Feb 25 2021 : 09:21:05
Thanks, Nigel!

I've got something working that will do until I have more time to go deeper.

I kinda used the first method. I could not figure out how to code for "U+2605" and all I could find on the internet was really deep, involved coding. I ended up copying and pasting the star into my unit as a constant (const _star = '#9733;';) and saving the unit with UTF8 encoding.

In my grid load, I use the following

  x := TheGrid.AppendImage;
  TheGrid.ImageFileName[x] := sl[i];
  if (sbtnToggleRatingMode.Down) and (ckbShowImageRatingOnGrid.Checked) then
    begin
      ia.FileName := ExtractFileName(sl[i]);
      TheGrid.ImageTopText[x] := ia.SeqNo;
      TheGrid.ImageBottomText[x] := GetFileStars(sl[i]);
    end;

function TfrmAssetCurator.GetFileStars (sFile: String): String;
var cds: TClientDataSet;
  ia: TImageAsset;
begin
  cds := FRollData.FetchCDS ('FlagAndTag');
  ia := TImageAsset.Create(sFile);
  with cds do
    begin
      Filter := 'filename=' + QuotedStr(ia.MasterName);
      Filtered := True;
      Result := ShowStars (FieldByName('rating').AsString);
      Filtered := False;
    end;
  FreeAndNil(ia);
end;

function TfrmAssetCurator.ShowStars (sIn: String): String;
var z: Integer;
  i: Integer;
begin
  Result := '';
  if (sIn = '') or (sIn = '0') then
    begin
      Exit;
    end
  else
    begin
      i := StrtoInt(sIn);
      for z := 1 to i do
        begin
          Result := Result + _star;
        end;
    end;
end;


Here's a screenshot of the result


Cheers, and thanks again,
Skip
xequte Posted - Feb 16 2021 : 15:55:45
Hi Skip

Well the easiest way would be to use a star character (e.g. U+2605):

https://unicode-search.net/unicode-namesearch.pl?term=STAR

Then you can just specify it for the bottom text.

Otherwise you would need to custom draw it using:

http://www.imageen.com/help/TImageEnMView.OnImageDraw2.html

Nigel
Xequte Software
www.imageen.com