Changeset 3292 for libcaca/trunk


Ignore:
Timestamp:
Nov 5, 2008, 1:39:18 AM (11 years ago)
Author:
bsittler
Message:

add AnsiColor?, EventType? and EventKey? constants parallel to the .NET ones

Location:
libcaca/trunk/caca-php
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca-php/caca.php

    r3286 r3292  
    1313 */
    1414
     15class AnsiColor
     16{
     17        const BLACK = CACA_BLACK;
     18        const BLUE = CACA_BLUE;
     19        const GREEN = CACA_GREEN;
     20        const CYAN = CACA_CYAN;
     21        const RED = CACA_RED;
     22        const MAGENTA = CACA_MAGENTA;
     23        const BROWN = CACA_BROWN;
     24        const LIGHTGRAY = CACA_LIGHTGRAY;
     25        const DARKGRAY = CACA_DARKGRAY;
     26        const LIGHTBLUE = CACA_LIGHTBLUE;
     27        const LIGHTGREEN = CACA_LIGHTGREEN;
     28        const LIGHTCYAN = CACA_LIGHTCYAN;
     29        const LIGHTRED = CACA_LIGHTRED;
     30        const LIGHTMAGENTA = CACA_LIGHTMAGENTA;
     31        const YELLOW = CACA_YELLOW;
     32        const WHITE = CACA_WHITE;
     33        /* NOTE: We can't call this one DEFAULT because that's a reserved
     34         * token in PHP. */
     35        const DEFAULTCOLOR = CACA_DEFAULT;
     36        const TRANSPARENT = CACA_TRANSPARENT;
     37}
    1538
    1639class Canvas {
     
    240263                return $this->cv;
    241264        }
     265}
     266
     267class EventType
     268{
     269        const NONE = CACA_EVENT_NONE;
     270
     271        const KEY_PRESS = CACA_EVENT_KEY_PRESS;
     272        const KEY_RELEASE = CACA_EVENT_KEY_RELEASE;
     273        const MOUSE_PRESS = CACA_EVENT_MOUSE_PRESS;
     274        const MOUSE_RELEASE = CACA_EVENT_MOUSE_RELEASE;
     275        const MOUSE_MOTION = CACA_EVENT_MOUSE_MOTION;
     276        const RESIZE = CACA_EVENT_RESIZE;
     277        const QUIT = CACA_EVENT_QUIT;
     278
     279        const ANY = CACA_EVENT_ANY;
     280}
     281   
     282class EventKey
     283{
     284        const UNKNOWN = CACA_KEY_UNKNOWN;
     285
     286        const CTRL_A = CACA_KEY_CTRL_A;
     287        const CTRL_B = CACA_KEY_CTRL_B;
     288        const CTRL_C = CACA_KEY_CTRL_C;
     289        const CTRL_D = CACA_KEY_CTRL_D;
     290        const CTRL_E = CACA_KEY_CTRL_E;
     291        const CTRL_F = CACA_KEY_CTRL_F;
     292        const CTRL_G = CACA_KEY_CTRL_G;
     293        const BACKSPACE = CACA_KEY_BACKSPACE;
     294        const TAB = CACA_KEY_TAB;
     295        const CTRL_J = CACA_KEY_CTRL_J;
     296        const CTRL_K = CACA_KEY_CTRL_K;
     297        const CTRL_L = CACA_KEY_CTRL_L;
     298        /* NOTE: We can't call this one RETURN because that's a
     299         * reserved token in PHP */
     300        const RETURN_KEY = CACA_KEY_RETURN;
     301        const CTRL_N = CACA_KEY_CTRL_N;
     302        const CTRL_O = CACA_KEY_CTRL_O;
     303        const CTRL_P = CACA_KEY_CTRL_P;
     304        const CTRL_Q = CACA_KEY_CTRL_Q;
     305        const CTRL_R = CACA_KEY_CTRL_R;
     306        const PAUSE = CACA_KEY_PAUSE;
     307        const CTRL_T = CACA_KEY_CTRL_T;
     308        const CTRL_U = CACA_KEY_CTRL_U;
     309        const CTRL_V = CACA_KEY_CTRL_V;
     310        const CTRL_W = CACA_KEY_CTRL_W;
     311        const CTRL_X = CACA_KEY_CTRL_X;
     312        const CTRL_Y = CACA_KEY_CTRL_Y;
     313        const CTRL_Z = CACA_KEY_CTRL_Z;
     314        const ESCAPE = CACA_KEY_ESCAPE;
     315        const DELETE = CACA_KEY_DELETE;
     316
     317        const UP = CACA_KEY_UP;
     318        const DOWN = CACA_KEY_DOWN;
     319        const LEFT = CACA_KEY_LEFT;
     320        const RIGHT = CACA_KEY_RIGHT;
     321
     322        const INSERT = CACA_KEY_INSERT;
     323        const HOME = CACA_KEY_HOME;
     324        const END = CACA_KEY_END;
     325        const PAGEUP = CACA_KEY_PAGEUP;
     326        const PAGEDOWN = CACA_KEY_PAGEDOWN;
     327
     328        const F1 = CACA_KEY_F1;
     329        const F2 = CACA_KEY_F2;
     330        const F3 = CACA_KEY_F3;
     331        const F4 = CACA_KEY_F4;
     332        const F5 = CACA_KEY_F5;
     333        const F6 = CACA_KEY_F6;
     334        const F7 = CACA_KEY_F7;
     335        const F8 = CACA_KEY_F8;
     336        const F9 = CACA_KEY_F9;
     337        const F10 = CACA_KEY_F10;
     338        const F11 = CACA_KEY_F11;
     339        const F12 = CACA_KEY_F12;
     340        const F13 = CACA_KEY_F13;
     341        const F14 = CACA_KEY_F14;
     342        const F15 = CACA_KEY_F15;
    242343}
    243344
  • libcaca/trunk/caca-php/examples/test.php

    r3290 r3292  
    4242
    4343                $this->scroll = new Canvas(strlen($message), 1);
    44                 $this->scroll->setColorAnsi(CACA_WHITE, CACA_TRANSPARENT);
     44                $this->scroll->setColorAnsi(AnsiColor::WHITE, AnsiColor::TRANSPARENT);
    4545                $this->scroll->putStr(0, 0, $message);
    4646
     
    6565                $this->Clear();
    6666
    67                 $this->setColorAnsi(CACA_WHITE, CACA_BLACK);
     67                $this->setColorAnsi(AnsiColor::WHITE, AnsiColor::BLACK);
    6868                for($i = 0; $i < $barCount; $i++)
    6969                {
     
    7373                        $p2_x = $this->getWidth() - 1; $p2_y = intval($v);
    7474
    75                         $this->setColorAnsi(($i + 9), CACA_BLACK);
     75                        $this->setColorAnsi(($i + 9), AnsiColor::BLACK);
    7676                        /* drawLine is already clipped, we don't care about overflows */
    7777                        $this->drawLine($p1_x + 0, $p1_y - 2, $p2_x + 0, $p2_y - 2, ord('-'));
     
    8989                $this->d->bitmap($this, 12 * $w - $x, $h / 2 - $y, $w * 12, $y * 2);
    9090 
    91                 $this->setColorAnsi(CACA_WHITE, CACA_BLUE);
     91                $this->setColorAnsi(AnsiColor::WHITE, AnsiColor::BLUE);
    9292                $this->putStr($this->getWidth() - 30, $this->getHeight() - 2, " -=[ Powered by libcaca ]=- ");
    93                 $this->setColorAnsi(CACA_WHITE, CACA_BLACK);
     93                $this->setColorAnsi(AnsiColor::WHITE, AnsiColor::BLACK);
    9494        }
    9595}
     
    109109        function EventLoop()
    110110        {
    111                 while(! ($ev = $this->getEvent(CACA_EVENT_KEY_RELEASE, 10)))
     111                while(! ($ev = $this->getEvent(EventType::KEY_RELEASE, 10)))
    112112                {
    113113                        $this->cv->Draw();
Note: See TracChangeset for help on using the changeset viewer.