[ Pobierz całość w formacie PDF ]
.Now the program hastwo other forms, with similar settings (although they host different controls):object Form2: TForm2Caption =  Small EditorCopyright ©2001 SYBEX, Inc., Alameda, CA www.sybex.com 2874c08.qxd 7/2/01 4:27 PM Page 309Delphi s Docking Support 309DragKind = dkDockDragMode = dmAutomaticobject Memo1: TMemoAlign = alClientendendYou can drag these forms onto the page control to add new pages to it, with captions corre-sponding with the form titles.You can also undock each of these controls and even the entirePageControl.To do this, the program doesn t enable automatic dragging, which would makeit impossible to switch pages anymore.Instead, the feature is activated when the user clickson the area of the PageControl that has no tabs that is, on the underlying panel:procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);beginPageControl1.BeginDrag (False, 10);end;You can test this behavior by running the DockPage example, although Figure 8.8 tries todepict it.Notice that when you remove the PageControl from the main form, you candirectly dock the other forms to the panel and then split the area with other controls.This isthe situation captured by the figure.FI GURE 8.8:The main form of the Dock-Page example after a formhas been docked to thepage control on the left.Notice that another formuses part of the area of ahosting panel.Copyright ©2001 SYBEX, Inc., Alameda, CA www.sybex.com 2874c08.qxd 7/2/01 4:27 PM Page 310310 Chapter8 " Building the User InterfaceThe ActionManager ArchitectureWe have seen that actions and the ActionManager component can play a central role in thedevelopment of Delphi applications, since they allow a much better separation of the userinterface from the actual code of the application.The user interface, in fact, can now easilychange without impacting the code too much.The drawback of this approach is that a pro-grammer has more work to do.To have a new menu item, you need to add the correspondingaction first, than move to the menu, add the menu item, and connect it to the action.To solve this issue, and to provider developers and end users with some advanced features,Delphi 6 introduces a brand new architecture, based on the ActionManager component,which largely extends the role of actions.The ActionManager, in fact, has a collection ofactions but also a collection of toolbars and menus tied to them.The development of thesetoolbars and menus is completely visual: you drag actions from a special component editor ofthe ActionManager to the toolbars to have the buttons you need.Moreover, you can let theend user of your programs do the same operation, and rearrange their own toolbars andmenus starting with the actions you provide them.In other words, using this architecture allows you to build applications with a modern userinterface, customizable by the user.The menu can show only the recently used items (asmany Microsoft programs do, nowadays), allows for animation, and more.This architecture is centered on the ActionManager component, but includes also a fewothers components found at the end of the Additional page of the palette:" The ActionManager component is a replacement of the ActionList (but can also useone or more existing ActionLists) adding to the architecture visual containers ofactions." The ActionMainMenuBar control is a toolbar used to display the menu of an applica-tion based on the actions of an ActionManager component." The ActionToolBar control is a toolbar used to host buttons based on the actions of anActionManager component." The CustomizeDlg component includes the dialog box you can use to let users cus-tomize the user interface of an application based on the ActionManager component.Building a Simple DemoAs this architecture is mostly a visual architecture, a demo is probably worth more than ageneral discussion (although a printed book is not the best way to discuss a highly visualseries of operations).To create a sample program based on this architecture, first drop anActionManager component on a form, then double click it to open its component editor,Copyright ©2001 SYBEX, Inc., Alameda, CA www.sybex.com 2874c08.qxd 7/2/01 4:27 PM Page 311The ActionManager Architecture 311shown in Figure 8.9.Notice that this editor is not modal, so you can keep it open whiledoing other operations in Delphi.Consider also that this same dialog box is displayed by theCustomizeDlg component, although with some limited features (for example, adding newactions is disabled).FI GURE 8 [ Pobierz caÅ‚ość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • higrostat.htw.pl
  •