The C64 OS Programmer's Guide is being written

This guide is being written and released and few chapters at a time. If a chapter seems to be empty, or if you click a chapter in the table of contents but it loads up Chapter 1, that's mostly likely because the chapter you've clicked doesn't exist yet.

Discussion of development topics are on-going about what to put in this guide. The discusssions are happening in the C64 OS Community Support Discord server, available to licensed C64 OS users.

C64 OS PROGRAMMER'S GUIDE

Class Reference: TKObj

Overview

TKObj is the root class. It inherits from nothing, and all other classes inherit, ultimately, from it.

TKObj is mostly an abstract superclass which defines the ISA pointer at the core of every Toolkit object. The ISA pointer is what makes a memory structure in fact an object and not just a generic memory structure. By pointing to the class definition, it becomes possible to lookup methods which are capable of acting upon this object and its properties.

There is very little point to instantiating TKObj directly. Its init method does nothing. Its delete_ method only frees the memory that was previous allocated with malloc to hold the new object. And it has no other methods or properties. Additionally, TKObj is not a subclass of TKView, which means it cannot be appended to a view hierarchy.

Subclassing notes

There is only one class included with C64 OS that inherits directly from TKObj, and that class is TKView. All other classes inherit either directly or indirectly from TKView. If you want to create any kind of Toolkit user interface class, you should inherit from TKView or one of its subclasses. TKView provides all of the logic for event propagation, and node properties, and positioning, anchoring and sizing properties.

Although Toolkit is primarily designed to be used to build user interfaces, separating TKObj from TKView opens the door to allow Applications to create non-UI related subclasses, which inherit directly from TKObj. These can be used for other purposes such as data modeling.

Class Definition

//os/tk/h/:tkobj.h
Property Type Size Offset
super_ superclass pointer 2 0
size_ object size 2 2
init_ method 3 4
delete_ method 3 7

Object Definition

//os/tk/s/:tkobj.s

Object Size: 2 (+3) bytes
Property Type Size Offset
isa_ class pointer 2 0

Relationships

Inherits from: Nothing. TKObj is the root object.

Parent Section: Class Reference

Next Section: Subclassing


Next Chapter: Writing an Application

Table of Contents



This document is subject to revision updates.

Last modified: Jul 02, 2024