package Win32::GUI::Constants::Tags;
# $Id:,v 1.7 2008/02/08 18:47:17 robertemay Exp $

use strict;
use warnings;

# On one line so MakeMaker will see it.
require Win32::GUI::Constants;  our $VERSION = $Win32::GUI::Constants::VERSION;

use AutoLoader 'AUTOLOAD';

=head1 NAME

Win32::GUI::Constants::Tags - export :tag definitions for Win32::GUI::Constants


  use Win32::GUI::Constants qw ( :tag ... );

Win32::GUI::Constants::Tags provide export :tag definitions for use with
Win32::GUI::Constants.  It is implemented as a seperate module to improve
the speed and memory usage of Win32::GUI::Constants if no :tag symbols
are used on the import line.


The following tags are defined for use with Win32::GUI::Constants:

=head2 General Export Tags


=item B<:common>

A somewhat subjective list of commonly used constants.

=item B<:customdraw>

Constants related to custom draw handling.

=item B<:stockobjects>

Constants defining the system objects that can be created with GetStockObject().

=item B<:compatibility_win32_gui>

All constants exported by default by Win32::GUI up to v1.03.  Note that this is a large list.

=item B<:all>

All defined constants.  Note that this is a very large list.


=head2 Package Specific Export Tags

The following list of export tags is defined, each exporting constant that may be
useful with the related Win32::GUI package(s).  Note that some currently export nothing.

:accelerator, :animation, :bitmap, :brush, :button, :class, :combobox, :cursor,
:datetime, :dc, :font, :header, :icon, :imagelist, :label, :listbox, :listview, :mdi,
:menu, :monthcal, :notifyicon, :pen, :progressbar, :rebar, :region, :richedit,
:scrollbar, :slider, :splitter, :statusbar, :tabstrip, :textfield, :timer, :toolbar,
:tooltip, :treeview, :updown, :window


# tag spec's
# keys are tags, values are array ref containg regex patterns of
# constants to match.  If value is undef, then the definition will
# be the return value of a subroutine named tag_spec().  These
# subroutines are defined after the __END__ token in this file, and processed
# by AutoSplit and AutoLoader.
our %TAG_SPECS = (
    common      => [ qw( ^CW_USEDEFAULT$ ) ],
    customdraw  => [ qw( ^CDDS_ ^CDRF_ ) ],
    stockobjects=> undef,
    all         => [ qw( .* ) ],

    compatibility_win32_gui => undef,

    accelerator => [ qw( ^VK_ ) ],
    animation   => [ qw( ^ACS_ ^ACM_ ^ACN_ ) ],
    bitmap      => [ qw( ^OBM_ ) ],
    brush       => [ qw() ],
    button      => undef,
    class       => [ qw( ^COLOR_ ^CS_ ) ],
    combobox    => [ qw( ^CB_ ^CBS_ ^CBES_ ^CBN_ ) ],
    cursor      => [ qw( ^IDC_ ^OCR_ ) ],
    datetime    => [ qw( ^DTS_ ) ],
    dc          => undef,
    font        => [ qw() ],
    header      => [ qw( ^HDS_ ) ],
    icon        => [ qw( ^IDI_ ^OIC_ ) ],
    imagelist   => [ qw( ^ILC_ ^ILD_ ^ILS_ ^CLR_NONE$ ^CLR_DEFAULT$ ^IMAGE_ ) ],
    label       => [ qw( ^IMAGE_ ^STM_ ^STN_ ) ],
    listbox     => [ qw( ^LB_ ^LBN_ ^LBS_ ) ],
    listview    => [ qw( ^LVS_ ^LVIS_ ^LVIR_ ^LVSIL_ ^CLR_NONE$ ) ],
    mdi         => [ qw() ],
    menu        => [ qw( ^MF_ ^SC_ ^TPM_ ) ],
    monthcal    => [ qw( ^MCS_ ^MCSC_ ) ],
    notifyicon  => [ qw() ],
    pen         => [ qw( ^PS_ ) ],
    progressbar => [ qw( ^PBS_ ^PBM_ ^CLR_DEFAULT$ ) ],
    rebar       => [ qw( ^CLR_DEFAULT$ ^RBBS_ ) ],
    region      => [ qw( ^RGN_ ) ],
    richedit    => [ qw( ^CP_ ^EM_ ^ENM_ ^EN_ ^ES_ ^GT_ ^SF_ ^SFF_ ) ],
    scrollbar   => [ qw( ^SB_ ^SBM_ ^SBS_ ) ],
    slider      => [ qw( ^TBTS_ ) ],
    splitter    => [ qw() ],
    statusbar   => [ qw( ^CLR_DEFAULT$ ^SBT_ ) ],
    tabstrip    => [ qw() ],
    textfield   => [ qw( ^EM_ ^ES_ ) ],
    timer       => [ qw() ],
    toolbar     => [ qw( ^BTNS_ ^TBSTATE_ ^TBSTYLE_ ^I_ ^CLR_DEFAULT$ ^TRANSPARENT$
                         ^OPAQUE$ ^HINST_COMMCTRL$ ^IBD_ ) ],
    tooltip     => [ qw( ^TTDT_ ^TTF_ ^TTM_ ^TTN_ ) ],
    treeview    => [ qw( ^CLR_DEFAULT$ ^TVGN_ ^TVHT_ ) ],
    updown      => [ qw() ],
    window      => [ qw( ^DS_ ^ID.[^_]+ ^MA_ ^MK_ ^NM_ ^RDW_ ^SIZE_ ^SW_ ^WA_ ^WM_
                             ^WS_ ) ],

# tag() returns a reference to a list of constant names,
# or undef if the tag passed has no definition
sub tag {
    my $spec = shift;

    if(exists $TAG_SPECS{$spec}) {
        my $patterns;
        if(defined($TAG_SPECS{$spec})) {
            $patterns = $TAG_SPECS{$spec};
        else {
            no strict 'refs';
            $patterns = &{"tag_$spec"};
        my @names = ();
        my @syms = @{Win32::GUI::Constants::_export_ok()};
        foreach my $patn (@$patterns) {
            push @names, grep(/$patn/, @syms);
        return \@names;
    return undef;

1; #End of

=head1 SUPPORT

Homepage: L<>.

For further support join the users mailing list
(C<>) from the website
at L<>.
There is a searchable list archive at

=head1 BUGS

No all constants are covered.  If you find missing constants
please raise a feature request at

=head1 AUTHORS

Robert May, E<lt>robertemay@users.sourceforge.netE<gt>


Many thanks to the Win32::GUI developers at
L<> for suggestions
and assistance.


Copyright 2005..2006 Robert May, All Rights Reserved.


#AutoLoaded subs go after the __END__ token
# each sub here is the name of a tag, and returns an array ref
# to a list of patterns to match
sub tag_stockobjects() { [
] }
sub tag_button() { [
    ^BM_ ^BCM_ ^BN_ )
] }
sub tag_dc() { [
] }
sub tag_compatibility_win32_gui() { [
] }