← Mastering the Think Class Library 1995

Mastering the Think Class Library 1995

From the originals

13 scans

Machine-transcribed text and image descriptions. Check the linked original for uncertain words or fine print.

These are transcribed pages from the documents, not the full publications. Open the original for the remaining pages.

Image 1

mastering the THINK class library

mastering the THINK class library using SYMANTEC C++™ and VISUAL ARCHITECT™ Richard O. Parker

A sepia-toned photograph of an incandescent light bulb fills the background, with large white serif title text over it and the word THINK rendered in large multicolored striped letters across the middle.

Reading notes: Trademark symbols ™ after SYMANTEC C++ and VISUAL ARCHITECT are small and may be partly obscured; transcribed as shown. The word THINK uses multicolored striped lettering that is stylized but legible.

Printed product names
SYMANTEC C++ · THINK class library
Languages
English
PDF page 1

mastering the THINK class library using SYMANTEC C++™ and VISUAL ARCHITECT™ Richard O. Parker

A sepia-toned book cover showing a photograph of a light bulb with the large word THINK in multicolored striped letters across the middle, with the title and author name in white and black serif type.

Reading notes: Headline is split across several lines with the word THINK in larger, colorful letters; reading order follows the visual top-to-bottom sequence. Trademark symbols (™) after SYMANTEC C++ and VISUAL ARCHITECT are small and included as printed.

Printed product names
SYMANTEC C++ · THINK class library
Languages
English
PDF page 2

Mastering the THINK Class Library Using Symantec C++ ™ and Visual Architect™ Richard 0. Parker .. 'Y'Y Addison-Wesley Publishing Company Reading, Massachusetts • Menlo Park, California • New York Don Mills, Ontario • Wokingham, England • Amsterdam Bonn • Sydney • Singapore • Tokyo • Madrid • San Juan Paris • Seoul • Milan • Mexico City • Taipei

Reading notes: No image was supplied, so the fields were filled from the provided extracted copy only. The line '.. 'Y'Y' near the author name appears to be a stray mark or OCR artifact and was not treated as text. The copy is a book title page rather than an advertisement, so no advertised products, prices, or dates were identified. Product-like names 'Symantec C++' and 'Visual Architect' appear only in the subtitle and were not listed as advertised products.

Languages
English
PDF page 3

Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and Addison-Wesley was aware of a trademark claim, the designations have been printed in initial capital letters or all capital letters. The author and publishers have taken care in preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the information or programs contained herein. Library of Congress Cataloging-in-Publication Data Parker, Richard 0. Mastering the THINK Class Library : Using Symantec C++ and Visual Architect I Richard 0. Parker. p. cm. Includes index. ISBN 0-201-48356-4 (alk. paper) 1. Symantec C++ for the Macintosh. -Programming. I. Tide. QA76.73.C153P39 1995 005.26'2-dc20 2. Macintosh (Computer)- Copyright© 1995 by Addison-Wesley Publishing Company 95-218 CIP All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. Printed in the United States of America. Published simultaneously in Canada. Sponsoring Editor: Martha Steffen Project Manager: Sarah Weaver Production Coordinator: Deborah McKenna Cover design: David High Set in 11 point Adobe Garamond by Pure Imaging 1 2 3 4 5 6 7 8 9-MA-9998979695 First printing, July 1995 Addison-Wesley books are available for bulk purchases by corporations, institutions, and other organizations. For more information please contact the Corporate, Government, and Special Sales Department at (800) 238-9682.

Reading notes: Library of Congress Cataloging-in-Publication data contains OCR-style spacing and split tokens such as 'Parker, Richard 0.' that may need verification Subject heading line '2. Macintosh (Computer)-' and '-Programming.' appear split across lines, so reading order is uncertain

Printed product names
Symantec C++ · Visual Architect · THINK Class Library · Symantec C++ for the Macintosh
Printed dates
1995 · July 1995 · 95-218 · 005.26'2-dc20 · QA76.73.C153P39
Languages
English
PDF page 4

This book is dedicated to my extended family, and especially to my mother, my son Rick, my daughter Kathryn, her husband Jerry, and my grandchildren Shannon, Aaron, and Emily. My sister Marianne, her husband Terry, her son Dafydd, and their son Chris are always close to my heart. My family is more important to me than any of them imagines. May they always give more than they get and love one another-that's what makes life worthwhile.

Languages
English
PDF page 5

Contents Preface ...................................................................................................................................... xvii Notation Used in This Book ............................................................................ xx Acknowledgments ............................................................................................ xx Chapter 1 Introduction to the TCL ............................................................................................................. 1 Looking More Deeply into the TCL .................................................................. 2 Basic Structure of the TCL ....................................................................... 3 Defining the Visual Hierarchy .................................................................. 4 Defining the Chain of Command ............................................................. 5 More About Commands ........................................................................... 7 Using the Visual Architect .................................................................................. 8 Chapter Summary ........................................................................................... 10 Chapter 2 Building the Application's Foundation .................................................................................... 11 Creating the Skeleton Application .................................................................... 11 Examining the Skeleton Application Code ....................................................... 14 Starting in the Main Function ................................................................ 16 Constructing the CApp Object ............................................................... 17 CCollaborator Construction, 17 CBureaucrat Construction, 18 CDirectorOwner Construction, 18 CApplication Construction, 19 X_CApp and CApp Construction, 22 Initializing the Application Object .......................................................... 22 Initializing CApp, 22 Initializing CApplication, 23 Making the Application Helpers ............................................................. 26 Loading Important Resources, 26 v

Reading notes: Source is a table of contents excerpt with page-number leaders; no advertising copy present.

Languages
English
PDF page 6

vi >- Contents Chapter 3 Creating the CSwitchboard Object, 27 Creating the CError Object, 28 Creating the CDesktop Object, 28 Creating the CClipboard Object, 29 Creating the CDecorator Object, 32 Setting the File Parameters, 33 Forcing Class References, 33 Setting Up the Application's Menus, 35 Running the Application .................................................................................. 37 Processing Events ................................................................................... 40 Customizing the Application Skeleton ............................................................. 41 Examining the Application's Initialization Code ..................................... 41 Modifying the Apple Event-Handling Code ........................................... 42 Existing Handlers, 42 Handling New Events, 43 Other Application Services ............................................................................... 46 Chapter Summary ............................................................................................ 47 Creating and Managing Documents ......... ............................................................................... .49 Creating the Default Document and Its Window ............................................ 49 Creating the Document with an Open Application Event ...................... 57 Managing the Document's Data ...................................................................... 58 Handling a Single File Type ................................................................... 59 Handling Multiple File Types ................................................................ 63 Opening a Document, 65 Creating a New Document, 68 Creating a File Type Dialog, 69 Generating the Dialog Code, 73 Adding the DoNewDialog Code, 74 Modifying the GetDocTypeFromDialog Code, 75 Modifying the CNewFile Dialog Code, 76 Performing Simple Text File Input and Output ............................................... 78 Creating a CTextEdit Panorama in the NewView Window .................... 79 Examining the x_CNewView Header File Changes ................................ 81 Examining the x_CNewView Source File Changes ................................. 82 Examining the CTextData Header File ................................................... 83 Examining the CTextData Source File ................................................... 83 CTextData.cp Beginning Declarations, 84 CTextData OpenFile Function Code, 84 CTextData ReadData Function Code, 86 CTextData DoSave Function Code, 87 CTextData WriteData Function Code, 88

Reading notes: Source is a table of contents; no headline, product names, prices, or dates are printed in the supplied copy. Page numbers listed after entries are not dates and are not extracted.

Languages
English
PDF page 7

Chapter4 CTextData DoSaveAs Function Code, 89 CTextData DoRevert Function Code, 91 CTextData Position Window Function Code, 92 CTextData ContentsToWindow Function Code, 92 CTextData WindowToContents Function Code, 93 CTextData MakeWindowName Function Code, 93 Contents vii Examining the CNewView Source File Changes .............................................. 94 CNewView ICNewView Function Code, 94 CNewView ContentsToWindow Function Code, 94 CNewView WindowToContents Function Code, 95 CApp ICApp Function Code Addition, 95 CApp MakeNewWindow Override Suggestion, 98 Multiple Documents Versus Multiple Views .................................................... 98 Application Document Summary ...................................................................... 99 Creating and Displaying Views ......................................................................................... ...... 101 Creating a Business Account View ................................................................. 101 Creating the Main View ....................................................................... 102 Creating the Account View ................................................................... 105 Adding an Account Menu .................................................................... 113 Creating a New Account Dialog ........................................................... 113 Adding Menu Commands to the Account Menu .................................. 115 Generating Code and Viewing the Results ............................................ 117 Examining the Generated Code in x_CMain............. .. ... ...................... 119 MakeNewWindow Function Code, 119 DoCommand Function Code, 120 DoCmdNewAcct Function Code, 120 DoCmdEditAcct Function Code, 121 DoCmdDeleteAcct Function Code, 121 UpdateMenus Function Code, 122 What About the Rest of the Generated Code? ...................................... 122 Making the Business View Fully Functional ......................................... 123 Examining the Custom Code in the CApp Class .................................. 124 Adding a New Instance Variable, 124 Newly Added Initialization Features, 125 Examining Custom Code in the CMain Class ...................................... 125 CMain Header File Additions, 126 ICMain Function Code, 126 MakeNewWindow Override Function Code, 127 DoCommand Override Function Code, 127 DoCmdNewAcct Override Function Code, 128 DoCmdEditAcct Override Function Code, 129

Languages
English
PDF page 8

viii :>- Contents DoCmdDeleteAcct Override Function Code, 131 MakeDefau!tSettings Function Code, 133 ProviderChanged Override Function Code, 133 Examining the Custom Code in the CMainList Class .......................... 135 GetCellText Function Code, 135 Examining Newly Added CTransaction Class Code ............................. 135 CTransaction Class Header File, 135 CTransaction Class Source Code, 137 Examining Custom Code in the CAccount Class ................................. 139 CAccount Class Header File, 139 Preprocessor and Compiler Directives, 141 ICAccount Member Function Code, 141 CloseWind Override Function Code, 142 CreateNewEntries Function Code, 142 Examining Custom Code in the CAcctList Class .................................. 144 CAcctList Header File Contents, 144 Global List Border Array, 144 DrawCell Override Function Source Code, 145 Recommended Tasks For Completing The Business Account View ..... 146 Creating a Splash Screen View ....................................................................... 150 Creating the Splash View ...................................................................... 150 Examining the Splash View Code ......................................................... 152 MakeNewWindow Function Code, 152 ShowSplashScreen Function Code, 153 Creating a Floating Palette View .................................................................... 154 Creating the View ................................................................................. 154 Creating the PICT Image for the Palette .............................................. 156 Creating the PICT Grid Resource ........................................................ 157 Examining the Floating Palette View Code ........................................... 158 SetUpMenus Function Code, 159 CWidgets Constructor Function Code, 159 MakeNewWindow Function Code, 160 CMain MakeNewWindow Override Function Code, 161 CMain Activate Override Function Code, 161 CMain Deactivate Override Function Code, 161 CWidgets DoCommand Function Code, 162 Creating a Tear-off Menu View ..................................................................... 163 Creating the Tear-off View ................................................................... 163 Examining the Tear-off View's Code .................................................... 167 SetUpMenus Function Code, 168 CTools Constructor Function Code, 168 A View Summary ........................................................................................... 169

Reading notes: Source appears to be a table of contents with the word 'Contents' as the only heading; no primary headline was identified. The OCR-like text contains a stray character in 'MakeDefau!tSettings', preserved as printed.

Languages
English
PDF page 9

Contents ix Chapter 5 Creating and Managing Dialogs ............................................................................................. 171 Creating a Text Style Modal Dialog ............................................................... 171 Creating the Main and Notebook Views ........................................................ 172 Creating The CFontList and CSizeList Classes, 173 Creating the Font and Size Lists, 174 Creating the Style Checkboxes, 175 Creating the Justification Radio Buttons, 175 Creating the CDialogText Fields, 175 Creating the OK and Cancel Buttons, 175 Creating the Labels, 176 Creating the Format Menu ................................................................... 176 Generating and Running the Skeleton Code ......................................... 177 Examining the Custom CApp Code ..................................................... 179 SetUpMenus Function Code, 179 Examining the Custom CMain Code ................................................... 179 Defining the CTextSettings Structure, 179 The CMain Header File Contents, 180 ICMain Initialization Function Code, 181 DoCommand Function Code, 182 DoCmdNotebook Override Function Code, 182 Initializing the Dialog, 183 ExchangeSettings Function Code, 183 Examining the Notebook Dialog Code ................................................. 184 Ix_CNotebook Function Code, 184 MakeNewWindow Function Code, 185 DoBeginData Function Code, 187 BeginData Function Code, 189 DrawSample Function Code, 192 DispensePaneValues Function Code, 193 Examining the Code for Running the Notebook Dialog ....................... 195 DoModalDialog Function Code, 196 x_CNotebook ProviderChanged Function Code, 198 CNotebookUpdate Structure Definition, 200 UpdateData Function Code, 201 Examining the Code to Dismiss the Notebook Dialog ......................... 203 EndDialog Function Code, 203 DoEndData Function Code, 205 EndData Function Code, 205 Update Function Code, 207 Creating a Category Editor Dialog ................................................................. 208 Creating the Dialog Views .................................................................... 208 Examining the CMain Code ................................................................. 216 CMain.h Header File Contents, 217

Reading notes: Table-of-contents page numbers are partly ambiguous due to OCR-style line breaks.

Languages
English
PDF page 10

x :>-Contents Chapter6 ICMain Function Code, 218 AddCategory Function Code, 218 De!Category Function Code, 219 GetCategory Function Code, 219 SetCategory Function Code, 220 SorrCat Function Code, 220 SetSelected Category Function Code, 221 DoCmdEditCategories Function Code, 222 Examining the CCategories Code ......................................................... 223 The x_ CCategories Class Header File, 223 Ix_CCategories Function Code, 225 MakeNewWindow Function Code, 226 The CCategories Class Header File, 227 ICCategories Function Code, 228 BeginData Function Code, 229 DisableButtons Function Code, 230 CmdUseCat Function Code, 230 CmdDeleteCat Function Code, 230 CmdNewCat Function Code, 231 DoCmdEditCat Function Code, 233 ExchangeSettings Function Code, 234 Examining the CNewCat Dialog Code ................................................. 234 BeginData Function Code, 234 EndData Function Code, 236 CNewCat Header File Additions, 236 Examining the CCatTable Class Code .................................................. 237 Examining the CCat Class Code .......................................................... 237 CCat Class Header File, 238 CCat Constructor Function Code, 238 PutTo and GetFrom Function Code, 239 CCat Class Access Function Code, 239 Creating a Dynamic Modeless Dialog ............................................................ 241 Examining the x_CMain Code ............................................................. 245 Examining the CSettings Code ............................................................. 246 MakeNewWindow Override Function Code, 247 ProviderChanged Function Code, 248 Modal and Modeless Dialog Summary ........................................................... 250 Creating and Managing Controls ........................................................................................... 253 So What Is a Semantic Event? ........................................................................ 253 Learning About Buttons ................................................................................. 260 Examining the CButton Class .............................................................. 261

Reading notes: Source appears to be a table of contents with page numbers; dot leaders and some OCR spacing irregularities make certain entries uncertain (e.g., 'x_CCategories', 'Ix_CCategories', 'SorrCat'). Entries such as 'ICMain Function Code' and 'De!Category' may contain OCR-damaged characters.

Languages
English
PDF page 11

Chapter? Button Properties, 261 Button Actions, 265 Contents xi Examining the CRadioControl Class .................................................... 267 Radio Button Properties, 268 Radio Button Actions, 269 Examining the CCheckBox Class ......................................................... 271 CCheckBox Properties, 271 CCheckBox Actions, 271 Learning About Pop-Up Menus ..................................................................... 272 Pop-up Menu Properties, 273 Pop-up Menu Actions, 275 Learning About Tables ................................................................................... 277 Table Properties, 278 Table Actions, 285 Learning About Text ...................................................................................... 289 Text Properties, 290 Text Actions, 292 Control Object Summary ............................................................................... 294 Handling Events ...................................................................................................................... 295 Examining the Main Event Loop ................................................................... 295 The Process Event Function's Role ....................................................... 297 The Doldle Function's Role ................................................................. 297 The DispatchEvent Function's Role ..................................................... 299 Handling Mouse Down Events, 299 Handling Mouse Up Events, 299 Handling Key Events, 300 Handling Disk Inserted Events, 301 Handling Update Events, 301 Handling Activate and Deactivate Events, 305 Handling Suspend and Resume Events, 309 Handling High-Level Events, 309 More About Mouse Down Events ........................................................ 310 Handling inDesk Clicks, 311 Handling inMenuBar Clicks, 311 Handling inSysWindow Clicks, 312 Handling inContent Clicks, 312 Handling inDrag Clicks, 315 Handling inGrow Clicks, 316 Handling inGoAway Clicks, 321 Handling inZoomln and inZoomOut Clicks, 323 Summary Event Processing ............................................................................ 325

Reading notes: Source appears to be a table of contents; no headline or advertised products identified. Some entries contain stray characters such as the leading 'Chapter?' and 'Contents xi' which may be OCR artifacts.

Languages
English