In file include/csws/cscomp.h:

## class csComponent : public csBase

> Graphics system component: a menu, window etc

## Inheritance:

### Public Fields

csApp* app
  Top-level application object
csRect bound
  Component size/position rectangle
csVector clipchildren
  An array of 'clip children', i.e. components which are clipped against us
csComponent* focused
  The focused child window
unsigned int id
  Component ID, unique within its parrent's child ring
csComponent* next
  Next and previous neightbours
csComponent* parent
  Parent component or NULL
csComponent* top
  The top-Z child window

### Public Methods

void Box(int xmin, int ymin, int xmax, int ymax, int colindx)
  Draw a box
void Center(bool iHoriz = true, bool iVert = true)
  Center window inside parent
virtual void Close()
  Destroy this component

  You should not call any methods or use any variables after this! When this function returns, the object is already destroyed

csComponent(csComponent *iParent)
  Create a component and insert it into parent's child list if parent != NULL
virtual void Delete(csComponent *comp)
  Delete a child component
void DeleteAll()
  Delete all children components
void DeleteClipChild(csComponent *clipchild)
  Remove a 'clip child'
void Drag(int x, int y, int DragMode)
  Drag a window with mouse located at (x,y) window-local coordinates
virtual void Draw()
  Draw the component (only dirty rectangle should be redrawn)
void FindMaxFreeRect(csRect &area)
  Find the maximal rectangle uncovered by child windows
virtual void FixPosition(int &newX, int &newY)
  Fix new window position before assigning to component
virtual void FixSize(int &newW, int &newH)
  Fix new window size before assigning to component
csComponent* ForEach(bool (*func) (csComponent *child, void *param), void *param = NULL, bool Zorder = false)
  For each child component call a function with a optional arg Function returns the first child on which func returnes 'true' Function can scan from top-Z child (Zorder == true) or from focused child (Zorder == false)
csComponent* GetChild(int find_id)
  Find a child component by its ID
csComponent* GetClipParent()
  Return the 'clip parent' component
int GetColor(int Index)
  Get a color from logical palette
csComponent* GetDefault()
  Find the 'default' child
int GetDragStyle()
  Query drag style flags
csComponent* GetFocused()
  Get the focused child window
int GetFont()
  Query current text font for this component
int GetState(int mask)
  Return component state flags
virtual char* GetText()
  Same, but you cannot change returned value
virtual void GetText(char *oText, int iTextSize)
  Query component text
csComponent* GetTop()
  Get the top Z-order child window
void GlobalToLocal(int &x, int &y)
  Convert a pair of X,Y coordinates from global to local coordinate system
bool HandleDragEvent(csEvent &Event, int BorderW, int BorderH)
  Handle a mouse drag event
virtual bool HandleEvent(csEvent &Event)
  Handle a event and return true if processed
virtual void Hide()
  Hide the component
virtual void Insert(csComponent *comp)
  Insert a child component
void InsertClipChild(csComponent *clipchild)
  Insert a 'clip child'
void Invalidate(csRect &area, bool IncludeChildren = false)
  Invalidate a area of component (force a redraw of this area)
void Invalidate(bool IncludeChildren = false)
  Same, but invalidates entire component
void Invalidate(int xmin, int ymin, int xmax, int ymax, bool IncludeChildren = false)
  Same, but with coordinates instead of rectangle
void Line(float x1, float y1, float x2, float y2, int colindx)
  Draw a line
void LocalToGlobal(int &x, int &y)
  Convert a pair of X,Y coordinates from local to global coordinate system
virtual bool Maximize()
  Maximize window if it is not already and if DragStyle has CS_DRAG_SIZEABLE
virtual csComponent* NextChild(csComponent *start = NULL, bool disabled = false)
  Return next selectable child window after 'start'
virtual csComponent* NextControl(csComponent *start = NULL)
  Return next control after 'start', looping through groups
virtual csComponent* NextGroup(csComponent *start = NULL)
  Return control in next group after 'start'
void ObliqueRect3D(int xmin, int ymin, int xmax, int ymax, int cornersize, int darkindx, int lightindx)
  Draw a 3D rectangle with two oblique corners (used for buttons, for example)
void Pixel(int x, int y, int colindx)
  Draw a pixel
virtual bool PostHandleEvent(csEvent &Event)
  Handle a event if nobody eaten it.
virtual bool PreHandleEvent(csEvent &Event)
  Handle a event BEFORE all others
virtual csComponent* PrevChild(csComponent *start = NULL, bool disabled = false)
  Return previous selectable child window before 'start'
virtual csComponent* PrevControl(csComponent *start = NULL)
  Return previous control before 'start', looping through groups
virtual csComponent* PrevGroup(csComponent *start = NULL)
  Return control in previous group before 'start'
void Rect3D(int xmin, int ymin, int xmax, int ymax, int darkindx, int lightindx)
  Draw a 3D-looking thin rectangle
void Redraw()
  Redraw the component if it has a dirty area
virtual bool Restore()
  Restore window if it is maximized and if DragStyle has CS_DRAG_SIZEABLE
bool Select()
  Select (focus) this component and return true if successful
void* SendCommand(int CommandCode, void *Info = NULL)
  Send a command to this window and returns the Info field of csEvent object
void SetApp(csApp *newapp)
  Set the application for this object and all its children
void SetClipRect(int xmin, int ymin, int xmax, int ymax)
  Set clipping rectangle
void SetClipRect()
  Disable clipping
void SetColor(int Index, int Color)
  Set a color value in palette (makes a copy of *palette if not already)
bool SetDragRect(int xmin, int ymin, int xmax, int ymax)
  Calls SetRect after calling FixPosition and FixSize (used when dragging)
void SetDragStyle(int iDragStyle)
  Set drag style flags
bool SetFocused(csComponent *comp)
  Focus a child component
void SetFont(int iFont, bool IncludeChildren = false)
  Set text font for this component and possibly its children
void SetMouse(csMouseCursorID Cursor)
  Set mouse cursor pointer
void SetPalette(int *iPalette, int iPaletteSize)
  Set component logical palette
void SetPalette(int iPaletteID)
  Same, but accepts the index into cswsPalette[] array
void SetPos(int x, int y)
  Set component position to given X and Y
virtual bool SetRect(int xmin, int ymin, int xmax, int ymax)
  Set component rectangle to given. Return false if not changed
bool SetRect(csRect &rect)
  Same, but with csRect argument
void SetSize(int w, int h)
  Set component size to given Width and Height
void SetSizingCursor(int dragtype)
  Set mouse cursor to one of sizing cursors depending on drag mode flags (dragtype should be any combination of CS_DRAG_XXX bits)
virtual void SetState(int mask, bool enable)
  Set/clear given component state flags
virtual void SetSuggestedSize(int dw, int dh)
  Set the size of component to minimal possible plus delta
virtual void SetText(char *iText)
  Most components have a text string field
bool SetZorder(csComponent *comp, csComponent *below)
  Change Z-order of a child component above 'below' (can be NULL for lowest Z-order) neightbour
virtual void Show(bool focused = false)
  Show the component (and activate it if focused == true)
void Sprite2D(csSprite2D *s2d, int x, int y, int w, int h)
  Draw a (scaled) 2D sprite
void Sprite2D(csSprite2D *s2d, int x, int y)
  Draw a (non-scaled) 2D sprite
virtual void SuggestSize(int &w, int &h)
  Return the recommended minimal size of component
void Text(int x, int y, int fgindx, int bgindx, char *s)
  Draw a text string: if bg < 0 background is not drawn
int TextHeight()
  Return the height of currently selected font
int TextWidth(char *text)
  Return the width of given text using currently selected font
virtual ~csComponent()
  Destroy component and remove it from parent't child list

### Public

  The following methods should be used for drawing

### Protected Fields

csRect clip
  Clipping rectangle (if not empty)
csComponent* clipparent
  Component against which this component is clipped

csRect dirty
  Rectangle that should be redrawn
static csRect dragBound
  The component bound before drag started
int DragStyle
  Window drag style (see CS_DRAG_XXX above)
static int dragX
  Used on drag operations
int Font
  Current font index
bool Maximized
  true if window is maximized, false if not (OrgBound invalid in this case)
csRect OrgBound
  Original bound when window is maximized
bool originalpalette
  false if palette points to static array, true if it is a copy
int* palette
  Component palette and palette length
int state
  Object state flags (see csState structure)
char* text
  Most components contain a text string. Unify the interface.

### Protected Methods

void Clip(csObjVector &rect, csComponent *last)
  Clip a set of rectangles so that they will contain only rectangles uncovered by other windows
void ClipAlienChildren(csObjVector &rect, csComponent *child)
  Clip a set of rectangles against 'clip children'
void DrawUnderline(int iX, int iY, char *iText, int iUnderlinePos, int iColor)
  Draw a underline under iText drawn at iX,iY with iColor
static void PrepareLabel(char *iLabel, char * &oLabel, int &oUnderlinePos)
  Prepare a label
static int WordLeft(char *iText, int StartPos)
  Utility functions: return position one word left from StartPos
static int WordRight(char *iText, int StartPos)
  Return position one word right from StartPos

### Inherited from csBase:

## Documentation

> Graphics system component: a menu, window etc.

> This is an abstract base class: all windowing system classes should be subclassed from csComponent. Each component can have a number of child components. Child components are chained together in a ring list; the only case when a NULL can be encountered in this list is when component has no children. When a component has at least one child and you traverse the child list you should take care to avoid looping forever through them.

> A csComponent object is a rectangle area of screen which can contain absolutely any content. The object is responsible for filling all pixels within that rectangle, i.e. underlying windows will never touch other window's area (and partially transparent windows like in X Windows are impossible).

`int state`
  Object state flags (see csState structure)

`csRect dirty`
  Rectangle that should be redrawn

`csRect clip`
  Clipping rectangle (if not empty)

`int* palette`
  Component palette and palette length

`bool originalpalette`
  false if palette points to static array, true if it is a copy

`int DragStyle`
  Window drag style (see CS_DRAG_XXX above)

`static int dragX`
  Used on drag operations

`static csRect dragBound`
  The component bound before drag started

`csComponent* clipparent`
  Component against which this component is clipped

`char* text`
  Most components contain a text string. Unify the interface.

`int Font`
  Current font index

`bool Maximized`
  true if window is maximized, false if not (OrgBound invalid in this case)

`csRect OrgBound`
  Original bound when window is maximized

`csComponent* focused`
  The focused child window

`csComponent* top`
  The top-Z child window

`csComponent* next`
  Next and previous neightbours

`csComponent* parent`
  Parent component or NULL

`csVector clipchildren`
  An array of 'clip children', i.e. components which are clipped against us

`csApp* app`
  Top-level application object

`unsigned int id`
  Component ID, unique within its parrent's child ring

`csRect bound`
  Component size/position rectangle

`csComponent(csComponent *iParent)`
  Create a component and insert it into parent's child list if parent != NULL

`virtual ~csComponent()`
  Destroy component and remove it from parent't child list

`virtual void Insert(csComponent *comp)`
  Insert a child component

`virtual void Delete(csComponent *comp)`
  Delete a child component

`void DeleteAll()`
  Delete all children components

`void InsertClipChild(csComponent *clipchild)`
  Insert a 'clip child'

`void DeleteClipChild(csComponent *clipchild)`
  Remove a 'clip child'

`csComponent* GetClipParent()`
  Return the 'clip parent' component

`bool SetFocused(csComponent *comp)`
  Focus a child component

`csComponent* GetFocused()`
  Get the focused child window

`bool Select()`
  Select (focus) this component and return true if successful

`virtual csComponent* NextChild(csComponent *start = NULL, bool disabled = false)`
  Return next selectable child window after 'start'

`virtual csComponent* PrevChild(csComponent *start = NULL, bool disabled = false)`
  Return previous selectable child window before 'start'

`virtual csComponent* NextControl(csComponent *start = NULL)`
  Return next control after 'start', looping through groups

`virtual csComponent* PrevControl(csComponent *start = NULL)`
  Return previous control before 'start', looping through groups

`virtual csComponent* NextGroup(csComponent *start = NULL)`
  Return control in next group after 'start'

`virtual csComponent* PrevGroup(csComponent *start = NULL)`
  Return control in previous group before 'start'

`bool SetZorder(csComponent *comp, csComponent *below)`
  Change Z-order of a child component above 'below' (can be NULL for lowest Z-order) neightbour. This also changes the order in which components are inserted into parent window, since we have only one linked list.

`csComponent* GetTop()`
  Get the top Z-order child window

`void SetPalette(int *iPalette, int iPaletteSize)`
  Set component logical palette.

  Each component has its own logical palette. A logical palette component is a index into a global table which resides in csApp object. The table in csApp maps a color (such as cs_Color_White) to a real index into the physical palette.

  It is highly desirable for components to contain in their 1st element their background color. This is sometimes used (for example by irregularily-shaped buttons).

`void SetPalette(int iPaletteID)`
  Same, but accepts the index into cswsPalette[] array

`void SetColor(int Index, int Color)`
  Set a color value in palette (makes a copy of *palette if not already)

`int GetColor(int Index)`
  Get a color from logical palette

`virtual void SetText(char *iText)`
  Most components have a text string field. For example, titlebars, buttons, input lines, static components etc etc etc. The following routines are used to access this field in a component-independent manner.

`virtual void GetText(char *oText, int iTextSize)`
  Query component text

`virtual char* GetText()`
  Same, but you cannot change returned value

`csComponent* ForEach(bool (*func) (csComponent *child, void *param), void *param = NULL, bool Zorder = false)`
  For each child component call a function with a optional arg Function returns the first child on which func returnes 'true' Function can scan from top-Z child (Zorder == true) or from focused child (Zorder == false)

`csComponent* GetChild(int find_id)`
  Find a child component by its ID

`void SetApp(csApp *newapp)`
  Set the application for this object and all its children

`virtual bool HandleEvent(csEvent &Event)`
  Handle a event and return true if processed

`virtual bool PreHandleEvent(csEvent &Event)`
  Handle a event BEFORE all others. You will receive ALL events including focused events. For example, a object will receive mouse events even if object is not visible. A object should take care not to block events expected by other objects.

`virtual bool PostHandleEvent(csEvent &Event)`
  Handle a event if nobody eaten it.

`void* SendCommand(int CommandCode, void *Info = NULL)`
  Send a command to this window and returns the Info field of csEvent object

`csComponent* GetDefault()`
  Find the 'default' child

`void Redraw()`
  Redraw the component if it has a dirty area

`virtual void Draw()`
  Draw the component (only dirty rectangle should be redrawn)

`virtual void Show(bool focused = false)`
  Show the component (and activate it if focused == true)

`virtual void Hide()`
  Hide the component

`virtual bool SetRect(int xmin, int ymin, int xmax, int ymax)`
  Set component rectangle to given. Return false if not changed

`bool SetRect(csRect &rect)`
  Same, but with csRect argument

`bool SetDragRect(int xmin, int ymin, int xmax, int ymax)`
  Calls SetRect after calling FixPosition and FixSize (used when dragging)

`void SetPos(int x, int y)`
  Set component position to given X and Y

`void SetSize(int w, int h)`
  Set component size to given Width and Height

`void Center(bool iHoriz = true, bool iVert = true)`
  Center window inside parent

`virtual bool Maximize()`
  Maximize window if it is not already and if DragStyle has CS_DRAG_SIZEABLE

`virtual bool Restore()`
  Restore window if it is maximized and if DragStyle has CS_DRAG_SIZEABLE

`void Invalidate(csRect &area, bool IncludeChildren = false)`
  Invalidate a area of component (force a redraw of this area)

`void Invalidate(int xmin, int ymin, int xmax, int ymax, bool IncludeChildren = false)`
  Same, but with coordinates instead of rectangle

`void Invalidate(bool IncludeChildren = false)`
  Same, but invalidates entire component

`virtual void SetState(int mask, bool enable)`
  Set/clear given component state flags

`int GetState(int mask)`
  Return component state flags

`void SetDragStyle(int iDragStyle)`
  Set drag style flags

`int GetDragStyle()`
  Query drag style flags

`void LocalToGlobal(int &x, int &y)`
  Convert a pair of X,Y coordinates from local to global coordinate system

`void GlobalToLocal(int &x, int &y)`
  Convert a pair of X,Y coordinates from global to local coordinate system

`void Drag(int x, int y, int DragMode)`
  Drag a window with mouse located at (x,y) window-local coordinates

`void SetMouse(csMouseCursorID Cursor)`
  Set mouse cursor pointer

`virtual void Close()`
  Destroy this component

  You should not call any methods or use any variables after this! When this function returns, the object is already destroyed

`void SetSizingCursor(int dragtype)`
  Set mouse cursor to one of sizing cursors depending on drag mode flags (dragtype should be any combination of CS_DRAG_XXX bits)

`bool HandleDragEvent(csEvent &Event, int BorderW, int BorderH)`
  Handle a mouse drag event. Check if mouse cursor is within BorderW/BorderH distance from window border; for mouse move events just sets the corresponding mouse shape (if DragMode has CS_DRAG_SIZEABLE bit set). If event is a mouse down event and mouse cursor falls within that distance from window border either resize or move window mode is entered. The function returns "true" if event has been processed, and false if it can be processed by other handlers. This function is handy to call from event handlers of all windows that can be resized and/or moved, example:

      switch (Event.Type)
      {
      case csevMouseDown:
      case csevMouseMove:
      if (HandleDragEvent (Event, BorderWidth, BorderHeight))
      return true;
      return csComponent::HandleEvent (Event);
      ...
      }

`virtual void FixPosition(int &newX, int &newY)`
  Fix new window position before assigning to component

`virtual void FixSize(int &newW, int &newH)`
  Fix new window size before assigning to component

`virtual void SuggestSize(int &w, int &h)`
  Return the recommended minimal size of component

`virtual void SetSuggestedSize(int dw, int dh)`
  Set the size of component to minimal possible plus delta

`void FindMaxFreeRect(csRect &area)`
  Find the maximal rectangle uncovered by child windows

``
  The following methods should be used for drawing. All drawing should perform all expected clipping. Some routines works somewhat kludgy for now, but its enough.

`void SetClipRect(int xmin, int ymin, int xmax, int ymax)`
  Set clipping rectangle. All following drawing will be clipped against given rectangle. Setting w=0 or h=0 will disable clipping (although it will be anyway performed relative to component bound).

`void SetClipRect()`
  Disable clipping

`int GetFont()`
  Query current text font for this component

`void SetFont(int iFont, bool IncludeChildren = false)`
  Set text font for this component and possibly its children

`void Box(int xmin, int ymin, int xmax, int ymax, int colindx)`
  Draw a box

`void Line(float x1, float y1, float x2, float y2, int colindx)`
  Draw a line

`void Pixel(int x, int y, int colindx)`
  Draw a pixel

`void Text(int x, int y, int fgindx, int bgindx, char *s)`
  Draw a text string: if bg < 0 background is not drawn

`void Sprite2D(csSprite2D *s2d, int x, int y, int w, int h)`
  Draw a (scaled) 2D sprite

`void Sprite2D(csSprite2D *s2d, int x, int y)`
  Draw a (non-scaled) 2D sprite

`int TextWidth(char *text)`
  Return the width of given text using currently selected font

`int TextHeight()`
  Return the height of currently selected font

`void Rect3D(int xmin, int ymin, int xmax, int ymax, int darkindx, int lightindx)`
  Draw a 3D-looking thin rectangle

`void ObliqueRect3D(int xmin, int ymin, int xmax, int ymax, int cornersize, int darkindx, int lightindx)`
  Draw a 3D rectangle with two oblique corners (used for buttons, for example)

`void Clip(csObjVector &rect, csComponent *last)`
  Clip a set of rectangles so that they will contain only rectangles uncovered by other windows. Initial rectangles are in local coordinates, final rectangles are in global coordinates.

`void ClipAlienChildren(csObjVector &rect, csComponent *child)`
  Clip a set of rectangles against 'clip children'

`static void PrepareLabel(char *iLabel, char * &oLabel, int &oUnderlinePos)`
  Prepare a label. Search for '~' in iLabel, and copy text without '~' into oLabel. Former underline position is stored into oUnderlinePos. This is used by labels, menuitems, static components etc.

`void DrawUnderline(int iX, int iY, char *iText, int iUnderlinePos, int iColor)`
  Draw a underline under iText drawn at iX,iY with iColor

`static int WordLeft(char *iText, int StartPos)`
  Utility functions: return position one word left from StartPos

`static int WordRight(char *iText, int StartPos)`
  Return position one word right from StartPos

Direct child classes:
  mzDraftEditor
  mzCameraView
  csWindow
  csTitleBar
  csTimer
  csStatic
  csScrollBar
  csMousePointer
  csMouse
  csMenuItem
  csMenu
  csListBoxItem
  csListBox
  csKeyboardAccelerator
  csInputLine
  csDialog
  csButton
  csApp

alphabetic index hierarchy of classes

this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de