{"id":1633,"date":"2008-03-07T15:27:38","date_gmt":"2008-03-07T15:27:38","guid":{"rendered":"http:\/\/www.amibroker.org\/userkb\/2008\/03\/07\/a-basic-message-panel\/"},"modified":"2011-01-11T22:27:28","modified_gmt":"2011-01-11T22:27:28","slug":"a-basic-message-panel","status":"publish","type":"post","link":"http:\/\/www.amibroker.org\/editable_userkb\/2008\/03\/07\/a-basic-message-panel\/","title":{"rendered":"A Basic Messaging Panel"},"content":{"rendered":"
Also see Moving Low Level Graphics (GFX) Objects on your Charts<\/a><\/p>\n This first post introduces you to the basic techniques on how to create a matrix of text cells to display messages and system status on your chart. At this stage the cells are not mouse-click sensitive; this and other features will be added later. In this example the number of columns, rows, the font size, and the location of the message panel, can be set from the Param window. In your final application you might want to make these parameters constant and remove the corresponding Param statements. You can combine any number of Panels, here is an example for multiple panels layouts:<\/p>\n <\/a><\/p>\n The following simple panel is produced by the code in this post.<\/p>\n <\/a><\/p>\n The code below will place the above Message panel on your chart. A code description follows below listing.<\/p>\n Message Panel code above calls the Include file listed at the end of this post. The The MsgCol_Begin() function defines the name and dimensions for the current column:<\/p>\n You can create many columns. The ColName is used in Static variables to allow the code to know to which Column the TextCells belong. The last four arguments are self-explanatory. The Overlay and background modes can be changed inside this function, or you can extract these GFX statements and execute them separately.<\/p>\n The TextCell() function adds one TextCell to the column. It defines the Message, Background color, and TextColor to be used:<\/p>\n The MsgCol_End() terminates the current column and draws the GFX pgraphics to the chart.<\/p>\n The Include file makes extensive use of static variables that are wrapped in kStaticVar\u2026() to make the static variables unique to the current ChartID. This is needed to call the functions from different panes and windows without interfering with one another. For more on this see Keying Static Variables<\/a>.<\/p>\n\r<\/span>#include <MessagePanelInclude.afl>\r\r<\/span>global <\/span>ColNumber<\/span>;\r\r<\/span>CellHeight <\/span>= <\/span>Param<\/span>(<\/span>"Cell Height"<\/span>,<\/span>20<\/span>,<\/span>5<\/span>,<\/span>200<\/span>,<\/span>5<\/span>);\r\r<\/span>CellWidth <\/span>= <\/span>Param<\/span>(<\/span>"Cell Width"<\/span>,<\/span>120<\/span>,<\/span>5<\/span>,<\/span>200<\/span>,<\/span>5<\/span>);\r\r<\/span>PanelYoffset <\/span>= <\/span>Param<\/span>(<\/span>"Cell Row Offset (px)"<\/span>,<\/span>10<\/span>,<\/span>0<\/span>,<\/span>Status<\/span>(<\/span>"pxheight"<\/span>),<\/span>5<\/span>);\r\r<\/span>PanelXoffset <\/span>= <\/span>Param<\/span>(<\/span>"Cell Column Offset (px)"<\/span>,<\/span>10<\/span>,<\/span>0<\/span>,<\/span>Status<\/span>(<\/span>"pxwidth"<\/span>),<\/span>5<\/span>);\r\r<\/span>FontRatio <\/span>= <\/span>Param<\/span>(<\/span>"Font:CellHeight ratio"<\/span>,<\/span>2<\/span>,<\/span>1<\/span>,<\/span>20<\/span>,<\/span>0.1<\/span>);\r\r<\/span>MsgCol_Begin<\/span>( <\/span>"COLUMNNAME 1"<\/span>, <\/span>CellHeight<\/span>, <\/span>CellWidth<\/span>, <\/span>PanelXoffset<\/span>, <\/span>PanelYoffset <\/span>);\r\r<\/span>TextCell<\/span>( <\/span>"Text Message 1"<\/span>, <\/span>BackgroundColor<\/span>=<\/span>1<\/span>, <\/span>TextColor<\/span>=<\/span>2<\/span>);\r\r<\/span>TextCell<\/span>( <\/span>"Text Message 2"<\/span>, <\/span>2<\/span>, <\/span>3<\/span>);\r\r<\/span>TextCell<\/span>( <\/span>"Text Message 3"<\/span>, <\/span>8<\/span>, <\/span>4<\/span>);\r\r<\/span>TextCell<\/span>( <\/span>"Text Message 4"<\/span>, <\/span>7<\/span>, <\/span>5<\/span>);\r\r<\/span>TextCell<\/span>( <\/span>"Text Message 5"<\/span>, <\/span>4<\/span>, <\/span>6<\/span>);\r\r<\/span>TextCell<\/span>( <\/span>"Text Message 6"<\/span>, <\/span>3<\/span>, <\/span>7<\/span>);\r\r<\/span>TextCell<\/span>( <\/span>"Text Message 7"<\/span>, <\/span>2<\/span>, <\/span>8<\/span>);\r\r<\/span>MsgCol_End<\/span>();\r\r<\/span>MsgCol_Begin<\/span>( <\/span>" COLUMNNAME 2"<\/span>, <\/span>CellHeight<\/span>, <\/span>CellWidth<\/span>, <\/span>PanelXoffset<\/span>, <\/span>PanelYoffset <\/span>);\r\r<\/span>TextCell<\/span>( <\/span>"Text Message 1"<\/span>, <\/span>9<\/span>, <\/span>2<\/span>);\r\r<\/span>TextCell<\/span>( <\/span>"Text Message 2"<\/span>, <\/span>8<\/span>, <\/span>3<\/span>);\r\r<\/span>TextCell<\/span>( <\/span>"Text Message 3"<\/span>, <\/span>7<\/span>, <\/span>4<\/span>);\r\r<\/span>TextCell<\/span>( <\/span>"Text Message 4"<\/span>, <\/span>6<\/span>, <\/span>5<\/span>);\r\r<\/span>TextCell<\/span>( <\/span>"Text Message 5"<\/span>, <\/span>5<\/span>, <\/span>6<\/span>);\r\r<\/span>TextCell<\/span>( <\/span>"Text Message 6"<\/span>, <\/span>4<\/span>, <\/span>7<\/span>);\r\r<\/span>TextCell<\/span>( <\/span>"Text Message 7"<\/span>, <\/span>3<\/span>, <\/span>8<\/span>);\r\r<\/span>MsgCol_End<\/span>();\r<\/span><\/pre>\n
MsgCol_Begin<\/span>( <\/span>"COLUMNNAME 1"<\/span>, <\/span>CellHeight<\/span>, <\/span>CellWidth<\/span>, <\/span>PanelXoffset<\/span>, <\/span>PanelYoffset <\/span>);<\/span><\/pre>\n
\rTextCell<\/span>( <\/span>"Text Message 1"<\/span>, <\/span>colorBlack<\/span>, <\/span>colorWhite<\/span>);<\/span><\/pre>\n