Back to index

plt-scheme  4.2.1
Public Member Functions | Public Attributes | Private Attributes | Friends
wxColour Class Reference

#include <Colour.h>

Inheritance diagram for wxColour:
Inheritance graph
[legend]
Collaboration diagram for wxColour:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 wxColour (void)
 wxColour (unsigned char r, unsigned char g, unsigned char b)
 wxColour (wxColour *col)
 wxColour (const char *col)
 ~wxColour (void)
wxColourCopyFrom (wxColour *)
wxColourCopyFrom (const char *)
wxColouroperator= (wxColour &x)
Bool Ok (void)
void Get (unsigned char *r, unsigned char *b, unsigned char *g)
void Set (unsigned char r, unsigned char b, unsigned char g)
unsigned char Red (void)
unsigned char Green (void)
unsigned char Blue (void)
unsigned long GetPixel (wxColourMap *cmap=wxAPP_COLOURMAP, Bool is_color=1, Bool fg=1)
void FreePixel (Bool del)
Bool IsMutable (void)
void Lock (int d)
void install_cleanup ()
voidoperator new (size_t size)
voidoperator new (size_t size, GCPlacement gcp)
voidoperator new (size_t size, void *p)
voidoperator new (size_t size)
voidoperator new (size_t size, GCPlacement gcp)
void operator delete (void *obj)
void operator delete (void *, void *)
void operator delete (void *obj)
voidoperator new[] (size_t size)
voidoperator new[] (size_t size, GCPlacement gcp)
voidoperator new[] (size_t size, void *p)
void operator delete[] (void *obj)
void operator delete[] (void *, void *)

Public Attributes

WXTYPE __type
void__gc_external

Private Attributes

wxColour_XinternX
int locked

Friends

class wxColourMap

Detailed Description

Definition at line 46 of file Colour.h.


Constructor & Destructor Documentation

Definition at line 72 of file Colour.cc.

: wxObject(COLOR_CLEANUP)
{
    __type = wxTYPE_COLOUR;

    X = NULL; // not Ok
    locked = 0;
}
wxColour::wxColour ( unsigned char  r,
unsigned char  g,
unsigned char  b 
)

Definition at line 101 of file Colour.cc.

: wxObject(COLOR_CLEANUP)
{
    __type = wxTYPE_COLOUR;

    locked = 0;
    X = NULL; Set(r, g, b); // set RGB-values
}

Here is the call graph for this function:

Definition at line 81 of file Colour.cc.

Here is the call graph for this function:

wxColour::wxColour ( const char *  col)

Definition at line 91 of file Colour.cc.

Here is the call graph for this function:

Definition at line 110 of file Colour.cc.

{
  /* If you do anything important here, be sure to change
     COLOR_CLEANUP */

  /* This doesn't count as important, because the MrEd
     color manage never frees colors: */
  FreePixel(TRUE);
}

Here is the call graph for this function:


Member Function Documentation

unsigned char wxColour::Blue ( void  )

Definition at line 194 of file Colour.cc.

{
  return ( X ? (unsigned char)(X->xcolor.blue >> SHIFT) : 0 );
}

Here is the caller graph for this function:

Definition at line 122 of file Colour.cc.

{
  if (col->Ok()) {
    FreePixel(FALSE);
    if (!X) {
      X  = new wxColour_Xintern; // create new X representation;
    }
    *X = *(col->X);         // assign data
    X->have_pixel = FALSE;
  } else
    FreePixel(TRUE);

  return this;
}

Here is the call graph for this function:

Here is the caller graph for this function:

wxColour * wxColour::CopyFrom ( const char *  col)

Definition at line 137 of file Colour.cc.

{
  wxColour *the_colour;

  the_colour = wxTheColourDatabase->FindColour(col); // find colour by name
  
  if (the_colour) {
    FreePixel(FALSE);
    if (!X) {
       X = new wxColour_Xintern; // create new X representation
     }
    *X = *(the_colour->X);     // assign data
    X->have_pixel = FALSE;
  } else
    FreePixel(TRUE); // free pixel before assignment

  return this;
}

Here is the call graph for this function:

Definition at line 308 of file Colour.cc.

{
    if (X) {
       if (X->have_pixel) {
           // free allocated colour
           // -- currently don't free colours, because the ownership of
           // -- the pixel-value is not specified!
           // XFreeColors(wxAPP_DISPLAY, X->xcolormap, &(X->xcolor.pixel), 1, 0);
           X->have_pixel = FALSE;
       }
       if (del) {
           DELETE_OBJ X; // destroy X representation;
           X = NULL; // not Ok
       }
    }
}

Here is the caller graph for this function:

void wxColour::Get ( unsigned char *  r,
unsigned char *  b,
unsigned char *  g 
)

Definition at line 173 of file Colour.cc.

{
  if (X) {
    *r = (unsigned char)(X->xcolor.red   >> SHIFT);
    *g = (unsigned char)(X->xcolor.green >> SHIFT);
    *b = (unsigned char)(X->xcolor.blue  >> SHIFT);
  } else {
    *r = *g = *b = 0;
  }
}
unsigned long wxColour::GetPixel ( wxColourMap cmap = wxAPP_COLOURMAP,
Bool  is_color = 1,
Bool  fg = 1 
)

Definition at line 246 of file Colour.cc.

{
  if (!is_color) {
    int white;
    if (!X) {
      white = 1;
    } else if (fg) {
      /* foreground: white = white, all else = black */
      white = (((X->xcolor.red >> SHIFT) == 255)
              && ((X->xcolor.green >> SHIFT) == 255)
              && ((X->xcolor.blue >> SHIFT) == 255));
    } else {
      /* background: black = black, all else = white */
      white = (X->xcolor.red || X->xcolor.green || X->xcolor.blue);
    }

    if (white)
      return 0; /* WhitePixelOfScreen(wxAPP_SCREEN); */
    else
      return 1; /* BlackPixelOfScreen(wxAPP_SCREEN); */
  }

    if (X) {
       if (!X->have_pixel) {
         XColor xcol;
         Colormap cm;

           // no pixel value or wrong colourmap
           FreePixel(FALSE); // free pixel value if any
           cm = GETCOLORMAP(cmap); // colourmap to use
           X->xcolormap = cm;

           // allocate pixel
           /* Copy color b/c XAllocColour sets RGB values */
           xcol.red = X->xcolor.red;
           xcol.green = X->xcolor.green;
           xcol.blue = X->xcolor.blue;
           xcol.flags = DoRed | DoBlue | DoGreen;

           if (!wxAllocColor(wxAPP_DISPLAY, X->xcolormap, &xcol)
              && !alloc_close_color(wxAPP_DISPLAY, X->xcolormap, &xcol)) {
             // failed => used default
             static int message_printed = FALSE;
             if (!message_printed) {
              wxError("Colour allocation failed, using black.\n(Future allocations may fail without reports.)", 
                     "wxColour");
              message_printed = TRUE;
             } 
             return BlackPixelOfScreen(wxAPP_SCREEN);
           } else {
             X->xcolor.pixel = xcol.pixel;
             X->have_pixel = TRUE; // allocation successful
           }
       }
    } else {
       // use something as a default value
       wxDebugMsg("wxColour: no colour specified, using white\n");
       return(WhitePixelOfScreen(wxAPP_SCREEN));
    }
    return (X->xcolor.pixel);
}

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned char wxColour::Green ( void  )

Definition at line 189 of file Colour.cc.

{
  return ( X ? (unsigned char)(X->xcolor.green >> SHIFT) : 0 );
}

Here is the caller graph for this function:

Definition at line 99 of file wxGC.cxx.

{
  GC_finalization_proc old_fn;
  void *old_data;

# ifdef MZ_PRECISE_GC
#  define ALLOW_NON_BASE 0
#  define CHECK_BASE 0
# else
#  ifdef wx_xt
#   define ALLOW_NON_BASE 0
#   define CHECK_BASE 0
#  else
#   ifdef WIN32
#    define ALLOW_NON_BASE 0
#    define CHECK_BASE 1
#    define CRASH_ON_NONBASE 1
#   else
#    define ALLOW_NON_BASE 1
#    define CHECK_BASE 0
#   endif
#  endif
# endif

# if CHECK_BASE || ALLOW_NON_BASE
  if (GC_base(this) != (void *)this) {
#  if ALLOW_NON_BASE
    return;
#  else
#   ifdef CRASH_ON_NONBASE
    *(long *)0x0 = 1;
#   else
    printf("Clean-up object is not the base object\n");
    abort();
#   endif
#  endif
  }
# endif

  GC_register_finalizer_ignore_self(gcOBJ_TO_PTR(this), 
                                CAST_GCP GC_cleanup, NULL, 
                                CAST_GCPP &old_fn, &old_data);

# if CHECK_BASE
  if (old_fn) {
#  ifdef CRASH_ON_NONBASE
       *(long *)0x0 = 1;
#  else
    printf("Object already has a clean-up\n");
    abort();
#  endif
  }
# endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

Bool wxColour::IsMutable ( void  ) [inline]

Definition at line 78 of file Colour.h.

{ return !locked; } 

Here is the caller graph for this function:

void wxColour::Lock ( int  d) [inline]

Definition at line 79 of file Colour.h.

{ locked += d; }

Here is the caller graph for this function:

Bool wxColour::Ok ( void  ) [inline]

Definition at line 65 of file Colour.h.

{ return (X!=NULL); }

Here is the caller graph for this function:

void gc::operator delete ( void obj) [inline, inherited]
void gc::operator delete ( void obj) [inline, inherited]

Definition at line 287 of file gc_cpp.h.

                                           {
    GC_FREE( obj );}

Here is the caller graph for this function:

void gc::operator delete ( void ,
void  
) [inline, inherited]

Definition at line 291 of file gc_cpp.h.

{}
void gc::operator delete[] ( void obj) [inline, inherited]

Definition at line 305 of file gc_cpp.h.

                                             {
    gc::operator delete( obj );}

Here is the call graph for this function:

void gc::operator delete[] ( void ,
void  
) [inline, inherited]

Definition at line 309 of file gc_cpp.h.

{}
void* gc::operator new ( size_t  size) [inline, inherited]
void* gc::operator new ( size_t  size,
GCPlacement  gcp 
) [inline, inherited]
void * gc::operator new ( size_t  size) [inline, inherited]

Definition at line 273 of file gc_cpp.h.

                                           {
    return GC_MALLOC( size );}

Here is the caller graph for this function:

void * gc::operator new ( size_t  size,
GCPlacement  gcp 
) [inline, inherited]

Definition at line 276 of file gc_cpp.h.

                                                            {
    if (gcp == UseGC) 
        return GC_MALLOC( size );
    else if (gcp == PointerFreeGC)
       return GC_MALLOC_ATOMIC( size );
    else
        return GC_MALLOC_UNCOLLECTABLE( size );}
void * gc::operator new ( size_t  size,
void p 
) [inline, inherited]

Definition at line 284 of file gc_cpp.h.

                                                    {
    return p;}
void * gc::operator new[] ( size_t  size) [inline, inherited]

Definition at line 296 of file gc_cpp.h.

                                             {
    return gc::operator new( size );}

Here is the call graph for this function:

void * gc::operator new[] ( size_t  size,
GCPlacement  gcp 
) [inline, inherited]

Definition at line 299 of file gc_cpp.h.

                                                              {
    return gc::operator new( size, gcp );}

Here is the call graph for this function:

void * gc::operator new[] ( size_t  size,
void p 
) [inline, inherited]

Definition at line 302 of file gc_cpp.h.

                                                      {
    return p;}
wxColour& wxColour::operator= ( wxColour x) [inline]

Definition at line 58 of file Colour.h.

                                      { 
      printf("Error: shouldn't use = on color objects anymore\n");
      CopyFrom(&x);
      return *this;
    }

Here is the call graph for this function:

unsigned char wxColour::Red ( void  )

Definition at line 184 of file Colour.cc.

{
  return ( X ? (unsigned char)(X->xcolor.red >> SHIFT) : 0 );
}

Here is the caller graph for this function:

void wxColour::Set ( unsigned char  r,
unsigned char  b,
unsigned char  g 
)

Definition at line 158 of file Colour.cc.

{
    FreePixel(FALSE);

    if (!X) {
       X = new wxColour_Xintern; // create new X representation
     }

    X->xcolor.red   = ((unsigned short)r) << SHIFT; // init XColor structure
    X->xcolor.green = ((unsigned short)g) << SHIFT;
    X->xcolor.blue  = ((unsigned short)b) << SHIFT;
    X->xcolor.flags = DoRed | DoGreen | DoBlue;
    X->have_pixel   = FALSE; // no pixel value assigned
}

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class wxColourMap [friend]

Definition at line 82 of file Colour.h.


Member Data Documentation

Definition at line 146 of file wxGC.h.

WXTYPE wxObject::__type [inherited]

Definition at line 77 of file Object.h.

int wxColour::locked [private]

Definition at line 85 of file Colour.h.

Definition at line 84 of file Colour.h.


The documentation for this class was generated from the following files: