Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
extending [2016/03/24 11:23]
christian [Add attributes]
extending [2016/09/28 23:05] (current)
93.204.170.83 ↷ Links adapted because of a move operation
Line 42: Line 42:
 === Choose a class name === === Choose a class name ===
  
-As name for this example, I use ''BorderStyle''. Ideally the name should be the same as used in the PDF specification.+As name for this example, I use ''BorderStyle''. Ideally the name should be the same as used in the PDF specification. If the name does not match the name in the specification, be it because the name is already defined or for estetic reasons, the class method ''type'' (or ''subtype'', depending on the type inference mechanism) needs to be implemented.
  
 === Choose the superclass === === Choose the superclass ===
Line 145: Line 145:
 An attribute method consists of a number of describing pragmas and the code for access. An attribute method consists of a number of describing pragmas and the code for access.
  
-=== The ''type:'' pragma ===+=== The type: pragma ===
  
-Mandatory is the ''<type: aSymbol>'' pragma: it takes the name symbol of the Smalltalk class implementing the PDF type. This is derived from the "Type" column of the definition table. For more information about typing and the possible type pragmas, see [[Typing]].+Mandatory is the ''<type: aSymbol>'' pragma: it takes the name symbol of the Smalltalk class implementing the PDF type. This is derived from the "Type" column of the definition table. For more information about typing and the possible type pragmas, see [[typing]].
  
 === The documentation pragma === === The documentation pragma ===
Line 158: Line 158:
  
 Also references to other parts of the specification are removed (which is not the case in the example). Also references to other parts of the specification are removed (which is not the case in the example).
 +
 +=== The version: pragma ===
 +
 +Often, new attributes were added with later PDF versions. The version of an attribute, if it is higher than the version of the type, can be noted with the ''<version: anInteger>'' pragma, where the argument is the minor version of the PDF (i.e. 2 for version PDF-1.2).
  
 === The access code === === The access code ===
Line 172: Line 176:
  
 for a required attribute. This will raise an error if the attribute is not present in the object. for a required attribute. This will raise an error if the attribute is not present in the object.
 +
 +The method will return the object of the value of the attribute. The object is either stored directly in the attribute or a reference to it. In any case, the object is returned. To access the value (object or reference), the following methods can be used:
 +<code smalltalk>
 + ^self at: #Type ifAbsent: [#Border asPDF]
 +</code>
 +<code smalltalk>
 + ^self at: #Type
 +</code>
  
  
 ===== Customize an object type ===== ===== Customize an object type =====
  
-docs, icon, string, attributes (docstypeorderversion, required)+Nowthe PDF type is sufficiently defined to be usefully displayed in the PDFExplorer. But more can be done by defining some of the following methods. 
 + 
 +==== Optional customization methods ==== 
 + 
 +=== Display name === 
 + 
 +The method ''listText'' returns a short Text used in the treeview of the PDFExplorer. The method ''titleText'' is used for the display of the selected object on the right side. 
 + 
 +=== Icon === 
 + 
 +The method ''toolListIcon'' can be defined on the class side to get an icon for the class in the Smalltalk browser. A PDF type class has the method ''listIcon'' on the instance side whichby defaultis the ''toolListIcon'' of the class. Therefore it is possible to select an icon depending on the object's state. 
 + 
 +=== Excluding attributes === 
 + 
 +Some attributes clutter the treeview on the left side of the PDFExplorer. For exampleevery ''TypedDictionary'' has the attribute ''/Type'' which is usually used as the name of the object itself. 
 + 
 +By defining the method ''displayKeysToOmit''such attributes can be excluded from the children of the object in the treeview. For the class ''TypedDictionary'' the method looks like this: 
 + 
 +<code smalltalk> 
 +displayKeysToOmit 
 + ^super displayKeysToOmit #(#Type) 
 +</code> 
  • extending.1458814983.txt.gz
  • Last modified: 2016/03/24 11:23
  • by christian