home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / ADDONINC.PAK / IMPD.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  8.9 KB  |  249 lines

  1. /*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2.  
  3.   impd.h
  4.   Created: 11/14/95
  5.   Copyright (c) 1995, 1996 Borland International
  6.   $Header:   Y:\admin\bride\addon\deliver\interfac\impd.h_v   1.20   18 Nov 1996 11:29:40   JDOUGLAS  $
  7.   $Revision:   1.20  $
  8.    
  9.   MPD refers to the Multi-Page-Dialog boxes used for setting options in the 
  10.   BCW IDE. A "Chapter" represents a high level item containing one or more
  11.   "Pages" which can be colapsed under the Chapter.
  12.  
  13.   Interface declared in this file:
  14.  
  15.   implemented by IDE
  16.  
  17.   IMpdServer
  18.   IMpdLocalOverride
  19.  
  20.   implemented by IDE client
  21.  
  22.   IMpdPage  
  23.   IMpdChapter
  24.   IMpdPageLocalOverride
  25.  
  26.   Overview:
  27.  
  28.   User implements IMpdChaper and calls IMpdServer::RegisterChapter() to register
  29.   the chapter. There are two MPDs, Project and Environment in IDE currently.
  30.   Client calls RegisterChapter() with MpdType type == MT_EnvironmentOptions to
  31.   add a chapter to Option|Project MPD or register with MpdType
  32.   type == MT_ProjectOptions to add chapter to Option|Envoronment MPD.
  33.  
  34.   The following actions occour during MPD open:
  35.  
  36.     1. IDE calls IMpdChapter::SetEditNode(node) to inform client that IDE
  37.        is about to open a MPD for node. For environment MPD, this argument
  38.        should be ignored.
  39.  
  40.     2. IDE calls IMpdChapter::GetPageCount() to determine the number of page
  41.        client will have.  If the returned page count is 0, MPD will not show
  42.        any page from this chapter and no calls will be made to this chapter
  43.        until next MPD open.  Client can return different values based
  44.        on the node passed in IMpdChapter::SetEditNode()
  45.  
  46.     3. If IMpdChapter::GetPageCount() retuns no-zero value.
  47.        IDE calls IMpdChapter::GetPage(iPage) to retrieve all the pages
  48.        available.
  49.        
  50.     4. IDE calls IMpdPage::GetHInstance() and IMpdPage::GetResourceId() to
  51.        locate the MPD dialog resource. 
  52.        IDE calls to IMpdPage::GetPageTitle() to get the text displayed in
  53.        MPD tree window and on top of the dialog page.
  54.        IDE calls GetPageStyle() to determine the chapter configuration in 
  55.        MPD tree window.
  56.  
  57.     5. When an addon page is selected in MPD, IDE calls IMpdChapter::OpenPage()
  58.        to open an addon page. The PageResourceId in the argument is the returned
  59.        value of IMpdPage::GetResourceId(). It indicates which page to open.
  60.  
  61.     6. If IMpdChapter::OpenPage() returns a valid IMpdPage. IMpdPage::Init() is
  62.        called and addon page is passed a valid dialog window handle.  If the
  63.        addon page supports IMpdPageLocalOverride interface, 
  64.        IDE calls IMpdPageLocalOverride::InitLocalOverride() and passes addon
  65.        page IMpdLocalOverride interface to intialize local override.  After
  66.        calling Init(), IDE calls SetDlgItems() to initialize the page.
  67.  
  68.     7. Now the addon page is on the screen.  If user select a different page,
  69.        IDE will call IMpdPage::CanClose() to get permission to switch to a
  70.        different page. If CanClose() returns TRUE, IDE will switch to the new
  71.        page.  Otherwise nothing is changed. If user selects the Undo button,
  72.        IMpdPage::Undo() is called to undo user changes.  Addon page can also
  73.        implement IMpdPage::OnCommand() perform any WM_COMMAND message
  74.        processing.
  75.  
  76.     8. If user clicks on OK button and IMpdPage::IsModified() returns TRUE,
  77.        IDE calls IMpdPage::GetDlgItems() to retrieve any user changes at the
  78.        dialog UI level.
  79.  
  80.     9. After the MPD is closed. All clients' IMpdChapter::Close(fOk) is called.
  81.        If user clicks OK button, then fOk is TRUE. Otherwise fOk is FALSE.
  82.     
  83. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ 
  84. #ifndef __IMPD_H
  85. #define __IMPD_H
  86.  
  87. #include <ideaddon\ipolystr.h>
  88. #include <ideaddon\isbar.h>
  89. #include <ideaddon\common.h>    // ProjectNode
  90. #include <ideaddon\impd.uid>
  91.  
  92. enum MpdType {
  93.   MT_EnvironmentOptions,
  94.   MT_ProjectOptions
  95. };
  96.  
  97. #define MPD_SUMMARY       0x0000
  98. #define MPD_PAGE          0x0001
  99.  
  100. #define MPDF_OPEN         0x1000
  101. #define MPDF_CLOSE        0x0000
  102.  
  103. #define MPD_OPENSUMMARY  MPD_SUMMARY|MPDF_OPEN
  104. #define MPD_CLOSEPAGE    MPD_PAGE|MPDF_CLOSE
  105.  
  106. //.............................................................................
  107. //
  108. //  User implements this class and returns a pointer to an instance of it when
  109. //  IMpdChapter::OpenPage() is called by the AddOn wrapper dll.
  110. //
  111. class IMpdPage : public IUnknown {
  112.  public:
  113.   //
  114.   //  Init() is called when the page dialog object is initially created.
  115.   //  HWND hDlg         dialog window handle of the page
  116.   //  IStatusBar* isb   represent the status window in MPD
  117.   //
  118.   virtual void BCWADDON_CMETHOD Init(HWND hDlg, IStatusBar* isb) = 0;
  119.   //
  120.   // return TRUE if a page can be turned, otherwise return 0.
  121.   //
  122.   virtual BOOL BCWADDON_CMETHOD CanClose() = 0;
  123.   //
  124.   //  SetDlgItems() is called to set the page content to the current state
  125.   //  represented by the application internal data
  126.   //
  127.   virtual void BCWADDON_CMETHOD SetDlgItems() = 0;
  128.   //
  129.   //  GetDlgItems() is called to set the applcaition internal data based
  130.   //  on current user input
  131.   //
  132.   virtual void BCWADDON_CMETHOD GetDlgItems() = 0;
  133.   //
  134.   //  return the modified state of the page
  135.   //  return TRUE if the page has been modified, otherwise return FALSE.
  136.   //
  137.   virtual BOOL BCWADDON_CMETHOD IsModified(void) = 0;
  138.   //
  139.   //  undo user modification on current page. IsModified returns FALSE
  140.   //  after Undo() 
  141.   //
  142.   virtual void BCWADDON_CMETHOD Undo() = 0;
  143.   //
  144.   //  OnComamnd() is called in response to perform WM_COMMAND processing.
  145.   //  If an application processes this message, it should return zero
  146.   //
  147.   virtual LRESULT BCWADDON_CMETHOD OnCommand(UINT id, HWND hWndCtl, UINT notifyCode) = 0;
  148.   //
  149.   //
  150.   //
  151.   virtual HINSTANCE BCWADDON_CMETHOD GetHInstance() = 0;
  152.   virtual UINT BCWADDON_CMETHOD GetResourceId() = 0;
  153.   virtual IPolyString* BCWADDON_CMETHOD GetPageTitle() = 0;
  154.   //
  155.   // return a combination of MPDF_* flags defined in this file
  156.   //
  157.   virtual UINT BCWADDON_CMETHOD GetPageStyle() = 0;
  158.   //
  159.   // call help on the page
  160.   //
  161.   virtual void BCWADDON_CMETHOD Help(BOOL fF1Key) = 0;
  162.   //
  163.   // display information about this page in the status line
  164.   //
  165.   virtual void BCWADDON_CMETHOD DisplayPageStatus() = 0;
  166. };
  167.  
  168. //.............................................................................
  169. //
  170. // User implements this class and passes a pointer to an instance of it in
  171. // IMpdServer::RegisterChapter.
  172. //
  173. class IMpdChapter : public IUnknown {
  174.  public:
  175.   //
  176.   // SetEditNode set the node to be changed
  177.   //
  178.   //
  179.   virtual void BCWADDON_CMETHOD SetEditNode(ProjectNode node) = 0;
  180.   //
  181.   // open the page indicated by PageResourceId
  182.   //
  183.   virtual IMpdPage* BCWADDON_CMETHOD OpenPage(UINT PageResourceId, ProjectNode node = 0 ) = 0;
  184.   //
  185.   // return the number of pages in the chapter
  186.   //
  187.   virtual UINT BCWADDON_CMETHOD GetPageCount() = 0;
  188.   //
  189.   // The first page starts at 1
  190.   //
  191.   virtual IMpdPage* BCWADDON_CMETHOD GetPage(UINT iPage) = 0;
  192.   //
  193.   // Close() is called when MPD is closed
  194.   // fOk is 1 if user select OK button to close MPD
  195.   //
  196.   virtual void BCWADDON_CMETHOD Close(UINT fOk) = 0;
  197. };
  198.  
  199. //.............................................................................
  200. class IMpdServer : public IUnknown {
  201.  public:
  202.   //
  203.   // Register a MPD chapter
  204.   //  
  205.   virtual void BCWADDON_CMETHOD RegisterChapter( IMpdChapter * chapter, MpdType type ) = 0;
  206.   //
  207.   // Unregister a MPD chapter. 
  208.   //  
  209.   virtual void BCWADDON_CMETHOD UnRegisterChapter(IMpdChapter* chapter) = 0;
  210. };
  211.  
  212. //
  213. // value of local override state
  214. //
  215. #define MLS_UNKNOWN 0    // local check box is disabled
  216. #define MLS_ON      1    // local check box is checked
  217. #define MLS_OFF     2    // local check box is not checked
  218.  
  219. struct IMpdLocalOverride : IUnknown {
  220.   //
  221.   // This interface is implemented by IDE and addon client.
  222.   //
  223.   //  IDE MPD implementation:
  224.   //    SetState() sets the local check box to value passed in state.
  225.   //
  226.   //  Addon client implementation:
  227.   //    IDE calls SetSate() when user checks or unchecks the check box.
  228.   //
  229.   //  int  state:   new state of the MPD local override checkbox
  230.   //
  231.   virtual void BCWADDON_CMETHOD SetState(int state) = 0;
  232. };
  233.  
  234. struct IMpdPageLocalOverride : IMpdLocalOverride {
  235.   //
  236.   //  addon client implements this interface.  MPD will pass its local
  237.   //  override interface to client thru InitLocalOverride() call.
  238.   // 
  239.   //  The IMpdLocalOverride pointer is good for as long as the MPD page
  240.   //  is open. An easy way to handle the issue of when to release this
  241.   //  is to keep an override pointer around until you are issued a 
  242.   //  new one, via the next call of this method, or until the Chapter
  243.   //  closes.
  244.   //
  245.   virtual void BCWADDON_CMETHOD InitLocalOverride(IMpdLocalOverride*) = 0;
  246. };
  247.  
  248. #endif  // __IMPD_H
  249.