Audacity  2.2.2
Public Member Functions | Public Attributes | Private Attributes | List of all members
FlowPacker Class Reference

Packs rectangular boxes into a rectangle, using simple first fit. More...

#include <Theme.h>

Public Member Functions

 FlowPacker ()
 
 ~FlowPacker ()
 
void Init (int width)
 
void GetNextPosition (int xSize, int ySize)
 
void SetNewGroup (int iGroupSize)
 
void SetColourGroup ()
 
wxRect Rect ()
 
wxRect RectInner ()
 
void RectMid (int &x, int &y)
 

Public Attributes

int mFlags
 
int mxPos
 
int myPos
 
int myHeight
 
int mBorderWidth
 

Private Attributes

int iImageGroupSize
 
int iImageGroupIndex
 
int mOldFlags
 
int myPosBase
 
int mxWidth
 
int mxCacheWidth
 
int mComponentWidth
 
int mComponentHeight
 

Detailed Description

Packs rectangular boxes into a rectangle, using simple first fit.

This class is currently used by Theme to pack its images into the image cache. Perhaps someday we will improve FlowPacker and make it more flexible, and use it for toolbar and window layouts too.

Definition at line 60 of file Theme.h.

Constructor & Destructor Documentation

FlowPacker::FlowPacker ( )
inline

Definition at line 63 of file Theme.h.

63 {;};
FlowPacker::~FlowPacker ( )
inline

Definition at line 64 of file Theme.h.

64 {;};

Member Function Documentation

void FlowPacker::GetNextPosition ( int  xSize,
int  ySize 
)

Definition at line 538 of file Theme.cpp.

References resFlagPaired, and resFlagSkip.

Referenced by ThemeBase::CreateImageCache(), ThemeBase::ReadImageCache(), and ThemeBase::WriteImageMap().

539 {
540  xSize += 2*mBorderWidth;
541  ySize += 2*mBorderWidth;
542  // if the height has increased, then we are on a NEW group.
543  if(( ySize > myHeight )||(((mFlags ^ mOldFlags )& ~resFlagSkip)!=0))
544  {
545  SetNewGroup( ((mFlags & resFlagPaired)!=0) ? 2 : 1 );
546  myHeight = ySize;
547 // mFlags &= ~resFlagNewLine;
548 // mOldFlags = mFlags;
549  }
550 
553  {
554  iImageGroupIndex = 0;
556  }
557 
558  if(mxPos > (mxCacheWidth - xSize ))
559  {
562  myHeight = ySize;
563  }
565 
566  mComponentWidth = xSize;
567  mComponentHeight = ySize;
568 }
int myPosBase
Definition: Theme.h:84
int iImageGroupIndex
Definition: Theme.h:82
int mComponentWidth
Definition: Theme.h:88
int mxPos
Definition: Theme.h:75
int myPos
Definition: Theme.h:76
int mBorderWidth
Definition: Theme.h:78
int mFlags
Definition: Theme.h:74
void SetNewGroup(int iGroupSize)
Definition: Theme.cpp:517
int mOldFlags
Definition: Theme.h:83
int iImageGroupSize
Definition: Theme.h:81
int mxCacheWidth
Definition: Theme.h:86
int mComponentHeight
Definition: Theme.h:89
int myHeight
Definition: Theme.h:77
void FlowPacker::Init ( int  width)

Definition at line 503 of file Theme.cpp.

References resFlagPaired.

Referenced by ThemeBase::CreateImageCache(), ThemeBase::ReadImageCache(), and ThemeBase::WriteImageMap().

504 {
506  mOldFlags = mFlags;
507  mxCacheWidth = width;
508 
509  myPos = 0;
510  myPosBase =0;
511  myHeight = 0;
512  iImageGroupSize = 1;
513  SetNewGroup(1);
514  mBorderWidth = 0;
515 }
int myPosBase
Definition: Theme.h:84
int myPos
Definition: Theme.h:76
int mBorderWidth
Definition: Theme.h:78
int mFlags
Definition: Theme.h:74
void SetNewGroup(int iGroupSize)
Definition: Theme.cpp:517
int mOldFlags
Definition: Theme.h:83
int iImageGroupSize
Definition: Theme.h:81
int mxCacheWidth
Definition: Theme.h:86
int myHeight
Definition: Theme.h:77
wxRect FlowPacker::Rect ( )

Definition at line 570 of file Theme.cpp.

Referenced by ThemeBase::CreateImageCache().

571 {
572  return wxRect( mxPos, myPos, mComponentWidth, mComponentHeight);
573 }
int mComponentWidth
Definition: Theme.h:88
int mxPos
Definition: Theme.h:75
int myPos
Definition: Theme.h:76
int mComponentHeight
Definition: Theme.h:89
wxRect FlowPacker::RectInner ( )

Definition at line 575 of file Theme.cpp.

Referenced by ThemeBase::CreateImageCache(), ThemeBase::ReadImageCache(), and ThemeBase::WriteImageMap().

576 {
577  return Rect().Deflate( mBorderWidth, mBorderWidth );
578 }
wxRect Rect()
Definition: Theme.cpp:570
int mBorderWidth
Definition: Theme.h:78
void FlowPacker::RectMid ( int &  x,
int &  y 
)

Definition at line 580 of file Theme.cpp.

Referenced by ThemeBase::ReadImageCache().

581 {
582  x = mxPos + mComponentWidth/2;
583  y = myPos + mComponentHeight/2;
584 }
int mComponentWidth
Definition: Theme.h:88
int mxPos
Definition: Theme.h:75
int myPos
Definition: Theme.h:76
int mComponentHeight
Definition: Theme.h:89
void FlowPacker::SetColourGroup ( )

Definition at line 527 of file Theme.cpp.

Referenced by ThemeBase::CreateImageCache(), ThemeBase::ReadImageCache(), and ThemeBase::WriteImageMap().

528 {
529  myPosBase = 750;
530  mxPos =0;
531  mOldFlags = mFlags;
532  iImageGroupSize = 1;
533  iImageGroupIndex = -1;
534  mComponentWidth=0;
535  myHeight = 11;
536 }
int myPosBase
Definition: Theme.h:84
int iImageGroupIndex
Definition: Theme.h:82
int mComponentWidth
Definition: Theme.h:88
int mxPos
Definition: Theme.h:75
int mFlags
Definition: Theme.h:74
int mOldFlags
Definition: Theme.h:83
int iImageGroupSize
Definition: Theme.h:81
int myHeight
Definition: Theme.h:77
void FlowPacker::SetNewGroup ( int  iGroupSize)

Definition at line 517 of file Theme.cpp.

518 {
520  mxPos =0;
521  mOldFlags = mFlags;
522  iImageGroupSize = iGroupSize;
523  iImageGroupIndex = -1;
524  mComponentWidth=0;
525 }
int myPosBase
Definition: Theme.h:84
int iImageGroupIndex
Definition: Theme.h:82
int mComponentWidth
Definition: Theme.h:88
int mxPos
Definition: Theme.h:75
int mFlags
Definition: Theme.h:74
int mOldFlags
Definition: Theme.h:83
int iImageGroupSize
Definition: Theme.h:81
int myHeight
Definition: Theme.h:77

Member Data Documentation

int FlowPacker::iImageGroupIndex
private

Definition at line 82 of file Theme.h.

int FlowPacker::iImageGroupSize
private

Definition at line 81 of file Theme.h.

int FlowPacker::mBorderWidth
int FlowPacker::mComponentHeight
private

Definition at line 89 of file Theme.h.

int FlowPacker::mComponentWidth
private

Definition at line 88 of file Theme.h.

int FlowPacker::mFlags
int FlowPacker::mOldFlags
private

Definition at line 83 of file Theme.h.

int FlowPacker::mxCacheWidth
private

Definition at line 86 of file Theme.h.

int FlowPacker::mxPos

Definition at line 75 of file Theme.h.

Referenced by ThemeBase::CreateImageCache().

int FlowPacker::mxWidth
private

Definition at line 85 of file Theme.h.

int FlowPacker::myHeight

Definition at line 77 of file Theme.h.

int FlowPacker::myPos

Definition at line 76 of file Theme.h.

Referenced by ThemeBase::CreateImageCache().

int FlowPacker::myPosBase
private

Definition at line 84 of file Theme.h.


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