Skip to content

GraphiteControls: the Control Manager - #29

Merged
colemancda merged 13 commits into
masterfrom
feature/controls
Nov 26, 2026
Merged

colemancda merged 13 commits into
masterfrom
feature/controls

Conversation

@colemancda

Copy link
Copy Markdown
Member

Summary

The Control Manager, the next of the Toolbox's managers after the Menu Manager: the controls a window holds, their values and parts, and the 'CNTL' resources that define them — everything but the drawing and the tracking, which are the host's, as Perry's controls.c made them AppKit's.

  • ControlPart (ControlPartCode): inButton 10, inCheckBox 11, the scroll arrows 20 and 21, the pages 22 and 23, the thumb 129, and the appearance's disabled 254 and inactive 255 — as the classic's part codes were. ControlKind, the five standard kinds by their control definition IDs (pushButProc 0, checkBoxProc 1, radioButProc 2, scrollBarProc 16, popupMenuProc 1008), with a useWFont variation (the ID plus 8) read as the kind beneath it; a definition ID of the host's own reads as none, for the definition the host brings.
  • ControlDefinition, the CDEFs: what kind of value a control keeps (a button's none, a checkbox's or radio button's on-or-off, a scroll bar's and a pop-up menu's range), which part a point is on with the control's real value placing its thumb, the thumb's rectangle, and where any part is. StandardControlDefinition is the classic's look: arrows 16 pixels square at a scroll bar's ends, a fixed-size thumb — the arrow's length — placed by the value in the travel between the arrows, the pages the bar on either side of the thumb, and a bar taller than wide vertical.
  • Control: the rectangle, the value with SetControlValue's pinning, the range, the title, the reference value, visibility (ShowControl, HideControl), enabling (EnableControl, DisableControl), activity (ActivateControl, DeactivateControl) and HiliteControl's pressed part; the command ID, the signature-and-ID pair GetControlByID finds, and the action procedure the classic's TrackControl called. A pop-up menu keeps its menu's resource ID in its minimum and its title's width in its maximum, as the classic's resources did — so a maximum below a minimum is allowed, the fields being the program's to read. A scroll bar's drag names a value by the thumb's center under the point.
  • ControlList: a window's controls, last added first, as NewControl added them and FindControl searched them; GetControlByID, and the command ID a control answers to; CreateRootControl, with errRootAlreadyExists for a second.
  • Control.make (GetNewControl): a 'CNTL' resource — the rectangle, the setting, the visibility, the fill byte, the maximum and minimum, the control definition ID, the reference value, and the title — with bytes past the title ignored, and paramErr for a definition ID no standard kind answers and no host definition given.
  • The Control Manager's result codes (-30581 through -30596), which are Carbon's, in MacError with the rest.

Notes for review

  • One commit per file, and the package builds at every one: the result codes first, then the sources as files no target reads yet, then "Added the GraphiteControls module" wires them in.
  • The classic's scroll bar thumb is a fixed-size scroll box, not a proportional one; its length here is the arrow's, and it travels the whole run between the arrows. The value a drag names measures the point from the bar's arrow, the thumb's center held under it.
  • A checkbox created directly is given the maximum 1, as the classic's 'CNTL' resources kept it; a scroll bar's and a pop-up menu's maxima start at 0.
  • A disabled control is hit nowhere, and its part is the whole control drawn disabled (254) — as the classic's definition functions answered a hit in an inactive control.
  • Not here: 'cctb' color tables, auxilliary control records, 32-bit value calls over 16-bit ones (Graphite's values are 32-bit outright), TrackControl's tracking loop (the host tracks and calls the action procedure), pop-up menus' drawing and their menus (the Menu Manager holds the menu; a pop-up control keeps its ID), controls as dialog items (the Dialog Manager's to come), and Carbon's embedding hierarchy beyond the root control.

Testing

  • 13 new tests in three files: the part codes and definition IDs, every standard kind and the ones that are none; controls made directly and their values pinned into their ranges, the thumb's value at a point (the middle names the middle, the edges pin, points outside pin, a button has none, an empty range no thumb), states changed in place with isLive answering visible-and-enabled-and-active, hilited parts, reference values, command IDs, identifiers, action procedures through a lock, moving and sizing, titles in MacRoman; hit testing on buttons, checkboxes, radio buttons and pop-up menus (a disabled one hit as 254), scroll bars' arrows, thumbs at both ends, pages below a top thumb and by the thumb's place, horizontal bars' parts at their ends; bars too short for their arrows, a bar exactly as long as them, a range of one's thumb at both ends of its travel; and 'CNTL' resources — the button, the checkbox on with a useWFont variation, the radio button, the horizontal scroll bar with its range and place, the invisible pop-up menu holding its menu's resource ID in its minimum, bytes past the title ignored, four damaged resources each paramErr.
  • The package's whole suite passes on macOS, with and without the FreeType trait. Linux and the 32-bit targets are left to CI.

@colemancda
colemancda merged commit 382d6a6 into master Nov 26, 2026
3 checks passed
@colemancda
colemancda deleted the feature/controls branch November 26, 2026 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant