Architecture¶
Layered Architecture¶
Layer Responsibilities¶
1. User API Layer¶
Public interfaces for developers. Located in cjform/src/, one file per widget:
| File | Responsibility |
|---|---|
window.cj |
Window creation, message loop, event dispatch, file drop |
button.cj |
Button (click, hover, press animations) |
text_box.cj |
Single-line text input (including password mode) |
text_edit.cj |
Multi-line editor (cursor, selection, undo/redo) |
label.cj |
Text label |
check_box.cj |
Checkbox |
radio_button.cj |
Radio button + RadioGroup |
slider.cj |
Slider |
toggle_switch.cj |
Toggle switch |
spin_box.cj |
Number stepper |
combo_box.cj |
Dropdown selector |
progress_bar.cj |
Progress bar |
list_view.cj |
List view |
tree_view.cj |
Tree view |
table_view.cj |
Table view |
tab_view.cj |
Tab view |
scroll_area.cj |
Scroll area |
vbox.cj / hbox.cj |
Vertical / horizontal layout |
group_box.cj |
Group box |
split_pane.cj |
Split pane |
menu_bar.cj |
Menu bar |
context_menu.cj |
Context menu |
popover.cj |
Popover |
tooltip.cj |
Tooltip |
image.cj |
Image |
separator.cj |
Separator |
dialogs.cj |
MessageBox dialog |
2. Widget Layer¶
Core abstractions and shared infrastructure:
| File | Responsibility |
|---|---|
widget.cj |
Widget interface (paint / hitTest / handleEvent / updateAnimation) |
event.cj |
Mouse and keyboard event definitions |
focus_manager.cj |
Focus management (Tab navigation) |
position.cj |
Position abstraction (absolute / percentage) |
shadow.cj |
Shadow effects |
tooltip.cj |
Tooltip management |
3. Canvas Rendering Abstraction¶
canvas.cj encapsulates all drawing operations bridged to GDI+:
- Fill rect / rounded rect
- Draw border / text / lines
- Shadow rendering
- Text measurement
- Double-buffered swap
4. bridge.dll Bridge Layer¶
bridge.cpp implements low-level functionality using Win32 API and GDI+:
- Window creation (
CreateWindowExW) - Message loop (
GetMessage/DispatchMessage) - GDI+ rendering (
Graphics/SolidBrush/GraphicsPath) - Text measurement (
MeasureString) - DWM dark mode (
DwmSetWindowAttribute) - File drag and drop (
DragAcceptFiles/WM_DROPFILES) - Window state persistence (
GetWindowPlacement/SetWindowPlacement)
The Cangjie side calls these C++ functions via foreign func declarations in bridge.cj.
Data Flow¶
Render Flow¶
Event Flow¶
Theme Switch Flow¶
Widget Interface¶
All widgets implement the Widget interface: