Rapid-Q Documentation by William Yu (c)1999 | Appendix A: QHEADER

# QHEADER Component

  QHeader is a set of column headers that the user can resize at runtime.
  QHeader Internal Types

         TYPE SectionsType       '' ie. Header.Sections(0).Caption
           Alignment AS INTEGER  '' Default taLeftJustify
           AllowClick AS INTEGER '' True
           Caption AS STRING
           MaxWidth AS INTEGER   '' Default  10000
           MinWidth AS INTEGER   '' Default 0
           Style AS INTEGER      '' Default hsText
           Width AS INTEGER      '' Default 50
         END TYPE

  QHeader Properties

  Field | Type | R/W | Default

  Align | INTEGER | RW | alNone
  ClientHeight | INTEGER | RW |
  ClientWidth | INTEGER | RW |
  CopyMode | INTEGER | RW | cmBlackness
  Cursor | INTEGER | RW | crDefault
  Enabled | INTEGER | RW | True
  Font | QFONT | W |
  Handle | INTEGER | RW |
  Height | INTEGER | RW |
  Hint | STRING | RW |
  HotTrack | INTEGER | RW | False
  Left | INTEGER | RW | 0
  Parent | QFORM/QPANEL/QTABCONTROL | W |
  Pixel | 2D ARRAY of INTEGER | RW |
  PopupMenu | QPOPUPMENU | W |
  Sections | ARRAY of SectionsType | RW |
  SectionsCount | INTEGER | R |
  ShowHint | INTEGER | RW | False
  Tag | INTEGER | RW |
  Top | INTEGER | RW | 0
  Width | INTEGER | RW |
  Visible | INTEGER | RW | True

  QHeader Methods

  Method | Type | Description | Params

  AddSections | SUBI | Add new sections to header | STRING, Infinite
  Clear | SUB | Clears all sections | 0
  Circle | SUB (x1%, y1%, x2%, y2%, c%, fill%) | Draw & Fill Circle | 6
  CopyRect | SUB (D, Image, S) | D and S are QRECTs, Image can be a QImage, QCanvas, or QBitmap | 3
  Draw | SUB (x%, y%, BMP) | Draw Bitmap at (X,Y) | 3
  FillRect | SUB (x1%, y1%, x2%, y2%, c%) | Draws & Fills a rectangle | 5
  Line | SUB (x1%, y1%, x2%, y2%, c%) | Draws a line | 5
  Paint | SUB (x%, y%, c%, borderc%) | Fill Region | 4
  Pset | SUB (x%, y%, c%) | Pixel plot | 3
  Rectangle | SUB (x1%, y1%, x2%, y2%, c%) | Draws a rectangle | 5
  Repaint | SUB | Force repainting of header | 0
  RoundRect | SUB (x1%, y1%, x2%, y2%, x3%, y3%, c%) | Draws & Fills a rounded rectangle | 7
  StretchDraw | SUB (Rect AS QRECT, BMP) | Draw BMP and stretch to fit inside Rect | 2
  TextHeight | FUNCTION (Text$) AS WORD | Returns the height, in pixels, of Text$ string | 1
  TextWidth | FUNCTION (Text$) AS WORD | Returns the width, in pixels, of Text$ string | 1
  TextRect | SUB (Rect AS QRECT, x%, y%, S$, fc%, bc%) | Write text, and clip within region Rect | 6
  TextOut | SUB (x%, y%, S$, fc%, bc%) | Writes text to image | 5

  QHeader Events

  Event | Type | Occurs when... | Params

  OnDrawSection | SUB (Index%, Pressed%, Rect AS QRECT) | A header section needs to be redisplayed. Header section's Style property must be hsOwnerDraw | 3
  OnMouseDown | SUB (Button%, X%, Y%, Shift%) | Mouse button held down | 4
  OnMouseMove | SUB (X%, Y%, Shift%) | Mouse moves | 3
  OnMouseUp | SUB (Button%, X%, Y%, Shift%) | Mouse button is released | 4
  OnResize | VOID | Size of header control changes | 0
  OnSectionClick | SUB (Index%) | Header section Index% is clicked | 1
  OnSectionResize | SUB (Index%) | Header section is resized | 1
  OnSectionTrack | SUB (Index%, Width%, State%) | Header section is dragged | 3

  QHeader Examples

      $TYPECHECK ON
      $INCLUDE "RAPIDQ.INC"

      DECLARE SUB DrawSection (Index AS INTEGER, Pressed AS INTEGER, Rect AS QRECT, Sender AS QHEADER)
      DECLARE SUB SectionTrack (Index AS INTEGER, Width AS INTEGER, State AS INTEGER, Sender AS QHEADER)

      CREATE Form AS QFORM
          Caption = "QHeader example"
          Center
          CREATE Header AS QHEADER
              AddSections "1", "2", "3"
              Sections(1).AllowClick = FALSE
              Sections(0).Style = hsOwnerDraw
              Sections(0).Width = 100
              Sections(1).Style = hsOwnerDraw
              Sections(2).Style = hsOwnerDraw
              OnDrawSection = DrawSection
              OnSectionTrack = SectionTrack
          END CREATE
          CREATE ListBox1 AS QLISTBOX
              Align = alLeft
              Width = 100
              AddItems "1. Rapid-Q", "2. Taxes"
          END CREATE
          CREATE StatusBar AS QSTATUSBAR
              SimplePanel = TRUE
              SimpleText = "Not moving"
          END CREATE
          ShowModal
      END CREATE

      SUB DrawSection (Index AS INTEGER, Pressed AS INTEGER, Rect AS QRECT, Sender AS QHEADER)
          Sender.TextOut(Rect.Left+5,Rect.Top+1, STR$(Index+1), &HFF0000, -1)
          SELECT CASE Index
              CASE 0
                  Sender.FillRect(Rect.Left+20,Rect.Top+2,Rect.Right-20,Rect.Bottom-2, &H00FF00)
              CASE 1
                  Sender.Circle(Rect.Left+20,Rect.Top+2,Rect.Right-20,Rect.Bottom-2, &HFF, &HFF)
              CASE 2
          END SELECT
      END SUB

      SUB SectionTrack (Index AS INTEGER, Width AS INTEGER, State AS INTEGER, Sender AS QHEADER)
          StatusBar.SimpleText = "Moving "+STR$(Width)
          SELECT CASE Index
              CASE 0
                  ListBox1.Width = Width
          END SELECT
      END SUB

  Prev Component | Contents | Next Component