home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / PowerPlant / AGA Classes 1.2 / IndexTabs / LAGAIndexTab.h < prev   
Encoding:
Text File  |  1996-06-30  |  5.3 KB  |  149 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    LAGAIndexTab.h
  3. // ===========================================================================
  4. //    “Apple Grayscale Appearance” compliant Index Tabs
  5. //    Copyright © 1996 Chrisoft (Christophe ANDRES)  All rights reserved.
  6. //
  7. //    You may use this source code in any application (commercial, shareware, freeware,
  8. //    postcardware, etc), but not remove this notice (no need to acknowledge the use of
  9. //    this class in the about box)
  10. //    You may not sell this source code in any form. This source code may be placed on 
  11. //    publicly accessable archive sites and source code disks. It may not be placed on 
  12. //    profit archive sites and source code disks without the permission of the author, 
  13. //    Christophe ANDRES.
  14. //    
  15. //        This source code is distributed in the hope that it will be useful,
  16. //        but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. //        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  18. //
  19. //    If you make any change or improvement on this class, please send the improved/changed
  20. //    version to : chrisoft@calva.net or Christophe ANDRES
  21. //                                     20, rue Prosper Mérimée
  22. //                                     67100 STRASBOURG
  23. //                                     FRANCE
  24. //
  25. // ===========================================================================
  26. //    LAGAIndexTab.cp            <- double-click + Command-D to see classes implementation
  27. //
  28. //    LAGAIndexTab is my implementation of the “Apple Grayscale Appearance for System 7.5”
  29. //        Index Tabs. Index Tabs where not defined in this document, but some pictures where
  30. //        found in the March 1996 issue of “Apple Directions” pages 16 and 18.
  31. //        LAGAIndexTab relies on view scrolling to perform its switch between differents tabs.
  32. //        mTabbedViewID is a reference to a view that is embeddedin the LAGAIndexTab.
  33. //        This tabbed view has to be placed at least at 21 pixels from the top of LAGAIndexTab,
  34. //        and must leave at least 1 pixel on each side (left, right and bottom).
  35. //        the LAGAIndexTab will use the vertical scroll unit of the tabbed view to perform its
  36. //        tab switch (adapt also the image size height accordingly).
  37. //        This means that all tab elements are always present (although only one is visible)
  38. //        and the switch between tabs is very fast.
  39. //
  40. //        Index Tabs are not suitable for large number of tabs, so LAGAIndexTab will display only
  41. //        the Index Tabs fitting in the view size.
  42. //
  43. //        An alternate way of using the index tabs is by NOT setting mTabbedViewID (nil) and to
  44. //        override LAGAIndexTab::AdaptTab to perform whatever is needed
  45. //
  46. //    LSTRxAGAIndexTab is a subclass of LAGAIndexTab, which reads the name of its tabs from a
  47. //        'STR#' resource
  48. //
  49. //        This class requires AGAColors.cp to be present in your project
  50. //
  51. //        Version : 1.2
  52. //
  53. //        Change History (most recent first, date in US form : mm/dd/yy):
  54. //
  55. //                        06/30/96    ca        Public release of version 1.2
  56. //                        06/04/96    ca        Added RegisterClass method to ease registry
  57. //                                                        Added guard macros in header files
  58. //                                                        Increased version to 1.2
  59. //                        05/16/96    ca        Increased version to 1.1
  60. //                                                        Added change history
  61. //                        04/22/96    ca        class made available by Christophe ANDRES <chrisoft@calva.net>
  62. //                                                        (version 1.0)
  63. //
  64. //        To Do:
  65. //                        Remove hardcoded maximum tabs and use some sort of dynamic list
  66. //
  67.  
  68. #ifndef _H_LAGAIndexTab
  69. #define _H_LAGAIndexTab
  70. #pragma once
  71.  
  72. #include    <LView.h>
  73. #include    <LString.h>
  74.  
  75. void RegisterAGAIndexTab ();
  76.  
  77. //    Maximum number of index tabs in a view
  78. #define    kMaxTabs                                                            10
  79.  
  80.  
  81. class LAGAIndexTab : public LView
  82. {
  83.     public        :
  84.         enum { class_ID = 'AGAi' };
  85.         static void RegisterClass ();                                                                                                                        //    <06/04/96    ca>
  86.         static LAGAIndexTab* CreateAGAIndexTabStream (LStream *inStream);
  87.     
  88.         LAGAIndexTab ();
  89.         
  90.         LAGAIndexTab (LStream    *inStream);
  91.         
  92.         virtual Boolean SetTabCount (short inCount);
  93.         
  94.         virtual void SetTabTitle (short inTab, LStr255& inTitle);
  95.         
  96.         virtual void GetTabTitle (short inTab, LStr255& outTitle);
  97.         
  98.         virtual void SetSelectedTab (short inTab);
  99.         
  100.         virtual short GetSelectedTab ();
  101.         
  102.         virtual void EventMouseUp (const EventRecord &inMouseUp);
  103.         
  104.     protected    :
  105.         virtual void FinishCreateSelf ();
  106.         
  107.         virtual void DrawSelf ();
  108.         
  109.         virtual void DrawText (LStr255 &inText, short inLeftBorder, short inTagWidth, short inTextPos);
  110.         
  111.         virtual void CalculateTitleWidths ();
  112.                 
  113.         //    scroll the view referenced in mUserCon to the appropriate position
  114.         virtual void AdaptTab (Boolean inRefresh = true);
  115.         
  116.         //    number of index tabs
  117.         short mTabNumber;
  118.         //    selected index tab (0 based)
  119.         short    mSelectedTab;
  120.         short    mWasSelectedTab;
  121.         //    titles of the index tabs
  122.         LStr255 mTabTitle[kMaxTabs];
  123.         //    with of titles of the index tabs
  124.         short mTabTitleWidth[kMaxTabs];
  125.         short mTabLeftPositions[kMaxTabs];
  126.         //    
  127.         ResIDT mTextTraitsID;
  128.         //    ID of the view that contains the tag panels
  129.         UInt32 mTabbedViewID;
  130.     
  131.     private        :
  132.         void InitIndexTab ();
  133. };
  134.  
  135. class LSTRxAGAIndexTab : public LAGAIndexTab
  136. {
  137.     public        :
  138.         enum { class_ID = 'AGAx' };
  139.         static void RegisterClass ();                                                                                                                        //    <06/04/96    ca>
  140.         static LSTRxAGAIndexTab* CreateSTRxAGAIndexTabStream (LStream *inStream);
  141.     
  142.         LSTRxAGAIndexTab (LStream    *inStream);
  143.     
  144.     private        :
  145.         void InitSTRxIndexTab (short inSTRxID);
  146. };
  147.  
  148. #endif
  149.