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
 TIEColorPalette suggestion

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
PeterPanino Posted - Sep 15 2017 : 14:34:12
Hello,

I need the TIEColorPalette control to select a Foreground color and a Background color:



For this purpose, I need to LEFT-click on a cell to select the Foreground color (mark the cell with "F") and to RIGHT-click on a cell to select the background color (mark the cell with "B").

Is this possible?

This could be easily achieved with this code:

procedure TformMain.IEColorPalette1CellClick(Button: TMouseButton; 
    Shift: TShiftState; Index: Integer; aColor: TColor; 
    var Allow: Boolean; var CellChar: Char);
begin
  if Button = mbLeft then
    CellChar := 'F' 
  else if Button = mbRight then
    CellChar := 'B'
  else
    CellChar := '';
end;
4   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Sep 19 2017 : 19:38:06
Hi Peter

Bill's suggestion in the other post looks good:

https://www.imageen.com/ieforum/topic.asp?TOPIC_ID=3235

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
PeterPanino Posted - Sep 18 2017 : 07:12:31
Nigel,

thank you very much!

How can the cellChar color be controlled, i.e. making it bright in a dark cell color and making it dark in a bright cell color?
xequte Posted - Sep 17 2017 : 21:05:28
Hi

I have added OnAfterPaintCell. Email me if you want a pre-release.


// Draw an "F" on the foreground color, and a "B" on background color
procedure TMainForm.IEColorPalette1AfterPaintCell(ACanvas: TCanvas; CellRect: TRect;
    aColor: TColor; Index: Integer; aState: TIEColorCellState; var aStyle:
    TIETransparentStyle; var Handled: Boolean);
var
  cellChar: string;
begin
  cellChar := '';
  if aColor = fForegroundColor then
    cellChar := 'F'
  else
  if aColor = fBackgroundColor then
    cellChar := 'B';

  if cellChar <> '' then
  begin
    ACanvas.Brush.Style := bsClear;
    ACanvas.Font.Style := [ fsBold ];

    // Draw text in center of cell
    ACanvas.TextOut( CellRect.Left + ( CellRect.Right - CellRect.Left ) div 2 - ACanvas.TextWidth( cellChar ) div 2,
                     CellRect.Top + ( CellRect.Bottom - CellRect.Top ) div 2 - ACanvas.TextHeight( cellChar ) div 2,
                     cellChar );
  end;
end;


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
w2m Posted - Sep 15 2017 : 16:53:48
I tried to create a demo to achieve this by getting the TShiftState (ieLeft or ieRight) in OnNMouseDown, then draw the 'F'or 'B' on the selected cell's canvas depending on the TShiftState and then set a global var AForgroundColor or ABackgroundColor value.

Unfortunately, the IEColorPalette1PaintCell event used to draw on the canvas is executed before the cell colors are drawn, so I was not successful. I could draw the text but it is over written by the cells color rect. You could probably draw your own cells first by setting Handled parameter to True and then draw the cell colors and then the text ('F' or 'B') on the canvas, but I did not want to take the time to do that much work.

It seems like there should be another event (eg. OnPaintCellText) that occurs after IEColorPalette1PaintCell to draw the text on the canvas. If possible the new event should also provide a parameter that indicates which button was pressed so a Foreground and background color could be set.

I am not sure if the ImageEn folks want to extend the component to allow selecting two colors but that would probably be the best route to go, otherwise you need to use multiple events OnMouseDown, OnPaintCell and the new event OnPaintCellText to draw the cells, text and to set the two color values.

This is a bit farther than I want to go.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development