GtkWidget::shape_combine_mask

GtkWidget::shape_combine_mask

void shape_combine_mask( GdkBitmap shape_mask , int offset_x, int offset_y);

This method can be used to give widgets an unnormal shape, e.g. a circle or something angulary. You can use it with all types of widgets, e.g. buttons and even windows. But see yourself:

Example 59. Making an unusual shaped button

<?php
if( !extension_loaded('gtk')) {
    dl( 'php_gtk.' . PHP_SHLIB_SUFFIX); 
}

$clickme = array(
"174 70 3 1",
" 	c None",
".	c #000000",
"+	c #FFBA01",
"                   +++++++++++++++++++++++++++++++++++++++++++++                        "
. "                                                                                      ",
"                ++++++++++++++++++++++++++++++++++++++++++++++++++++                    "
. "                                                                                      ",
"               +++++++++++++++++++++++++++++++++++++++++++++++++++++++++                "
. "                                                                                      ",
"            ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++              "
. "                                                                                      ",
"          ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++          "
. "                                                                                      ",
"        ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
. "+++++++++++++++++++++++++++++++++++++++++++++++                                       ",
"       +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
. "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++                             ",
"      ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
. "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                       ",
"    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
. "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                  ",
"   +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
. "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                 ",
"  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
. "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++               ",
"  ++++++++++++++++++++++                                 +++++++++++++++++++++++++++++++"
. "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++             ",
" +++++++++++++++++++++                                    ++++++++++++++++++++++++++++++"
. "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++           ",
" ++++++++++++++++++++                                       ++++++++++++++++++++++++++++"
. "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++         ",
" ++++++++++++++++                                             ++++++++++++++++++++++++++"
. "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++        ",
" ++++++++++++++                                                          +++++++++++++++"
. "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++      ",
" +++++++++++++                                                             +++++++      "
. "                                         ++++++++++++++++++++++++++++++++++++++++     ",
" ++++++++++++                                                                           "
. "                                                    ++++++++++++++++++++++++++++++    ",
" +++++++++++                                                                            "
. "                                                          ++++++++++++++++++++++++    ",
" +++++++++++                                                                            "
. "                                                              +++++++++++++++++++++   ",
" +++++++++++                                                                            "
. "                                                                +++++++++++++++++++   ",
" +++++++++++                                                                            "
. "                                                                  ++++++++++++++++++  ",
" +++++++++++                                                                            "
. "                                                                    ++++++++++++++++  ",
"++++++++++++                                                                            "
. "                                                                      +++++++++++++++ ",
"++++++++++++                                                                            "
. "                                                                       +++++++++++++++",
"++++++++++++                                                                            "
. "                                                                        ++++++++++++++",
"++++++++++++                               ..                                ..         "
. "                                                                         +++++++++++++",
"++++++++++++                   ........   ....      ...                     ....        "
. "                                                                         +++++++++++++",
"+++++++++++                  ...........  ....     .....                    ....        "
. "                                                                          ++++++++++++",
"+++++++++++                 ............  ....     .....                    ....        "
. "                                                                          ++++++++++++",
"+++++++++++                .............  ....      ...                     ....        "
. "                                                                           +++++++++++",
"+++++++++++               .......  .....  ....                              .....       "
. "                                                                           +++++++++++",
"+++++++++++              ......     ....  ....                              .....       "
. "                                                                           +++++++++++",
"+++++++++++             ......      ...   ....                              .....       "
. "                                                                           +++++++++++",
"+++++++++++             .....             ....                              .....      ."
. "..                  ..                                                     +++++++++++",
"+++++++++++            .....              ....      ..         .......      .....     .."
. "...                ....  ......  ......           ......                   +++++++++++",
"+++++++++++            .....              ....     ....       ..........    .....    ..."
. "...                .... ................        ..........                 +++++++++++",
"+++++++++++           .....               ....     ....      ............   .....   ...."
. "...                .....................       ............                +++++++++++",
"+++++++++++           ....                ....     ....     .............   .....  ....."
. "..                 ......................     .............                +++++++++++",
"+++++++++++           ....                ....     ....     .....    ...    ..... ......"
. ".                  ........ ....... .....    ......   .....                +++++++++++",
"+++++++++++          .....                ....     ....    .....            ............"
. "                   .......  .....    ....    .....    .....               ++++++++++++",
"+++++++++++          ....                 ....     ....    .....            ........... "
. "                   ......   ....     ....    ....   .......               ++++++++++++",
"+++++++++++          ....                 ....     ....   .....             ..........  "
. "                   .....    ....     ....   ....  ........               +++++++++++++",
"+++++++++++          ....                 ....     ....   .....             ........... "
. "                   ....     ....     ....   ............                ++++++++++++++",
"+++++++++++          ....           ..    ....     ....   ....              ............"
. "                   ....     ....     .....  ..........                  ++++++++++++++",
"++++++++++++         .....        .....   ....     ....   ....              ...... ....."
. "                   ....     .....    .....  ........                    +++++++++++++ ",
"++++++++++++          .....      ......   ....     ....   ....              ....    ...."
. ".                  ....     .....    .....  ......                      +++++++++++++ ",
"+++++++++++++         ......   ........   ....     ....   .....       ..    ....    ...."
. "..                 ....     .....    .....  .....        ...           +++++++++++++  ",
"++++++++++++++         ...............    ....     ....    ......   .....   ....     ..."
. "...                ....      ....     ....   ......    .....           +++++++++++++  ",
"+++++++++++++++         ............      ....     ....    ..............   ....      .."
. "...                ....      ....     ....   ...............           ++++++++++++   ",
" ++++++++++++++++        ..........       ....     ....     .............   ....       ."
. "....               ....      ....     ....    .............            ++++++++++++   ",
" +++++++++++++++++         .....          ....     ....      ..........     ....       ."
. "...                ....      ....     ....     ...........            +++++++++++++   ",
" +++++++++++++++++++                       ..       ..         ......        ..         "
. "...                 ..       ...       ...       .......             +++++++++++++    ",
"  +++++++++++++++++++                                                                   "
. "                                                                    ++++++++++++++    ",
"   ++++++++++++++++++++++                                                               "
. "                                                                 +++++++++++++++++    ",
"    +++++++++++++++++++++++++++++                                                       "
. "                                                               +++++++++++++++++++    ",
"     +++++++++++++++++++++++++++++++++                                                  "
. "                                                           ++++++++++++++++++++++     ",
"      ++++++++++++++++++++++++++++++++++++++++++++                                      "
. "                                                 ++++++++++++++++++++++++++++++++     ",
"       ++++++++++++++++++++++++++++++++++++++++++++++++++++++                           "
. "                                           +++++++++++++++++++++++++++++++++++++      ",
"        ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
. "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++       ",
"          ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
. "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++        ",
"           +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
. "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++         ",
"             +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
. "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++          ",
"              ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
. "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++           ",
"                ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
. "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++            ",
"                    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
. "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                ",
"                             +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
. "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                 ",
"                                 +++++++++++++++++++++++++++++++++++++++++++++++++++++++"
. "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                      ",
"                                              ++++++++++++++++++++++++++++++++++++++++++"
. "++++++++++++++++++++++++++++++++++++++++++++++++++++++                                ",
"                                                        ++++++++++++++++++++++++++++++++"
. "++++++++++++++++++++++++++++++++++++++++++++++++                                      "
);

$window = &new GtkWindow();
$window->set_default_size( 200, 100);

$window->connect_object('destroy', array('gtk', 'main_quit'));
$window->realize();

list($pixmap, $mask) = gdk::pixmap_create_from_xpm_d( $window->window, null, $clickme);

$btn = &new GtkButton( '');
$btn->shape_combine_mask($mask, 5, 5);

$style = $btn->style;
$style->bg[GTK_STATE_NORMAL]	= new GdkColor( 'orange');
$style->bg[GTK_STATE_PRELIGHT] = new GdkColor('#FF0000');
$style->bg[GTK_STATE_ACTIVE] = new GdkColor('#00FF00');
$btn->set_style( $style);

$window->add( $btn);

$window->show_all();
gtk::main();
?>
© Copyright 2003-2023 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.