// Ryzom - MMORPG Framework
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
#ifndef NL_VIEW_BITMAP_COMBO_H
#define NL_VIEW_BITMAP_COMBO_H
#include "../cdb.h"
#include "view_base.h"
#include "nel/3d/u_texture.h"
#include
#include
/** Description of a combo box, this can be parsed from an xml node
* The bitmap layout is as follow :
*
* I W I W I W
* t G t G t G
* e a e a e a
* m p m p m p
* W S W W
* i e i i
* d l d d
* t e t t
* h c h h
* t
* e
* d
* +----+---+----+---+---+---+---+--...
* |ssss| |****| |***| |***|
* ItemHeight |ssss| |****| |***| |***
* +----+---+----+---+---+---+---+--...
* | | | | | | | |
* HGapSeleted | | | | | | | |
* +----+---+----+---+---+---+---+--...
* |****| |****| |***| |***|
* ItemHeight |****| |****| |***| |***|
* +----+---+----+---+---+---+---+--...
* | | | | | | | |
* HGap | | | | | | | |
* +----+---+----+---+---+---+---+--...
* |****| |****| |***| |***|
* ItemHeight |****| |****| |***| |***|
* . . . . . . . .
* . . . . . . . .
* s : selected item. . . . . . .
* * : where bitmap are displayed
*/
struct CComboBoxDesc
{
bool parse(xmlNodePtr cur, CInterfaceElement *owner);
void addObserver(ICDBNode::IPropertyObserver *obs);
void getGridSize(uint &numRow,uint &numCol) const;
void getDimensions(uint &width, uint &height) const;
CInterfaceProperty NumRow;
CInterfaceProperty NumCol;
CInterfaceProperty CurrSelected;
CInterfaceProperty ItemWidth;
CInterfaceProperty ItemHeight;
CInterfaceProperty Unrolled;
CInterfaceProperty WGapSelected;
CInterfaceProperty WGap;
CInterfaceProperty HGapSelected;
CInterfaceProperty HGap;
CInterfaceProperty NumSel;
CInterfaceProperty Align;
};
/**
* A combo box with several bitmaps in it
* \author Nicolas Vizerie
* \author Nevrax France
* \date 2002
*/
class CViewBitmapCombo : public CViewBase, public ICDBNode::IPropertyObserver
{
public:
typedef std::vector TIdArray;
typedef std::vector TStringArray;
typedef std::vector TColorArray;
public:
/// ctor
CViewBitmapCombo(const TCtorParam ¶m);
/**
* parse an xml node and initialize the base view members. Must call CViewBase::parse
* \param cur : pointer to the xml node to be parsed
* \param parentGroup : the parent group of the view
* \partam id : a refence to the string that will receive the view ID
* \return true if success
*/
bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup);
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
/**
* draw the view
*/
void draw();
// access to texture & colors
const TStringArray &getTexs() const { return _Texs; }
const TStringArray &getTexsOver() const { return _TexsOver; }
const TStringArray &getTexsPushed() const { return _TexsPushed; }
//
const TColorArray &getColors() const { return _Col; }
const TColorArray &getColorsOver() const { return _ColOver; }
const TColorArray &getColorsPushed() const { return _ColPushed; }
//
void setTexs(const char * const tex[], uint numTex);
void setTexsOver(const char * const tex[], uint numTex);
void setTexsPushed(const char * const tex[], uint numTex);
//
void setColors(const NLMISC::CRGBA colors[], uint numColors);
void setColorsOver(const NLMISC::CRGBA colors[], uint numColors);
void setColorsPushed(const NLMISC::CRGBA colors[], uint numColors);
///////////////////////////////////////////////////////////////////////////////////
private:
//
TStringArray _Texs;
TStringArray _TexsOver;
TStringArray _TexsPushed;
TIdArray _TexsId;
TIdArray _TexsOverId;
TIdArray _TexsPushedId;
TColorArray _Col;
TColorArray _ColOver;
TColorArray _ColPushed;
CComboBoxDesc _CD;
CInterfaceElement *_Owner;
private:
void parseTexList(const std::string &names, TStringArray &dest);
void parseColList(const std::string &names, TColorArray &dest);
void setupSize();
void getDimensions(uint &numRow, uint &numCol);
// From ICDBNode::IPropertyObserver
void update(ICDBNode *leaf);
// Return a color from the array, or white if it is empty
static NLMISC::CRGBA getCol(const TColorArray &array, uint index);
static const std::string *getTex(const TStringArray &array, uint index);
static sint32 getTexId(const TIdArray &array, uint index);
};
#endif