XenevaOS
Loading...
Searching...
No Matches
Macros | Enumerations | Functions
scrollbar.cpp File Reference
#include "scrollbar.h"
#include <stdlib.h>
#include <math.h>
Include dependency graph for scrollbar.cpp:

Macros

#define ARROW_SIZE   10
 
#define MIN_THUMB_SIZE   20
 
#define SCROLLBAR_CLAMP(v, lo, hi)   ((v) < (lo) ? (lo) : (v) > (hi) ? (hi) : (v))
 
#define SCROLLBAR_MAX(a, b)   ((a) > (b) ? (a) : (b))
 
#define COLOR_TRACK   0xFF2D2D2D
 
#define COLOR_THUMB   0xFF666666
 
#define COLOR_THUMB_HOVER   0xFF888888
 
#define COLOR_THUMB_DRAG   0xFFAAAAAA
 
#define COLOR_ARROW_BG   0xFF3A3A3A
 
#define COLOR_ARROW_FG   0xFFCCCCCC
 

Enumerations

enum  {
  SB_HIT_NONE , SB_HIT_ARROW_DEC , SB_HIT_TRACK_DEC , SB_HIT_THUMB ,
  SB_HIT_TRACK_INC , SB_HIT_ARROW_INC
}
 

Functions

void ChScrollBarPaint (ChWidget *wid, ChWindow *win)
 
void ScrollBarMouseEvent (ChWidget *wid, ChWindow *win, int mx, int my, int button)
 ScrollBarMouseEvent – scroll bar mouse event.
 
ChScrollBarChCreateScrollBar (int x, int y, int width, int height, uint8_t orientation)
 ChCreateScrollBar – create a scrollbar.
 
void ChScrollBarInit (ChScrollBar *sb, int x, int y, int width, int height, uint8_t orientation)
 
void ChScrollBarSetRange (ChScrollBar *sb, int min_val, int max_val, int page_size)
 
void ChScrollBarSetValue (ChScrollBar *sb, int value)
 

Detailed Description

BSD 2-Clause License

Copyright (c) 2022-2026, Manas Kamal Choudhury All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

◆ ARROW_SIZE

#define ARROW_SIZE   10

◆ COLOR_ARROW_BG

#define COLOR_ARROW_BG   0xFF3A3A3A

◆ COLOR_ARROW_FG

#define COLOR_ARROW_FG   0xFFCCCCCC

◆ COLOR_THUMB

#define COLOR_THUMB   0xFF666666

◆ COLOR_THUMB_DRAG

#define COLOR_THUMB_DRAG   0xFFAAAAAA

◆ COLOR_THUMB_HOVER

#define COLOR_THUMB_HOVER   0xFF888888

◆ COLOR_TRACK

#define COLOR_TRACK   0xFF2D2D2D

◆ MIN_THUMB_SIZE

#define MIN_THUMB_SIZE   20

◆ SCROLLBAR_CLAMP

#define SCROLLBAR_CLAMP (   v,
  lo,
  hi 
)    ((v) < (lo) ? (lo) : (v) > (hi) ? (hi) : (v))

◆ SCROLLBAR_MAX

#define SCROLLBAR_MAX (   a,
 
)    ((a) > (b) ? (a) : (b))

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
SB_HIT_NONE 
SB_HIT_ARROW_DEC 
SB_HIT_TRACK_DEC 
SB_HIT_THUMB 
SB_HIT_TRACK_INC 
SB_HIT_ARROW_INC 

Function Documentation

◆ ChCreateScrollBar()

ChScrollBar * ChCreateScrollBar ( int  x,
int  y,
int  width,
int  height,
uint8_t  orientation 
)

ChCreateScrollBar – create a scrollbar.

Parameters
x– x location within the window
y– y location within the window
width– width of the viewport
height– height of the viewport
orientation– scrollbar type, either VERTICAL or HORIZONTAL

Re calculate the thumb

◆ ChScrollBarInit()

void ChScrollBarInit ( ChScrollBar sb,
int  x,
int  y,
int  width,
int  height,
uint8_t  orientation 
)

Re calculate the thumb

◆ ChScrollBarPaint()

void ChScrollBarPaint ( ChWidget wid,
ChWindow win 
)

◆ ChScrollBarSetRange()

void ChScrollBarSetRange ( ChScrollBar sb,
int  min_val,
int  max_val,
int  page_size 
)

◆ ChScrollBarSetValue()

void ChScrollBarSetValue ( ChScrollBar sb,
int  value 
)

◆ ScrollBarMouseEvent()

void ScrollBarMouseEvent ( ChWidget wid,
ChWindow win,
int  mx,
int  my,
int  button 
)

ScrollBarMouseEvent – scroll bar mouse event.