Win32::GUI::Grid - add a grid control to Win32::GUI. |
Win32::GUI::Grid - add a grid control to Win32::GUI.
use strict; use Win32::GUI; use Win32::GUI::Grid; # main Window my $Window = new Win32::GUI::Window ( -title => "Win32::GUI::Grid", -pos => [100, 100], -size => [400, 400], -name => "Window", ) or die "new Window"; # Grid Window my $Grid = $Window->AddGrid ( -name => "Grid", -pos => [0, 0], -rows => 50, -columns => 10, -fixedrows => 1, -fixedcolumns => 1, -editable => 1, ) or die "new Grid"; # Fill Grid for my $row (0..$Grid->GetRows()) { for my $col (0..$Grid->GetColumns()) { if ($row == 0) { $Grid->SetCellText($row, $col,"Column : $col"); } elsif ($col == 0) { $Grid->SetCellText($row, $col, "Row : $row"); } else { $Grid->SetCellText($row, $col, "Cell : ($row,$col)"); } } } # Resize Grid Cell $Grid->AutoSize(); # Event loop $Window->Show(); Win32::GUI::Dialog(); # Main window event handler sub Window_Terminate {
return -1; } sub Window_Resize { my ($width, $height) = ($Window->GetClientRect)[2..3]; $Grid->Resize ($width, $height); } # Grid event handler sub Grid_Click { my ($col, $row) = @_; print "Click on Cell ($col, $row)\n"; }
This package uses the MFC Grid control 2.25 By Chris Maunder. homepage: http://www.codeproject.com/miscctrl/gridctrl.asp
new
Parameter : -name : Window name -parent : Parent window
-left : Left position -top : Top position -width : Width -height : Heigth
-pos : [x, y] position -size : [w, h] size
-visible : Visible -hscroll : Horizontal scroll -vscroll : Vertical scroll -enable : Enable
-style : Default style -pushstyle : Push style -popstyle : Pop style
-rows : Total rows -columns : Total columns -fixedrows : Fixed rows -fixedcolumns : Fixed columns -editable : Editable -doublebuffer : Double buffering display
Win32::GUI::Window::AddGrid
SetRows
([nRows=10])GetRows
()SetColumns
([nCols=10])GetColumns
()SetFixedRows
([nFixedRows = 1])GetFixedRows
()SetFixedColumns
([nFixedCols = 1])GetFixedColumns
()
SetRowHeight
(nRow, height)GetRowHeight
(nRow)SetColumnWidth
(nCol, width)GetColumnWidth
(nCol)GetFixedRowsHeight
()GetFixedColumnsWidth
()GetVirtualHeight
()GetVirtualWidth
()GetCellOrigin
(row, col)GetCellRect
(row, col)GetTextRect
(row, col)GetTextExtent
(nRow, nCol, str)GetCellTextExtent
(nRow, nCol)GetCellFromPt
(x, y)
SetVirtualMode
([mode = TRUE])GetVirtualMode
()
SetImageList
(imagelist)GetImageList
()SetGridLines
([nWhichLines = GVL_BOTH])Possible values. GVL_NONE = No grid lines GVL_HORZ = Horizontal lines only GVL_VERT = Vertical lines only GVL_BOTH = Both vertical and horizontal lines
GetGridLines
()Possible values. GVL_NONE = No grid lines GVL_HORZ = Horizontal lines only GVL_VERT = Vertical lines only GVL_BOTH = Both vertical and horizontal lines
SetEditable
([bEditable = TRUE])IsEditable
()SetListMode
([bEnableListMode = TRUE])GetListMode
()SetSingleRowSelection
([bSingle = TRUE])GetSingleRowSelection
()SetSingleColSelection
([bSing = TRUE])GetSingleColSelection
()EnableSelection
([bEnable = TRUE])IsSelectable
()SetFixedRowSelection
([bSelect = TRUE])GetFixedRowSelection
()SetFixedColumnSelection
([bSelect = TRUE])GetFixedColumnSelection
()EnableDragAndDrop
([bAllow = TRUE]);GetDragAndDrop
()SetRowResize
([bResize = TRUE])GetRowResize
()SetColumnResize
([bResize = TRUE])GetColumnResize
()SetHandleTabKey
([bHandleTab = TRUE])GetHandleTabKey
()SetDoubleBuffering
([bBuffer = TRUE])GetDoubleBuffering
()EnableTitleTips
([bEnable = TRUE])GetTitleTips
()SetTrackFocusCell
([bTrack = TRUE])GetTrackFocusCell
()SetFrameFocusCell
([bFrame = TRUE])GetFrameFocusCell
()SetAutoSizeStyle
([nStyle = GVS_BOTH])Possible values. GVS_BOTH = use fixed and non fixed cells; GVS_HEADER = use only the fixed cells; GVS_DATA = use only non-fixed cells.
GetAutoSizeStyle
()EnableHiddenColUnhide
([bEnable = TRUE])GetHiddenColUnhide
()void EnableHiddenRowUnhide
([bEnable = TRUE])GetHiddenRowUnhide
()EnableColumnHide
([bEnable = TRUE])GetColumnHide
()void EnableRowHide
([bEnable = TRUE])GetRowHide
()
SetGridBkColor
(color)GetGridBkColor
()SetGridLineColor
(color)GetGridLineColor
()SetTitleTipBackClr
(clr = CLR_DEFAULT)GetTitleTipBackClr
()SetTitleTipTextClr
(clr = CLR_DEFAULT)GetTitleTipTextClr
()
Change and query the default cell implementation for the desired cell type. bFixedRow and bFixedCol specify whether the cell is fixed (in row, column or both) or unfixed. Use this to set default properties for the grid. Actual cells in the grid have their values set as default values when they are first created. They will use GetDefCell to query the grids default cell properties and use these values for drawing themselves.
SetDefCellTextColor
(bFixedRow, bFixedCol, [clr = CLR_DEFAULT])GetDefCellTextColor
(bFixedRow, bFixedCol)SetDefCellBackColor
(bFixedRow, bFixedCol, [clr = CLR_DEFAULT])GetDefCellBackColor
(bFixedRow, bFixedCol)SetDefCellWidth
(bFixedRow, bFixedCol, nWidth)GetDefCellWidth
(bFixedRow, bFixedCol)SetDefCellHeight
(bFixedRow, bFixedCol, height)GetDefCellHeight
(bFixedRow, bFixedCol)SetDefCellMargin
(bFixedRow, bFixedCol, nMargin)GetDefCellMargin
(bFixedRow, bFixedCol)SetDefCellFormat
(bFixedRow, bFixedCol, nFormat)GetDefCellFormat
(bFixedRow, bFixedCol)SetDefCellStyle
(bFixedRow, bFixedCol, dwStyle)GetDefCellStyle
(bFixedRow, bFixedCol)SetDefCellFont
(bFixedRow, bFixedCol, dwStyle)GetDefCellFont
(bFixedRow, bFixedCol)
SetDefCellType
(iType = GVIT_DEFAULT)Cell type :
GVIT_NUMERIC = Numeric control edit GVIT_DATE = Date control GVIT_DATECAL = Date control with calendar control GVIT_TIME = Time control GVIT_CHECK = Check Box GVIT_COMBO = Combo Box GVIT_LIST = List Box GVIT_URL = Url control
SetCellType
(nRow, nCol, iType = GVIT_DEFAULT)Cell type :
GVIT_NUMERIC = Numeric control edit GVIT_DATE = Date control GVIT_DATECAL = Date control with calendar control GVIT_TIME = Time control GVIT_CHECK = Check Box GVIT_COMBO = Combo Box GVIT_LIST = List Box GVIT_URL = Url control
SetCellCheck
(nRow, nCol, bChecked = TRUE)GetCellCheck
(nRow, nCol)SetCellOptions
(nRow, nCol, ...)For GVIT_COMBO, GVIT_LIST : An array reference with list of string value ([``Option1'',``Option2''])
For GVIT_CHECK : -checked => 0/1 : Set check.
For GVIT_URL : -autolaunch => 0/1 : Set autolauch mode (default : 1).
SetModified
([bModified = TRUE], [nRow = -1], [nCol = -1])GetModified
([nRow = -1], [nCol = -1])SetCellText
(nRow, nCol, str)GetCellText
(nRow, nCol)SetCellData
(nRow, nCol, lParam)GetCellData
(nRow, nCol)SetCellImage
(nRow, nCol, iImage)GetCellImage
(nRow, nCol)SetCellState
(nRow, nCol, state)GetCellState
(nRow, nCol)SetCellFormat
(nRow, nCol, nFormat)Default implementation of cell drawing uses CDC::DrawText, so any of the DT_* formats are available:
DT_TOP DT_LEFT DT_CENTER DT_RIGHT DT_VCENTER DT_BOTTOM DT_WORDBREAK DT_SINGLELINE DT_EXPANDTABS DT_TABSTOP DT_NOCLIP DT_EXTERNALLEADING DT_CALCRECT DT_NOPREFIX DT_INTERNAL DT_EDITCONTROL DT_PATH_ELLIPSIS DT_END_ELLIPSIS DT_MODIFYSTRING DT_RTLREADING DT_WORD_ELLIPSIS
GetCellFormat
(nRow, nCol)SetCellBkColor
(nRow, nCol, [color = CLR_DEFAULT])GetCellBkColor
(nRow, nCol)SetCellColor
(nRow, nCol, [color = CLR_DEFAULT])GetCellColor
(nRow, nCol)SetCellFont
(nRow, nCol, ...)GetCellFont
(nRow, nCol)EnsureCellVisible
(nRow, nCol)IsCellVisible
(nRow, nCol)IsCellSelected
(nRow, nCol)SetCellEditable
(nRow, nCol, [bEditable = TRUE])IsCellEditable
(nRow, nCol)IsCellEditing
(nRow, nCol)IsCellFixed
(nRow, nCol)GetSelectedCount
()SetFocusCell
(nRow, nCol)GetFocusCell
()
InsertColumn
(strHeading, [nFormat = DT_CENTER|DT_VCENTER|DT_SINGLELINE], [nColumn = -1])InsertRow
(strHeading, [nRow = -1])DeleteColumn
(nColumn)DeleteRow
(nRow)DeleteAllCells
()DeleteNonFixedRows
()AutoSizeRow
(nRow, [bResetScroll = TRUE])AutoSizeColumn
(nCol, [nAutoSizeStyle = GVS_DEFAULT], [bResetScroll = TRUE])AutoSizing options :
GVS_DEFAULT = default GVS_HEADER = Size using column fixed cells data only GVS_DATA = Size using column non-fixed cells data only GVS_BOTH = Size using column fixed and non-fixed
AutoSizeRows
()AutoSizeColumns
([nAutoSizeStyle = GVS_DEFAULT])AutoSizing options :
GVS_DEFAULT = default GVS_HEADER = Size using column fixed cells data only GVS_DATA = Size using column non-fixed cells data only GVS_BOTH = Size using column fixed and non-fixed
AutoSize
([nAutoSizeStyle = GVS_DEFAULT])AutoSizing options :
GVS_DEFAULT = default GVS_HEADER = Size using column fixed cells data only GVS_DATA = Size using column non-fixed cells data only GVS_BOTH = Size using column fixed and non-fixed
ExpandColumnsToFit
([bExpandFixed = TRUE])ExpandLastColumn
()ExpandRowsToFit
([bExpandFixed = TRUE])ExpandToFit
([bExpandFixed = TRUE])SetRedraw
(bAllowDraw, [bResetScrollBars = FALSE])RedrawCell
(nRow, nCol, [hDC=0])RedrawRow
(row)RedrawColumn
(col);Refresh
()GetCellRange
()SetSelectedCellRange
(nMinRow, nMinCol, nMaxRow, nMaxCol, [bForceRepaint = FALSE], [bSelectCells = TRUE])GetSelectedCellRange
()IsValid
(nRow, nCol)GetNextCell
(nRow, nCol, nFlags)Cell Searching options :
GVNI_FOCUSED = Search for focus cell GVNI_SELECTED = Search for selected cells GVNI_DROPHILITED = Search for drop highlighted cells GVNI_READONLY = Search for read-only cells GVNI_FIXED = Search for fixed cells GVNI_MODIFIED = Search for modified cells GVNI_ABOVE = Search above initial cell GVNI_BELOW = Search below initial cell GVNI_TOLEFT = Search to the left of the initial cell GVNI_TORIGHT = Search to the right of the initial cell GVNI_ALL = Search all cells in the grid starting from the given cell GVNI_AREA = Search all cells below and to the right of the given cell
ClearCells
(nMinRow, nMinCol, nMaxRow, nMaxCol)AutoFill
()
SetHeaderSort
([bSortOnClick = TRUE])GetHeaderSort
()SetSortColumn
(nCol)GetSortColumn
()SetSortAscending
([bAscending = TRUE])GetSortAscending
()SortTextCells
(nCol, bAscending)SortNumericCells
(nCol, bAscending)SortCells
(nCol, bAscending, [pfun = NULL])Sort Function sample :
sub { my ($e1, $e2) = @_; return (int($e1) - int ($e2)); }
SetSortFunction
([pFun = NULL], [nCol = -1])If nCol is -1, Set or remove a default sort method. If nCol is a valid column , Set or remove a sort method for this column only.
Sort Function sample :
sub { my ($e1, $e2) = @_; return (int($e1) - int ($e2)); }
TODO
Save
(filename, [chSeparator = ',']);Load
(filename, [chSeparator = ',']);
OnEditCut
()OnEditCopy
()OnEditPaste
()OnEditSelectAll
()
_Click
(nRow, nCol)_RClick
(nRow, nCol)_DblClick
(nRow, nCol)_Changing
(nRow, nCol)_Changed
(nRow, nCol)_BeginEdit
(nRow, nCol)_ChangedEdit
(nRow, nCol, str)_EndEdit
(nRow, nCol, [str])[virtual Mode Only] str contains edited cell data.
_BeginDrag
(nRow, nCol)_GetData
(nRow, nCol)[virtual Mode Only] You must return cell data.
_CacheHint
(nMinRow, nMinCol, nMaxRow, nMaxCol)[virtual Mode Only] Range before request data.
Win32::GUI Microsoft Foundation Classes (MFC)
Laurent Rocher (lrocher@cpan.org)
Copyright 2003..2006 by Laurent Rocher (lrocher@cpan.org)
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html
Modified code from the MFC Grid control by Chris Maunder is statically linked into this module. The MFC Grid control is released with the following notice:
This code may be used in compiled form in any way you desire (including commercial use). The code may be redistributed unmodified by any means providing it is not sold for profit without the authors written consent, and providing that this notice and the authors name and all copyright notices remains intact. However, this file and the accompanying source code may not be hosted on a website or bulletin board without the authors written permission.
This software is provided "as is" without express or implied warranty. Use it at your own risk!
Whilst I have made every effort to remove any undesirable "features", I cannot be held responsible if it causes any damage or loss of time or data.
Win32::GUI::Grid - add a grid control to Win32::GUI. |