Is there a way to show the button in the TNxButtonItem/TNxFolderItem all the time. Right now it only shows up if the item is selected, i want it visible all the time.
Also have you considered creating a TNxFileItem (like the folder one, but you can select a file instead of folder), it should be simple to do, same as the TNxFolderItem just using a OpenFile dialog.
Always show button on TNxButtonItem
Started by Faw, Mar 30 2012 11:59 PM
2 replies to this topic
#1
Posted 30 March 2012 - 11:59 PM
#2
Posted 31 March 2012 - 06:04 PM
Hi,
Unfortunately button can't be shown since it is only part of Editor and I am hiding editor when item is deselected.
I will consider your suggestion. It is good suggestion.
Unfortunately button can't be shown since it is only part of Editor and I am hiding editor when item is deselected.
I will consider your suggestion. It is good suggestion.
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#3
Posted 02 April 2012 - 10:52 PM
Hi,
Unfortunately button can't be shown since it is only part of Editor and I am hiding editor when item is deselected.
Boki I think I found a bug when I was working on this. On TNxExecuteButton.Paint (on NxEdit.pas) there's this code:
if Assigned(FGlyph) then begin X := Width div 2 - FGlyph.Width div 2; Y := Height div 2 - FGlyph.Height div 2; TDrawProvider.ApplyBitmap(Canvas, X, Y, Glyph); end; TGraphicsProvider.DrawTextRect(Canvas, ClientRect, taCenter, Caption);
As far as I know, it should either show the glyph or the text, but not both. Right now that code will paint the glyph and write the text over it. I think the DrawText should be in an else.
Anyway, just in case anyone is interested I was able to draw the button all the time. Created 2 functions, DrawButton, ClickButton. To use them:
1. Set TNxButtonItem.DrawOptions to 'Custom'.
2. Put DrawButton in TNextInspector.CustomDrawItem event
3. Put ClickButton in TNextInspector.MouseUp event
Will show the buttons on all TNxButtonItems.
procedure ClickButton(inspector:TNextInspector;pt:TPoint); var Item: TNxPropertyItem; rc:TRect; begin Item:=inspector.GetItemAtPos(pt); // check if a TNxButtonItem if(not (Item is TNxButtonItem)) then exit; // ok, it a TNxButtonItem, paint button rc:=Rect( inspector.ClientRect.Left, Item.Top, inspector.ClientRect.Right, Item.Top+inspector.RowHeight ); // select the item inspector.SelectedItem:=Item; // click button if in button area if(PtInRect(rc, pt)) then begin pt := inspector.ClientToScreen(pt) ; pt.x := Round(pt.x * (65535 / Screen.Width)) ; pt.y := Round(pt.y * (65535 / Screen.Height)) ; // Simulate the left mouse button down Mouse_Event(MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_LEFTDOWN,pt.x, pt.y, 0, 0) ; // Simulate the left mouse button up Mouse_Event(MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_LEFTUP, pt.x, pt.y, 0, 0) ; end; end; procedure DrawButton(inspector:TNextInspector;Item:TNxPropertyItem;rc:TRect); var DrawFlags, State, X, Y: Integer; r:TRect; FTheme: HTHEME; begin // check if a TNxButtonItem if(not (Item is TNxButtonItem)) then exit; // resize rc to button size (receives full item dimensions) rc.Right:=rc.Right-1; rc.Left:=rc.Right-(TNxButtonItem(Item).ButtonWidth); // ok, it a TNxButtonItem, paint button if IsThemed then begin inspector.Canvas.Brush.Color := TNxButtonItem(Item).Color; inspector.Canvas.FillRect(rc); State := 2; if not inspector.Enabled then State := 4; r:=rc; InflateRect(r,1,0); FTheme := OpenThemeData(inspector.Handle, 'Button'); DrawThemeBackground(FTheme, inspector.Canvas.Handle, 1, State, r, nil); CloseThemeData(inspector.Handle); end else begin { theme off } DrawFlags := DFCS_BUTTONPUSH; // DFCS_ADJUSTRECT or if not inspector.Enabled then DrawFlags := DrawFlags or DFCS_INACTIVE; DrawFrameControl(inspector.Canvas.Handle, rc, DFC_BUTTON, DrawFlags) end; // draw glyph or caption if Assigned(TNxButtonItem(Item).Glyph) then begin X := rc.Left + (TNxButtonItem(Item).ButtonWidth div 2 - TNxButtonItem(Item).Glyph.Width div 2); Y := rc.Top + (inspector.RowHeight div 2 - TNxButtonItem(Item).Glyph.Height div 2); TDrawProvider.ApplyBitmap(inspector.Canvas, X, Y, TNxButtonItem(Item).Glyph); end else begin TGraphicsProvider.DrawTextRect(inspector.Canvas, rc, taCenter, TNxButtonItem(Item).ButtonCaption); end; end;
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users