Attribute VB_Name = "Layout" Option Explicit Const basket_item_count = 10 Const layout_style_none = 0 Const layout_style_outline = 1 Const layout_style_underline = 2 Const layout_style_bold = 3 Const layout_style_checkbox_true = 4 Const layout_style_checkbox_false = 5 Const layout_style_bmp = 6 Const layout_style_cross = 7 Const layout_style_header = 8 Const layout_align_left = 0 Const layout_align_right = 1 Const layout_align_center = 2 Const layout_box_x = 0 Const layout_box_y = 1 Const layout_box_w = 2 Const layout_box_h = 3 Const layout_box_repaint = 4 Const layout_box_style = 5 Const layout_box_bgColor = 6 Const layout_box_fgColor = 7 Const layout_box_styleColor = 8 Const layout_box_fontSize = 9 Const layout_box_sIndex = 10 Const layout_box_eIndex = 11 Const layout_box_dimension = 11 Const layout_cell_x = 0 Const layout_cell_y = 1 Const layout_cell_w = 2 Const layout_cell_h = 3 Const layout_cell_str = 4 Const layout_cell_align = 5 Const layout_cell_style = 6 Const layout_cell_dimension = 6 Public Sub BasketInfoLayoutInit(box, cells) Dim h As Long ReDim box(layout_box_dimension) ReDim cells(7, layout_cell_dimension) h = 18 box(layout_box_x) = 1 box(layout_box_y) = 22 box(layout_box_w) = 238 box(layout_box_h) = 78 box(layout_box_repaint) = True box(layout_box_fgColor) = g_colorBlack box(layout_box_bgColor) = g_colorYellow box(layout_box_styleColor) = g_colorGray box(layout_box_style) = layout_style_outline box(layout_box_fontSize) = 8 box(layout_box_sIndex) = 0 box(layout_box_eIndex) = 7 cells(0, layout_cell_x) = 1 cells(0, layout_cell_y) = 1 cells(0, layout_cell_w) = 120 cells(0, layout_cell_h) = h cells(0, layout_cell_str) = "# of Items :" cells(0, layout_cell_align) = layout_align_right cells(0, layout_cell_style) = layout_style_none cells(1, layout_cell_x) = 125 cells(1, layout_cell_y) = 1 cells(1, layout_cell_w) = 110 cells(1, layout_cell_h) = h cells(1, layout_cell_str) = "" cells(1, layout_cell_align) = layout_align_left cells(1, layout_cell_style) = layout_style_underline cells(2, layout_cell_x) = 1 cells(2, layout_cell_y) = h cells(2, layout_cell_w) = 120 cells(2, layout_cell_h) = h cells(2, layout_cell_str) = "Estimated Amount :" cells(2, layout_cell_align) = layout_align_right cells(2, layout_cell_style) = layout_style_none cells(3, layout_cell_x) = 125 cells(3, layout_cell_y) = h cells(3, layout_cell_w) = 110 cells(3, layout_cell_h) = h cells(3, layout_cell_str) = "" cells(3, layout_cell_align) = layout_align_left cells(3, layout_cell_style) = layout_style_underline cells(4, layout_cell_x) = 1 cells(4, layout_cell_y) = 2 * h cells(4, layout_cell_w) = 120 cells(4, layout_cell_h) = h cells(4, layout_cell_str) = "# of Purchased Items :" cells(4, layout_cell_align) = layout_align_right cells(4, layout_cell_style) = layout_style_none cells(5, layout_cell_x) = 125 cells(5, layout_cell_y) = 2 * h cells(5, layout_cell_w) = 110 cells(5, layout_cell_h) = h cells(5, layout_cell_str) = "" cells(5, layout_cell_align) = layout_align_left cells(5, layout_cell_style) = layout_style_underline cells(6, layout_cell_x) = 1 cells(6, layout_cell_y) = 3 * h cells(6, layout_cell_w) = 120 cells(6, layout_cell_h) = 18 cells(6, layout_cell_str) = "Purchased Amount :" cells(6, layout_cell_align) = layout_align_right cells(6, layout_cell_style) = layout_style_none cells(7, layout_cell_x) = 125 cells(7, layout_cell_y) = 3 * h cells(7, layout_cell_w) = 110 cells(7, layout_cell_h) = h cells(7, layout_cell_str) = "" cells(7, layout_cell_align) = layout_align_left cells(7, layout_cell_style) = layout_style_underline Exit Sub End Sub Public Sub BasketReportLayoutInit(box, cells) Dim h As Long ReDim box(layout_box_dimension) ReDim cells(13, layout_cell_dimension) h = 18 box(layout_box_x) = 1 box(layout_box_y) = 1 box(layout_box_w) = 238 box(layout_box_h) = 130 box(layout_box_repaint) = True box(layout_box_fgColor) = g_colorBlack box(layout_box_bgColor) = g_colorYellow box(layout_box_styleColor) = g_colorGray box(layout_box_style) = layout_style_outline box(layout_box_fontSize) = 8 box(layout_box_sIndex) = 0 box(layout_box_eIndex) = 13 cells(0, layout_cell_x) = 1 cells(0, layout_cell_y) = 1 cells(0, layout_cell_w) = 128 cells(0, layout_cell_h) = h cells(0, layout_cell_str) = "# of Items :" cells(0, layout_cell_align) = layout_align_right cells(0, layout_cell_style) = layout_style_none cells(1, layout_cell_x) = 133 cells(1, layout_cell_y) = 1 cells(1, layout_cell_w) = 100 cells(1, layout_cell_h) = h cells(1, layout_cell_str) = "" cells(1, layout_cell_align) = layout_align_left cells(1, layout_cell_style) = layout_style_underline cells(2, layout_cell_x) = 1 cells(2, layout_cell_y) = h cells(2, layout_cell_w) = 128 cells(2, layout_cell_h) = h cells(2, layout_cell_str) = "Estimated Amount :" cells(2, layout_cell_align) = layout_align_right cells(2, layout_cell_style) = layout_style_none cells(3, layout_cell_x) = 133 cells(3, layout_cell_y) = h cells(3, layout_cell_w) = 100 cells(3, layout_cell_h) = h cells(3, layout_cell_str) = "" cells(3, layout_cell_align) = layout_align_left cells(3, layout_cell_style) = layout_style_underline cells(4, layout_cell_x) = 1 cells(4, layout_cell_y) = 2 * h cells(4, layout_cell_w) = 128 cells(4, layout_cell_h) = h cells(4, layout_cell_str) = "# of Purchased Items :" cells(4, layout_cell_align) = layout_align_right cells(4, layout_cell_style) = layout_style_none cells(5, layout_cell_x) = 133 cells(5, layout_cell_y) = 2 * h cells(5, layout_cell_w) = 100 cells(5, layout_cell_h) = h cells(5, layout_cell_str) = "" cells(5, layout_cell_align) = layout_align_left cells(5, layout_cell_style) = layout_style_underline cells(6, layout_cell_x) = 1 cells(6, layout_cell_y) = 3 * h cells(6, layout_cell_w) = 128 cells(6, layout_cell_h) = 18 cells(6, layout_cell_str) = "Purchased Amount :" cells(6, layout_cell_align) = layout_align_right cells(6, layout_cell_style) = layout_style_none cells(7, layout_cell_x) = 133 cells(7, layout_cell_y) = 3 * h cells(7, layout_cell_w) = 100 cells(7, layout_cell_h) = h cells(7, layout_cell_str) = "" cells(7, layout_cell_align) = layout_align_left cells(7, layout_cell_style) = layout_style_underline cells(8, layout_cell_x) = 1 cells(8, layout_cell_y) = 4 * h cells(8, layout_cell_w) = 128 cells(8, layout_cell_h) = 18 cells(8, layout_cell_str) = "# of Unpurchased Items :" cells(8, layout_cell_align) = layout_align_right cells(8, layout_cell_style) = layout_style_none cells(9, layout_cell_x) = 133 cells(9, layout_cell_y) = 4 * h cells(9, layout_cell_w) = 100 cells(9, layout_cell_h) = h cells(9, layout_cell_str) = "" cells(9, layout_cell_align) = layout_align_left cells(9, layout_cell_style) = layout_style_underline cells(10, layout_cell_x) = 1 cells(10, layout_cell_y) = 5 * h cells(10, layout_cell_w) = 128 cells(10, layout_cell_h) = 18 cells(10, layout_cell_str) = "Unpurchased Amount :" cells(10, layout_cell_align) = layout_align_right cells(10, layout_cell_style) = layout_style_none cells(11, layout_cell_x) = 133 cells(11, layout_cell_y) = 5 * h cells(11, layout_cell_w) = 100 cells(11, layout_cell_h) = h cells(11, layout_cell_str) = "" cells(11, layout_cell_align) = layout_align_left cells(11, layout_cell_style) = layout_style_underline cells(12, layout_cell_x) = 1 cells(12, layout_cell_y) = 6 * h cells(12, layout_cell_w) = 128 cells(12, layout_cell_h) = 18 cells(12, layout_cell_str) = "# of Items w/ Zero Price :" cells(12, layout_cell_align) = layout_align_right cells(12, layout_cell_style) = layout_style_none cells(13, layout_cell_x) = 133 cells(13, layout_cell_y) = 6 * h cells(13, layout_cell_w) = 100 cells(13, layout_cell_h) = h cells(13, layout_cell_str) = "" cells(13, layout_cell_align) = layout_align_left cells(13, layout_cell_style) = layout_style_underline Exit Sub End Sub Public Sub BasketPageLayoutInit(box, cells) Dim h As Long Dim i As Long, ct As Long Dim tm As Long ct = basket_item_count h = 20 ReDim box(layout_box_dimension) ReDim cells(3 * ct - 1, layout_cell_dimension) box(layout_box_x) = 0 box(layout_box_y) = 55 box(layout_box_w) = 240 box(layout_box_h) = ct * h + 1 box(layout_box_repaint) = True box(layout_box_fgColor) = g_colorBlack box(layout_box_bgColor) = g_colorYellow box(layout_box_styleColor) = RGB(128, 128, 128) ' g_colorGray box(layout_box_style) = layout_style_none box(layout_box_fontSize) = 8 box(layout_box_sIndex) = 0 box(layout_box_eIndex) = 3 * ct - 1 i = 0 tm = 0 For i = 0 To ct - 1 cells(3 * i, layout_cell_x) = 4 cells(3 * i, layout_cell_y) = i * h + tm cells(3 * i, layout_cell_w) = 146 cells(3 * i, layout_cell_h) = h cells(3 * i, layout_cell_str) = "" cells(3 * i, layout_cell_align) = layout_align_left cells(3 * i, layout_cell_style) = layout_style_underline cells(3 * i + 1, layout_cell_x) = 150 cells(3 * i + 1, layout_cell_y) = i * h + tm cells(3 * i + 1, layout_cell_w) = 30 cells(3 * i + 1, layout_cell_h) = h cells(3 * i + 1, layout_cell_str) = "" cells(3 * i + 1, layout_cell_align) = layout_align_right cells(3 * i + 1, layout_cell_style) = layout_style_underline cells(3 * i + 2, layout_cell_x) = 180 cells(3 * i + 2, layout_cell_y) = i * h + tm cells(3 * i + 2, layout_cell_w) = 58 cells(3 * i + 2, layout_cell_h) = h cells(3 * i + 2, layout_cell_str) = "" cells(3 * i + 2, layout_cell_align) = layout_align_right cells(3 * i + 2, layout_cell_style) = layout_style_underline Next i Exit Sub End Sub Public Sub BasketHeaderLayoutInit(box, cells) Dim h As Long h = 18 ReDim box(layout_box_dimension) ReDim cells(8, layout_cell_dimension) box(layout_box_x) = 0 box(layout_box_y) = 0 box(layout_box_w) = 240 box(layout_box_h) = 56 box(layout_box_repaint) = True box(layout_box_fgColor) = g_colorBlack box(layout_box_bgColor) = g_colorYellow box(layout_box_styleColor) = RGB(128, 128, 128) ' g_colorGray box(layout_box_style) = layout_style_none box(layout_box_fontSize) = 8 box(layout_box_sIndex) = 0 box(layout_box_eIndex) = 8 cells(0, layout_cell_x) = 0 cells(0, layout_cell_y) = 0 cells(0, layout_cell_w) = 59 cells(0, layout_cell_h) = h cells(0, layout_cell_str) = "Basket :" cells(0, layout_cell_align) = layout_align_right cells(0, layout_cell_style) = layout_style_none cells(1, layout_cell_x) = 64 cells(1, layout_cell_y) = 0 cells(1, layout_cell_w) = 156 cells(1, layout_cell_h) = h cells(1, layout_cell_str) = "" cells(1, layout_cell_align) = layout_align_left cells(1, layout_cell_style) = layout_style_none cells(2, layout_cell_x) = 224 cells(2, layout_cell_y) = 4 cells(2, layout_cell_w) = 12 cells(2, layout_cell_h) = 12 cells(2, layout_cell_str) = g_docPath & "downarrow.bmp" cells(2, layout_cell_align) = layout_align_center cells(2, layout_cell_style) = layout_style_bmp cells(3, layout_cell_x) = 0 cells(3, layout_cell_y) = h cells(3, layout_cell_w) = 59 cells(3, layout_cell_h) = h cells(3, layout_cell_str) = "Pick from :" cells(3, layout_cell_align) = layout_align_right cells(3, layout_cell_style) = layout_style_none cells(4, layout_cell_x) = 64 cells(4, layout_cell_y) = h cells(4, layout_cell_w) = 156 cells(4, layout_cell_h) = h cells(4, layout_cell_str) = "" cells(4, layout_cell_align) = layout_align_left cells(4, layout_cell_style) = layout_style_none cells(5, layout_cell_x) = 224 cells(5, layout_cell_y) = h + 4 cells(5, layout_cell_w) = 12 cells(5, layout_cell_h) = 12 cells(5, layout_cell_str) = g_docPath & "downarrow.bmp" cells(5, layout_cell_align) = layout_align_center cells(5, layout_cell_style) = layout_style_bmp cells(6, layout_cell_x) = 4 cells(6, layout_cell_y) = 2 * h cells(6, layout_cell_w) = 146 cells(6, layout_cell_h) = h cells(6, layout_cell_str) = "Description" cells(6, layout_cell_align) = layout_align_left cells(6, layout_cell_style) = layout_style_underline cells(7, layout_cell_x) = 150 cells(7, layout_cell_y) = 2 * h cells(7, layout_cell_w) = 28 cells(7, layout_cell_h) = h cells(7, layout_cell_str) = "Qty" cells(7, layout_cell_align) = layout_align_right cells(7, layout_cell_style) = layout_style_underline cells(8, layout_cell_x) = 178 cells(8, layout_cell_y) = 2 * h cells(8, layout_cell_w) = 60 cells(8, layout_cell_h) = h cells(8, layout_cell_str) = "Amt" cells(8, layout_cell_align) = layout_align_right cells(8, layout_cell_style) = layout_style_underline Exit Sub End Sub Public Sub CategoryPageLayoutInit(box, cells) Dim i As Long Dim h As Long ReDim box(layout_box_dimension) ReDim cells(9, layout_cell_dimension) box(layout_box_x) = 1 box(layout_box_y) = 177 box(layout_box_w) = 238 box(layout_box_h) = 90 box(layout_box_repaint) = True box(layout_box_style) = layout_style_outline box(layout_box_fgColor) = g_colorBlack box(layout_box_bgColor) = g_colorWhite box(layout_box_styleColor) = g_colorGray box(layout_box_style) = layout_style_outline box(layout_box_fontSize) = 8 box(layout_box_sIndex) = 0 box(layout_box_eIndex) = 9 h = 18 For i = 0 To 4 cells(2 * i, layout_cell_x) = (h - 12) / 2 cells(2 * i, layout_cell_y) = i * h + (h - 12) / 2 cells(2 * i, layout_cell_w) = 12 cells(2 * i, layout_cell_h) = 12 cells(2 * i, layout_cell_str) = "" cells(2 * i, layout_cell_style) = layout_style_checkbox_false cells(2 * i + 1, layout_cell_x) = 22 cells(2 * i + 1, layout_cell_y) = i * h cells(2 * i + 1, layout_cell_w) = 212 cells(2 * i + 1, layout_cell_h) = h cells(2 * i + 1, layout_cell_str) = "" cells(2 * i + 1, layout_cell_style) = layout_style_none cells(2 * i + 1, layout_cell_align) = layout_align_left Next i Exit Sub End Sub Public Function LayoutClick(x As Long, y As Long, box, cells) As Long Dim cx As Long, cy As Long, cw As Long, ch As Long Dim i As Long, ct As Long, sIndex As Long, eIndex As Long sIndex = box(layout_box_sIndex) eIndex = box(layout_box_eIndex) ct = UBound(cells, 1) LayoutClick = -1 For i = sIndex To eIndex If (i <= ct) Then cx = box(layout_box_x) + cells(i, layout_cell_x) cy = box(layout_box_y) + cells(i, layout_cell_y) cw = cells(i, layout_cell_w) ch = cells(i, layout_cell_h) If (x >= cx And x <= cx + cw) Then If (y >= cy And y <= cy + ch) Then LayoutClick = i Exit For End If End If End If Next i Exit Function End Function Public Sub LayoutPaint(box, cells, pic As PictureBox) Dim i As Long, ct As Long, sIndex As Long, eIndex As Long Dim x As Long, y As Long, w As Long, h As Long Dim bx As Long, by As Long, bw As Long, bh As Long Dim tx As Long, ty As Long, tw As Long, th As Long Dim lw As Long, wct As Long Dim astr As String, bstr As String Dim bRepaint As Boolean bx = box(layout_box_x) by = box(layout_box_y) bw = box(layout_box_w) bh = box(layout_box_h) bRepaint = box(layout_box_repaint) If (bRepaint) Then pic.FontBold = False pic.FontSize = box(layout_box_fontSize) pic.ForeColor = box(layout_box_fgColor) pic.FillColor = box(layout_box_bgColor) Select Case box(layout_box_style) Case layout_style_none pic.DrawLine bx, by, bx + bw, by + bh, box(layout_box_bgColor), True Case layout_style_outline pic.DrawLine bx, by, bx + bw, by + bh, box(layout_box_fgColor), True End Select End If sIndex = box(layout_box_sIndex) eIndex = box(layout_box_eIndex) ct = UBound(cells, 1) For i = sIndex To eIndex If (i <= ct) Then astr = cells(i, layout_cell_str) x = cells(i, layout_cell_x) y = cells(i, layout_cell_y) w = cells(i, layout_cell_w) h = cells(i, layout_cell_h) If (Not bRepaint) Then pic.FillColor = box(layout_box_bgColor) pic.DrawLine bx + x, by + y + 1, bx + x + w - 1, by + y + h - 1, box(layout_box_bgColor), True End If If (astr <> "") Then If (cells(i, layout_cell_style) = layout_style_bmp) Then pic.DrawPicture astr, bx + x, by + y, w, h, 0, 0, w, h Else If (cells(i, layout_cell_style) = layout_style_header) Then pic.FontBold = True End If lw = pic.TextWidth("W") wct = Int(w / lw) If (Len(astr) > wct) Then If (wct < 1) Then wct = 1 For lw = wct To Len(astr) bstr = Left(astr, lw) If (pic.TextWidth(bstr) > w) Then bstr = Left(astr, lw - 1) Exit For End If Next i astr = bstr End If tw = pic.TextWidth(astr) th = pic.TextHeight(astr) Select Case cells(i, layout_cell_align) Case layout_align_left tx = x Case layout_align_center tx = x + (w - tw) / 2 Case layout_align_right tx = x + w - tw End Select tx = bx + tx ty = by + y + (h - th) - 1 pic.DrawText astr, tx, ty If (cells(i, layout_cell_style) = layout_style_header) Then pic.FontBold = False End If End If End If Select Case cells(i, layout_cell_style) Case layout_style_outline Case layout_style_underline, layout_style_header pic.DrawLine bx + x, by + y + h, bx + x + w, by + y + h, box(layout_box_styleColor) Case layout_style_checkbox_false pic.FillColor = box(layout_box_bgColor) pic.DrawLine bx + x, by + y, bx + x + w, by + y + h, box(layout_box_fgColor), True Case layout_style_checkbox_true pic.FillColor = box(layout_box_bgColor) pic.DrawLine bx + x, by + y, bx + x + w, by + y + h, box(layout_box_fgColor), True pic.DrawLine bx + x, by + y, bx + x + w, by + y + h, box(layout_box_fgColor) pic.DrawLine bx + x, by + y + h - 1, bx + x + w - 1, by + y, box(layout_box_fgColor) Case layout_style_cross pic.DrawLine bx + x, by + y + h, bx + x + w, by + y + h, box(layout_box_styleColor) If (astr <> "") Then ty = ty + th / 2 pic.DrawLine tx, ty, tx + tw + 4, ty, RGB(0, 196, 0) End If End Select Else box(layout_box_eIndex) = i Exit For End If Next i pic.Refresh Exit Sub End Sub