@@ -46,6 +46,31 @@ extern PyObject *WinObj_WhichWindow(WindowPtr);
4646
4747#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
4848
49+ /*
50+ ** Parse/generate RGB records
51+ */
52+ PyObject * QdRGB_New (itself )
53+ RGBColorPtr itself ;
54+ {
55+
56+ return Py_BuildValue ("lll" , (long )itself -> red , (long )itself -> green , (long )itself -> blue );
57+ }
58+
59+ QdRGB_Convert (v , p_itself )
60+ PyObject * v ;
61+ RGBColorPtr p_itself ;
62+ {
63+ long red , green , blue ;
64+
65+ if ( !PyArg_ParseTuple (v , "lll" , & red , & green , & blue ) )
66+ return 0 ;
67+ p_itself -> red = (unsigned short )red ;
68+ p_itself -> green = (unsigned short )green ;
69+ p_itself -> blue = (unsigned short )blue ;
70+ return 1 ;
71+ }
72+
73+
4974static PyObject * Qd_Error ;
5075
5176/* ---------------------- Object type GrafPort ---------------------- */
@@ -2238,6 +2263,24 @@ static PyObject *Qd_GetPixPat(_self, _args)
22382263 return _res ;
22392264}
22402265
2266+ static PyObject * Qd_MakeRGBPat (_self , _args )
2267+ PyObject * _self ;
2268+ PyObject * _args ;
2269+ {
2270+ PyObject * _res = NULL ;
2271+ PixPatHandle pp ;
2272+ RGBColor myColor ;
2273+ if (!PyArg_ParseTuple (_args , "O&O&" ,
2274+ ResObj_Convert , & pp ,
2275+ QdRGB_Convert , & myColor ))
2276+ return NULL ;
2277+ MakeRGBPat (pp ,
2278+ & myColor );
2279+ Py_INCREF (Py_None );
2280+ _res = Py_None ;
2281+ return _res ;
2282+ }
2283+
22412284static PyObject * Qd_FillCRect (_self , _args )
22422285 PyObject * _self ;
22432286 PyObject * _args ;
@@ -2358,6 +2401,57 @@ static PyObject *Qd_FillCPoly(_self, _args)
23582401 return _res ;
23592402}
23602403
2404+ static PyObject * Qd_RGBForeColor (_self , _args )
2405+ PyObject * _self ;
2406+ PyObject * _args ;
2407+ {
2408+ PyObject * _res = NULL ;
2409+ RGBColor color ;
2410+ if (!PyArg_ParseTuple (_args , "O&" ,
2411+ QdRGB_Convert , & color ))
2412+ return NULL ;
2413+ RGBForeColor (& color );
2414+ Py_INCREF (Py_None );
2415+ _res = Py_None ;
2416+ return _res ;
2417+ }
2418+
2419+ static PyObject * Qd_RGBBackColor (_self , _args )
2420+ PyObject * _self ;
2421+ PyObject * _args ;
2422+ {
2423+ PyObject * _res = NULL ;
2424+ RGBColor color ;
2425+ if (!PyArg_ParseTuple (_args , "O&" ,
2426+ QdRGB_Convert , & color ))
2427+ return NULL ;
2428+ RGBBackColor (& color );
2429+ Py_INCREF (Py_None );
2430+ _res = Py_None ;
2431+ return _res ;
2432+ }
2433+
2434+ static PyObject * Qd_SetCPixel (_self , _args )
2435+ PyObject * _self ;
2436+ PyObject * _args ;
2437+ {
2438+ PyObject * _res = NULL ;
2439+ short h ;
2440+ short v ;
2441+ RGBColor cPix ;
2442+ if (!PyArg_ParseTuple (_args , "hhO&" ,
2443+ & h ,
2444+ & v ,
2445+ QdRGB_Convert , & cPix ))
2446+ return NULL ;
2447+ SetCPixel (h ,
2448+ v ,
2449+ & cPix );
2450+ Py_INCREF (Py_None );
2451+ _res = Py_None ;
2452+ return _res ;
2453+ }
2454+
23612455static PyObject * Qd_SetPortPix (_self , _args )
23622456 PyObject * _self ;
23632457 PyObject * _args ;
@@ -2373,6 +2467,84 @@ static PyObject *Qd_SetPortPix(_self, _args)
23732467 return _res ;
23742468}
23752469
2470+ static PyObject * Qd_GetCPixel (_self , _args )
2471+ PyObject * _self ;
2472+ PyObject * _args ;
2473+ {
2474+ PyObject * _res = NULL ;
2475+ short h ;
2476+ short v ;
2477+ RGBColor cPix ;
2478+ if (!PyArg_ParseTuple (_args , "hh" ,
2479+ & h ,
2480+ & v ))
2481+ return NULL ;
2482+ GetCPixel (h ,
2483+ v ,
2484+ & cPix );
2485+ _res = Py_BuildValue ("O&" ,
2486+ QdRGB_New , & cPix );
2487+ return _res ;
2488+ }
2489+
2490+ static PyObject * Qd_GetForeColor (_self , _args )
2491+ PyObject * _self ;
2492+ PyObject * _args ;
2493+ {
2494+ PyObject * _res = NULL ;
2495+ RGBColor color ;
2496+ if (!PyArg_ParseTuple (_args , "" ))
2497+ return NULL ;
2498+ GetForeColor (& color );
2499+ _res = Py_BuildValue ("O&" ,
2500+ QdRGB_New , & color );
2501+ return _res ;
2502+ }
2503+
2504+ static PyObject * Qd_GetBackColor (_self , _args )
2505+ PyObject * _self ;
2506+ PyObject * _args ;
2507+ {
2508+ PyObject * _res = NULL ;
2509+ RGBColor color ;
2510+ if (!PyArg_ParseTuple (_args , "" ))
2511+ return NULL ;
2512+ GetBackColor (& color );
2513+ _res = Py_BuildValue ("O&" ,
2514+ QdRGB_New , & color );
2515+ return _res ;
2516+ }
2517+
2518+ static PyObject * Qd_OpColor (_self , _args )
2519+ PyObject * _self ;
2520+ PyObject * _args ;
2521+ {
2522+ PyObject * _res = NULL ;
2523+ RGBColor color ;
2524+ if (!PyArg_ParseTuple (_args , "O&" ,
2525+ QdRGB_Convert , & color ))
2526+ return NULL ;
2527+ OpColor (& color );
2528+ Py_INCREF (Py_None );
2529+ _res = Py_None ;
2530+ return _res ;
2531+ }
2532+
2533+ static PyObject * Qd_HiliteColor (_self , _args )
2534+ PyObject * _self ;
2535+ PyObject * _args ;
2536+ {
2537+ PyObject * _res = NULL ;
2538+ RGBColor color ;
2539+ if (!PyArg_ParseTuple (_args , "O&" ,
2540+ QdRGB_Convert , & color ))
2541+ return NULL ;
2542+ HiliteColor (& color );
2543+ Py_INCREF (Py_None );
2544+ _res = Py_None ;
2545+ return _res ;
2546+ }
2547+
23762548static PyObject * Qd_AllocCursor (_self , _args )
23772549 PyObject * _self ;
23782550 PyObject * _args ;
@@ -2400,6 +2572,69 @@ static PyObject *Qd_GetCTSeed(_self, _args)
24002572 return _res ;
24012573}
24022574
2575+ static PyObject * Qd_Color2Index (_self , _args )
2576+ PyObject * _self ;
2577+ PyObject * _args ;
2578+ {
2579+ PyObject * _res = NULL ;
2580+ long _rv ;
2581+ RGBColor myColor ;
2582+ if (!PyArg_ParseTuple (_args , "O&" ,
2583+ QdRGB_Convert , & myColor ))
2584+ return NULL ;
2585+ _rv = Color2Index (& myColor );
2586+ _res = Py_BuildValue ("l" ,
2587+ _rv );
2588+ return _res ;
2589+ }
2590+
2591+ static PyObject * Qd_Index2Color (_self , _args )
2592+ PyObject * _self ;
2593+ PyObject * _args ;
2594+ {
2595+ PyObject * _res = NULL ;
2596+ long index ;
2597+ RGBColor aColor ;
2598+ if (!PyArg_ParseTuple (_args , "l" ,
2599+ & index ))
2600+ return NULL ;
2601+ Index2Color (index ,
2602+ & aColor );
2603+ _res = Py_BuildValue ("O&" ,
2604+ QdRGB_New , & aColor );
2605+ return _res ;
2606+ }
2607+
2608+ static PyObject * Qd_InvertColor (_self , _args )
2609+ PyObject * _self ;
2610+ PyObject * _args ;
2611+ {
2612+ PyObject * _res = NULL ;
2613+ RGBColor myColor ;
2614+ if (!PyArg_ParseTuple (_args , "" ))
2615+ return NULL ;
2616+ InvertColor (& myColor );
2617+ _res = Py_BuildValue ("O&" ,
2618+ QdRGB_New , & myColor );
2619+ return _res ;
2620+ }
2621+
2622+ static PyObject * Qd_RealColor (_self , _args )
2623+ PyObject * _self ;
2624+ PyObject * _args ;
2625+ {
2626+ PyObject * _res = NULL ;
2627+ Boolean _rv ;
2628+ RGBColor color ;
2629+ if (!PyArg_ParseTuple (_args , "O&" ,
2630+ QdRGB_Convert , & color ))
2631+ return NULL ;
2632+ _rv = RealColor (& color );
2633+ _res = Py_BuildValue ("b" ,
2634+ _rv );
2635+ return _res ;
2636+ }
2637+
24032638static PyObject * Qd_SetClientID (_self , _args )
24042639 PyObject * _self ;
24052640 PyObject * _args ;
@@ -3067,6 +3302,8 @@ static PyMethodDef Qd_methods[] = {
30673302 "(PixPatHandle pp) -> None" },
30683303 {"GetPixPat" , (PyCFunction )Qd_GetPixPat , 1 ,
30693304 "(short patID) -> (PixPatHandle _rv)" },
3305+ {"MakeRGBPat" , (PyCFunction )Qd_MakeRGBPat , 1 ,
3306+ "(PixPatHandle pp, RGBColor myColor) -> None" },
30703307 {"FillCRect" , (PyCFunction )Qd_FillCRect , 1 ,
30713308 "(Rect r, PixPatHandle pp) -> None" },
30723309 {"FillCOval" , (PyCFunction )Qd_FillCOval , 1 ,
@@ -3079,12 +3316,36 @@ static PyMethodDef Qd_methods[] = {
30793316 "(RgnHandle rgn, PixPatHandle pp) -> None" },
30803317 {"FillCPoly" , (PyCFunction )Qd_FillCPoly , 1 ,
30813318 "(PolyHandle poly, PixPatHandle pp) -> None" },
3319+ {"RGBForeColor" , (PyCFunction )Qd_RGBForeColor , 1 ,
3320+ "(RGBColor color) -> None" },
3321+ {"RGBBackColor" , (PyCFunction )Qd_RGBBackColor , 1 ,
3322+ "(RGBColor color) -> None" },
3323+ {"SetCPixel" , (PyCFunction )Qd_SetCPixel , 1 ,
3324+ "(short h, short v, RGBColor cPix) -> None" },
30823325 {"SetPortPix" , (PyCFunction )Qd_SetPortPix , 1 ,
30833326 "(PixMapHandle pm) -> None" },
3327+ {"GetCPixel" , (PyCFunction )Qd_GetCPixel , 1 ,
3328+ "(short h, short v) -> (RGBColor cPix)" },
3329+ {"GetForeColor" , (PyCFunction )Qd_GetForeColor , 1 ,
3330+ "() -> (RGBColor color)" },
3331+ {"GetBackColor" , (PyCFunction )Qd_GetBackColor , 1 ,
3332+ "() -> (RGBColor color)" },
3333+ {"OpColor" , (PyCFunction )Qd_OpColor , 1 ,
3334+ "(RGBColor color) -> None" },
3335+ {"HiliteColor" , (PyCFunction )Qd_HiliteColor , 1 ,
3336+ "(RGBColor color) -> None" },
30843337 {"AllocCursor" , (PyCFunction )Qd_AllocCursor , 1 ,
30853338 "() -> None" },
30863339 {"GetCTSeed" , (PyCFunction )Qd_GetCTSeed , 1 ,
30873340 "() -> (long _rv)" },
3341+ {"Color2Index" , (PyCFunction )Qd_Color2Index , 1 ,
3342+ "(RGBColor myColor) -> (long _rv)" },
3343+ {"Index2Color" , (PyCFunction )Qd_Index2Color , 1 ,
3344+ "(long index) -> (RGBColor aColor)" },
3345+ {"InvertColor" , (PyCFunction )Qd_InvertColor , 1 ,
3346+ "() -> (RGBColor myColor)" },
3347+ {"RealColor" , (PyCFunction )Qd_RealColor , 1 ,
3348+ "(RGBColor color) -> (Boolean _rv)" },
30883349 {"SetClientID" , (PyCFunction )Qd_SetClientID , 1 ,
30893350 "(short id) -> None" },
30903351 {"ProtectEntry" , (PyCFunction )Qd_ProtectEntry , 1 ,
0 commit comments