%
% Windows7-like Button Macro
% require: tikz
%
% usage: \button{xxxx}
% or
% usage: \button[NNN]{xxxx}
%
% xxxx: string overlayed to button.
% NNN:  magnification(default is 100).
%
\def\filedate{2014/03/07}
\def\fileversion{1.0}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{button}[\filedate\space\fileversion\space sakapon <sakapon@sit.ac.jp>]

\RequirePackage[dvipdfm]{graphicx}
\RequirePackage[dvipdfm]{xcolor}
\RequirePackage{tikz}

\definecolor{707070}{HTML}{707070}
\definecolor{777777}{HTML}{777777}
\definecolor{909090}{HTML}{909090}
\definecolor{CECECE}{HTML}{CECECE}
\definecolor{D4D4D4}{HTML}{D4D4D4}
\definecolor{DADADA}{HTML}{DADADA}
\definecolor{E0E0E0}{HTML}{E0E0E0}
\definecolor{E4E4E4}{HTML}{E4E4E4}
\definecolor{E6E6E6}{HTML}{E6E6E6}
\definecolor{E8E8E8}{HTML}{E8E8E8}
\definecolor{ECECEC}{HTML}{ECECEC}
\definecolor{F2F2F2}{HTML}{F2F2F2}
\definecolor{F3F3F3}{HTML}{F3F3F3}
\definecolor{F4F4F4}{HTML}{F4F4F4}
\definecolor{F5F5F5}{HTML}{F5F5F5}
\definecolor{F6F6F6}{HTML}{F6F6F6}
\definecolor{FAFAFA}{HTML}{FAFAFA}
\definecolor{FBFBFB}{HTML}{FBFBFB}
\definecolor{FCFCFC}{HTML}{FCFCFC}

\def\tikz@d@t#1(#2,#3){\fill [fill=#1] (#2, #3) rectangle (#2+1, #3+1);}
\def\tikz@r@ct#1(#2,#3)(#4,#5){\fill [fill=#1] (#2, #3) rectangle (#4+1, #5+1);}

\newcount\butt@nwd  % default width 84 (virtual)pixel
\newcount\butt@nwdaa    % \butt@nwd + 2
\newcount\butt@nwds     % \butt@nwd - 1
\newcount\butt@nwdss    % \butt@nwd - 2
\newcount\butt@nwdsss   % \butt@nwd - 3
\newcount\butt@nwdssss  % \butt@nwd - 4
\newcount\butt@nwdsssss % \butt@nwd - 5

\newcommand{\button}[2][100]{%
\butt@nwd=84 \multiply\butt@nwd by #1 \divide\butt@nwd by 100
\butt@nwdaa=\butt@nwd \advance\butt@nwds by 2
\butt@nwds=\butt@nwd \advance\butt@nwds by -1
\butt@nwdss=\butt@nwds \advance\butt@nwdss by -1
\butt@nwdsss=\butt@nwdss \advance\butt@nwdsss by -1
\butt@nwdssss=\butt@nwdsss \advance\butt@nwdssss by -1
\butt@nwdsssss=\butt@nwdssss \advance\butt@nwdsssss by -1
\ \raise-.38em\hbox{%
\begin{tikzpicture}[x=0.060em,y=0.060em]
% inner
\tikz@r@ct{CECECE}( 2, 2)(\butt@nwdsss, 5)
\tikz@r@ct{D4D4D4}( 2, 6)(\butt@nwdsss, 8)
\tikz@r@ct{DADADA}( 2, 9)(\butt@nwdsss,11)
\tikz@r@ct{E0E0E0}( 2,12)(\butt@nwdsss,14)
\tikz@r@ct{E6E6E6}( 2,15)(\butt@nwdsss,17)
\tikz@r@ct{ECECEC}( 2,18)(\butt@nwdsss,20)
\tikz@r@ct{F2F2F2}( 2,21)(\butt@nwdsss,23)
% left-bottom
\tikz@d@t{909090}( 1, 0)
\tikz@d@t{909090}( 0, 1)
\tikz@d@t{909090}( 1, 1)
\tikz@d@t{777777}( 2, 0)
\tikz@d@t{777777}( 0, 2)
\tikz@d@t{E4E4E4}( 2, 1)
\tikz@d@t{E4E4E4}( 1, 2)
\tikz@d@t{F3F3F3}( 3, 1)
\tikz@d@t{F3F3F3}( 2, 2)
\tikz@d@t{F3F3F3}( 1, 3)
% left
\tikz@r@ct{707070}( 0, 3)( 0,22)
\tikz@r@ct{F4F4F4}( 1, 4)( 1, 6)
\tikz@r@ct{F5F5F5}( 1, 7)( 1, 9)
\tikz@r@ct{F6F6F6}( 1,10)( 1,13)
\tikz@r@ct{FAFAFA}( 1,14)( 1,17)
\tikz@r@ct{FBFBFB}( 1,18)( 1,21)
% left-top
\tikz@d@t{909090}( 1,25)
\tikz@d@t{909090}( 0,24)
\tikz@d@t{909090}( 1,24)
\tikz@d@t{777777}( 2,25)
\tikz@d@t{777777}( 0,23)
\tikz@d@t{E8E8E8}( 2,24)
\tikz@d@t{E8E8E8}( 1,23)
\tikz@d@t{FCFCFC}( 3, 1)
\tikz@d@t{FCFCFC}( 2, 2)
\tikz@d@t{FCFCFC}( 1, 3)
% right-bottom
\tikz@d@t{909090}(\butt@nwdss, 0)
\tikz@d@t{909090}(\butt@nwds, 1)
\tikz@d@t{909090}(\butt@nwdss, 1)
\tikz@d@t{777777}(\butt@nwdsss, 0)
\tikz@d@t{777777}(\butt@nwds, 2)
\tikz@d@t{E4E4E4}(\butt@nwdsss, 1)
\tikz@d@t{E4E4E4}(\butt@nwdss, 2)
\tikz@d@t{F3F3F3}(\butt@nwdssss, 1)
\tikz@d@t{F3F3F3}(\butt@nwdsss, 2)
\tikz@d@t{F3F3F3}(\butt@nwdss, 3)
% right
\tikz@r@ct{707070}(\butt@nwds, 3)(\butt@nwds,22)
\tikz@r@ct{F4F4F4}(\butt@nwdss, 4)(\butt@nwdss, 6)
\tikz@r@ct{F5F5F5}(\butt@nwdss, 7)(\butt@nwdss, 9)
\tikz@r@ct{F6F6F6}(\butt@nwdss,10)(\butt@nwdss,13)
\tikz@r@ct{FAFAFA}(\butt@nwdss,14)(\butt@nwdss,17)
\tikz@r@ct{FBFBFB}(\butt@nwdss,18)(\butt@nwdss,21)
% right-top
\tikz@d@t{909090}(\butt@nwdss,25)
\tikz@d@t{909090}(\butt@nwds,24)
\tikz@d@t{909090}(\butt@nwdss,24)
\tikz@d@t{777777}(\butt@nwdsss,25)
\tikz@d@t{777777}(\butt@nwds,23)
\tikz@d@t{E8E8E8}(\butt@nwdsss,24)
\tikz@d@t{E8E8E8}(\butt@nwdss,23)
\tikz@d@t{FCFCFC}(\butt@nwdssss,24)
\tikz@d@t{FCFCFC}(\butt@nwdsss,23)
\tikz@d@t{FCFCFC}(\butt@nwdss,22)
% bottom
\tikz@r@ct{707070}( 3, 0)(\butt@nwdssss, 0)
\tikz@r@ct{F3F3F3}( 4, 1)(\butt@nwdsssss, 1)
% top
\tikz@r@ct{FCFCFC}( 4,24)(\butt@nwdsssss,24)
\tikz@r@ct{707070}( 3,25)(\butt@nwdssss,25)
% string
\draw (\butt@nwdaa/2, 26/2) node {\bf\sffamily #2};
\end{tikzpicture}}\ }
