Documentation Index
Fetch the complete documentation index at: https://mintlify.com/fltk/fltk/llms.txt
Use this file to discover all available pages before exploring further.
What This Example Demonstrates
Fl_Grid provides a powerful grid-based layout system:- Position widgets in rows and columns
- Widgets can span multiple cells
- Control which rows/columns resize
- Set gaps between cells
- Align widgets within cells
- Similar to HTML table layouts
Simple Grid Example
Source file:examples/grid-simple.cxx
Compilation Command
Expected Behavior
- 3x3 grid with buttons in specific cells
- Some cells are empty (no widget assigned)
- 10 pixel margin around the grid
- 10 pixel gap between cells
- All cells resize proportionally
- Minimum window size enforced
Key Concepts
Creating Fl_Grid
Placing Widgets
Cell Spanning Example
Row and Column Weights
Control which rows/columns resize:Widget Alignment
Login Form Example
Source file:test/grid_login.cxx (simplified)
Compilation
Variations and Extensions
Calculator Layout
Form with Labels
Debug: Show Grid Lines
Dynamic Grid Modification
Comparison: Fl_Grid vs Fl_Flex
| Feature | Fl_Grid | Fl_Flex |
|---|---|---|
| Best for | Forms, tables, structured layouts | Toolbars, simple rows/columns |
| Positioning | Row/column coordinates | Sequential |
| Spanning | Yes (rowspan/colspan) | No |
| Alignment | Per-widget in cell | Container-level |
| Complexity | More options | Simpler |
| Use when | Need precise control | Need flexible sizing |
Best Practices
- Use Fl_Grid for forms where labels align with inputs
- Set row/column weights to control resize behavior
- Use show_grid(1) during development to visualize layout
- Span cells for titles, large widgets, or status bars
- Combine with Fl_Flex - use Grid for forms, Flex for toolbars
- Set explicit sizes for predictable layouts
- Use alignment to position widgets within cells
Next Steps
- Compare with Fl_Flex layout
- Learn about responsive design
- See custom widgets