aboutsummaryrefslogtreecommitdiff
path: root/guilib
diff options
context:
space:
mode:
authortheuni <theuni-nospam-@xbmc.org>2011-01-24 16:05:21 -0500
committertheuni <theuni-nospam-@xbmc.org>2011-01-24 16:05:21 -0500
commitc51b1189e3d5353e842991f5859ddcea0f73e426 (patch)
treeef2cb8a6184699aa614f3655dca4ce661cdc108e /guilib
parentbe61ebdc9e897fe40c6f371111724de79ddee8d5 (diff)
Merged cptspiff's code-reshuffle branch.
Squashed commit due to build breakage during code-reshuffle history. Conflicts: xbmc/Util.cpp xbmc/cdrip/CDDARipper.cpp xbmc/filesystem/Directory.cpp xbmc/filesystem/File.cpp
Diffstat (limited to 'guilib')
-rw-r--r--guilib/AnimatedGif.cpp651
-rw-r--r--guilib/AnimatedGif.h159
-rw-r--r--guilib/AudioContext.cpp273
-rw-r--r--guilib/AudioContext.h76
-rw-r--r--guilib/D3DResource.cpp456
-rw-r--r--guilib/D3DResource.h138
-rw-r--r--guilib/DDSImage.cpp266
-rw-r--r--guilib/DDSImage.h149
-rw-r--r--guilib/DirectXGraphics.cpp380
-rw-r--r--guilib/DirectXGraphics.h171
-rw-r--r--guilib/FrameBufferObject.cpp144
-rw-r--r--guilib/FrameBufferObject.h116
-rw-r--r--guilib/GUIActionDescriptor.h59
-rw-r--r--guilib/GUIAudioManager.cpp447
-rw-r--r--guilib/GUIAudioManager.h87
-rw-r--r--guilib/GUIBaseContainer.cpp1106
-rw-r--r--guilib/GUIBaseContainer.h189
-rw-r--r--guilib/GUIBorderedImage.cpp73
-rw-r--r--guilib/GUIBorderedImage.h47
-rw-r--r--guilib/GUIButtonControl.cpp318
-rw-r--r--guilib/GUIButtonControl.h105
-rw-r--r--guilib/GUIButtonScroller.cpp919
-rw-r--r--guilib/GUIButtonScroller.h129
-rw-r--r--guilib/GUICallback.h193
-rw-r--r--guilib/GUICheckMarkControl.cpp185
-rw-r--r--guilib/GUICheckMarkControl.h76
-rw-r--r--guilib/GUIColorManager.cpp120
-rw-r--r--guilib/GUIColorManager.h70
-rw-r--r--guilib/GUIControl.cpp895
-rw-r--r--guilib/GUIControl.h341
-rw-r--r--guilib/GUIControlFactory.cpp1356
-rw-r--r--guilib/GUIControlFactory.h112
-rw-r--r--guilib/GUIControlGroup.cpp649
-rw-r--r--guilib/GUIControlGroup.h122
-rw-r--r--guilib/GUIControlGroupList.cpp450
-rw-r--r--guilib/GUIControlGroupList.h77
-rw-r--r--guilib/GUIControlProfiler.cpp358
-rw-r--r--guilib/GUIControlProfiler.h102
-rw-r--r--guilib/GUIDialog.cpp284
-rw-r--r--guilib/GUIDialog.h78
-rw-r--r--guilib/GUIEditControl.cpp555
-rw-r--r--guilib/GUIEditControl.h119
-rw-r--r--guilib/GUIFadeLabelControl.cpp247
-rw-r--r--guilib/GUIFadeLabelControl.h85
-rw-r--r--guilib/GUIFixedListContainer.cpp316
-rw-r--r--guilib/GUIFixedListContainer.h73
-rw-r--r--guilib/GUIFont.cpp292
-rw-r--r--guilib/GUIFont.h168
-rw-r--r--guilib/GUIFontManager.cpp553
-rw-r--r--guilib/GUIFontManager.h102
-rw-r--r--guilib/GUIFontTTF.cpp834
-rw-r--r--guilib/GUIFontTTF.h174
-rw-r--r--guilib/GUIFontTTFDX.cpp286
-rw-r--r--guilib/GUIFontTTFDX.h57
-rw-r--r--guilib/GUIFontTTFGL.cpp242
-rw-r--r--guilib/GUIFontTTFGL.h56
-rw-r--r--guilib/GUIImage.cpp351
-rw-r--r--guilib/GUIImage.h119
-rw-r--r--guilib/GUIIncludes.cpp271
-rw-r--r--guilib/GUIIncludes.h62
-rw-r--r--guilib/GUIInfoTypes.cpp316
-rw-r--r--guilib/GUIInfoTypes.h115
-rw-r--r--guilib/GUILabel.cpp190
-rw-r--r--guilib/GUILabel.h219
-rw-r--r--guilib/GUILabelControl.cpp216
-rw-r--r--guilib/GUILabelControl.h85
-rw-r--r--guilib/GUIListContainer.cpp319
-rw-r--r--guilib/GUIListContainer.h64
-rw-r--r--guilib/GUIListGroup.cpp189
-rw-r--r--guilib/GUIListGroup.h60
-rw-r--r--guilib/GUIListItem.cpp411
-rw-r--r--guilib/GUIListItem.h153
-rw-r--r--guilib/GUIListItemLayout.cpp204
-rw-r--r--guilib/GUIListItemLayout.h73
-rw-r--r--guilib/GUIListLabel.cpp95
-rw-r--r--guilib/GUIListLabel.h65
-rw-r--r--guilib/GUIMessage.cpp185
-rw-r--r--guilib/GUIMessage.h314
-rw-r--r--guilib/GUIMoverControl.cpp256
-rw-r--r--guilib/GUIMoverControl.h97
-rw-r--r--guilib/GUIMultiImage.cpp254
-rw-r--r--guilib/GUIMultiImage.h80
-rw-r--r--guilib/GUIMultiSelectText.cpp436
-rw-r--r--guilib/GUIMultiSelectText.h101
-rw-r--r--guilib/GUIPanelContainer.cpp492
-rw-r--r--guilib/GUIPanelContainer.h70
-rw-r--r--guilib/GUIProgressControl.cpp256
-rw-r--r--guilib/GUIProgressControl.h76
-rw-r--r--guilib/GUIRSSControl.cpp146
-rw-r--r--guilib/GUIRSSControl.h89
-rw-r--r--guilib/GUIRadioButtonControl.cpp159
-rw-r--r--guilib/GUIRadioButtonControl.h69
-rw-r--r--guilib/GUIRenderingControl.cpp113
-rw-r--r--guilib/GUIRenderingControl.h43
-rw-r--r--guilib/GUIResizeControl.cpp237
-rw-r--r--guilib/GUIResizeControl.h85
-rw-r--r--guilib/GUIScrollBarControl.cpp325
-rw-r--r--guilib/GUIScrollBarControl.h85
-rw-r--r--guilib/GUISelectButtonControl.cpp411
-rw-r--r--guilib/GUISelectButtonControl.h134
-rw-r--r--guilib/GUISettingsSliderControl.cpp123
-rw-r--r--guilib/GUISettingsSliderControl.h77
-rw-r--r--guilib/GUIShader.cpp83
-rw-r--r--guilib/GUIShader.h58
-rw-r--r--guilib/GUISliderControl.cpp376
-rw-r--r--guilib/GUISliderControl.h103
-rw-r--r--guilib/GUISound.cpp280
-rw-r--r--guilib/GUISound.h56
-rw-r--r--guilib/GUISpinControl.cpp930
-rw-r--r--guilib/GUISpinControl.h132
-rw-r--r--guilib/GUISpinControlEx.cpp156
-rw-r--r--guilib/GUISpinControlEx.h73
-rw-r--r--guilib/GUIStandardWindow.cpp50
-rw-r--r--guilib/GUIStandardWindow.h39
-rw-r--r--guilib/GUIStaticItem.cpp118
-rw-r--r--guilib/GUIStaticItem.h75
-rw-r--r--guilib/GUITextBox.cpp361
-rw-r--r--guilib/GUITextBox.h98
-rw-r--r--guilib/GUITextLayout.cpp628
-rw-r--r--guilib/GUITextLayout.h144
-rw-r--r--guilib/GUITexture.cpp626
-rw-r--r--guilib/GUITexture.h185
-rw-r--r--guilib/GUITextureD3D.cpp232
-rw-r--r--guilib/GUITextureD3D.h51
-rw-r--r--guilib/GUITextureGL.cpp191
-rw-r--r--guilib/GUITextureGL.h47
-rw-r--r--guilib/GUITextureGLES.cpp272
-rw-r--r--guilib/GUITextureGLES.h50
-rw-r--r--guilib/GUIToggleButtonControl.cpp152
-rw-r--r--guilib/GUIToggleButtonControl.h66
-rw-r--r--guilib/GUIVideoControl.cpp97
-rw-r--r--guilib/GUIVideoControl.h51
-rw-r--r--guilib/GUIVisualisationControl.cpp126
-rw-r--r--guilib/GUIVisualisationControl.h37
-rw-r--r--guilib/GUIWindow.cpp950
-rw-r--r--guilib/GUIWindow.h295
-rw-r--r--guilib/GUIWindowManager.cpp924
-rw-r--r--guilib/GUIWindowManager.h159
-rw-r--r--guilib/GUIWrappingListContainer.cpp251
-rw-r--r--guilib/GUIWrappingListContainer.h62
-rw-r--r--guilib/Geometry.h149
-rw-r--r--guilib/GraphicContext.cpp775
-rw-r--r--guilib/GraphicContext.h222
-rw-r--r--guilib/IAudioDeviceChangedCallback.h31
-rw-r--r--guilib/IMsgTargetCallback.h45
-rw-r--r--guilib/IWindowManagerCallback.cpp29
-rw-r--r--guilib/IWindowManagerCallback.h42
-rw-r--r--guilib/Key.cpp259
-rw-r--r--guilib/Key.h565
-rw-r--r--guilib/LocalizeStrings.cpp221
-rw-r--r--guilib/LocalizeStrings.h72
-rw-r--r--guilib/Makefile.in97
-rw-r--r--guilib/MatrixGLES.cpp304
-rw-r--r--guilib/MatrixGLES.h69
-rw-r--r--guilib/Resolution.h110
-rw-r--r--guilib/Shader.cpp516
-rw-r--r--guilib/Shader.h264
-rw-r--r--guilib/StdString.h4336
-rw-r--r--guilib/Texture.cpp315
-rw-r--r--guilib/Texture.h123
-rw-r--r--guilib/TextureBundle.cpp130
-rw-r--r--guilib/TextureBundle.h53
-rw-r--r--guilib/TextureBundleXBT.cpp269
-rw-r--r--guilib/TextureBundleXBT.h58
-rw-r--r--guilib/TextureBundleXPR.cpp507
-rw-r--r--guilib/TextureBundleXPR.h69
-rw-r--r--guilib/TextureDX.cpp129
-rw-r--r--guilib/TextureDX.h52
-rw-r--r--guilib/TextureGL.cpp146
-rw-r--r--guilib/TextureGL.h52
-rw-r--r--guilib/TextureManager.cpp581
-rw-r--r--guilib/TextureManager.h141
-rw-r--r--guilib/TransformMatrix.h240
-rw-r--r--guilib/Tween.h408
-rw-r--r--guilib/VisibleEffect.cpp702
-rw-r--r--guilib/VisibleEffect.h204
-rw-r--r--guilib/XBTF.cpp199
-rw-r--r--guilib/XBTF.h100
-rw-r--r--guilib/XBTFReader.cpp210
-rw-r--r--guilib/XBTFReader.h50
-rw-r--r--guilib/XMLUtils.cpp274
-rw-r--r--guilib/XMLUtils.h56
-rw-r--r--guilib/common/IRServerSuite/IRServerSuite.cpp480
-rw-r--r--guilib/common/IRServerSuite/IRServerSuite.h67
-rw-r--r--guilib/common/IRServerSuite/IrssMessage.cpp146
-rw-r--r--guilib/common/IRServerSuite/IrssMessage.h209
-rw-r--r--guilib/common/LIRC.cpp344
-rw-r--r--guilib/common/LIRC.h71
-rw-r--r--guilib/common/Makefile.in14
-rw-r--r--guilib/common/SDLJoystick.cpp412
-rw-r--r--guilib/common/SDLJoystick.h91
-rw-r--r--guilib/gui3d.h105
-rw-r--r--guilib/guilib_win32.vcproj772
-rw-r--r--guilib/system.h262
-rw-r--r--guilib/tinyXML/Makefile6
-rw-r--r--guilib/tinyXML/tinystr.cpp116
-rw-r--r--guilib/tinyXML/tinystr.h319
-rw-r--r--guilib/tinyXML/tinyxml.cpp2043
-rw-r--r--guilib/tinyXML/tinyxml.h1834
-rw-r--r--guilib/tinyXML/tinyxmlerror.cpp53
-rw-r--r--guilib/tinyXML/tinyxmlparser.cpp1683
201 files changed, 0 insertions, 55160 deletions
diff --git a/guilib/AnimatedGif.cpp b/guilib/AnimatedGif.cpp
deleted file mode 100644
index b8702ce39c..0000000000
--- a/guilib/AnimatedGif.cpp
+++ /dev/null
@@ -1,651 +0,0 @@
-
-// ****************************************************************************
-//
-// WINIMAGE.CPP : Generic classes for raster images (MSWindows specialization)
-//
-// Content: Member definitions for:
-// - class CAnimatedGif : Storage class for single images
-// - class CAnimatedGifSet : Storage class for sets of images
-//
-// (Includes routines to Load and Save BMP files and to load GIF files into
-// these classes).
-//
-// --------------------------------------------------------------------------
-//
-// Copyright (c) 2000, Juan Soulie <jsoulie@cplusplus.com>
-//
-// Permission to use, copy, modify, distribute and sell this software or any
-// part thereof and/or its documentation for any purpose is granted without fee
-// provided that the above copyright notice and this permission notice appear
-// in all copies.
-//
-// This software is provided "as is" without express or implied warranty of
-// any kind. The author shall have no liability with respect to the
-// infringement of copyrights or patents that any modification to the content
-// of this file or this file itself may incur.
-//
-// ****************************************************************************
-
-#include "AnimatedGif.h"
-#include "FileSystem/SpecialProtocol.h"
-#include "utils/EndianSwap.h"
-
-#ifdef _WIN32
-extern "C" FILE *fopen_utf8(const char *_Filename, const char *_Mode);
-#else
-#define fopen_utf8 fopen
-#endif
-
-#pragma pack(1)
-// Error processing macro (NO-OP by default):
-#define ERRORMSG(PARAM) {}
-
-#ifndef BI_RGB
- #define BI_RGB 0L
- #define BI_RLE8 1L
- #define BI_RLE4 2L
- #define BI_BITFIELDS 3L
-#endif
-
-#undef ALIGN
-#define ALIGN sizeof(int) ///< Windows GDI expects all int-aligned
-
-// Macros to swap data endianness
-#define SWAP16(X) X=Endian_SwapLE16(X)
-#define SWAP32(X) X=Endian_SwapLE32(X)
-
-// pre-declaration:
-int LZWDecoder (char*, char*, short, int, int, int, const int);
-
-// ****************************************************************************
-// * CAnimatedGif Member definitions *
-// ****************************************************************************
-
-CAnimatedGif::CAnimatedGif()
-{
- Height = Width = 0;
- Raster = NULL;
- Palette = NULL;
- pbmi = NULL;
- BPP = Transparent = BytesPerRow = 0;
- xPos = yPos = Delay = Transparency = 0;
- nLoops = 1; //default=play animation 1 time
-}
-
-CAnimatedGif::~CAnimatedGif()
-{
- delete [] pbmi;
- delete [] Raster;
- delete [] Palette;
-}
-
-// Init: Allocates space for raster and palette in GDI-compatible structures.
-void CAnimatedGif::Init(int iWidth, int iHeight, int iBPP, int iLoops)
-{
- delete[] Raster;
- Raster = NULL;
-
- delete[] pbmi;
- pbmi = NULL;
-
- delete[] Palette;
- Palette = NULL;
-
- // Standard members setup
- Transparent = -1;
- BytesPerRow = Width = iWidth;
- Height = iHeight;
- BPP = iBPP;
- // Animation Extra members setup:
- xPos = yPos = Delay = Transparency = 0;
- nLoops = iLoops;
-
- if (BPP == 24)
- {
- BytesPerRow *= 3;
- pbmi = (GUIBITMAPINFO*)new char [sizeof(GUIBITMAPINFO)];
- }
- else
- {
- pbmi = (GUIBITMAPINFO*)new char[sizeof(GUIBITMAPINFOHEADER)];
- Palette = new COLOR[256];
- }
-
- BytesPerRow += (ALIGN - Width % ALIGN) % ALIGN; // Align BytesPerRow
- int size = BytesPerRow * Height;
-
- Raster = new char [size];
-
- pbmi->bmiHeader.biSize = sizeof (GUIBITMAPINFOHEADER);
- pbmi->bmiHeader.biWidth = Width;
- pbmi->bmiHeader.biHeight = -Height; // negative means up-to-bottom
- pbmi->bmiHeader.biPlanes = 1;
- pbmi->bmiHeader.biBitCount = (BPP < 8 ? 8 : BPP); // Our raster is byte-aligned
- pbmi->bmiHeader.biCompression = BI_RGB;
- pbmi->bmiHeader.biSizeImage = 0;
- pbmi->bmiHeader.biXPelsPerMeter = 11811;
- pbmi->bmiHeader.biYPelsPerMeter = 11811;
- pbmi->bmiHeader.biClrUsed = 0;
- pbmi->bmiHeader.biClrImportant = 0;
-}
-
-// operator=: copies an object's content to another
-CAnimatedGif& CAnimatedGif::operator = (CAnimatedGif& rhs)
-{
- Init(rhs.Width, rhs.Height, rhs.BPP); // respects virtualization
- memcpy(Raster, rhs.Raster, BytesPerRow*Height);
- memcpy(Palette, rhs.Palette, 256*sizeof(COLOR));
- return *this;
-}
-
-
-
-CAnimatedGifSet::CAnimatedGifSet()
-{
- FrameHeight = FrameWidth = 0;
- nLoops = 1; //default=play animation 1 time
-}
-
-CAnimatedGifSet::~CAnimatedGifSet()
-{
- Release();
-}
-
-void CAnimatedGifSet::Release()
-{
- FrameWidth = 0;
- FrameHeight = 0;
- for (int i = 0; i < (int)m_vecimg.size(); ++i)
- {
- CAnimatedGif* pImage = m_vecimg[i];
- delete pImage;
- }
- m_vecimg.erase(m_vecimg.begin(), m_vecimg.end());
-
-}
-
-// ****************************************************************************
-// * CAnimatedGifSet Member definitions *
-// ****************************************************************************
-
-// AddImage: Adds an image object to the back of the img vector.
-void CAnimatedGifSet::AddImage (CAnimatedGif* newimage)
-{
- m_vecimg.push_back(newimage);
-}
-
-int CAnimatedGifSet::GetImageCount() const
-{
- return m_vecimg.size();
-}
-
-unsigned char CAnimatedGifSet::getbyte(FILE *fd)
-{
- unsigned char uchar;
- if (fread(&uchar, 1, 1, fd) == 1)
- return uchar;
- else
- return 0;
-}
-
-// ****************************************************************************
-// * LoadGIF *
-// * Load a GIF File into the CAnimatedGifSet object *
-// * (c) Nov 2000, Juan Soulie <jsoulie@cplusplus.com> *
-// ****************************************************************************
-int CAnimatedGifSet::LoadGIF (const char * szFileName)
-{
- int n;
- // Global GIF variables:
- int GlobalBPP; // Bits per Pixel.
- COLOR * GlobalColorMap; // Global colormap (allocate)
-
- struct GIFGCEtag
- { // GRAPHIC CONTROL EXTENSION
- unsigned char BlockSize; // Block Size: 4 bytes
- unsigned char PackedFields; // 3.. Packed Fields. Bits detail:
- // 0: Transparent Color Flag
- // 1: User Input Flag
- // 2-4: Disposal Method
- unsigned short Delay; // 4..5 Delay Time (1/100 seconds)
- unsigned char Transparent; // 6.. Transparent Color Index
- }
- gifgce;
-
- struct GIFNetscapeTag
- {
- unsigned char comment[11]; //4...14 NETSCAPE2.0
- unsigned char SubBlockLength; //15 0x3
- unsigned char reserved; //16 0x1
- unsigned short iIterations ; //17..18 number of iterations (lo-hi)
- }
- gifnetscape;
-
- int GraphicExtensionFound = 0;
-
- // OPEN FILE
- FILE *fd = fopen_utf8(_P(szFileName), "rb");
- if (!fd)
- {
- return 0;
- }
-
- // *1* READ HEADERBLOCK (6bytes) (SIGNATURE + VERSION)
- char szSignature[6]; // First 6 bytes (GIF87a or GIF89a)
- int iRead = fread(szSignature, 1, 6, fd);
- if (iRead != 6)
- {
- fclose(fd);
- return 0;
- }
- if ( memcmp(szSignature, "GIF", 2) != 0)
- {
- fclose(fd);
- return 0;
- }
- // *2* READ LOGICAL SCREEN DESCRIPTOR
- struct GIFLSDtag
- {
- unsigned short ScreenWidth; // Logical Screen Width
- unsigned short ScreenHeight; // Logical Screen Height
- unsigned char PackedFields; // Packed Fields. Bits detail:
- // 0-2: Size of Global Color Table
- // 3: Sort Flag
- // 4-6: Color Resolution
- // 7: Global Color Table Flag
- unsigned char Background; // Background Color Index
- unsigned char PixelAspectRatio; // Pixel Aspect Ratio
- }
- giflsd;
-
- iRead = fread(&giflsd, 1, sizeof(giflsd), fd);
- if (iRead != sizeof(giflsd))
- {
- fclose(fd);
- return 0;
- }
- // endian swap
- SWAP16(giflsd.ScreenWidth);
- SWAP16(giflsd.ScreenHeight);
-
- GlobalBPP = (giflsd.PackedFields & 0x07) + 1;
-
- // fill some animation data:
- FrameWidth = giflsd.ScreenWidth;
- FrameHeight = giflsd.ScreenHeight;
- nLoops = 1; //default=play animation 1 time
-
- // *3* READ/GENERATE GLOBAL COLOR MAP
- GlobalColorMap = new COLOR [1 << GlobalBPP];
- if (giflsd.PackedFields & 0x80) // File has global color map?
- for (n = 0;n < 1 << GlobalBPP;n++)
- {
- GlobalColorMap[n].r = getbyte(fd);
- GlobalColorMap[n].g = getbyte(fd);
- GlobalColorMap[n].b = getbyte(fd);
- }
-
- else // GIF standard says to provide an internal default Palette:
- for (n = 0;n < 256;n++)
- GlobalColorMap[n].r = GlobalColorMap[n].g = GlobalColorMap[n].b = n;
-
- // *4* NOW WE HAVE 3 POSSIBILITIES:
- // 4a) Get and Extension Block (Blocks with additional information)
- // 4b) Get an Image Separator (Introductor to an image)
- // 4c) Get the trailer Char (End of GIF File)
- do
- {
- int charGot = getbyte(fd);
-
- if (charGot == 0x21) // *A* EXTENSION BLOCK
- {
- unsigned char extensionType = getbyte(fd);
- switch (extensionType)
- {
- case 0xF9: // Graphic Control Extension
- {
- if (fread((char*)&gifgce, 1, sizeof(gifgce), fd) == sizeof(gifgce))
- SWAP16(gifgce.Delay);
- GraphicExtensionFound++;
- getbyte(fd); // Block Terminator (always 0)
- }
- break;
-
- case 0xFE: // Comment Extension: Ignored
- {
- while (int nBlockLength = getbyte(fd))
- for (n = 0;n < nBlockLength;n++) getbyte(fd);
- }
- break;
-
- case 0x01: // PlainText Extension: Ignored
- {
- while (int nBlockLength = getbyte(fd))
- for (n = 0;n < nBlockLength;n++) getbyte(fd);
- }
- break;
-
- case 0xFF: // Application Extension: Ignored
- {
- int nBlockLength = getbyte(fd);
- if (nBlockLength == 0x0b)
- {
- struct GIFNetscapeTag tag;
- if (fread((char*)&tag, 1, sizeof(gifnetscape), fd) == sizeof(gifnetscape))
- {
- SWAP16(tag.iIterations);
- nLoops = tag.iIterations;
- }
- else
- nLoops = 0;
-
- if (nLoops) nLoops++;
- getbyte(fd);
- }
- else
- {
- do
- {
- for (n = 0;n < nBlockLength;n++) getbyte(fd);
- }
- while ((nBlockLength = getbyte(fd)) != 0);
- }
- }
- break;
-
- default: // Unknown Extension: Ignored
- {
- // read (and ignore) data sub-blocks
- while (int nBlockLength = getbyte(fd))
- for (n = 0;n < nBlockLength;n++) getbyte(fd);
- }
- break;
- }
- }
- else if (charGot == 0x2c)
- { // *B* IMAGE (0x2c Image Separator)
- // Create a new Image Object:
- CAnimatedGif* NextImage = new CAnimatedGif();
-
- // Read Image Descriptor
- struct GIFIDtag
- {
- unsigned short xPos; // Image Left Position
- unsigned short yPos; // Image Top Position
- unsigned short Width; // Image Width
- unsigned short Height; // Image Height
- unsigned char PackedFields; // Packed Fields. Bits detail:
- // 0-2: Size of Local Color Table
- // 3-4: (Reserved)
- // 5: Sort Flag
- // 6: Interlace Flag
- // 7: Local Color Table Flag
- }
- gifid;
-
- memset(&gifid, 0, sizeof(gifid));
-
- int LocalColorMap = 0;
- if (fread((char*)&gifid, 1, sizeof(gifid), fd) == sizeof(gifid))
- {
- SWAP16(gifid.xPos);
- SWAP16(gifid.yPos);
- SWAP16(gifid.Width);
- SWAP16(gifid.Height);
-
- LocalColorMap = (gifid.PackedFields & 0x08) ? 1 : 0;
- }
-
- NextImage->Init(gifid.Width, gifid.Height, LocalColorMap ? (gifid.PackedFields&7) + 1 : GlobalBPP);
-
- // Fill NextImage Data
- NextImage->xPos = gifid.xPos;
- NextImage->yPos = gifid.yPos;
- if (GraphicExtensionFound)
- {
- NextImage->Transparent = (gifgce.PackedFields & 0x01) ? gifgce.Transparent : -1;
- NextImage->Transparency = (gifgce.PackedFields & 0x1c) > 1 ? 1 : 0;
- NextImage->Delay = gifgce.Delay * 10;
- }
-
- if (NextImage->Transparent != -1)
- memset(NextImage->Raster, NextImage->Transparent, NextImage->BytesPerRow * NextImage->Height);
- else
- memset(NextImage->Raster, giflsd.Background, NextImage->BytesPerRow * NextImage->Height);
-
- // Read Color Map (if descriptor says so)
- size_t palSize = sizeof(COLOR)*(1 << NextImage->BPP);
- bool isPalRead = false;
- if (LocalColorMap && fread((char*)NextImage->Palette, 1, palSize, fd) == palSize)
- isPalRead = true;
-
- // Copy global, if no palette
- if (!isPalRead)
- memcpy(NextImage->Palette, GlobalColorMap, palSize);
-
- short firstbyte = getbyte(fd); // 1st byte of img block (CodeSize)
-
- // Calculate compressed image block size
- // to fix: this allocates an extra byte per block
- long ImgStart, ImgEnd;
- ImgEnd = ImgStart = ftell(fd);
- while ((n = getbyte(fd)) != 0) fseek (fd, ImgEnd += n + 1, SEEK_SET );
- fseek (fd, ImgStart, SEEK_SET);
-
- // Allocate Space for Compressed Image
- char * pCompressedImage = new char [ImgEnd - ImgStart + 4];
-
- // Read and store Compressed Image
- char * pTemp = pCompressedImage;
- while (int nBlockLength = getbyte(fd))
- {
- if (fread(pTemp, 1, nBlockLength, fd) != (size_t)nBlockLength)
- {
- // Error?
- }
- pTemp += nBlockLength;
- }
-
- // Call LZW/GIF decompressor
- n = LZWDecoder(
- (char*) pCompressedImage,
- (char*) NextImage->Raster,
- firstbyte, NextImage->BytesPerRow, //NextImage->AlignedWidth,
- gifid.Width, gifid.Height,
- ((gifid.PackedFields & 0x40) ? 1 : 0) //Interlaced?
- );
-
- if (n)
- AddImage(NextImage);
- else
- {
- delete NextImage;
- ERRORMSG("GIF File Corrupt");
- }
-
- // Some cleanup
- delete[] pCompressedImage;
- GraphicExtensionFound = 0;
- }
- else if (charGot == 0x3b)
- {
- // *C* TRAILER: End of GIF Info
- break; // Ok. Standard End.
- }
-
- }
- while ( !feof(fd) );
-
- delete[] GlobalColorMap;
- fclose(fd);
- if ( GetImageCount() == 0) ERRORMSG("Premature End Of File");
- return GetImageCount();
-}
-
-// ****************************************************************************
-// * LZWDecoder (C/C++) *
-// * Codec to perform LZW (GIF Variant) decompression. *
-// * (c) Nov2000, Juan Soulie <jsoulie@cplusplus.com> *
-// ****************************************************************************
-//
-// Parameter description:
-// - bufIn: Input buffer containing a "de-blocked" GIF/LZW compressed image.
-// - bufOut: Output buffer where result will be stored.
-// - InitCodeSize: Initial CodeSize to be Used
-// (GIF files include this as the first byte in a picture block)
-// - AlignedWidth : Width of a row in memory (including alignment if needed)
-// - Width, Height: Physical dimensions of image.
-// - Interlace: 1 for Interlaced GIFs.
-//
-int LZWDecoder (char * bufIn, char * bufOut,
- short InitCodeSize, int AlignedWidth,
- int Width, int Height, const int Interlace)
-{
- int n;
- int row = 0, col = 0; // used to point output if Interlaced
- int nPixels, maxPixels; // Output pixel counter
-
- short CodeSize; // Current CodeSize (size in bits of codes)
- short ClearCode; // Clear code : resets decompressor
- short EndCode; // End code : marks end of information
-
- long whichBit; // Index of next bit in bufIn
- long LongCode; // Temp. var. from which Code is retrieved
- short Code; // Code extracted
- short PrevCode; // Previous Code
- short OutCode; // Code to output
-
- // Translation Table:
- short Prefix[4096]; // Prefix: index of another Code
- unsigned char Suffix[4096]; // Suffix: terminating character
- short FirstEntry; // Index of first free entry in table
- short NextEntry; // Index of next free entry in table
-
- unsigned char OutStack[4097]; // Output buffer
- int OutIndex; // Characters in OutStack
-
- int RowOffset; // Offset in output buffer for current row
-
- // Set up values that depend on InitCodeSize Parameter.
- CodeSize = InitCodeSize + 1;
- ClearCode = (1 << InitCodeSize);
- EndCode = ClearCode + 1;
- NextEntry = FirstEntry = ClearCode + 2;
-
- whichBit = 0;
- nPixels = 0;
- maxPixels = Width * Height;
- RowOffset = 0;
- PrevCode = 0;
-
- while (nPixels < maxPixels)
- {
- OutIndex = 0; // Reset Output Stack
-
- // GET NEXT CODE FROM bufIn:
- // LZW compression uses code items longer than a single byte.
- // For GIF Files, code sizes are variable between 9 and 12 bits
- // That's why we must read data (Code) this way:
- LongCode = *((long*)(bufIn + whichBit / 8)); // Get some bytes from bufIn
- SWAP32(LongCode);
- LongCode >>= (whichBit&7); // Discard too low bits
- Code = (short)((LongCode & ((1 << CodeSize) - 1) )); // Discard too high bits
- whichBit += CodeSize; // Increase Bit Offset
-
- // SWITCH, DIFFERENT POSIBILITIES FOR CODE:
- if (Code == EndCode) // END CODE
- break; // Exit LZW Decompression loop
-
- if (Code == ClearCode)
- {
- // CLEAR CODE:
- CodeSize = InitCodeSize + 1; // Reset CodeSize
- NextEntry = FirstEntry; // Reset Translation Table
- PrevCode = Code; // Prevent next to be added to table.
- continue; // restart, to get another code
- }
- if (Code < NextEntry) // CODE IS IN TABLE
- OutCode = Code; // Set code to output.
-
- else
- { // CODE IS NOT IN TABLE:
- OutIndex++; // Keep "first" character of previous output.
- OutCode = PrevCode; // Set PrevCode to be output
- }
-
- // EXPAND OutCode IN OutStack
- // - Elements up to FirstEntry are Raw-Codes and are not expanded
- // - Table Prefices contain indexes to other codes
- // - Table Suffices contain the raw codes to be output
- while (OutCode >= FirstEntry)
- {
- if (OutIndex > 4096 || OutCode >= 4096)
- return 0;
- OutStack[OutIndex++] = Suffix[OutCode]; // Add suffix to Output Stack
- OutCode = Prefix[OutCode]; // Loop with preffix
- }
-
- // NOW OutCode IS A RAW CODE, ADD IT TO OUTPUT STACK.
- if (OutIndex > 4096)
- return 0;
- OutStack[OutIndex++] = (unsigned char) OutCode;
-
- // ADD NEW ENTRY TO TABLE (PrevCode + OutCode)
- // (EXCEPT IF PREVIOUS CODE WAS A CLEARCODE)
- if (PrevCode != ClearCode)
- {
- Prefix[NextEntry] = PrevCode;
- Suffix[NextEntry] = (unsigned char) OutCode;
- NextEntry++;
-
- // Prevent Translation table overflow:
- if (NextEntry >= 4096)
- return 0;
-
- // INCREASE CodeSize IF NextEntry IS INVALID WITH CURRENT CodeSize
- if (NextEntry >= (1 << CodeSize))
- {
- if (CodeSize < 12) CodeSize++;
- else
- {
- ;
- } // Do nothing. Maybe next is Clear Code.
- }
- }
-
- PrevCode = Code;
-
- // Avoid the possibility of overflow on 'bufOut'.
- if (nPixels + OutIndex > maxPixels) OutIndex = maxPixels - nPixels;
-
- // OUTPUT OutStack (LAST-IN FIRST-OUT ORDER)
- for (n = OutIndex - 1; n >= 0; n--)
- {
- if (col == Width) // Check if new row.
- {
- if (Interlace)
- {
- // If interlaced::
- if ((row&7) == 0) {row += 8; if (row >= Height) row = 4;}
- else if ((row&3) == 0) {row += 8; if (row >= Height) row = 2;}
- else if ((row&1) == 0) {row += 4; if (row >= Height) row = 1;}
- else row += 2;
- }
- else // If not interlaced:
- row++;
-
- RowOffset = row * AlignedWidth; // Set new row offset
- col = 0;
- }
- bufOut[RowOffset + col] = OutStack[n]; // Write output
- col++; nPixels++; // Increase counters.
- }
-
- } // while (main decompressor loop)
-
- return whichBit;
-}
-
-// Refer to WINIMAGE.TXT for copyright and patent notices on GIF and LZW.
-
-#pragma pack()
diff --git a/guilib/AnimatedGif.h b/guilib/AnimatedGif.h
deleted file mode 100644
index 4c4d23d797..0000000000
--- a/guilib/AnimatedGif.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/*!
-\file AnimatedGif.h
-\brief
-*/
-
-
-// ****************************************************************************
-//
-// WINIMAGE.H : Generic classes for raster images (MSWindows specialization)
-//
-// Content: Class declarations of:
-// - class CAnimatedGif : Storage class for single images
-// - class CAnimatedGifSet : Storage class for sets of images
-// - class C_AnimationWindow : Window Class to display animations
-//
-// (Includes declarations of routines to Load and Save BMP files and to load
-// GIF files into these classes).
-//
-// --------------------------------------------------------------------------
-//
-// Copyright (c) 2000, Juan Soulie <jsoulie@cplusplus.com>
-//
-// Permission to use, copy, modify, distribute and sell this software or any
-// part thereof and/or its documentation for any purpose is granted without fee
-// provided that the above copyright notice and this permission notice appear
-// in all copies.
-//
-// This software is provided "as is" without express or implied warranty of
-// any kind. The author shall have no liability with respect to the
-// infringement of copyrights or patents that any modification to the content
-// of this file or this file itself may incur.
-//
-// ****************************************************************************
-
-
-#include "Texture.h" // for COLOR
-
-#pragma pack(1)
-
-/*!
- \ingroup textures
- \brief
- */
-typedef struct tagGUIRGBQUAD
-{
- BYTE rgbBlue;
- BYTE rgbGreen;
- BYTE rgbRed;
- BYTE rgbReserved;
-}
-GUIRGBQUAD;
-
-/*!
- \ingroup textures
- \brief
- */
-typedef struct tagGUIBITMAPINFOHEADER
-{
- DWORD biSize;
- LONG biWidth;
- LONG biHeight;
- WORD biPlanes;
- WORD biBitCount;
- DWORD biCompression;
- DWORD biSizeImage;
- LONG biXPelsPerMeter;
- LONG biYPelsPerMeter;
- DWORD biClrUsed;
- DWORD biClrImportant;
-}
-GUIBITMAPINFOHEADER;
-
-/*!
- \ingroup textures
- \brief
- */
-typedef struct tagGUIBITMAPINFO
-{
- GUIBITMAPINFOHEADER bmiHeader;
- GUIRGBQUAD bmiColors[1];
-} GUIBITMAPINFO;
-
-#pragma pack()
-
-
-// ****************************************************************************
-// * CAnimatedGif *
-// * Storage class for single images *
-// ****************************************************************************
-/*!
- \ingroup textures
- \brief Storage class for single images
- */
-class CAnimatedGif
-{
-public:
- CAnimatedGif();
- virtual ~CAnimatedGif();
-
- // standard members:
- int Width, Height; ///< Dimensions in pixels
- int BPP; // Bits Per Pixel
- char* Raster; ///< Bits of Raster Data (Byte Aligned)
- COLOR* Palette; ///< Color Map
- int BytesPerRow; ///< Width (in bytes) including alignment!
- int Transparent; ///< Index of Transparent color (-1 for none)
-
- // Extra members for animations:
- int nLoops;
- int xPos, yPos; ///< Relative Position
- int Delay; ///< Delay after image in 1/1000 seconds.
- int Transparency; ///< Animation Transparency.
- // Windows GDI specific:
- GUIBITMAPINFO* pbmi; ///< BITMAPINFO structure
-
- // constructor and destructor:
-
- // operator= (object copy)
- CAnimatedGif& operator= (CAnimatedGif& rhs);
-
- /// \brief Image initializer (allocates space for raster and palette):
- void Init (int iWidth, int iHeight, int iBPP, int iLoops = 0);
-
- inline char& Pixel (int x, int y) { return Raster[y*BytesPerRow + x];}
-
-};
-
-// ****************************************************************************
-// * CAnimatedGifSet *
-// * Storage class for sets of images *
-// ****************************************************************************
-/*!
- \ingroup textures
- \brief Storage class for sets of images
- */
-class CAnimatedGifSet
-{
-public:
-
- // constructor and destructor:
- CAnimatedGifSet();
- virtual ~CAnimatedGifSet();
-
- int FrameWidth, FrameHeight; ///< Dimensions of ImageSet in pixels.
- int nLoops; // Number of Loops (0 = infinite)
-
- std::vector<CAnimatedGif*> m_vecimg; ///< Images' Vector.
-
- void AddImage (CAnimatedGif*); ///< Append new image to vector (push_back)
-
- int GetImageCount() const;
- // File Formats:
- int LoadGIF (const char* szFile);
-
- void Release();
-protected:
- unsigned char getbyte(FILE *fd);
-};
-
diff --git a/guilib/AudioContext.cpp b/guilib/AudioContext.cpp
deleted file mode 100644
index e0b923c144..0000000000
--- a/guilib/AudioContext.cpp
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "system.h"
-#include "AudioContext.h"
-#include "GUIAudioManager.h"
-#include "Settings.h"
-#include "GUISettings.h"
-#ifdef _WIN32
-#include "WINDirectSound.h"
-#endif
-extern HWND g_hWnd;
-
-#ifdef _WIN32
-static GUID g_digitaldevice;
-BOOL CALLBACK DSEnumCallback(
- LPGUID lpGuid,
- LPCSTR lpcstrDescription,
- LPCSTR lpcstrModule,
- LPVOID lpContext
-)
-{
- if(strstr(lpcstrDescription, "Digital Output") != NULL)
- {
- g_digitaldevice = *lpGuid;
- return false;
- }
- return true;
-}
-#endif
-
-CAudioContext::CAudioContext()
-{
- m_bAC3EncoderActive=false;
- m_iDevice=DEFAULT_DEVICE;
- m_strDevice.clear();
-#ifdef HAS_AUDIO
-#ifdef HAS_AUDIO_PASS_THROUGH
- m_pAC97Device=NULL;
-#endif
- m_pDirectSoundDevice=NULL;
-#endif
-}
-
-CAudioContext::~CAudioContext()
-{
-}
-
-// \brief Create a new device by type (DEFAULT_DEVICE, DIRECTSOUND_DEVICE, AC97_DEVICE)
-void CAudioContext::SetActiveDevice(int iDevice)
-{
- CStdString strAudioDev = g_guiSettings.GetString("audiooutput.audiodevice");
-
- /* if device is the same, no need to bother */
-#ifdef _WIN32
-
- HRESULT hr;
- int iPos = strAudioDev.Find(':');
- if(iPos != CStdString::npos)
- strAudioDev.erase(0, iPos+1);
-
- if (iDevice == DEFAULT_DEVICE)
- iDevice = DIRECTSOUND_DEVICE; // default device on win32 is directsound device
- if(m_iDevice == iDevice && strAudioDev.Equals(m_strDevice))
- {
- if (iDevice != NONE && m_pDirectSoundDevice)
- {
- DSCAPS devCaps = {0};
- devCaps.dwSize = sizeof(devCaps);
- HRESULT hr = m_pDirectSoundDevice->GetCaps(&devCaps);
- if (SUCCEEDED(hr)) // Make sure the DirectSound interface is still valid.
- return;
- CLog::Log(LOGDEBUG, "%s - DirectSoundDevice no longer valid and is going to be recreated (0x%08x)", __FUNCTION__, hr);
- }
- }
-
-#else
- if(m_iDevice == iDevice)
- return;
-#endif
-
- CLog::Log(LOGDEBUG, "%s - SetActiveDevice from %i to %i", __FUNCTION__, m_iDevice, iDevice);
- /* deinit current device */
- RemoveActiveDevice();
-
- m_iDevice=iDevice;
- m_strDevice=strAudioDev;
-
-#ifdef HAS_AUDIO
- memset(&g_digitaldevice, 0, sizeof(GUID));
- hr = DirectSoundEnumerate(DSEnumCallback, this);
- if (FAILED(hr))
- CLog::Log(LOGERROR, "%s - failed to enumerate output devices (0x%08X)", __FUNCTION__, hr);
-
- if (iDevice==DIRECTSOUND_DEVICE
- || iDevice==DIRECTSOUND_DEVICE_DIGITAL)
- {
- LPGUID guid = NULL;
-#ifdef _WIN32
- CWDSound p_dsound;
- std::vector<DSDeviceInfo > deviceList = p_dsound.GetSoundDevices();
- if (deviceList.size() == 0)
- CLog::Log(LOGDEBUG, "%s - no output devices found.", __FUNCTION__);
-
- std::vector<DSDeviceInfo >::const_iterator iter = deviceList.begin();
- for (int i=0; iter != deviceList.end(); i++)
- {
- DSDeviceInfo dev = *iter;
-
- if (strAudioDev.Equals(dev.strDescription))
- {
- guid = dev.lpGuid;
- CLog::Log(LOGDEBUG, "%s - selecting %s as output devices", __FUNCTION__, dev.strDescription.c_str());
- break;
- }
-
- ++iter;
- }
- if (guid == NULL)
- CLog::Log(LOGDEBUG, "%s - (default playback device).", __FUNCTION__);
-#else
- if(iDevice == DIRECTSOUND_DEVICE_DIGITAL
- && ( g_digitaldevice.Data1 || g_digitaldevice.Data2
- || g_digitaldevice.Data3 || g_digitaldevice.Data4 ))
- guid = &g_digitaldevice;
-#endif
-
- // Create DirectSound
- hr = DirectSoundCreate( guid, &m_pDirectSoundDevice, NULL );
- if (FAILED(hr))
- {
- CLog::Log(LOGERROR, "DirectSoundCreate() Failed (0x%08X)", hr);
- return;
- }
- hr = m_pDirectSoundDevice->SetCooperativeLevel(g_hWnd, DSSCL_PRIORITY);
- if (FAILED(hr))
- {
- CLog::Log(LOGERROR, "DirectSoundDevice::SetCooperativeLevel() Failed (0x%08X)", hr);
- return;
- }
- }
- else if (iDevice == DIRECTSOUND_DEVICE_DIGITAL)
- {
-
- }
-#ifdef HAS_AUDIO_PASS_THROUGH
- else if (iDevice==AC97_DEVICE)
- {
- // Create AC97 Device
- if (FAILED(Ac97CreateMediaObject(DSAC97_CHANNEL_DIGITAL, NULL, NULL, &m_pAC97Device)))
- {
- CLog::Log(LOGERROR, "Failed to create digital Ac97CreateMediaObject()");
- return;
- }
- }
-#endif
- // Don't log an error if the caller specifically asked for no device
- // externalplayer does this to ensure all audio devices are closed
- // during external playback
- else if (iDevice != NONE)
- {
- CLog::Log(LOGERROR, "Failed to create audio device");
- return;
- }
-#endif
- g_audioManager.Initialize(m_iDevice);
-}
-
-// \brief Return the active device type (NONE, DEFAULT_DEVICE, DIRECTSOUND_DEVICE, AC97_DEVICE)
-int CAudioContext::GetActiveDevice()
-{
- return m_iDevice;
-}
-
-// \brief Remove the current sound device, eg. to setup new speaker config
-void CAudioContext::RemoveActiveDevice()
-{
- CLog::Log(LOGDEBUG, "%s - Removing device %i", __FUNCTION__, m_iDevice);
- g_audioManager.DeInitialize(m_iDevice);
- m_iDevice=NONE;
-
-#ifdef HAS_AUDIO
-#ifdef HAS_AUDIO_PASS_THROUGH
- SAFE_RELEASE(m_pAC97Device);
-#endif
- SAFE_RELEASE(m_pDirectSoundDevice);
-#endif
-}
-
-// \brief set a new speaker config
-void CAudioContext::SetupSpeakerConfig(int iChannels, bool& bAudioOnAllSpeakers, bool bIsMusic)
-{
- m_bAC3EncoderActive = false;
- bAudioOnAllSpeakers = false;
-
-#ifdef HAS_AUDIO
- return; //not implemented
- DWORD spconfig = DSSPEAKER_USE_DEFAULT;
- if (AUDIO_IS_BITSTREAM(g_guiSettings.GetInt("audiooutput.mode")))
- {
- if (g_settings.m_currentVideoSettings.m_OutputToAllSpeakers && !bIsMusic)
- {
- bAudioOnAllSpeakers = true;
- m_bAC3EncoderActive = true;
- spconfig = DSSPEAKER_USE_DEFAULT; //Allows ac3 encoder should it be enabled
- }
- else
- {
- if (iChannels == 1)
- spconfig = DSSPEAKER_MONO;
- else if (iChannels == 2)
- spconfig = DSSPEAKER_STEREO;
- else
- spconfig = DSSPEAKER_USE_DEFAULT; //Allows ac3 encoder should it be enabled
- }
- }
- else // We don't want to use the Dolby Digital Encoder output. Downmix to surround instead.
- {
- if (iChannels == 1)
- spconfig = DSSPEAKER_MONO;
- else
- {
- // check if surround mode is allowed, if not then use normal stereo
- // don't always set it to default as that enabled ac3 encoder if that is allowed in dash
- // ruining quality
- spconfig = DSSPEAKER_STEREO;
- }
- }
-
- DWORD spconfig_old = DSSPEAKER_USE_DEFAULT;
- if(m_pDirectSoundDevice)
- {
- m_pDirectSoundDevice->GetSpeakerConfig(&spconfig_old);
- spconfig_old = DSSPEAKER_CONFIG(spconfig_old);
- }
-
- /* speaker config identical, no need to do anything */
- if(spconfig == spconfig_old) return;
- CLog::Log(LOGDEBUG, "%s - Speakerconfig changed from %i to %i", __FUNCTION__, spconfig_old, spconfig);
-#endif
-
- /* speaker config has changed, caller need to recreate it */
- RemoveActiveDevice();
-}
-
-bool CAudioContext::IsAC3EncoderActive() const
-{
- return m_bAC3EncoderActive;
-}
-
-bool CAudioContext::IsPassthroughActive() const
-{
- return (m_iDevice == DIRECTSOUND_DEVICE_DIGITAL);
-}
-
diff --git a/guilib/AudioContext.h b/guilib/AudioContext.h
deleted file mode 100644
index 12c79ccecd..0000000000
--- a/guilib/AudioContext.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*!
-\file AudioContext.h
-\brief
-*/
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "StdString.h"
-
-#define DSMIXBINTYPE_STANDARD 1
-#define DSMIXBINTYPE_DMO 2
-#define DSMIXBINTYPE_AAC 3
-#define DSMIXBINTYPE_OGG 4
-#define DSMIXBINTYPE_CUSTOM 5
-#define DSMIXBINTYPE_STEREOALL 6
-#define DSMIXBINTYPE_STEREOLEFT 7
-#define DSMIXBINTYPE_STEREORIGHT 8
-
-class CAudioContext
-{
-public:
- CAudioContext();
- virtual ~CAudioContext();
-
- void SetActiveDevice(int iDevice);
- int GetActiveDevice();
-
-#ifdef HAS_AUDIO
- LPDIRECTSOUND8 GetDirectSoundDevice() { return m_pDirectSoundDevice; }
-#ifdef HAS_AUDIO_PASS_THROUGH
- LPAC97MEDIAOBJECT GetAc97Device() { return m_pAC97Device; }
-#endif
-#endif
-
- void SetupSpeakerConfig(int iChannels, bool& bAudioOnAllSpeakers, bool bIsMusic=true);
- bool IsAC3EncoderActive() const;
- bool IsPassthroughActive() const;
-
- enum AUDIO_DEVICE {NONE=0, DEFAULT_DEVICE, DIRECTSOUND_DEVICE, AC97_DEVICE, DIRECTSOUND_DEVICE_DIGITAL };
-protected:
- void RemoveActiveDevice();
-
-#ifdef HAS_AUDIO
-#ifdef HAS_AUDIO_PASS_THROUGH
- LPAC97MEDIAOBJECT m_pAC97Device;
-#endif
- LPDIRECTSOUND8 m_pDirectSoundDevice;
-#endif
-
- int m_iDevice;
- CStdString m_strDevice;
- bool m_bAC3EncoderActive;
-};
-
-extern CAudioContext g_audioContext;
diff --git a/guilib/D3DResource.cpp b/guilib/D3DResource.cpp
deleted file mode 100644
index b2ac1164f5..0000000000
--- a/guilib/D3DResource.cpp
+++ /dev/null
@@ -1,456 +0,0 @@
-/*
-* Copyright (C) 2005-2008 Team XBMC
-* http://www.xbmc.org
-*
-* This Program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, 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 General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with XBMC; see the file COPYING. If not, write to
-* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-* http://www.gnu.org/copyleft/gpl.html
-*
-*/
-
-#include "system.h"
-#include "D3DResource.h"
-#include "WindowingFactory.h"
-#include "utils/log.h"
-
-#ifdef HAS_DX
-
-using namespace std;
-
-CD3DTexture::CD3DTexture()
-{
- m_width = 0;
- m_height = 0;
- m_mipLevels = 0;
- m_usage = 0;
- m_format = D3DFMT_A8R8G8B8;
- m_pool = D3DPOOL_DEFAULT;
- m_texture = NULL;
- m_data = NULL;
- m_pitch = 0;
-}
-
-CD3DTexture::~CD3DTexture()
-{
- Release();
- delete[] m_data;
-}
-
-bool CD3DTexture::Create(UINT width, UINT height, UINT mipLevels, DWORD usage, D3DFORMAT format, D3DPOOL pool)
-{
- m_width = width;
- m_height = height;
- m_mipLevels = mipLevels;
- m_usage = usage;
- m_format = format;
- m_pool = pool;
- // create the texture
- Release();
- HRESULT hr = D3DXCreateTexture(g_Windowing.Get3DDevice(), m_width, m_height, m_mipLevels, m_usage, m_format, m_pool, &m_texture);
- if (FAILED(hr))
- {
- CLog::Log(LOGERROR, __FUNCTION__" - failed 0x%08X", hr);
- }
- else
- {
- D3DSURFACE_DESC desc;
- if( D3D_OK == m_texture->GetLevelDesc(0, &desc))
- {
- if(desc.Format != m_format)
- CLog::Log(LOGWARNING, "CD3DTexture::Create - format changed from %d to %d", m_format, desc.Format);
- if(desc.Height != m_height || desc.Width != m_width)
- CLog::Log(LOGWARNING, "CD3DTexture::Create - size changed from %ux%u to %ux%u", m_width, m_height, desc.Width, desc.Height);
- }
-
- g_Windowing.Register(this);
- return true;
- }
- return false;
-}
-
-void CD3DTexture::Release()
-{
- g_Windowing.Unregister(this);
- SAFE_RELEASE(m_texture);
-}
-
-bool CD3DTexture::LockRect(UINT level, D3DLOCKED_RECT *lr, const RECT *rect, DWORD flags)
-{
- if (m_texture)
- {
- if ((flags & D3DLOCK_DISCARD) && !(m_usage & D3DUSAGE_DYNAMIC))
- flags &= ~D3DLOCK_DISCARD;
- return (D3D_OK == m_texture->LockRect(level, lr, rect, flags));
- }
- return false;
-}
-
-bool CD3DTexture::UnlockRect(UINT level)
-{
- if (m_texture)
- return (D3D_OK == m_texture->UnlockRect(level));
- return false;
-}
-
-bool CD3DTexture::GetLevelDesc(UINT level, D3DSURFACE_DESC *desc)
-{
- if (m_texture)
- return (D3D_OK == m_texture->GetLevelDesc(level, desc));
- return false;
-}
-
-bool CD3DTexture::GetSurfaceLevel(UINT level, LPDIRECT3DSURFACE9 *surface)
-{
- if (m_texture)
- return (D3D_OK == m_texture->GetSurfaceLevel(level, surface));
- return false;
-}
-
-void CD3DTexture::SaveTexture()
-{
- if (m_texture)
- {
- delete[] m_data;
- m_data = NULL;
- if(!(m_usage & D3DUSAGE_RENDERTARGET)
- && !(m_usage & D3DUSAGE_DEPTHSTENCIL)
- && !(m_pool == D3DPOOL_DEFAULT && (m_usage & D3DUSAGE_DYNAMIC) == 0))
- {
- D3DLOCKED_RECT lr;
- if (LockRect( 0, &lr, NULL, D3DLOCK_READONLY ))
- {
- m_pitch = lr.Pitch;
- unsigned int memUsage = GetMemoryUsage(lr.Pitch);
- m_data = new unsigned char[memUsage];
- memcpy(m_data, lr.pBits, memUsage);
- UnlockRect(0);
- }
- }
- }
- SAFE_RELEASE(m_texture);
-}
-
-void CD3DTexture::OnDestroyDevice()
-{
- SaveTexture();
-}
-
-void CD3DTexture::OnLostDevice()
-{
- if (m_pool == D3DPOOL_DEFAULT)
- SaveTexture();
-}
-
-void CD3DTexture::RestoreTexture()
-{
- // yay, we're back - make a new copy of the texture
- if (!m_texture)
- {
- HRESULT hr = D3DXCreateTexture(g_Windowing.Get3DDevice(), m_width, m_height, m_mipLevels, m_usage, m_format, m_pool, &m_texture);
- if (FAILED(hr))
- {
- CLog::Log(LOGERROR, __FUNCTION__": D3DXCreateTexture failed 0x%08X", hr);
- }
- else
- {
- // copy the data to the texture
- D3DLOCKED_RECT lr;
- if (m_texture && m_data && LockRect(0, &lr, NULL, D3DLOCK_DISCARD ))
- {
- if (lr.Pitch == m_pitch)
- memcpy(lr.pBits, m_data, GetMemoryUsage(lr.Pitch));
- else
- {
- UINT minpitch = ((UINT)lr.Pitch < m_pitch) ? lr.Pitch : m_pitch;
-
- for(UINT i = 0; i < m_height; ++i)
- {
- // Get pointers to the "rows" of pixels in texture
- BYTE* pBits = (BYTE*)lr.pBits + i*lr.Pitch;
- BYTE* pData = m_data + i*m_pitch;
- memcpy(pBits, pData, minpitch);
- }
- }
- UnlockRect(0);
- }
- }
-
- delete[] m_data;
- m_data = NULL;
- m_pitch = 0;
- }
-}
-
-void CD3DTexture::OnCreateDevice()
-{
- RestoreTexture();
-}
-
-void CD3DTexture::OnResetDevice()
-{
- if (m_pool == D3DPOOL_DEFAULT)
- RestoreTexture();
-}
-
-
-unsigned int CD3DTexture::GetMemoryUsage(unsigned int pitch) const
-{
- switch (m_format)
- {
- case D3DFMT_DXT1:
- case D3DFMT_DXT3:
- case D3DFMT_DXT5:
- return pitch * m_height / 4;
- default:
- return pitch * m_height;
- }
-}
-
-CD3DEffect::CD3DEffect()
-{
- m_effect = NULL;
-}
-
-CD3DEffect::~CD3DEffect()
-{
- Release();
-}
-
-bool CD3DEffect::Create(const CStdString &effectString, DefinesMap* defines)
-{
- Release();
- m_effectString = effectString;
- m_defines.clear();
- if (defines != NULL)
- m_defines = *defines; //FIXME: is this a copy of all members?
- if (CreateEffect())
- {
- g_Windowing.Register(this);
- return true;
- }
- return false;
-}
-
-void CD3DEffect::Release()
-{
- g_Windowing.Unregister(this);
- SAFE_RELEASE(m_effect);
-}
-
-void CD3DEffect::OnDestroyDevice()
-{
- SAFE_RELEASE(m_effect);
-}
-
-void CD3DEffect::OnCreateDevice()
-{
- CreateEffect();
-}
-
-bool CD3DEffect::SetFloatArray(D3DXHANDLE handle, const float* val, unsigned int count)
-{
- if(m_effect)
- return (D3D_OK == m_effect->SetFloatArray(handle, val, count));
- return false;
-}
-
-bool CD3DEffect::SetMatrix(D3DXHANDLE handle, const D3DXMATRIX* mat)
-{
- if (m_effect)
- return (D3D_OK == m_effect->SetMatrix(handle, mat));
- return false;
-}
-
-bool CD3DEffect::SetTechnique(D3DXHANDLE handle)
-{
- if (m_effect)
- return (D3D_OK == m_effect->SetTechnique(handle));
- return false;
-}
-
-bool CD3DEffect::SetTexture(D3DXHANDLE handle, CD3DTexture &texture)
-{
- if (m_effect)
- return (D3D_OK == m_effect->SetTexture(handle, texture.Get()));
- return false;
-}
-
-bool CD3DEffect::Begin(UINT *passes, DWORD flags)
-{
- if (m_effect)
- return (D3D_OK == m_effect->Begin(passes, flags));
- return false;
-}
-
-bool CD3DEffect::BeginPass(UINT pass)
-{
- if (m_effect)
- return (D3D_OK == m_effect->BeginPass(pass));
- return false;
-}
-
-bool CD3DEffect::EndPass()
-{
- if (m_effect)
- return (D3D_OK == m_effect->EndPass());
- return false;
-}
-
-bool CD3DEffect::End()
-{
- if (m_effect)
- return (D3D_OK == m_effect->End());
- return false;
-}
-
-bool CD3DEffect::CreateEffect()
-{
- HRESULT hr;
- LPD3DXBUFFER pError = NULL;
-
- std::vector<D3DXMACRO> definemacros;
-
- for( DefinesMap::const_iterator it = m_defines.begin(); it != m_defines.end(); ++it )
- {
- D3DXMACRO m;
- m.Name = it->first.c_str();
- if (it->second.IsEmpty())
- m.Definition = NULL;
- else
- m.Definition = it->second.c_str();
- definemacros.push_back( m );
- }
-
- definemacros.push_back(D3DXMACRO());
- definemacros.back().Name = 0;
- definemacros.back().Definition = 0;
-
- hr = D3DXCreateEffect(g_Windowing.Get3DDevice(), m_effectString, m_effectString.length(), &definemacros[0], NULL, 0, NULL, &m_effect, &pError );
- if(hr == S_OK)
- return true;
- else if(pError)
- {
- CStdString error;
- error.assign((const char*)pError->GetBufferPointer(), pError->GetBufferSize());
- CLog::Log(LOGERROR, "%s", error.c_str());
- }
- return false;
-}
-
-void CD3DEffect::OnLostDevice()
-{
- if (m_effect)
- m_effect->OnLostDevice();
-}
-
-void CD3DEffect::OnResetDevice()
-{
- if (m_effect)
- m_effect->OnResetDevice();
-}
-
-CD3DVertexBuffer::CD3DVertexBuffer()
-{
- m_length = 0;
- m_usage = 0;
- m_fvf = 0;
- m_pool = D3DPOOL_DEFAULT;
- m_vertex = NULL;
- m_data = NULL;
-}
-
-CD3DVertexBuffer::~CD3DVertexBuffer()
-{
- Release();
- delete[] m_data;
-}
-
-bool CD3DVertexBuffer::Create(UINT length, DWORD usage, DWORD fvf, D3DPOOL pool)
-{
- m_length = length;
- m_usage = usage;
- m_fvf = fvf;
- m_pool = pool;
-
- // create the vertex buffer
- Release();
- if (CreateVertexBuffer())
- {
- g_Windowing.Register(this);
- return true;
- }
- return false;
-}
-
-void CD3DVertexBuffer::Release()
-{
- g_Windowing.Unregister(this);
- SAFE_RELEASE(m_vertex);
-}
-
-bool CD3DVertexBuffer::Lock(UINT level, UINT size, void **data, DWORD flags)
-{
- if (m_vertex)
- return (D3D_OK == m_vertex->Lock(level, size, data, flags));
- return false;
-}
-
-bool CD3DVertexBuffer::Unlock()
-{
- if (m_vertex)
- return (D3D_OK == m_vertex->Unlock());
- return false;
-}
-
-void CD3DVertexBuffer::OnDestroyDevice()
-{
- if (m_vertex)
- {
- delete[] m_data;
- m_data = NULL;
- void* data;
- if (Lock(0, 0, &data, 0))
- {
- m_data = new BYTE[m_length];
- memcpy(m_data, data, m_length);
- Unlock();
- }
- }
- SAFE_RELEASE(m_vertex);
-}
-
-void CD3DVertexBuffer::OnCreateDevice()
-{
- // yay, we're back - make a new copy of the vertices
- if (!m_vertex && m_data && CreateVertexBuffer())
- {
- void *data = NULL;
- if (Lock(0, 0, &data, 0))
- {
- memcpy(data, m_data, m_length);
- Unlock();
- }
- delete[] m_data;
- m_data = NULL;
- }
-}
-
-bool CD3DVertexBuffer::CreateVertexBuffer()
-{
- if (D3D_OK == g_Windowing.Get3DDevice()->CreateVertexBuffer(m_length, m_usage, m_fvf, m_pool, &m_vertex, NULL))
- return true;
- return false;
-}
-
-#endif
diff --git a/guilib/D3DResource.h b/guilib/D3DResource.h
deleted file mode 100644
index 7da5287c48..0000000000
--- a/guilib/D3DResource.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
-* Copyright (C) 2005-2008 Team XBMC
-* http://www.xbmc.org
-*
-* This Program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, 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 General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with XBMC; see the file COPYING. If not, write to
-* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-* http://www.gnu.org/copyleft/gpl.html
-*
-*/
-
-#pragma once
-
-#ifdef HAS_DX
-#include "StdString.h"
-#include <map>
-
-class ID3DResource
-{
-public:
- virtual ~ID3DResource() {};
-
- virtual void OnDestroyDevice()=0;
- virtual void OnCreateDevice()=0;
- virtual void OnLostDevice() {};
- virtual void OnResetDevice() {};
-};
-
-class CD3DTexture : public ID3DResource
-{
-public:
- CD3DTexture();
- ~CD3DTexture();
-
- bool Create(UINT width, UINT height, UINT mipLevels, DWORD usage, D3DFORMAT format, D3DPOOL pool);
- void Release();
- bool LockRect(UINT level, D3DLOCKED_RECT *lr, const RECT *rect, DWORD flags);
- bool UnlockRect(UINT level);
- bool GetLevelDesc(UINT level, D3DSURFACE_DESC *desc);
- bool GetSurfaceLevel(UINT level, LPDIRECT3DSURFACE9 *surface);
-
- LPDIRECT3DTEXTURE9 Get() const { return m_texture; };
-
- virtual void OnDestroyDevice();
- virtual void OnCreateDevice();
- virtual void OnLostDevice();
- virtual void OnResetDevice();
-
-private:
- unsigned int GetMemoryUsage(unsigned int pitch) const;
-
- void SaveTexture();
- void RestoreTexture();
-
- // creation parameters
- UINT m_width;
- UINT m_height;
- UINT m_mipLevels;
- DWORD m_usage;
- D3DFORMAT m_format;
- D3DPOOL m_pool;
- UINT m_pitch;
-
- // created texture
- LPDIRECT3DTEXTURE9 m_texture;
-
- // saved data
- BYTE* m_data;
-};
-
-typedef std::map<CStdString, CStdString> DefinesMap;
-
-class CD3DEffect : public ID3DResource
-{
-public:
- CD3DEffect();
- virtual ~CD3DEffect();
- bool Create(const CStdString &effectString, DefinesMap* defines);
- void Release();
- bool SetFloatArray(D3DXHANDLE handle, const float* val, unsigned int count);
- bool SetMatrix(D3DXHANDLE handle, const D3DXMATRIX* mat);
- bool SetTechnique(D3DXHANDLE handle);
- bool SetTexture(D3DXHANDLE handle, CD3DTexture &texture);
- bool Begin(UINT *passes, DWORD flags);
- bool BeginPass(UINT pass);
- bool EndPass();
- bool End();
-
- ID3DXEffect *Get() const { return m_effect; };
-
- virtual void OnDestroyDevice();
- virtual void OnCreateDevice();
- virtual void OnLostDevice();
- virtual void OnResetDevice();
-private:
- bool CreateEffect();
- CStdString m_effectString;
- ID3DXEffect *m_effect;
- DefinesMap m_defines;
-};
-
-class CD3DVertexBuffer : public ID3DResource
-{
-public:
- CD3DVertexBuffer();
- virtual ~CD3DVertexBuffer();
- bool Create(UINT length, DWORD usage, DWORD fvf, D3DPOOL pool);
- void Release();
- bool Lock(UINT offset, UINT size, void **data, DWORD flags);
- bool Unlock();
-
- LPDIRECT3DVERTEXBUFFER9 Get() const { return m_vertex; };
-
- virtual void OnDestroyDevice();
- virtual void OnCreateDevice();
-private:
- bool CreateVertexBuffer();
- UINT m_length;
- DWORD m_usage;
- DWORD m_fvf;
- D3DPOOL m_pool;
- LPDIRECT3DVERTEXBUFFER9 m_vertex;
-
- // saved data
- BYTE* m_data;
-};
-
-#endif
diff --git a/guilib/DDSImage.cpp b/guilib/DDSImage.cpp
deleted file mode 100644
index e909978735..0000000000
--- a/guilib/DDSImage.cpp
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright (C) 2005-2009 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "DDSImage.h"
-#include "XBTF.h"
-#include "lib/libsquish/squish.h"
-#include "utils/log.h"
-#include <string.h>
-
-#ifndef NO_XBMC_FILESYSTEM
-#include "FileSystem/File.h"
-using namespace XFILE;
-#else
-#include "SimpleFS.h"
-#endif
-
-using namespace std;
-
-CDDSImage::CDDSImage()
-{
- m_data = NULL;
- memset(&m_desc, 0, sizeof(m_desc));
-}
-
-CDDSImage::CDDSImage(unsigned int width, unsigned int height, unsigned int format)
-{
- m_data = NULL;
- Allocate(width, height, format);
-}
-
-CDDSImage::~CDDSImage()
-{
- delete[] m_data;
-}
-
-unsigned int CDDSImage::GetWidth() const
-{
- return m_desc.width;
-}
-
-unsigned int CDDSImage::GetHeight() const
-{
- return m_desc.height;
-}
-
-unsigned int CDDSImage::GetFormat() const
-{
- if (m_desc.pixelFormat.flags & DDPF_RGB)
- return 0; // Not supported
- if (m_desc.pixelFormat.flags & DDPF_FOURCC)
- {
- if (strncmp((const char *)&m_desc.pixelFormat.fourcc, "DXT1", 4) == 0)
- return XB_FMT_DXT1;
- if (strncmp((const char *)&m_desc.pixelFormat.fourcc, "DXT3", 4) == 0)
- return XB_FMT_DXT3;
- if (strncmp((const char *)&m_desc.pixelFormat.fourcc, "DXT5", 4) == 0)
- return XB_FMT_DXT5;
- if (strncmp((const char *)&m_desc.pixelFormat.fourcc, "ARGB", 4) == 0)
- return XB_FMT_A8R8G8B8;
- }
- return 0;
-}
-
-unsigned int CDDSImage::GetSize() const
-{
- return m_desc.linearSize;
-}
-
-unsigned char *CDDSImage::GetData() const
-{
- return m_data;
-}
-
-bool CDDSImage::ReadFile(const std::string &inputFile)
-{
- // open the file
- CFile file;
- if (!file.Open(inputFile))
- return false;
-
- // read the header
- uint32_t magic;
- if (file.Read(&magic, 4) != 4)
- return false;
- if (file.Read(&m_desc, sizeof(m_desc)) != sizeof(m_desc))
- return false;
- if (!GetFormat())
- return false; // not supported
-
- // allocate our data
- m_data = new unsigned char[m_desc.linearSize];
- if (!m_data)
- return false;
-
- // and read it in
- if (file.Read(m_data, m_desc.linearSize) != m_desc.linearSize)
- return false;
-
- file.Close();
- return true;
-}
-
-bool CDDSImage::Create(const std::string &outputFile, unsigned int width, unsigned int height, unsigned int pitch, unsigned char const *brga, double maxMSE)
-{
- if (!Compress(width, height, pitch, brga, maxMSE))
- { // use ARGB
- Allocate(width, height, XB_FMT_A8R8G8B8);
- for (unsigned int i = 0; i < height; i++)
- memcpy(m_data + i * width * 4, brga + i * pitch, min(width * 4, pitch));
- }
- return WriteFile(outputFile);
-}
-
-bool CDDSImage::WriteFile(const std::string &outputFile) const
-{
- // open the file
- CFile file;
- if (!file.OpenForWrite(outputFile, true))
- return false;
-
- // write the header
- file.Write("DDS ", 4);
- file.Write(&m_desc, sizeof(m_desc));
- // now the data
- file.Write(m_data, m_desc.linearSize);
- file.Close();
- return true;
-}
-
-unsigned int CDDSImage::GetStorageRequirements(unsigned int width, unsigned int height, unsigned int format) const
-{
- switch (format)
- {
- case XB_FMT_DXT1:
- return ((width + 3) / 4) * ((height + 3) / 4) * 8;
- case XB_FMT_DXT3:
- case XB_FMT_DXT5:
- return ((width + 3) / 4) * ((height + 3) / 4) * 16;
- case XB_FMT_A8R8G8B8:
- default:
- return width * height * 4;
- }
-}
-
-bool CDDSImage::Compress(unsigned int width, unsigned int height, unsigned int pitch, unsigned char const *brga, double maxMSE)
-{
- // first try DXT1, which is only 4bits/pixel
- Allocate(width, height, XB_FMT_DXT1);
-
- squish::CompressImage(brga, width, height, pitch, m_data, squish::kDxt1 | squish::kSourceBGRA);
- const char *fourCC = NULL;
-
- double colorMSE, alphaMSE;
- squish::ComputeMSE(brga, width, height, pitch, m_data, squish::kDxt1 | squish::kSourceBGRA, colorMSE, alphaMSE);
- if (!maxMSE || (colorMSE < maxMSE && alphaMSE < maxMSE))
- fourCC = "DXT1";
- else
- {
- if (alphaMSE == 0)
- { // no alpha channel, so DXT5YCoCg is going to be the best DXT5 format
- /* squish::CompressImage(brga, width, height, pitch, data2, squish::kDxt5 | squish::kSourceBGRA);
- squish::ComputeMSE(brga, width, height, pitch, m_data, squish::kDxt5 | squish::kSourceBGRA, colorMSE, alphaMSE);
- if (colorMSE < maxMSE && alphaMSE < maxMSE)
- { // success - use it
- compressedSize = squish::GetStorageRequirements(width, height, squish::kDxt5);
- format = XB_FMT_DXT5_YCoCg;
- }
- */
- }
- if (alphaMSE > 0)
- { // try DXT3 and DXT5 - use whichever is better (color is the same as DXT1, but alpha will be different)
- Allocate(width, height, XB_FMT_DXT3);
- squish::CompressImage(brga, width, height, pitch, m_data, squish::kDxt3 | squish::kSourceBGRA);
- squish::ComputeMSE(brga, width, height, pitch, m_data, squish::kDxt3 | squish::kSourceBGRA, colorMSE, alphaMSE);
- if (colorMSE < maxMSE)
- { // color is fine, test DXT5 as well
- double dxt5MSE;
- unsigned char *data2 = new unsigned char[GetStorageRequirements(width, height, XB_FMT_DXT5)];
- squish::CompressImage(brga, width, height, pitch, data2, squish::kDxt5 | squish::kSourceBGRA);
- squish::ComputeMSE(brga, width, height, pitch, data2, squish::kDxt5 | squish::kSourceBGRA, colorMSE, dxt5MSE);
- if (alphaMSE < maxMSE && alphaMSE < dxt5MSE)
- fourCC = "DXT3";
- else if (dxt5MSE < maxMSE)
- { // DXT5 passes
- fourCC = "DXT5";
- std::swap(m_data, data2);
- alphaMSE = dxt5MSE;
- }
- delete[] data2;
- }
- }
- }
- if (fourCC)
- {
- memcpy(&m_desc.pixelFormat.fourcc, fourCC, 4);
- CLog::Log(LOGDEBUG, "%s - using %s (min error is: %2.2f:%2.2f)", __FUNCTION__, fourCC, colorMSE, alphaMSE);
- return true;
- }
- CLog::Log(LOGDEBUG, "%s - no format suitable (min error is: %2.2f:%2.2f)", __FUNCTION__, colorMSE, alphaMSE);
- return false;
-}
-
-bool CDDSImage::Decompress(unsigned char *argb, unsigned int width, unsigned int height, unsigned int pitch, unsigned char const *dxt, unsigned int format)
-{
- if (!argb || !dxt || !(format & XB_FMT_DXT_MASK))
- return false;
-
- if (format == XB_FMT_DXT1)
- squish::DecompressImage(argb, width, height, pitch, dxt, squish::kDxt1 | squish::kSourceBGRA);
- else if (format == XB_FMT_DXT3)
- squish::DecompressImage(argb, width, height, pitch, dxt, squish::kDxt3 | squish::kSourceBGRA);
- else if (format == XB_FMT_DXT5)
- squish::DecompressImage(argb, width, height, pitch, dxt, squish::kDxt5 | squish::kSourceBGRA);
-
- return true;
-}
-
-void CDDSImage::Allocate(unsigned int width, unsigned int height, unsigned int format)
-{
- memset(&m_desc, 0, sizeof(m_desc));
- m_desc.size = sizeof(m_desc);
- m_desc.flags = ddsd_caps | ddsd_pixelformat | ddsd_width | ddsd_height | ddsd_linearsize;
- m_desc.height = height;
- m_desc.width = width;
- m_desc.linearSize = GetStorageRequirements(width, height, format);
- m_desc.pixelFormat.size = sizeof(m_desc.pixelFormat);
- m_desc.pixelFormat.flags = ddpf_fourcc;
- memcpy(&m_desc.pixelFormat.fourcc, GetFourCC(format), 4);
- m_desc.caps.flags1 = ddscaps_texture;
- delete[] m_data;
- m_data = new unsigned char[m_desc.linearSize];
-}
-
-const char *CDDSImage::GetFourCC(unsigned int format) const
-{
- switch (format)
- {
- case XB_FMT_DXT1:
- return "DXT1";
- case XB_FMT_DXT3:
- return "DXT3";
- case XB_FMT_DXT5:
- return "DXT5";
- case XB_FMT_A8R8G8B8:
- default:
- return "ARGB";
- }
-}
diff --git a/guilib/DDSImage.h b/guilib/DDSImage.h
deleted file mode 100644
index b814e62e99..0000000000
--- a/guilib/DDSImage.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright (C) 2005-2009 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#pragma once
-
-#include <string>
-#include <stdint.h>
-
-class CDDSImage
-{
-public:
- CDDSImage();
- CDDSImage(unsigned int width, unsigned int height, unsigned int format);
- ~CDDSImage();
-
- unsigned int GetWidth() const;
- unsigned int GetHeight() const;
- unsigned int GetFormat() const;
- unsigned int GetSize() const;
- unsigned char *GetData() const;
-
- bool ReadFile(const std::string &file);
-
- /*! \brief Create a DDS image file from the given an ARGB buffer
- \param file name of the file to write
- \param width width of the pixel buffer
- \param height height of the pixel buffer
- \param pitch pitch of the pixel buffer
- \param argb pixel buffer
- \param maxMSE maximum mean square error to allow, ignored if 0 (the default)
- \return true on successful image creation, false otherwise
- */
- bool Create(const std::string &file, unsigned int width, unsigned int height, unsigned int pitch, unsigned char const *argb, double maxMSE = 0);
-
- /*! \brief Decompress a DXT1/3/5 image to the given buffer
- Assumes the buffer has been allocated to at least width*height*4
- \param argb pixel buffer to write to (at least width*height*4 bytes)
- \param width width of the pixel buffer
- \param height height of the pixel buffer
- \param pitch pitch of the pixel buffer
- \param dxt compressed dxt data
- \param format format of the compressed dxt data
- \return true on success, false otherwise
- */
- static bool Decompress(unsigned char *argb, unsigned int width, unsigned int height, unsigned int pitch, unsigned char const *dxt, unsigned int format);
-
-private:
- void Allocate(unsigned int width, unsigned int height, unsigned int format);
- const char *GetFourCC(unsigned int format) const;
- bool WriteFile(const std::string &file) const;
-
- /*! \brief Compress an ARGB buffer into a DXT1/3/5 image
- \param width width of the pixel buffer
- \param height height of the pixel buffer
- \param pitch pitch of the pixel buffer
- \param argb pixel buffer
- \param maxMSE maximum mean square error to allow, ignored if 0 (the default)
- \return true on successful compression within the given maxMSE, false otherwise
- */
- bool Compress(unsigned int width, unsigned int height, unsigned int pitch, unsigned char const *argb, double maxMSE = 0);
-
- unsigned int GetStorageRequirements(unsigned int width, unsigned int height, unsigned int format) const;
- enum {
- ddsd_caps = 0x00000001,
- ddsd_height = 0x00000002,
- ddsd_width = 0x00000004,
- ddsd_pitch = 0x00000008,
- ddsd_pixelformat = 0x00001000,
- ddsd_mipmapcount = 0x00020000,
- ddsd_linearsize = 0x00080000,
- ddsd_depth = 0x00800000
- };
-
- enum {
- ddpf_alphapixels = 0x00000001,
- ddpf_fourcc = 0x00000004,
- ddpf_rgb = 0x00000040
- };
-
- enum {
- ddscaps_complex = 0x00000008,
- ddscaps_texture = 0x00001000,
- ddscaps_mipmap = 0x00400000
- };
-
- #pragma pack(push, 2)
- typedef struct
- {
- uint32_t size;
- uint32_t flags;
- uint32_t fourcc;
- uint32_t rgbBitCount;
- uint32_t rBitMask;
- uint32_t gBitMask;
- uint32_t bBitMask;
- uint32_t aBitMask;
- } ddpixelformat;
-
-#define DDPF_ALPHAPIXELS 0x00000001
-#define DDPF_ALPHA 0x00000002
-#define DDPF_FOURCC 0x00000004
-#define DDPF_RGB 0x00000040
-#define DDPF_YUV 0x00000200
-#define DDPF_LUMINANCE 0x00020000
-
- typedef struct
- {
- uint32_t flags1;
- uint32_t flags2;
- uint32_t reserved[2];
- } ddcaps2;
-
- typedef struct
- {
- uint32_t size;
- uint32_t flags;
- uint32_t height;
- uint32_t width;
- uint32_t linearSize;
- uint32_t depth;
- uint32_t mipmapcount;
- uint32_t reserved[11];
- ddpixelformat pixelFormat;
- ddcaps2 caps;
- uint32_t reserved2;
- } ddsurfacedesc2;
- #pragma pack(pop)
-
- ddsurfacedesc2 m_desc;
- unsigned char *m_data;
-};
diff --git a/guilib/DirectXGraphics.cpp b/guilib/DirectXGraphics.cpp
deleted file mode 100644
index f5257a7354..0000000000
--- a/guilib/DirectXGraphics.cpp
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "DirectXGraphics.h"
-#include "Texture.h"
-#include "FileSystem/File.h"
-#include "XBTF.h"
-
-LPVOID XPhysicalAlloc(SIZE_T s, DWORD ulPhysicalAddress, DWORD ulAlignment, DWORD flProtect)
-{
- return malloc(s);
-}
-
-void XPhysicalFree(LPVOID lpAddress)
-{
- free(lpAddress);
-}
-
-D3DFORMAT GetD3DFormat(XB_D3DFORMAT format)
-{
- switch (format)
- {
- case XB_D3DFMT_A8R8G8B8:
- case XB_D3DFMT_LIN_A8R8G8B8:
- return D3DFMT_LIN_A8R8G8B8;
- case XB_D3DFMT_DXT1:
- return D3DFMT_DXT1;
- case XB_D3DFMT_DXT2:
- return D3DFMT_DXT2;
- case XB_D3DFMT_DXT4:
- return D3DFMT_DXT4;
- case XB_D3DFMT_P8:
- return D3DFMT_LIN_A8R8G8B8;
- default:
- return D3DFMT_UNKNOWN;
- }
-}
-
-DWORD BytesPerPixelFromFormat(XB_D3DFORMAT format)
-{
- switch (format)
- {
- case XB_D3DFMT_A8R8G8B8:
- case XB_D3DFMT_LIN_A8R8G8B8:
- case XB_D3DFMT_DXT4:
- return 4;
- case XB_D3DFMT_P8:
- case XB_D3DFMT_DXT1:
- case XB_D3DFMT_DXT2:
- return 1;
- default:
- return 0;
- }
-}
-
-bool IsPalettedFormat(XB_D3DFORMAT format)
-{
- if (format == XB_D3DFMT_P8)
- return true;
- return false;
-}
-
-void ParseTextureHeader(D3DTexture *tex, XB_D3DFORMAT &fmt, DWORD &width, DWORD &height, DWORD &pitch, DWORD &offset)
-{
- fmt = (XB_D3DFORMAT)((tex->Format & 0xff00) >> 8);
- offset = tex->Data;
- if (tex->Size)
- {
- width = (tex->Size & 0x00000fff) + 1;
- height = ((tex->Size & 0x00fff000) >> 12) + 1;
- pitch = (((tex->Size & 0xff000000) >> 24) + 1) << 6;
- }
- else
- {
- width = 1 << ((tex->Format & 0x00f00000) >> 20);
- height = 1 << ((tex->Format & 0x0f000000) >> 24);
- pitch = width * BytesPerPixelFromFormat(fmt);
- }
-}
-
-bool IsSwizzledFormat(XB_D3DFORMAT format)
-{
- switch (format)
- {
- case XB_D3DFMT_A8R8G8B8:
- case XB_D3DFMT_P8:
- return true;
- default:
- return false;
- }
-}
-
-// Unswizzle.
-// Format is:
-
-// 00 01 04 05
-// 02 03 06 07
-// 08 09 12 13
-// 10 11 14 15 ...
-
-// Currently only works for 32bit and 8bit textures, with power of 2 width and height
-void Unswizzle(const void *src, unsigned int depth, unsigned int width, unsigned int height, void *dest)
-{
- for (UINT y = 0; y < height; y++)
- {
- UINT sy = 0;
- if (y < width)
- {
- for (int bit = 0; bit < 16; bit++)
- sy |= ((y >> bit) & 1) << (2*bit);
- sy <<= 1; // y counts twice
- }
- else
- {
- UINT y_mask = y % width;
- for (int bit = 0; bit < 16; bit++)
- sy |= ((y_mask >> bit) & 1) << (2*bit);
- sy <<= 1; // y counts twice
- sy += (y / width) * width * width;
- }
- BYTE *d = (BYTE *)dest + y * width * depth;
- for (UINT x = 0; x < width; x++)
- {
- UINT sx = 0;
- if (x < height * 2)
- {
- for (int bit = 0; bit < 16; bit++)
- sx |= ((x >> bit) & 1) << (2*bit);
- }
- else
- {
- int x_mask = x % (2*height);
- for (int bit = 0; bit < 16; bit++)
- sx |= ((x_mask >> bit) & 1) << (2*bit);
- sx += (x / (2 * height)) * 2 * height * height;
- }
- BYTE *s = (BYTE *)src + (sx + sy)*depth;
- for (unsigned int i = 0; i < depth; ++i)
- *d++ = *s++;
- }
- }
-}
-
-void DXT1toARGB(const void *src, void *dest, unsigned int destWidth)
-{
- const BYTE *b = (const BYTE *)src;
- // colour is in R5G6B5 format, convert to R8G8B8
- DWORD colour[4];
- BYTE red[4];
- BYTE green[4];
- BYTE blue[4];
- for (int i = 0; i < 2; i++)
- {
- red[i] = b[2*i+1] & 0xf8;
- green[i] = ((b[2*i+1] & 0x7) << 5) | ((b[2*i] & 0xe0) >> 3);
- blue[i] = (b[2*i] & 0x1f) << 3;
- colour[i] = (red[i] << 16) | (green[i] << 8) | blue[i];
- }
- if (colour[0] > colour[1])
- {
- red[2] = (2 * red[0] + red[1] + 1) / 3;
- green[2] = (2 * green[0] + green[1] + 1) / 3;
- blue[2] = (2 * blue[0] + blue[1] + 1) / 3;
- red[3] = (red[0] + 2 * red[1] + 1) / 3;
- green[3] = (green[0] + 2 * green[1] + 1) / 3;
- blue[3] = (blue[0] + 2 * blue[1] + 1) / 3;
- for (int i = 0; i < 4; i++)
- colour[i] = (red[i] << 16) | (green[i] << 8) | blue[i] | 0xFF000000;
- }
- else
- {
- red[2] = (red[0] + red[1]) / 2;
- green[2] = (green[0] + green[1]) / 2;
- blue[2] = (blue[0] + blue[1]) / 2;
- for (int i = 0; i < 3; i++)
- colour[i] = (red[i] << 16) | (green[i] << 8) | blue[i] | 0xFF000000;
- colour[3] = 0; // transparent
- }
- // ok, now grab the bits
- for (int y = 0; y < 4; y++)
- {
- DWORD *d = (DWORD *)dest + destWidth * y;
- *d++ = colour[(b[4 + y] & 0x03)];
- *d++ = colour[(b[4 + y] & 0x0c) >> 2];
- *d++ = colour[(b[4 + y] & 0x30) >> 4];
- *d++ = colour[(b[4 + y] & 0xc0) >> 6];
- }
-}
-
-void DXT4toARGB(const void *src, void *dest, unsigned int destWidth)
-{
- const BYTE *b = (const BYTE *)src;
- BYTE alpha[8];
- alpha[0] = b[0];
- alpha[1] = b[1];
- if (alpha[0] > alpha[1])
- {
- alpha[2] = (6 * alpha[0] + 1 * alpha[1]+ 3) / 7;
- alpha[3] = (5 * alpha[0] + 2 * alpha[1] + 3) / 7; // bit code 011
- alpha[4] = (4 * alpha[0] + 3 * alpha[1] + 3) / 7; // bit code 100
- alpha[5] = (3 * alpha[0] + 4 * alpha[1] + 3) / 7; // bit code 101
- alpha[6] = (2 * alpha[0] + 5 * alpha[1] + 3) / 7; // bit code 110
- alpha[7] = (1 * alpha[0] + 6 * alpha[1] + 3) / 7; // bit code 111
- }
- else
- {
- alpha[2] = (4 * alpha[0] + 1 * alpha[1] + 2) / 5; // Bit code 010
- alpha[3] = (3 * alpha[0] + 2 * alpha[1] + 2) / 5; // Bit code 011
- alpha[4] = (2 * alpha[0] + 3 * alpha[1] + 2) / 5; // Bit code 100
- alpha[5] = (1 * alpha[0] + 4 * alpha[1] + 2) / 5; // Bit code 101
- alpha[6] = 0; // Bit code 110
- alpha[7] = 255; // Bit code 111
- }
- // ok, now grab the bits
- BYTE a[4][4];
- a[0][0] = alpha[(b[2] & 0xe0) >> 5];
- a[0][1] = alpha[(b[2] & 0x1c) >> 2];
- a[0][2] = alpha[((b[2] & 0x03) << 1) | ((b[3] & 0x80) >> 7)];
- a[0][3] = alpha[(b[3] & 0x70) >> 4];
- a[1][0] = alpha[(b[3] & 0x0e) >> 1];
- a[1][1] = alpha[((b[3] & 0x01) << 2) | ((b[4] & 0xc0) >> 6)];
- a[1][2] = alpha[(b[4] & 0x38) >> 3];
- a[1][3] = alpha[(b[4] & 0x07)];
- a[2][0] = alpha[(b[5] & 0xe0) >> 5];
- a[2][1] = alpha[(b[5] & 0x1c) >> 2];
- a[2][2] = alpha[((b[5] & 0x03) << 1) | ((b[6] & 0x80) >> 7)];
- a[2][3] = alpha[(b[6] & 0x70) >> 4];
- a[3][0] = alpha[(b[6] & 0x0e) >> 1];
- a[3][1] = alpha[((b[6] & 0x01) << 2) | ((b[7] & 0xc0) >> 6)];
- a[3][2] = alpha[(b[7] & 0x38) >> 3];
- a[3][3] = alpha[(b[7] & 0x07)];
-
- b = (BYTE *)src + 8;
- // colour is in R5G6B5 format, convert to R8G8B8
- DWORD colour[4];
- BYTE red[4];
- BYTE green[4];
- BYTE blue[4];
- for (int i = 0; i < 2; i++)
- {
- red[i] = b[2*i+1] & 0xf8;
- green[i] = ((b[2*i+1] & 0x7) << 5) | ((b[2*i] & 0xe0) >> 3);
- blue[i] = (b[2*i] & 0x1f) << 3;
- }
- red[2] = (2 * red[0] + red[1] + 1) / 3;
- green[2] = (2 * green[0] + green[1] + 1) / 3;
- blue[2] = (2 * blue[0] + blue[1] + 1) / 3;
- red[3] = (red[0] + 2 * red[1] + 1) / 3;
- green[3] = (green[0] + 2 * green[1] + 1) / 3;
- blue[3] = (blue[0] + 2 * blue[1] + 1) / 3;
- for (int i = 0; i < 4; i++)
- colour[i] = (red[i] << 16) | (green[i] << 8) | blue[i];
- // and assign them to our texture
- for (int y = 0; y < 4; y++)
- {
- DWORD *d = (DWORD *)dest + destWidth * y;
- *d++ = colour[(b[4 + y] & 0x03)] | (a[y][0] << 24);
- *d++ = colour[(b[4 + y] & 0x0e) >> 2] | (a[y][1] << 24);
- *d++ = colour[(b[4 + y] & 0x30) >> 4] | (a[y][2] << 24);
- *d++ = colour[(b[4 + y] & 0xe0) >> 6] | (a[y][3] << 24);
- }
-
-}
-
-void ConvertDXT1(const void *src, unsigned int width, unsigned int height, void *dest)
-{
- for (unsigned int y = 0; y < height; y += 4)
- {
- for (unsigned int x = 0; x < width; x += 4)
- {
- const BYTE *s = (const BYTE *)src + y * width / 2 + x * 2;
- DWORD *d = (DWORD *)dest + y * width + x;
- DXT1toARGB(s, d, width);
- }
- }
-}
-
-void ConvertDXT4(const void *src, unsigned int width, unsigned int height, void *dest)
-{
- // [4 4 4 4][4 4 4 4]
- //
- //
- //
- for (unsigned int y = 0; y < height; y += 4)
- {
- for (unsigned int x = 0; x < width; x += 4)
- {
- const BYTE *s = (const BYTE *)src + y * width + x * 4;
- DWORD *d = (DWORD *)dest + y * width + x;
- DXT4toARGB(s, d, width);
- }
- }
-}
-
-void GetTextureFromData(D3DTexture *pTex, void *texData, CBaseTexture **ppTexture)
-{
- XB_D3DFORMAT fmt;
- DWORD width, height, pitch, offset;
- ParseTextureHeader(pTex, fmt, width, height, pitch, offset);
-
- *ppTexture = new CTexture(width, height, XB_FMT_A8R8G8B8);
-
- if (*ppTexture)
- {
- BYTE *texDataStart = (BYTE *)texData;
- COLOR *color = (COLOR *)texData;
- texDataStart += offset;
-/* DXMERGE - We should really support DXT1,DXT2 and DXT4 in both renderers
- Perhaps we should extend CTexture::Update() to support a bunch of different texture types
- Rather than assuming linear 32bits
- We could just override, as at least then all the loading code from various texture formats
- will be in one place
-
- BYTE *dstPixels = (BYTE *)lr.pBits;
- DWORD destPitch = lr.Pitch;
- if (fmt == XB_D3DFMT_DXT1) // Not sure if these are 100% correct, but they seem to work :P
- {
- pitch /= 2;
- destPitch /= 4;
- }
- else if (fmt == XB_D3DFMT_DXT2)
- {
- destPitch /= 4;
- }
- else if (fmt == XB_D3DFMT_DXT4)
- {
- pitch /= 4;
- destPitch /= 4;
- }
-*/
- if (fmt == XB_D3DFMT_DXT1)
- {
- pitch = width * 4;
- BYTE *decoded = new BYTE[pitch * height];
- ConvertDXT1(texDataStart, width, height, decoded);
- texDataStart = decoded;
- }
- else if (fmt == XB_D3DFMT_DXT2 || fmt == XB_D3DFMT_DXT4)
- {
- pitch = width * 4;
- BYTE *decoded = new BYTE[pitch * height];
- ConvertDXT4(texDataStart, width, height, decoded);
- texDataStart = decoded;
- }
- if (IsSwizzledFormat(fmt))
- { // first we unswizzle
- BYTE *unswizzled = new BYTE[pitch * height];
- Unswizzle(texDataStart, BytesPerPixelFromFormat(fmt), width, height, unswizzled);
- texDataStart = unswizzled;
- }
-
- if (IsPalettedFormat(fmt))
- (*ppTexture)->LoadPaletted(width, height, pitch, XB_FMT_A8R8G8B8, texDataStart, color);
- else
- (*ppTexture)->LoadFromMemory(width, height, pitch, XB_FMT_A8R8G8B8, texDataStart);
-
- if (IsSwizzledFormat(fmt) || fmt == XB_D3DFMT_DXT1 || fmt == XB_D3DFMT_DXT2 || fmt == XB_D3DFMT_DXT4)
- {
- delete[] texDataStart;
- }
- }
-}
diff --git a/guilib/DirectXGraphics.h b/guilib/DirectXGraphics.h
deleted file mode 100644
index 8565aeb820..0000000000
--- a/guilib/DirectXGraphics.h
+++ /dev/null
@@ -1,171 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-class CBaseTexture;
-
-#include "gui3d.h"
-
-LPVOID XPhysicalAlloc(SIZE_T s, DWORD ulPhysicalAddress, DWORD ulAlignment, DWORD flProtect);
-void XPhysicalFree(LPVOID lpAddress);
-
-// XPR header
-struct XPR_HEADER
-{
- DWORD dwMagic;
- DWORD dwTotalSize;
- DWORD dwHeaderSize;
-};
-#define XPR_MAGIC_VALUE (('0' << 24) | ('R' << 16) | ('P' << 8) | 'X')
-
-typedef enum _XB_D3DFORMAT
-{
- XB_D3DFMT_UNKNOWN = 0xFFFFFFFF,
-
- /* Swizzled formats */
-
- XB_D3DFMT_A8R8G8B8 = 0x00000006,
- XB_D3DFMT_X8R8G8B8 = 0x00000007,
- XB_D3DFMT_R5G6B5 = 0x00000005,
- XB_D3DFMT_R6G5B5 = 0x00000027,
- XB_D3DFMT_X1R5G5B5 = 0x00000003,
- XB_D3DFMT_A1R5G5B5 = 0x00000002,
- XB_D3DFMT_A4R4G4B4 = 0x00000004,
- XB_D3DFMT_A8 = 0x00000019,
- XB_D3DFMT_A8B8G8R8 = 0x0000003A,
- XB_D3DFMT_B8G8R8A8 = 0x0000003B,
- XB_D3DFMT_R4G4B4A4 = 0x00000039,
- XB_D3DFMT_R5G5B5A1 = 0x00000038,
- XB_D3DFMT_R8G8B8A8 = 0x0000003C,
- XB_D3DFMT_R8B8 = 0x00000029,
- XB_D3DFMT_G8B8 = 0x00000028,
-
- XB_D3DFMT_P8 = 0x0000000B,
-
- XB_D3DFMT_L8 = 0x00000000,
- XB_D3DFMT_A8L8 = 0x0000001A,
- XB_D3DFMT_AL8 = 0x00000001,
- XB_D3DFMT_L16 = 0x00000032,
-
- XB_D3DFMT_V8U8 = 0x00000028,
- XB_D3DFMT_L6V5U5 = 0x00000027,
- XB_D3DFMT_X8L8V8U8 = 0x00000007,
- XB_D3DFMT_Q8W8V8U8 = 0x0000003A,
- XB_D3DFMT_V16U16 = 0x00000033,
-
- XB_D3DFMT_D16_LOCKABLE = 0x0000002C,
- XB_D3DFMT_D16 = 0x0000002C,
- XB_D3DFMT_D24S8 = 0x0000002A,
- XB_D3DFMT_F16 = 0x0000002D,
- XB_D3DFMT_F24S8 = 0x0000002B,
-
- /* YUV formats */
-
- XB_D3DFMT_YUY2 = 0x00000024,
- XB_D3DFMT_UYVY = 0x00000025,
-
- /* Compressed formats */
-
- XB_D3DFMT_DXT1 = 0x0000000C,
- XB_D3DFMT_DXT2 = 0x0000000E,
- XB_D3DFMT_DXT3 = 0x0000000E,
- XB_D3DFMT_DXT4 = 0x0000000F,
- XB_D3DFMT_DXT5 = 0x0000000F,
-
- /* Linear formats */
-
- XB_D3DFMT_LIN_A1R5G5B5 = 0x00000010,
- XB_D3DFMT_LIN_A4R4G4B4 = 0x0000001D,
- XB_D3DFMT_LIN_A8 = 0x0000001F,
- XB_D3DFMT_LIN_A8B8G8R8 = 0x0000003F,
- XB_D3DFMT_LIN_A8R8G8B8 = 0x00000012,
- XB_D3DFMT_LIN_B8G8R8A8 = 0x00000040,
- XB_D3DFMT_LIN_G8B8 = 0x00000017,
- XB_D3DFMT_LIN_R4G4B4A4 = 0x0000003E,
- XB_D3DFMT_LIN_R5G5B5A1 = 0x0000003D,
- XB_D3DFMT_LIN_R5G6B5 = 0x00000011,
- XB_D3DFMT_LIN_R6G5B5 = 0x00000037,
- XB_D3DFMT_LIN_R8B8 = 0x00000016,
- XB_D3DFMT_LIN_R8G8B8A8 = 0x00000041,
- XB_D3DFMT_LIN_X1R5G5B5 = 0x0000001C,
- XB_D3DFMT_LIN_X8R8G8B8 = 0x0000001E,
-
- XB_D3DFMT_LIN_A8L8 = 0x00000020,
- XB_D3DFMT_LIN_AL8 = 0x0000001B,
- XB_D3DFMT_LIN_L16 = 0x00000035,
- XB_D3DFMT_LIN_L8 = 0x00000013,
-
- XB_D3DFMT_LIN_V16U16 = 0x00000036,
- XB_D3DFMT_LIN_V8U8 = 0x00000017,
- XB_D3DFMT_LIN_L6V5U5 = 0x00000037,
- XB_D3DFMT_LIN_X8L8V8U8 = 0x0000001E,
- XB_D3DFMT_LIN_Q8W8V8U8 = 0x00000012,
-
- XB_D3DFMT_LIN_D24S8 = 0x0000002E,
- XB_D3DFMT_LIN_F24S8 = 0x0000002F,
- XB_D3DFMT_LIN_D16 = 0x00000030,
- XB_D3DFMT_LIN_F16 = 0x00000031,
-
- XB_D3DFMT_VERTEXDATA = 100,
- XB_D3DFMT_INDEX16 = 101,
-
- XB_D3DFMT_FORCE_DWORD =0x7fffffff
-} XB_D3DFORMAT;
-
-D3DFORMAT GetD3DFormat(XB_D3DFORMAT format);
-DWORD BytesPerPixelFromFormat(XB_D3DFORMAT format);
-bool IsPalettedFormat(XB_D3DFORMAT format);
-void ParseTextureHeader(D3DTexture *tex, XB_D3DFORMAT &fmt, DWORD &width, DWORD &height, DWORD &pitch, DWORD &offset);
-bool IsSwizzledFormat(XB_D3DFORMAT format);
-
-#ifndef _LINUX
-typedef unsigned __int32 uint32_t;
-typedef unsigned __int8 uint8_t;
-typedef __int16 int16_t;
-#endif
-
-#pragma pack(push, 2)
-typedef struct {
- uint8_t id[2]; // offset
- uint32_t filesize; // 2
- uint32_t reserved; // 6
- uint32_t headersize; // 10
- uint32_t infoSize; // 14
- uint32_t width; // 18
- uint32_t height; // 22
- uint16_t biPlanes; // 26
- uint16_t bits; // 28
- uint32_t biCompression; // 30
- uint32_t biSizeImage; // 34
- uint32_t biXPelsPerMeter; // 38
- uint32_t biYPelsPerMeter; // 42
- uint32_t biClrUsed; // 46
- uint32_t biClrImportant; // 50
-} BMPHEAD;
-#pragma pack(pop)
-
-void Unswizzle(const void *src, unsigned int depth, unsigned int width, unsigned int height, void *dest);
-void DXT1toARGB(const void *src, void *dest, unsigned int destWidth);
-void DXT4toARGB(const void *src, void *dest, unsigned int destWidth);
-void ConvertDXT1(const void *src, unsigned int width, unsigned int height, void *dest);
-void ConvertDXT4(const void *src, unsigned int width, unsigned int height, void *dest);
-void GetTextureFromData(D3DTexture *pTex, void *texData, CBaseTexture** ppTexture);
diff --git a/guilib/FrameBufferObject.cpp b/guilib/FrameBufferObject.cpp
deleted file mode 100644
index 98b22269f1..0000000000
--- a/guilib/FrameBufferObject.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "system.h"
-
-#if defined(HAS_GL) || HAS_GLES == 2
-#include "../xbmc/Settings.h"
-#include "WindowingFactory.h"
-#include "FrameBufferObject.h"
-#include "utils/log.h"
-
-#if HAS_GLES == 2
-// For OpenGL ES2.0, FBO are not extensions but part of the API.
-#define glGenFramebuffersEXT glGenFramebuffers
-#define glDeleteFramebuffersEXT glDeleteFramebuffers
-#define glFramebufferTexture2DEXT glFramebufferTexture2D
-#define glCheckFramebufferStatusEXT glCheckFramebufferStatus
-#define GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT0
-#define GL_FRAMEBUFFER_COMPLETE_EXT GL_FRAMEBUFFER_COMPLETE
-#endif
-
-//////////////////////////////////////////////////////////////////////
-// CFrameBufferObject
-//////////////////////////////////////////////////////////////////////
-
-CFrameBufferObject::CFrameBufferObject()
-{
- m_fbo = 0;
- m_valid = false;
- m_supported = false;
- m_bound = false;
- m_texid = 0;
-}
-
-bool CFrameBufferObject::IsSupported()
-{
- if(g_Windowing.IsExtSupported("GL_EXT_framebuffer_object"))
- m_supported = true;
- else
- m_supported = false;
- return m_supported;
-}
-
-bool CFrameBufferObject::Initialize()
-{
- if (!IsSupported())
- return false;
-
- Cleanup();
-
- glGenFramebuffersEXT(1, &m_fbo);
- VerifyGLState();
-
- if (!m_fbo)
- return false;
-
- m_valid = true;
- return true;
-}
-
-void CFrameBufferObject::Cleanup()
-{
- if (!IsValid())
- return;
-
- if (m_fbo)
- glDeleteFramebuffersEXT(1, &m_fbo);
-
- if (m_texid)
- glDeleteTextures(1, &m_texid);
-
- m_texid = 0;
- m_fbo = 0;
- m_valid = false;
- m_bound = false;
-}
-
-bool CFrameBufferObject::CreateAndBindToTexture(GLenum target, int width, int height, GLenum format,
- GLenum filter, GLenum clampmode)
-{
- if (!IsValid())
- return false;
-
- if (m_texid)
- glDeleteTextures(1, &m_texid);
-
- glGenTextures(1, &m_texid);
- glBindTexture(target, m_texid);
- glTexImage2D(target, 0, format, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
- glTexParameteri(target, GL_TEXTURE_WRAP_S, clampmode);
- glTexParameteri(target, GL_TEXTURE_WRAP_T, clampmode);
- glTexParameteri(target, GL_TEXTURE_MAG_FILTER, filter);
- glTexParameteri(target, GL_TEXTURE_MIN_FILTER, filter);
- VerifyGLState();
- return BindToTexture(target, m_texid);
-}
-
-void CFrameBufferObject::SetFiltering(GLenum target, GLenum mode)
-{
- glBindTexture(target, m_texid);
- glTexParameteri(target, GL_TEXTURE_MAG_FILTER, mode);
- glTexParameteri(target, GL_TEXTURE_MIN_FILTER, mode);
-}
-
-bool CFrameBufferObject::BindToTexture(GLenum target, GLuint texid)
-{
- if (!IsValid())
- return false;
-
- m_bound = false;
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
- glBindTexture(target, texid);
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, target, texid, 0);
- VerifyGLState();
- GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
- {
- VerifyGLState();
- return false;
- }
- m_bound = true;
- return true;
-}
-
-#endif
diff --git a/guilib/FrameBufferObject.h b/guilib/FrameBufferObject.h
deleted file mode 100644
index d86182ffc9..0000000000
--- a/guilib/FrameBufferObject.h
+++ /dev/null
@@ -1,116 +0,0 @@
-#ifndef __FRAMEBUFFEROBJECT_H__
-#define __FRAMEBUFFEROBJECT_H__
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "system.h" // for HAS_GL
-
-#if defined(HAS_GL) || HAS_GLES == 2
-
-//
-// CFrameBufferObject
-// A class that abstracts FBOs to facilitate Render To Texture
-//
-// Requires OpenGL 1.5+ or the GL_EXT_framebuffer_object extension.
-//
-// Usage:
-//
-// CFrameBufferObject *fbo = new CFrameBufferObject();
-// fbo->Initialize();
-// fbo->CreateAndBindToTexture(GL_TEXTURE_2D, 256, 256, GL_RGBA);
-// OR fbo->BindToTexture(GL_TEXTURE_2D, <existing texture ID>);
-// fbo->BeginRender();
-// <normal GL rendering calls>
-// fbo->EndRender();
-// bind and use texture anywhere
-// glBindTexture(GL_TEXTURE_2D, fbo->Texture());
-//
-
-#if HAS_GLES == 2
-// For OpenGL ES2.0, FBO are not extensions but part of the API.
-#define glBindFramebufferEXT glBindFramebuffer
-#define GL_FRAMEBUFFER_EXT GL_FRAMEBUFFER
-#endif
-
-class CFrameBufferObject
-{
-public:
- // Constructor
- CFrameBufferObject();
-
- // returns true if FBO support is detected
- bool IsSupported();
-
- // returns true if FBO has been initialized
- bool IsValid() { return m_valid; }
-
- // returns true if FBO has a texture bound to it
- bool IsBound() { return m_bound; }
-
- // initialize the FBO
- bool Initialize();
-
- // Cleanup
- void Cleanup();
-
- // Bind to an exiting texture
- bool BindToTexture(GLenum target, GLuint texid);
-
- // Set texture filtering
- void SetFiltering(GLenum target, GLenum mode);
-
- // Create a new texture and bind to it
- bool CreateAndBindToTexture(GLenum target, int width, int height, GLenum format,
- GLenum filter=GL_LINEAR, GLenum clamp=GL_CLAMP_TO_EDGE);
-
- // Return the internally created texture ID
- GLuint Texture() { return m_texid; }
-
- // Begin rendering to FBO
- bool BeginRender()
- {
- if (IsValid() && IsBound())
- {
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
- return true;
- }
- return false;
- }
-
- // Finish rendering to FBO
- void EndRender()
- {
- if (IsValid())
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- }
-
-private:
- GLuint m_fbo;
- bool m_valid;
- bool m_bound;
- bool m_supported;
- GLuint m_texid;
-};
-
-#endif
-
-#endif
diff --git a/guilib/GUIActionDescriptor.h b/guilib/GUIActionDescriptor.h
deleted file mode 100644
index a29407ed8d..0000000000
--- a/guilib/GUIActionDescriptor.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2009-2010 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#ifndef GUI_ACTION_DESCRIPTOR
-#define GUI_ACTION_DESCRIPTOR
-
-#include "StdString.h"
-#include "system.h"
-
-class CGUIActionDescriptor
-{
-public:
- typedef enum { LANG_XBMC = 0, LANG_PYTHON = 1 /*, LANG_JAVASCRIPT = 2 */ } ActionLang;
-
- CGUIActionDescriptor()
- {
- m_lang = LANG_XBMC;
- m_action = "";
- m_sourceWindowId = -1;
- }
-
- CGUIActionDescriptor(CStdString& action)
- {
- m_lang = LANG_XBMC;
- m_action = action;
- m_sourceWindowId = -1;
- }
-
- CGUIActionDescriptor(ActionLang lang, CStdString& action)
- {
- m_lang = lang;
- m_action = action;
- m_sourceWindowId = -1;
- }
-
- CStdString m_action;
- ActionLang m_lang;
- int m_sourceWindowId; // the id of the window that was a source of an action
-};
-
-#endif
diff --git a/guilib/GUIAudioManager.cpp b/guilib/GUIAudioManager.cpp
deleted file mode 100644
index 9a9371594f..0000000000
--- a/guilib/GUIAudioManager.cpp
+++ /dev/null
@@ -1,447 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "system.h"
-#include "GUIAudioManager.h"
-#include "Key.h"
-#include "AudioContext.h"
-#include "GUISound.h"
-#include "GUISettings.h"
-#include "ButtonTranslator.h"
-#include "utils/SingleLock.h"
-#include "../xbmc/Util.h"
-#include "../xbmc/FileSystem/Directory.h"
-#include "tinyXML/tinyxml.h"
-#include "addons/Skin.h"
-#ifdef HAS_SDL_AUDIO
-#include <SDL/SDL_mixer.h>
-#endif
-
-using namespace std;
-using namespace XFILE;
-
-CGUIAudioManager g_audioManager;
-
-CGUIAudioManager::CGUIAudioManager()
-{
- m_bInitialized = false;
- m_bEnabled = false;
- m_actionSound=NULL;
-}
-
-CGUIAudioManager::~CGUIAudioManager()
-{
-
-}
-
-void CGUIAudioManager::Initialize(int iDevice)
-{
- if (g_guiSettings.GetString("lookandfeel.soundskin")=="OFF")
- return;
-
- if (iDevice==CAudioContext::DEFAULT_DEVICE)
- {
- CSingleLock lock(m_cs);
-
- if (m_bInitialized)
- return;
-
- CLog::Log(LOGDEBUG, "CGUIAudioManager::Initialize");
-#ifdef _WIN32
- bool bAudioOnAllSpeakers=false;
- g_audioContext.SetupSpeakerConfig(2, bAudioOnAllSpeakers);
- g_audioContext.SetActiveDevice(CAudioContext::DIRECTSOUND_DEVICE);
- m_bInitialized = true;
-#elif defined(HAS_SDL_AUDIO)
- Mix_CloseAudio();
- if (Mix_OpenAudio(44100, AUDIO_S16, 2, 4096))
- CLog::Log(LOGERROR, "Unable to open audio mixer");
- m_bInitialized = true;
-#endif
- }
-}
-
-void CGUIAudioManager::DeInitialize(int iDevice)
-{
- if (!(iDevice == CAudioContext::DIRECTSOUND_DEVICE || iDevice == CAudioContext::DEFAULT_DEVICE)) return;
-
- CSingleLock lock(m_cs);
-
- if (!m_bInitialized)
- return;
-
- CLog::Log(LOGDEBUG, "CGUIAudioManager::DeInitialize");
-
- if (m_actionSound)
- m_actionSound->Wait();
-
- Stop();
-#ifdef HAS_SDL_AUDIO
- Mix_CloseAudio();
-#endif
- m_bInitialized = false;
-}
-
-void CGUIAudioManager::Stop()
-{
- CSingleLock lock(m_cs);
- if (m_actionSound)
- {
- delete m_actionSound;
- m_actionSound=NULL;
- }
-
- for (windowSoundsMap::iterator it=m_windowSounds.begin();it!=m_windowSounds.end();it++)
- {
- CGUISound* sound=it->second;
- if (sound->IsPlaying())
- sound->Stop();
-
- delete sound;
- }
- m_windowSounds.clear();
-
- for (pythonSoundsMap::iterator it1=m_pythonSounds.begin();it1!=m_pythonSounds.end();it1++)
- {
- CGUISound* sound=it1->second;
- if (sound->IsPlaying())
- sound->Stop();
-
- delete sound;
- }
- m_pythonSounds.clear();
-}
-
-// \brief Clear any unused audio buffers
-void CGUIAudioManager::FreeUnused()
-{
- CSingleLock lock(m_cs);
-
- // Free the sound from the last action
- if (m_actionSound && !m_actionSound->IsPlaying())
- {
- delete m_actionSound;
- m_actionSound=NULL;
- }
-
- // Free sounds from windows
- windowSoundsMap::iterator it=m_windowSounds.begin();
- while (it!=m_windowSounds.end())
- {
- CGUISound* sound=it->second;
- if (!sound->IsPlaying())
- {
- delete sound;
- m_windowSounds.erase(it++);
- }
- else ++it;
- }
-
- // Free sounds from python
- pythonSoundsMap::iterator it1=m_pythonSounds.begin();
- while (it1!=m_pythonSounds.end())
- {
- CGUISound* sound=it1->second;
- if (!sound->IsPlaying())
- {
- delete sound;
- m_pythonSounds.erase(it1++);
- }
- else ++it1;
- }
-}
-
-// \brief Play a sound associated with a CAction
-void CGUIAudioManager::PlayActionSound(const CAction& action)
-{
- CSingleLock lock(m_cs);
-
- // it's not possible to play gui sounds when passthrough is active
- if (!m_bEnabled || !m_bInitialized || g_audioContext.IsPassthroughActive())
- return;
-
- actionSoundMap::iterator it=m_actionSoundMap.find(action.GetID());
- if (it==m_actionSoundMap.end())
- return;
-
- if (m_actionSound)
- {
- delete m_actionSound;
- m_actionSound=NULL;
- }
-
- m_actionSound=new CGUISound();
- if (!m_actionSound->Load(CUtil::AddFileToFolder(m_strMediaDir, it->second)))
- {
- delete m_actionSound;
- m_actionSound=NULL;
- return;
- }
-
- m_actionSound->Play();
-}
-
-// \brief Play a sound associated with a window and its event
-// Events: SOUND_INIT, SOUND_DEINIT
-void CGUIAudioManager::PlayWindowSound(int id, WINDOW_SOUND event)
-{
- CSingleLock lock(m_cs);
-
- // it's not possible to play gui sounds when passthrough is active
- if (!m_bEnabled || !m_bInitialized || g_audioContext.IsPassthroughActive())
- return;
-
- windowSoundMap::iterator it=m_windowSoundMap.find(id);
- if (it==m_windowSoundMap.end())
- return;
-
- CWindowSounds sounds=it->second;
- CStdString strFile;
- switch (event)
- {
- case SOUND_INIT:
- strFile=sounds.strInitFile;
- break;
- case SOUND_DEINIT:
- strFile=sounds.strDeInitFile;
- break;
- }
-
- if (strFile.IsEmpty())
- return;
-
- // One sound buffer for each window
- windowSoundsMap::iterator itsb=m_windowSounds.find(id);
- if (itsb!=m_windowSounds.end())
- {
- CGUISound* sound=itsb->second;
- if (sound->IsPlaying())
- sound->Stop();
- delete sound;
- m_windowSounds.erase(itsb++);
- }
-
- CGUISound* sound=new CGUISound();
- if (!sound->Load(CUtil::AddFileToFolder(m_strMediaDir, strFile)))
- {
- delete sound;
- return;
- }
-
- m_windowSounds.insert(pair<int, CGUISound*>(id, sound));
- sound->Play();
-}
-
-// \brief Play a sound given by filename
-void CGUIAudioManager::PlayPythonSound(const CStdString& strFileName)
-{
- CSingleLock lock(m_cs);
-
- // it's not possible to play gui sounds when passthrough is active
- if (!m_bEnabled || !m_bInitialized || g_audioContext.IsPassthroughActive())
- return;
-
- // If we already loaded the sound, just play it
- pythonSoundsMap::iterator itsb=m_pythonSounds.find(strFileName);
- if (itsb!=m_pythonSounds.end())
- {
- CGUISound* sound=itsb->second;
- if (sound->IsPlaying())
- sound->Stop();
-
- sound->Play();
-
- return;
- }
-
- CGUISound* sound=new CGUISound();
- if (!sound->Load(strFileName))
- {
- delete sound;
- return;
- }
-
- m_pythonSounds.insert(pair<CStdString, CGUISound*>(strFileName, sound));
- sound->Play();
-}
-
-// \brief Load the config file (sounds.xml) for nav sounds
-// Can be located in a folder "sounds" in the skin or from a
-// subfolder of the folder "sounds" in the root directory of
-// xbmc
-bool CGUIAudioManager::Load()
-{
- CSingleLock lock(m_cs);
-
- m_actionSoundMap.clear();
- m_windowSoundMap.clear();
-
- if (g_guiSettings.GetString("lookandfeel.soundskin")=="OFF")
- return true;
- else
- Enable(true);
-
- if (g_guiSettings.GetString("lookandfeel.soundskin")=="SKINDEFAULT")
- {
- m_strMediaDir = CUtil::AddFileToFolder(g_SkinInfo->Path(), "sounds");
- }
- else
- m_strMediaDir = CUtil::AddFileToFolder("special://xbmc/sounds", g_guiSettings.GetString("lookandfeel.soundskin"));
-
- CStdString strSoundsXml = CUtil::AddFileToFolder(m_strMediaDir, "sounds.xml");
-
- // Load our xml file
- TiXmlDocument xmlDoc;
-
- CLog::Log(LOGINFO, "Loading %s", strSoundsXml.c_str());
-
- // Load the config file
- if (!xmlDoc.LoadFile(strSoundsXml))
- {
- CLog::Log(LOGNOTICE, "%s, Line %d\n%s", strSoundsXml.c_str(), xmlDoc.ErrorRow(), xmlDoc.ErrorDesc());
- return false;
- }
-
- TiXmlElement* pRoot = xmlDoc.RootElement();
- CStdString strValue = pRoot->Value();
- if ( strValue != "sounds")
- {
- CLog::Log(LOGNOTICE, "%s Doesn't contain <sounds>", strSoundsXml.c_str());
- return false;
- }
-
- // Load sounds for actions
- TiXmlElement* pActions = pRoot->FirstChildElement("actions");
- if (pActions)
- {
- TiXmlNode* pAction = pActions->FirstChild("action");
-
- while (pAction)
- {
- TiXmlNode* pIdNode = pAction->FirstChild("name");
- int id = 0; // action identity
- if (pIdNode && pIdNode->FirstChild())
- {
- CButtonTranslator::TranslateActionString(pIdNode->FirstChild()->Value(), id);
- }
-
- TiXmlNode* pFileNode = pAction->FirstChild("file");
- CStdString strFile;
- if (pFileNode && pFileNode->FirstChild())
- strFile+=pFileNode->FirstChild()->Value();
-
- if (id > 0 && !strFile.IsEmpty())
- m_actionSoundMap.insert(pair<int, CStdString>(id, strFile));
-
- pAction = pAction->NextSibling();
- }
- }
-
- // Load window specific sounds
- TiXmlElement* pWindows = pRoot->FirstChildElement("windows");
- if (pWindows)
- {
- TiXmlNode* pWindow = pWindows->FirstChild("window");
-
- while (pWindow)
- {
- int id = 0;
-
- TiXmlNode* pIdNode = pWindow->FirstChild("name");
- if (pIdNode)
- {
- if (pIdNode->FirstChild())
- id = CButtonTranslator::TranslateWindow(pIdNode->FirstChild()->Value());
- }
-
- CWindowSounds sounds;
- LoadWindowSound(pWindow, "activate", sounds.strInitFile);
- LoadWindowSound(pWindow, "deactivate", sounds.strDeInitFile);
-
- if (id > 0)
- m_windowSoundMap.insert(pair<int, CWindowSounds>(id, sounds));
-
- pWindow = pWindow->NextSibling();
- }
- }
-
- return true;
-}
-
-// \brief Load a window node of the config file (sounds.xml)
-bool CGUIAudioManager::LoadWindowSound(TiXmlNode* pWindowNode, const CStdString& strIdentifier, CStdString& strFile)
-{
- if (!pWindowNode)
- return false;
-
- TiXmlNode* pFileNode = pWindowNode->FirstChild(strIdentifier);
- if (pFileNode && pFileNode->FirstChild())
- {
- strFile = pFileNode->FirstChild()->Value();
- return true;
- }
-
- return false;
-}
-
-// \brief Enable/Disable nav sounds
-void CGUIAudioManager::Enable(bool bEnable)
-{
- // always deinit audio when we don't want gui sounds
- if (g_guiSettings.GetString("lookandfeel.soundskin")=="OFF")
- bEnable = false;
-
- CSingleLock lock(m_cs);
-
- m_bEnabled = bEnable;
-
- if (bEnable)
- Initialize(CAudioContext::DEFAULT_DEVICE);
- else
- DeInitialize(CAudioContext::DEFAULT_DEVICE);
-}
-
-// \brief Sets the volume of all playing sounds
-void CGUIAudioManager::SetVolume(int iLevel)
-{
- CSingleLock lock(m_cs);
-
- if (m_actionSound)
- m_actionSound->SetVolume(iLevel);
-
- windowSoundsMap::iterator it=m_windowSounds.begin();
- while (it!=m_windowSounds.end())
- {
- if (it->second)
- it->second->SetVolume(iLevel);
-
- ++it;
- }
-
- pythonSoundsMap::iterator it1=m_pythonSounds.begin();
- while (it1!=m_pythonSounds.end())
- {
- if (it1->second)
- it1->second->SetVolume(iLevel);
-
- ++it1;
- }
-}
diff --git a/guilib/GUIAudioManager.h b/guilib/GUIAudioManager.h
deleted file mode 100644
index 6de7a04df3..0000000000
--- a/guilib/GUIAudioManager.h
+++ /dev/null
@@ -1,87 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "utils/CriticalSection.h"
-#include "utils/log.h"
-#include "StdString.h"
-
-#include <map>
-
-// forward definitions
-class CAction;
-class CGUISound;
-class TiXmlNode;
-
-enum WINDOW_SOUND { SOUND_INIT = 0, SOUND_DEINIT };
-
-class CGUIAudioManager
-{
- class CWindowSounds
- {
- public:
- CStdString strInitFile;
- CStdString strDeInitFile;
- };
-
-public:
- CGUIAudioManager();
- ~CGUIAudioManager();
-
- void Initialize(int iDevice);
- void DeInitialize(int iDevice);
-
- bool Load();
-
- void PlayActionSound(const CAction& action);
- void PlayWindowSound(int id, WINDOW_SOUND event);
- void PlayPythonSound(const CStdString& strFileName);
-
- void FreeUnused();
-
- void Enable(bool bEnable);
- void SetVolume(int iLevel);
- void Stop();
-private:
- bool LoadWindowSound(TiXmlNode* pWindowNode, const CStdString& strIdentifier, CStdString& strFile);
-
- typedef std::map<int, CStdString> actionSoundMap;
- typedef std::map<int, CWindowSounds> windowSoundMap;
-
- typedef std::map<CStdString, CGUISound*> pythonSoundsMap;
- typedef std::map<int, CGUISound*> windowSoundsMap;
-
- actionSoundMap m_actionSoundMap;
- windowSoundMap m_windowSoundMap;
-
- CGUISound* m_actionSound;
- windowSoundsMap m_windowSounds;
- pythonSoundsMap m_pythonSounds;
-
- CStdString m_strMediaDir;
- bool m_bInitialized;
- bool m_bEnabled;
-
- CCriticalSection m_cs;
-};
-
-extern CGUIAudioManager g_audioManager;
diff --git a/guilib/GUIBaseContainer.cpp b/guilib/GUIBaseContainer.cpp
deleted file mode 100644
index 9548444090..0000000000
--- a/guilib/GUIBaseContainer.cpp
+++ /dev/null
@@ -1,1106 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIBaseContainer.h"
-#include "GUIControlFactory.h"
-#include "GUIWindowManager.h"
-#include "utils/CharsetConverter.h"
-#include "utils/GUIInfoManager.h"
-#include "utils/TimeUtils.h"
-#include "utils/log.h"
-#include "XMLUtils.h"
-#include "StringUtils.h"
-#include "GUIStaticItem.h"
-#include "Key.h"
-#include "MathUtils.h"
-
-using namespace std;
-
-#define HOLD_TIME_START 100
-#define HOLD_TIME_END 3000
-
-CGUIBaseContainer::CGUIBaseContainer(int parentID, int controlID, float posX, float posY, float width, float height, ORIENTATION orientation, int scrollTime, int preloadItems)
- : CGUIControl(parentID, controlID, posX, posY, width, height)
-{
- m_cursor = 0;
- m_offset = 0;
- m_scrollOffset = 0;
- m_scrollSpeed = 0;
- m_scrollLastTime = 0;
- m_scrollTime = scrollTime ? scrollTime : 1;
- m_lastHoldTime = 0;
- m_itemsPerPage = 10;
- m_pageControl = 0;
- m_renderTime = 0;
- m_orientation = orientation;
- m_analogScrollCount = 0;
- m_lastItem = NULL;
- m_staticContent = false;
- m_staticUpdateTime = 0;
- m_wasReset = false;
- m_layout = NULL;
- m_focusedLayout = NULL;
- m_cacheItems = preloadItems;
-}
-
-CGUIBaseContainer::~CGUIBaseContainer(void)
-{
-}
-
-void CGUIBaseContainer::Render()
-{
- ValidateOffset();
-
- if (m_bInvalidated)
- UpdateLayout();
-
- if (!m_layout || !m_focusedLayout) return;
-
- UpdateScrollOffset();
-
- int offset = (int)floorf(m_scrollOffset / m_layout->Size(m_orientation));
-
- int cacheBefore, cacheAfter;
- GetCacheOffsets(cacheBefore, cacheAfter);
-
- // Free memory not used on screen
- if ((int)m_items.size() > m_itemsPerPage + cacheBefore + cacheAfter)
- FreeMemory(CorrectOffset(offset - cacheBefore, 0), CorrectOffset(offset + m_itemsPerPage + 1 + cacheAfter, 0));
-
- if (g_graphicsContext.SetClipRegion(m_posX, m_posY, m_width, m_height))
- {
- CPoint origin = CPoint(m_posX, m_posY) + m_renderOffset;
- float pos = (m_orientation == VERTICAL) ? origin.y : origin.x;
- float end = (m_orientation == VERTICAL) ? m_posY + m_height : m_posX + m_width;
-
- // we offset our draw position to take into account scrolling and whether or not our focused
- // item is offscreen "above" the list.
- float drawOffset = (offset - cacheBefore) * m_layout->Size(m_orientation) - m_scrollOffset;
- if (m_offset + m_cursor < offset)
- drawOffset += m_focusedLayout->Size(m_orientation) - m_layout->Size(m_orientation);
- pos += drawOffset;
- end += cacheAfter * m_layout->Size(m_orientation);
-
- float focusedPos = 0;
- CGUIListItemPtr focusedItem;
- int current = offset - cacheBefore;
- while (pos < end && m_items.size())
- {
- int itemNo = CorrectOffset(current, 0);
- if (itemNo >= (int)m_items.size())
- break;
- bool focused = (current == m_offset + m_cursor);
- if (itemNo >= 0)
- {
- CGUIListItemPtr item = m_items[itemNo];
- // render our item
- if (focused)
- {
- focusedPos = pos;
- focusedItem = item;
- }
- else
- {
- if (m_orientation == VERTICAL)
- RenderItem(origin.x, pos, item.get(), false);
- else
- RenderItem(pos, origin.y, item.get(), false);
- }
- }
- // increment our position
- pos += focused ? m_focusedLayout->Size(m_orientation) : m_layout->Size(m_orientation);
- current++;
- }
- // render focused item last so it can overlap other items
- if (focusedItem)
- {
- if (m_orientation == VERTICAL)
- RenderItem(origin.x, focusedPos, focusedItem.get(), true);
- else
- RenderItem(focusedPos, origin.y, focusedItem.get(), true);
- }
-
- g_graphicsContext.RestoreClipRegion();
- }
-
- UpdatePageControl(offset);
-
- CGUIControl::Render();
-}
-
-
-void CGUIBaseContainer::RenderItem(float posX, float posY, CGUIListItem *item, bool focused)
-{
- if (!m_focusedLayout || !m_layout) return;
-
- // set the origin
- g_graphicsContext.SetOrigin(posX, posY);
-
- if (m_bInvalidated)
- item->SetInvalid();
- if (focused)
- {
- if (!item->GetFocusedLayout())
- {
- CGUIListItemLayout *layout = new CGUIListItemLayout(*m_focusedLayout);
- item->SetFocusedLayout(layout);
- }
- if (item->GetFocusedLayout())
- {
- if (item != m_lastItem || !HasFocus())
- {
- item->GetFocusedLayout()->SetFocusedItem(0);
- }
- if (item != m_lastItem && HasFocus())
- {
- item->GetFocusedLayout()->ResetAnimation(ANIM_TYPE_UNFOCUS);
- unsigned int subItem = 1;
- if (m_lastItem && m_lastItem->GetFocusedLayout())
- subItem = m_lastItem->GetFocusedLayout()->GetFocusedItem();
- item->GetFocusedLayout()->SetFocusedItem(subItem ? subItem : 1);
- }
- item->GetFocusedLayout()->Render(item, m_parentID, m_renderTime);
- }
- m_lastItem = item;
- }
- else
- {
- if (item->GetFocusedLayout())
- item->GetFocusedLayout()->SetFocusedItem(0); // focus is not set
- if (!item->GetLayout())
- {
- CGUIListItemLayout *layout = new CGUIListItemLayout(*m_layout);
- item->SetLayout(layout);
- }
- if (item->GetFocusedLayout() && item->GetFocusedLayout()->IsAnimating(ANIM_TYPE_UNFOCUS))
- item->GetFocusedLayout()->Render(item, m_parentID, m_renderTime);
- else if (item->GetLayout())
- item->GetLayout()->Render(item, m_parentID, m_renderTime);
- }
- g_graphicsContext.RestoreOrigin();
-}
-
-bool CGUIBaseContainer::OnAction(const CAction &action)
-{
- if (action.GetID() >= KEY_ASCII)
- {
- OnJumpLetter((char)(action.GetID() & 0xff));
- return true;
- }
-
- switch (action.GetID())
- {
- case ACTION_MOVE_LEFT:
- case ACTION_MOVE_RIGHT:
- case ACTION_MOVE_DOWN:
- case ACTION_MOVE_UP:
- {
- if (!HasFocus()) return false;
- if (action.GetHoldTime() > HOLD_TIME_START &&
- ((m_orientation == VERTICAL && (action.GetID() == ACTION_MOVE_UP || action.GetID() == ACTION_MOVE_DOWN)) ||
- (m_orientation == HORIZONTAL && (action.GetID() == ACTION_MOVE_LEFT || action.GetID() == ACTION_MOVE_RIGHT))))
- { // action is held down - repeat a number of times
- float speed = std::min(1.0f, (float)(action.GetHoldTime() - HOLD_TIME_START) / (HOLD_TIME_END - HOLD_TIME_START));
- unsigned int itemsPerFrame = 1;
- if (m_lastHoldTime) // number of rows/10 items/second max speed
- itemsPerFrame = std::max((unsigned int)1, (unsigned int)(speed * 0.0001f * GetRows() * (CTimeUtils::GetFrameTime() - m_lastHoldTime)));
- m_lastHoldTime = CTimeUtils::GetFrameTime();
- if (action.GetID() == ACTION_MOVE_LEFT || action.GetID() == ACTION_MOVE_UP)
- while (itemsPerFrame--) MoveUp(false);
- else
- while (itemsPerFrame--) MoveDown(false);
- return true;
- }
- else
- {
- m_lastHoldTime = 0;
- return CGUIControl::OnAction(action);
- }
- }
- break;
-
- case ACTION_FIRST_PAGE:
- SelectItem(0);
- return true;
-
- case ACTION_LAST_PAGE:
- if (m_items.size())
- SelectItem(m_items.size() - 1);
- return true;
-
- case ACTION_NEXT_LETTER:
- {
- OnNextLetter();
- return true;
- }
- break;
- case ACTION_PREV_LETTER:
- {
- OnPrevLetter();
- return true;
- }
- break;
- case ACTION_JUMP_SMS2:
- case ACTION_JUMP_SMS3:
- case ACTION_JUMP_SMS4:
- case ACTION_JUMP_SMS5:
- case ACTION_JUMP_SMS6:
- case ACTION_JUMP_SMS7:
- case ACTION_JUMP_SMS8:
- case ACTION_JUMP_SMS9:
- {
- OnJumpSMS(action.GetID() - ACTION_JUMP_SMS2 + 2);
- return true;
- }
- break;
-
- default:
- if (action.GetID())
- {
- return OnClick(action.GetID());
- }
- }
- return false;
-}
-
-bool CGUIBaseContainer::OnMessage(CGUIMessage& message)
-{
- if (message.GetControlId() == GetID() )
- {
- if (!m_staticContent)
- {
- if (message.GetMessage() == GUI_MSG_LABEL_BIND && message.GetPointer())
- { // bind our items
- Reset();
- CFileItemList *items = (CFileItemList *)message.GetPointer();
- for (int i = 0; i < items->Size(); i++)
- m_items.push_back(items->Get(i));
- UpdateLayout(true); // true to refresh all items
- UpdateScrollByLetter();
- SelectItem(message.GetParam1());
- return true;
- }
- else if (message.GetMessage() == GUI_MSG_LABEL_RESET)
- {
- Reset();
- SetPageControlRange();
- return true;
- }
- }
- if (message.GetMessage() == GUI_MSG_ITEM_SELECTED)
- {
- message.SetParam1(GetSelectedItem());
- return true;
- }
- else if (message.GetMessage() == GUI_MSG_PAGE_CHANGE)
- {
- if (message.GetSenderId() == m_pageControl && IsVisible())
- { // update our page if we're visible - not much point otherwise
- if ((int)message.GetParam1() != m_offset)
- m_pageChangeTimer.StartZero();
- ScrollToOffset(message.GetParam1());
- return true;
- }
- }
- else if (message.GetMessage() == GUI_MSG_REFRESH_LIST)
- { // update our list contents
- for (unsigned int i = 0; i < m_items.size(); ++i)
- m_items[i]->SetInvalid();
- }
- else if (message.GetMessage() == GUI_MSG_MOVE_OFFSET)
- {
- int count = (int)message.GetParam1();
- while (count < 0)
- {
- MoveUp(true);
- count++;
- }
- while (count > 0)
- {
- MoveDown(true);
- count--;
- }
- return true;
- }
- }
- return CGUIControl::OnMessage(message);
-}
-
-void CGUIBaseContainer::OnUp()
-{
- bool wrapAround = m_controlUp == GetID() || !(m_controlUp || m_upActions.size());
- if (m_orientation == VERTICAL && MoveUp(wrapAround))
- return;
- // with horizontal lists it doesn't make much sense to have multiselect labels
- CGUIControl::OnUp();
-}
-
-void CGUIBaseContainer::OnDown()
-{
- bool wrapAround = m_controlDown == GetID() || !(m_controlDown || m_downActions.size());
- if (m_orientation == VERTICAL && MoveDown(wrapAround))
- return;
- // with horizontal lists it doesn't make much sense to have multiselect labels
- CGUIControl::OnDown();
-}
-
-void CGUIBaseContainer::OnLeft()
-{
- bool wrapAround = m_controlLeft == GetID() || !(m_controlLeft || m_leftActions.size());
- if (m_orientation == HORIZONTAL && MoveUp(wrapAround))
- return;
- else if (m_orientation == VERTICAL)
- {
- CGUIListItemLayout *focusedLayout = GetFocusedLayout();
- if (focusedLayout && focusedLayout->MoveLeft())
- return;
- }
- CGUIControl::OnLeft();
-}
-
-void CGUIBaseContainer::OnRight()
-{
- bool wrapAround = m_controlRight == GetID() || !(m_controlRight || m_rightActions.size());
- if (m_orientation == HORIZONTAL && MoveDown(wrapAround))
- return;
- else if (m_orientation == VERTICAL)
- {
- CGUIListItemLayout *focusedLayout = GetFocusedLayout();
- if (focusedLayout && focusedLayout->MoveRight())
- return;
- }
- CGUIControl::OnRight();
-}
-
-void CGUIBaseContainer::OnNextLetter()
-{
- int offset = CorrectOffset(m_offset, m_cursor);
- for (unsigned int i = 0; i < m_letterOffsets.size(); i++)
- {
- if (m_letterOffsets[i].first > offset)
- {
- SelectItem(m_letterOffsets[i].first);
- return;
- }
- }
-}
-
-void CGUIBaseContainer::OnPrevLetter()
-{
- int offset = CorrectOffset(m_offset, m_cursor);
- if (!m_letterOffsets.size())
- return;
- for (int i = (int)m_letterOffsets.size() - 1; i >= 0; i--)
- {
- if (m_letterOffsets[i].first < offset)
- {
- SelectItem(m_letterOffsets[i].first);
- return;
- }
- }
-}
-
-void CGUIBaseContainer::OnJumpLetter(char letter)
-{
- if (m_matchTimer.GetElapsedMilliseconds() < letter_match_timeout)
- m_match.push_back(letter);
- else
- m_match.Format("%c", letter);
-
- m_matchTimer.StartZero();
-
- // we can't jump through letters if we have none
- if (0 == m_letterOffsets.size())
- return;
-
- // find the current letter we're focused on
- unsigned int offset = CorrectOffset(m_offset, m_cursor);
- for (unsigned int i = (offset + 1) % m_items.size(); i != offset; i = (i+1) % m_items.size())
- {
- CGUIListItemPtr item = m_items[i];
- if (0 == strnicmp(SSortFileItem::RemoveArticles(item->GetLabel()).c_str(), m_match.c_str(), m_match.size()))
- {
- SelectItem(i);
- return;
- }
- }
- // no match found - repeat with a single letter
- if (m_match.size() > 1)
- {
- m_match.clear();
- OnJumpLetter(letter);
- }
-}
-
-void CGUIBaseContainer::OnJumpSMS(int letter)
-{
- static const char letterMap[8][6] = { "ABC2", "DEF3", "GHI4", "JKL5", "MNO6", "PQRS7", "TUV8", "WXYZ9" };
-
- // only 2..9 supported
- if (letter < 2 || letter > 9 || !m_letterOffsets.size())
- return;
-
- const CStdString letters = letterMap[letter - 2];
- // find where we currently are
- int offset = CorrectOffset(m_offset, m_cursor);
- unsigned int currentLetter = 0;
- while (currentLetter + 1 < m_letterOffsets.size() && m_letterOffsets[currentLetter + 1].first <= offset)
- currentLetter++;
-
- // now switch to the next letter
- CStdString current = m_letterOffsets[currentLetter].second;
- int startPos = (letters.Find(current) + 1) % letters.size();
- // now jump to letters[startPos], or another one in the same range if possible
- int pos = startPos;
- while (true)
- {
- // check if we can jump to this letter
- for (unsigned int i = 0; i < m_letterOffsets.size(); i++)
- {
- if (m_letterOffsets[i].second == letters.Mid(pos, 1))
- {
- SelectItem(m_letterOffsets[i].first);
- return;
- }
- }
- pos = (pos + 1) % letters.size();
- if (pos == startPos)
- return;
- }
-}
-
-bool CGUIBaseContainer::MoveUp(bool wrapAround)
-{
- return true;
-}
-
-bool CGUIBaseContainer::MoveDown(bool wrapAround)
-{
- return true;
-}
-
-// scrolls the said amount
-void CGUIBaseContainer::Scroll(int amount)
-{
- ScrollToOffset(m_offset + amount);
-}
-
-int CGUIBaseContainer::GetSelectedItem() const
-{
- return CorrectOffset(m_offset, m_cursor);
-}
-
-CGUIListItemPtr CGUIBaseContainer::GetListItem(int offset, unsigned int flag) const
-{
- if (!m_items.size())
- return CGUIListItemPtr();
- int item = GetSelectedItem() + offset;
- if (flag & INFOFLAG_LISTITEM_POSITION) // use offset from the first item displayed, taking into account scrolling
- item = CorrectOffset((int)(m_scrollOffset / m_layout->Size(m_orientation)), offset);
-
- if (flag & INFOFLAG_LISTITEM_WRAP)
- {
- item %= ((int)m_items.size());
- if (item < 0) item += m_items.size();
- return m_items[item];
- }
- else
- {
- if (item >= 0 && item < (int)m_items.size())
- return m_items[item];
- }
- return CGUIListItemPtr();
-}
-
-CGUIListItemLayout *CGUIBaseContainer::GetFocusedLayout() const
-{
- CGUIListItemPtr item = GetListItem(0);
- if (item.get()) return item->GetFocusedLayout();
- return NULL;
-}
-
-bool CGUIBaseContainer::OnMouseOver(const CPoint &point)
-{
- // select the item under the pointer
- SelectItemFromPoint(point - CPoint(m_posX, m_posY));
- return CGUIControl::OnMouseOver(point);
-}
-
-EVENT_RESULT CGUIBaseContainer::OnMouseEvent(const CPoint &point, const CMouseEvent &event)
-{
- if (event.m_id >= ACTION_MOUSE_LEFT_CLICK && event.m_id <= ACTION_MOUSE_DOUBLE_CLICK)
- {
- if (SelectItemFromPoint(point - CPoint(m_posX, m_posY)))
- {
- OnClick(event.m_id);
- return EVENT_RESULT_HANDLED;
- }
- }
- else if (event.m_id == ACTION_MOUSE_WHEEL_UP)
- {
- Scroll(-1);
- return EVENT_RESULT_HANDLED;
- }
- else if (event.m_id == ACTION_MOUSE_WHEEL_DOWN)
- {
- Scroll(1);
- return EVENT_RESULT_HANDLED;
- }
- else if (event.m_id == ACTION_GESTURE_NOTIFY)
- {
- return (m_orientation == HORIZONTAL) ? EVENT_RESULT_PAN_HORIZONTAL : EVENT_RESULT_PAN_VERTICAL;
- }
- else if (event.m_id == ACTION_GESTURE_BEGIN)
- { // grab exclusive access
- CGUIMessage msg(GUI_MSG_EXCLUSIVE_MOUSE, GetID(), GetParentID());
- SendWindowMessage(msg);
- return EVENT_RESULT_HANDLED;
- }
- else if (event.m_id == ACTION_GESTURE_PAN)
- { // do the drag and validate our offset (corrects for end of scroll)
- m_scrollOffset -= (m_orientation == HORIZONTAL) ? event.m_offsetX : event.m_offsetY;
- float size = (m_layout) ? m_layout->Size(m_orientation) : 10.0f;
- int offset = (int)MathUtils::round_int(m_scrollOffset / size);
- m_offset = offset;
- ValidateOffset();
- return EVENT_RESULT_HANDLED;
- }
- else if (event.m_id == ACTION_GESTURE_END)
- { // release exclusive access
- CGUIMessage msg(GUI_MSG_EXCLUSIVE_MOUSE, 0, GetParentID());
- SendWindowMessage(msg);
- // and compute the nearest offset from this and scroll there
- float size = (m_layout) ? m_layout->Size(m_orientation) : 10.0f;
- float offset = m_scrollOffset / size;
- int toOffset = (int)MathUtils::round_int(offset);
- if (toOffset < offset)
- m_offset = toOffset+1;
- else
- m_offset = toOffset-1;
- ScrollToOffset(toOffset);
- return EVENT_RESULT_HANDLED;
- }
- return EVENT_RESULT_UNHANDLED;
-}
-
-bool CGUIBaseContainer::OnClick(int actionID)
-{
- int subItem = 0;
- if (actionID == ACTION_SELECT_ITEM || actionID == ACTION_MOUSE_LEFT_CLICK)
- {
- if (m_staticContent)
- { // "select" action
- int selected = GetSelectedItem();
- if (selected >= 0 && selected < (int)m_items.size())
- {
- CFileItemPtr item = boost::static_pointer_cast<CFileItem>(m_items[selected]);
- // multiple action strings are concat'd together, separated with " , "
- int controlID = GetID(); // save as these could go away as we send messages
- int parentID = GetParentID();
- vector<CStdString> actions;
- StringUtils::SplitString(item->m_strPath, " , ", actions);
- for (unsigned int i = 0; i < actions.size(); i++)
- {
- CStdString action = actions[i];
- action.Replace(",,", ",");
- CGUIMessage message(GUI_MSG_EXECUTE, controlID, parentID);
- message.SetStringParam(action);
- g_windowManager.SendMessage(message);
- }
- }
- return true;
- }
- // grab the currently focused subitem (if applicable)
- CGUIListItemLayout *focusedLayout = GetFocusedLayout();
- if (focusedLayout)
- subItem = focusedLayout->GetFocusedItem();
- }
- // Don't know what to do, so send to our parent window.
- CGUIMessage msg(GUI_MSG_CLICKED, GetID(), GetParentID(), actionID, subItem);
- return SendWindowMessage(msg);
-}
-
-CStdString CGUIBaseContainer::GetDescription() const
-{
- CStdString strLabel;
- int item = GetSelectedItem();
- if (item >= 0 && item < (int)m_items.size())
- {
- CGUIListItemPtr pItem = m_items[item];
- if (pItem->m_bIsFolder)
- strLabel.Format("[%s]", pItem->GetLabel().c_str());
- else
- strLabel = pItem->GetLabel();
- }
- return strLabel;
-}
-
-void CGUIBaseContainer::SetFocus(bool bOnOff)
-{
- if (bOnOff != HasFocus())
- {
- SetInvalid();
- m_lastItem = NULL;
- }
- CGUIControl::SetFocus(bOnOff);
-}
-
-void CGUIBaseContainer::SaveStates(vector<CControlState> &states)
-{
- states.push_back(CControlState(GetID(), GetSelectedItem()));
-}
-
-void CGUIBaseContainer::SetPageControl(int id)
-{
- m_pageControl = id;
-}
-
-void CGUIBaseContainer::ValidateOffset()
-{
-}
-
-void CGUIBaseContainer::DoRender(unsigned int currentTime)
-{
- m_renderTime = currentTime;
- CGUIControl::DoRender(currentTime);
- if (m_pageChangeTimer.GetElapsedMilliseconds() > 200)
- m_pageChangeTimer.Stop();
- m_wasReset = false;
-}
-
-void CGUIBaseContainer::AllocResources()
-{
- CalculateLayout();
-}
-
-void CGUIBaseContainer::FreeResources(bool immediately)
-{
- CGUIControl::FreeResources(immediately);
- if (m_staticContent)
- { // free any static content
- Reset();
- }
- m_scrollSpeed = 0;
-}
-
-void CGUIBaseContainer::UpdateLayout(bool updateAllItems)
-{
- if (updateAllItems)
- { // free memory of items
- for (iItems it = m_items.begin(); it != m_items.end(); it++)
- (*it)->FreeMemory();
- }
- // and recalculate the layout
- CalculateLayout();
- SetPageControlRange();
-}
-
-void CGUIBaseContainer::SetPageControlRange()
-{
- if (m_pageControl)
- {
- CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), m_pageControl, m_itemsPerPage, GetRows());
- SendWindowMessage(msg);
- }
-}
-
-void CGUIBaseContainer::UpdatePageControl(int offset)
-{
- if (m_pageControl)
- { // tell our pagecontrol (scrollbar or whatever) to update (offset it by our cursor position)
- CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), m_pageControl, offset);
- SendWindowMessage(msg);
- }
-}
-
-void CGUIBaseContainer::UpdateVisibility(const CGUIListItem *item)
-{
- CGUIControl::UpdateVisibility(item);
-
- if (!IsVisible())
- return; // no need to update the content if we're not visible
-
- // check whether we need to update our layouts
- if ((m_layout && m_layout->GetCondition() && !g_infoManager.GetBool(m_layout->GetCondition(), GetParentID())) ||
- (m_focusedLayout && m_focusedLayout->GetCondition() && !g_infoManager.GetBool(m_focusedLayout->GetCondition(), GetParentID())))
- {
- // and do it
- int item = GetSelectedItem();
- UpdateLayout(true); // true to refresh all items
- SelectItem(item);
- }
-
- if (m_staticContent)
- { // update our item list with our new content, but only add those items that should
- // be visible. Save the previous item and keep it if we are adding that one.
- CGUIListItem *lastItem = m_lastItem;
- Reset();
- bool updateItems = false;
- if (!m_staticUpdateTime)
- m_staticUpdateTime = CTimeUtils::GetFrameTime();
- if (CTimeUtils::GetFrameTime() - m_staticUpdateTime > 1000)
- {
- m_staticUpdateTime = CTimeUtils::GetFrameTime();
- updateItems = true;
- }
- for (unsigned int i = 0; i < m_staticItems.size(); ++i)
- {
- CGUIStaticItemPtr item = boost::static_pointer_cast<CGUIStaticItem>(m_staticItems[i]);
- // m_idepth is used to store the visibility condition
- if (!item->m_idepth || g_infoManager.GetBool(item->m_idepth, GetParentID()))
- {
- m_items.push_back(item);
- if (item.get() == lastItem)
- m_lastItem = lastItem;
- }
- // update any properties
- if (updateItems)
- item->UpdateProperties(GetParentID());
- }
- UpdateScrollByLetter();
- }
-}
-
-void CGUIBaseContainer::CalculateLayout()
-{
- CGUIListItemLayout *oldFocusedLayout = m_focusedLayout;
- CGUIListItemLayout *oldLayout = m_layout;
- GetCurrentLayouts();
-
- // calculate the number of items to display
- if (!m_focusedLayout || !m_layout)
- return;
-
- if (oldLayout == m_layout && oldFocusedLayout == m_focusedLayout)
- return; // nothing has changed, so don't update stuff
-
- m_itemsPerPage = (int)((Size() - m_focusedLayout->Size(m_orientation)) / m_layout->Size(m_orientation)) + 1;
-
- // ensure that the scroll offset is a multiple of our size
- m_scrollOffset = m_offset * m_layout->Size(m_orientation);
-}
-
-void CGUIBaseContainer::UpdateScrollByLetter()
-{
- m_letterOffsets.clear();
-
- // for scrolling by letter we have an offset table into our vector.
- CStdString currentMatch;
- for (unsigned int i = 0; i < m_items.size(); i++)
- {
- CGUIListItemPtr item = m_items[i];
- // The letter offset jumping is only for ASCII characters at present, and
- // our checks are all done in uppercase
- CStdString nextLetter;
- g_charsetConverter.wToUTF8(item->GetSortLabel().Left(1).ToUpper(), nextLetter);
- if (currentMatch != nextLetter)
- {
- currentMatch = nextLetter;
- m_letterOffsets.push_back(make_pair((int)i, currentMatch));
- }
- }
-}
-
-unsigned int CGUIBaseContainer::GetRows() const
-{
- return m_items.size();
-}
-
-inline float CGUIBaseContainer::Size() const
-{
- return (m_orientation == HORIZONTAL) ? m_width : m_height;
-}
-
-#define MAX_SCROLL_AMOUNT 0.4f
-
-void CGUIBaseContainer::ScrollToOffset(int offset)
-{
- float size = (m_layout) ? m_layout->Size(m_orientation) : 10.0f;
- int range = m_itemsPerPage / 4;
- if (range <= 0) range = 1;
- if (offset * size < m_scrollOffset && m_scrollOffset - offset * size > size * range)
- { // scrolling up, and we're jumping more than 0.5 of a screen
- m_scrollOffset = (offset + range) * size;
- }
- if (offset * size > m_scrollOffset && offset * size - m_scrollOffset > size * range)
- { // scrolling down, and we're jumping more than 0.5 of a screen
- m_scrollOffset = (offset - range) * size;
- }
- m_scrollSpeed = (offset * size - m_scrollOffset) / m_scrollTime;
- if (!m_wasReset)
- {
- SetContainerMoving(offset - m_offset);
- if (m_scrollSpeed)
- m_scrollTimer.Start();
- else
- m_scrollTimer.Stop();
- }
- m_offset = offset;
-}
-
-void CGUIBaseContainer::SetContainerMoving(int direction)
-{
- if (direction)
- g_infoManager.SetContainerMoving(GetID(), direction > 0, m_scrollSpeed != 0);
-}
-
-void CGUIBaseContainer::UpdateScrollOffset()
-{
- m_scrollOffset += m_scrollSpeed * (m_renderTime - m_scrollLastTime);
- if ((m_scrollSpeed < 0 && m_scrollOffset < m_offset * m_layout->Size(m_orientation)) ||
- (m_scrollSpeed > 0 && m_scrollOffset > m_offset * m_layout->Size(m_orientation)))
- {
- m_scrollOffset = m_offset * m_layout->Size(m_orientation);
- m_scrollSpeed = 0;
- m_scrollTimer.Stop();
- }
- m_scrollLastTime = m_renderTime;
-}
-
-int CGUIBaseContainer::CorrectOffset(int offset, int cursor) const
-{
- return offset + cursor;
-}
-
-void CGUIBaseContainer::Reset()
-{
- m_wasReset = true;
- m_items.clear();
- m_lastItem = NULL;
-}
-
-void CGUIBaseContainer::LoadLayout(TiXmlElement *layout)
-{
- TiXmlElement *itemElement = layout->FirstChildElement("itemlayout");
- while (itemElement)
- { // we have a new item layout
- CGUIListItemLayout itemLayout;
- itemLayout.LoadLayout(itemElement, false);
- m_layouts.push_back(itemLayout);
- itemElement = itemElement->NextSiblingElement("itemlayout");
- }
- itemElement = layout->FirstChildElement("focusedlayout");
- while (itemElement)
- { // we have a new item layout
- CGUIListItemLayout itemLayout;
- itemLayout.LoadLayout(itemElement, true);
- m_focusedLayouts.push_back(itemLayout);
- itemElement = itemElement->NextSiblingElement("focusedlayout");
- }
-}
-
-void CGUIBaseContainer::LoadContent(TiXmlElement *content)
-{
- TiXmlElement *root = content->FirstChildElement("content");
- if (!root)
- return;
-
- vector<CGUIListItemPtr> items;
- TiXmlElement *item = root->FirstChildElement("item");
- while (item)
- {
- if (item->FirstChild())
- {
- CGUIStaticItemPtr newItem(new CGUIStaticItem(item, GetParentID()));
- items.push_back(newItem);
- }
- item = item->NextSiblingElement("item");
- }
- SetStaticContent(items);
-}
-
-void CGUIBaseContainer::SetStaticContent(const vector<CGUIListItemPtr> &items)
-{
- m_staticContent = true;
- m_staticUpdateTime = 0;
- m_staticItems.clear();
- m_staticItems.assign(items.begin(), items.end());
- UpdateVisibility();
-}
-
-void CGUIBaseContainer::SetRenderOffset(const CPoint &offset)
-{
- m_renderOffset = offset;
-}
-
-void CGUIBaseContainer::SetType(VIEW_TYPE type, const CStdString &label)
-{
- m_type = type;
- m_label = label;
-}
-
-void CGUIBaseContainer::FreeMemory(int keepStart, int keepEnd)
-{
- if (keepStart < keepEnd)
- { // remove before keepStart and after keepEnd
- for (int i = 0; i < keepStart && i < (int)m_items.size(); ++i)
- m_items[i]->FreeMemory();
- for (int i = keepEnd + 1; i < (int)m_items.size(); ++i)
- m_items[i]->FreeMemory();
- }
- else
- { // wrapping
- for (int i = keepEnd + 1; i < keepStart && i < (int)m_items.size(); ++i)
- m_items[i]->FreeMemory();
- }
-}
-
-bool CGUIBaseContainer::InsideLayout(const CGUIListItemLayout *layout, const CPoint &point) const
-{
- if (!layout) return false;
- if ((m_orientation == VERTICAL && (layout->Size(HORIZONTAL) > 1) && point.x > layout->Size(HORIZONTAL)) ||
- (m_orientation == HORIZONTAL && (layout->Size(VERTICAL) > 1)&& point.y > layout->Size(VERTICAL)))
- return false;
- return true;
-}
-
-#ifdef _DEBUG
-void CGUIBaseContainer::DumpTextureUse()
-{
- CLog::Log(LOGDEBUG, "%s for container %u", __FUNCTION__, GetID());
- for (unsigned int i = 0; i < m_items.size(); ++i)
- {
- CGUIListItemPtr item = m_items[i];
- if (item->GetFocusedLayout()) item->GetFocusedLayout()->DumpTextureUse();
- if (item->GetLayout()) item->GetLayout()->DumpTextureUse();
- }
-}
-#endif
-
-bool CGUIBaseContainer::GetCondition(int condition, int data) const
-{
- switch (condition)
- {
- case CONTAINER_ROW:
- return (m_orientation == VERTICAL) ? (m_cursor == data) : true;
- case CONTAINER_COLUMN:
- return (m_orientation == HORIZONTAL) ? (m_cursor == data) : true;
- case CONTAINER_POSITION:
- return (m_cursor == data);
- case CONTAINER_HAS_NEXT:
- return (HasNextPage());
- case CONTAINER_HAS_PREVIOUS:
- return (HasPreviousPage());
- case CONTAINER_SUBITEM:
- {
- CGUIListItemLayout *layout = GetFocusedLayout();
- return layout ? (layout->GetFocusedItem() == (unsigned int)data) : false;
- }
- case CONTAINER_SCROLLING:
- return (m_scrollTimer.GetElapsedMilliseconds() > m_scrollTime || m_pageChangeTimer.IsRunning());
- default:
- return false;
- }
-}
-
-void CGUIBaseContainer::GetCurrentLayouts()
-{
- m_layout = NULL;
- for (unsigned int i = 0; i < m_layouts.size(); i++)
- {
- int condition = m_layouts[i].GetCondition();
- if (!condition || g_infoManager.GetBool(condition, GetParentID()))
- {
- m_layout = &m_layouts[i];
- break;
- }
- }
- if (!m_layout && m_layouts.size())
- m_layout = &m_layouts[0]; // failsafe
-
- m_focusedLayout = NULL;
- for (unsigned int i = 0; i < m_focusedLayouts.size(); i++)
- {
- int condition = m_focusedLayouts[i].GetCondition();
- if (!condition || g_infoManager.GetBool(condition, GetParentID()))
- {
- m_focusedLayout = &m_focusedLayouts[i];
- break;
- }
- }
- if (!m_focusedLayout && m_focusedLayouts.size())
- m_focusedLayout = &m_focusedLayouts[0]; // failsafe
-}
-
-bool CGUIBaseContainer::HasNextPage() const
-{
- return false;
-}
-
-bool CGUIBaseContainer::HasPreviousPage() const
-{
- return false;
-}
-
-CStdString CGUIBaseContainer::GetLabel(int info) const
-{
- CStdString label;
- switch (info)
- {
- case CONTAINER_NUM_PAGES:
- label.Format("%u", (GetRows() + m_itemsPerPage - 1) / m_itemsPerPage);
- break;
- case CONTAINER_CURRENT_PAGE:
- label.Format("%u", GetCurrentPage());
- break;
- case CONTAINER_POSITION:
- label.Format("%i", m_cursor);
- break;
- case CONTAINER_NUM_ITEMS:
- {
- unsigned int numItems = GetNumItems();
- if (numItems && m_items[0]->IsFileItem() && (boost::static_pointer_cast<CFileItem>(m_items[0]))->IsParentFolder())
- label.Format("%u", numItems-1);
- else
- label.Format("%u", numItems);
- }
- break;
- default:
- break;
- }
- return label;
-}
-
-int CGUIBaseContainer::GetCurrentPage() const
-{
- if (m_offset + m_itemsPerPage >= (int)GetRows()) // last page
- return (GetRows() + m_itemsPerPage - 1) / m_itemsPerPage;
- return m_offset / m_itemsPerPage + 1;
-}
-
-void CGUIBaseContainer::GetCacheOffsets(int &cacheBefore, int &cacheAfter)
-{
- if (m_scrollSpeed > 0)
- {
- cacheBefore = 0;
- cacheAfter = m_cacheItems;
- }
- else if (m_scrollSpeed < 0)
- {
- cacheBefore = m_cacheItems;
- cacheAfter = 0;
- }
- else
- {
- cacheBefore = m_cacheItems / 2;
- cacheAfter = m_cacheItems / 2;
- }
-}
diff --git a/guilib/GUIBaseContainer.h b/guilib/GUIBaseContainer.h
deleted file mode 100644
index c3b6c415ef..0000000000
--- a/guilib/GUIBaseContainer.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/*!
-\file GUIListContainer.h
-\brief
-*/
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIControl.h"
-#include "GUIListItemLayout.h"
-#include "boost/shared_ptr.hpp"
-#include "utils/Stopwatch.h"
-
-typedef boost::shared_ptr<CGUIListItem> CGUIListItemPtr;
-
-/*!
- \ingroup controls
- \brief
- */
-
-class CGUIBaseContainer : public CGUIControl
-{
-public:
- CGUIBaseContainer(int parentID, int controlID, float posX, float posY, float width, float height, ORIENTATION orientation, int scrollTime, int preloadItems);
- virtual ~CGUIBaseContainer(void);
-
- virtual bool OnAction(const CAction &action);
- virtual void OnDown();
- virtual void OnUp();
- virtual void OnLeft();
- virtual void OnRight();
- virtual bool OnMouseOver(const CPoint &point);
- virtual bool OnMessage(CGUIMessage& message);
- virtual void SetFocus(bool bOnOff);
- virtual void AllocResources();
- virtual void FreeResources(bool immediately = false);
- virtual void UpdateVisibility(const CGUIListItem *item = NULL);
-
- virtual unsigned int GetRows() const;
-
- virtual bool HasNextPage() const;
- virtual bool HasPreviousPage() const;
-
- void SetPageControl(int id);
-
- virtual CStdString GetDescription() const;
- virtual void SaveStates(std::vector<CControlState> &states);
- virtual int GetSelectedItem() const;
-
- virtual void DoRender(unsigned int currentTime);
- void LoadLayout(TiXmlElement *layout);
- void LoadContent(TiXmlElement *content);
-
- VIEW_TYPE GetType() const { return m_type; };
- const CStdString &GetLabel() const { return m_label; };
- void SetType(VIEW_TYPE type, const CStdString &label);
-
- virtual bool IsContainer() const { return true; };
- CGUIListItemPtr GetListItem(int offset, unsigned int flag = 0) const;
-
- virtual bool GetCondition(int condition, int data) const;
- CStdString GetLabel(int info) const;
-
- void SetStaticContent(const std::vector<CGUIListItemPtr> &items);
-
- /*! \brief Set the offset of the first item in the container from the container's position
- Useful for lists/panels where the focused item may be larger than the non-focused items and thus
- normally cut off from the clipping window defined by the container's position + size.
- \param offset CPoint holding the offset in skin coordinates.
- */
- void SetRenderOffset(const CPoint &offset);
-
-#ifdef _DEBUG
- virtual void DumpTextureUse();
-#endif
-protected:
- virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event);
- bool OnClick(int actionID);
- virtual void Render();
- virtual void RenderItem(float posX, float posY, CGUIListItem *item, bool focused);
- virtual void Scroll(int amount);
- virtual bool MoveDown(bool wrapAround);
- virtual bool MoveUp(bool wrapAround);
- virtual void ValidateOffset();
- virtual int CorrectOffset(int offset, int cursor) const;
- virtual void UpdateLayout(bool refreshAllItems = false);
- virtual void SetPageControlRange();
- virtual void UpdatePageControl(int offset);
- virtual void CalculateLayout();
- virtual void SelectItem(int item) {};
- virtual bool SelectItemFromPoint(const CPoint &point) { return false; };
- virtual int GetCursorFromPoint(const CPoint &point, CPoint *itemPoint = NULL) const { return -1; };
- virtual void Reset();
- virtual unsigned int GetNumItems() const { return m_items.size(); };
- virtual int GetCurrentPage() const;
- bool InsideLayout(const CGUIListItemLayout *layout, const CPoint &point) const;
-
- inline float Size() const;
- void MoveToRow(int row);
- void FreeMemory(int keepStart, int keepEnd);
- void GetCurrentLayouts();
- CGUIListItemLayout *GetFocusedLayout() const;
-
- CPoint m_renderOffset; ///< \brief render offset of the first item in the list \sa SetRenderOffset
-
- int m_offset;
- int m_cursor;
- float m_analogScrollCount;
- unsigned int m_lastHoldTime;
-
- ORIENTATION m_orientation;
- int m_itemsPerPage;
-
- std::vector< CGUIListItemPtr > m_items;
- typedef std::vector<CGUIListItemPtr> ::iterator iItems;
- CGUIListItem *m_lastItem;
-
- int m_pageControl;
-
- unsigned int m_renderTime;
-
- std::vector<CGUIListItemLayout> m_layouts;
- std::vector<CGUIListItemLayout> m_focusedLayouts;
-
- CGUIListItemLayout *m_layout;
- CGUIListItemLayout *m_focusedLayout;
-
- void ScrollToOffset(int offset);
- void SetContainerMoving(int direction);
- void UpdateScrollOffset();
-
- unsigned int m_scrollLastTime;
- int m_scrollTime;
- float m_scrollOffset;
-
- VIEW_TYPE m_type;
- CStdString m_label;
-
- bool m_staticContent;
- unsigned int m_staticUpdateTime;
- std::vector<CGUIListItemPtr> m_staticItems;
- bool m_wasReset; // true if we've received a Reset message until we've rendered once. Allows
- // us to make sure we don't tell the infomanager that we've been moving when
- // the "movement" was simply due to the list being repopulated (thus cursor position
- // changing around)
-
- void UpdateScrollByLetter();
- void GetCacheOffsets(int &cacheBefore, int &cacheAfter);
- bool ScrollingDown() const { return m_scrollSpeed > 0; };
- bool ScrollingUp() const { return m_scrollSpeed < 0; };
- void OnNextLetter();
- void OnPrevLetter();
- void OnJumpLetter(char letter);
- void OnJumpSMS(int letter);
- std::vector< std::pair<int, CStdString> > m_letterOffsets;
-private:
- int m_cacheItems;
- float m_scrollSpeed;
- CStopWatch m_scrollTimer;
- CStopWatch m_pageChangeTimer;
-
- // letter match searching
- CStopWatch m_matchTimer;
- CStdString m_match;
-
- static const int letter_match_timeout = 1000;
-};
-
-
diff --git a/guilib/GUIBorderedImage.cpp b/guilib/GUIBorderedImage.cpp
deleted file mode 100644
index 28ee2ffdfd..0000000000
--- a/guilib/GUIBorderedImage.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIBorderedImage.h"
-
-CGUIBorderedImage::CGUIBorderedImage(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& texture, const CTextureInfo& borderTexture, const CRect &borderSize)
- : CGUIImage(parentID, controlID, posX + borderSize.x1, posY + borderSize.y1, width - borderSize.x1 - borderSize.x2, height - borderSize.y1 - borderSize.y2, texture),
- m_borderImage(posX, posY, width, height, borderTexture),
- m_borderSize(borderSize)
-{
- ControlType = GUICONTROL_BORDEREDIMAGE;
-}
-
-CGUIBorderedImage::CGUIBorderedImage(const CGUIBorderedImage &right)
-: CGUIImage(right), m_borderImage(right.m_borderImage)
-{
- m_borderSize = right.m_borderSize;
- ControlType = GUICONTROL_BORDEREDIMAGE;
-}
-
-CGUIBorderedImage::~CGUIBorderedImage(void)
-{
-}
-
-void CGUIBorderedImage::Render()
-{
- if (!m_borderImage.GetFileName().IsEmpty() && m_texture.ReadyToRender())
- {
- CRect rect = CRect(m_texture.GetXPosition(), m_texture.GetYPosition(), m_texture.GetXPosition() + m_texture.GetWidth(), m_texture.GetYPosition() + m_texture.GetHeight());
- rect.Intersect(m_texture.GetRenderRect());
- m_borderImage.SetPosition(rect.x1 - m_borderSize.x1, rect.y1 - m_borderSize.y1);
- m_borderImage.SetWidth(rect.Width() + m_borderSize.x1 + m_borderSize.x2);
- m_borderImage.SetHeight(rect.Height() + m_borderSize.y1 + m_borderSize.y2);
- m_borderImage.Render();
- }
- CGUIImage::Render();
-}
-
-void CGUIBorderedImage::AllocResources()
-{
- m_borderImage.AllocResources();
- CGUIImage::AllocResources();
-}
-
-void CGUIBorderedImage::FreeResources(bool immediately)
-{
- m_borderImage.FreeResources(immediately);
- CGUIImage::FreeResources(immediately);
-}
-
-void CGUIBorderedImage::DynamicResourceAlloc(bool bOnOff)
-{
- m_borderImage.DynamicResourceAlloc(bOnOff);
- CGUIImage::DynamicResourceAlloc(bOnOff);
-}
diff --git a/guilib/GUIBorderedImage.h b/guilib/GUIBorderedImage.h
deleted file mode 100644
index 62e15ceb30..0000000000
--- a/guilib/GUIBorderedImage.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef CGUIBorderedImage_H
-#define CGUIBorderedImage_H
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIControl.h"
-#include "TextureManager.h"
-#include "GUIImage.h"
-
-class CGUIBorderedImage : public CGUIImage
-{
-public:
- CGUIBorderedImage(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& texture, const CTextureInfo& borderTexture, const CRect &borderSize);
- CGUIBorderedImage(const CGUIBorderedImage &right);
- virtual ~CGUIBorderedImage(void);
- virtual CGUIBorderedImage *Clone() const { return new CGUIBorderedImage(*this); };
-
- virtual void Render();
- virtual void AllocResources();
- virtual void FreeResources(bool immediately = false);
- virtual void DynamicResourceAlloc(bool bOnOff);
-
-protected:
- CGUITexture m_borderImage;
- CRect m_borderSize;
-};
-
-#endif
diff --git a/guilib/GUIButtonControl.cpp b/guilib/GUIButtonControl.cpp
deleted file mode 100644
index a56bd4ab6b..0000000000
--- a/guilib/GUIButtonControl.cpp
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIButtonControl.h"
-#include "GUIWindowManager.h"
-#include "GUIDialog.h"
-#include "utils/CharsetConverter.h"
-#include "GUIFontManager.h"
-
-using namespace std;
-
-CGUIButtonControl::CGUIButtonControl(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& textureFocus, const CTextureInfo& textureNoFocus, const CLabelInfo& labelInfo)
- : CGUIControl(parentID, controlID, posX, posY, width, height)
- , m_imgFocus(posX, posY, width, height, textureFocus)
- , m_imgNoFocus(posX, posY, width, height, textureNoFocus)
- , m_label(posX, posY, width, height, labelInfo)
- , m_label2(posX, posY, width, height, labelInfo)
-{
- m_bSelected = false;
- m_alpha = 255;
- m_focusCounter = 0;
- ControlType = GUICONTROL_BUTTON;
-}
-
-CGUIButtonControl::~CGUIButtonControl(void)
-{
-}
-
-void CGUIButtonControl::Render()
-{
- if (m_bInvalidated)
- {
- m_imgFocus.SetWidth(m_width);
- m_imgFocus.SetHeight(m_height);
-
- m_imgNoFocus.SetWidth(m_width);
- m_imgNoFocus.SetHeight(m_height);
- }
-
- if (HasFocus())
- {
- if (m_pulseOnSelect)
- {
- unsigned int alphaCounter = m_focusCounter + 2;
- unsigned int alphaChannel;
- if ((alphaCounter % 128) >= 64)
- alphaChannel = alphaCounter % 64;
- else
- alphaChannel = 63 - (alphaCounter % 64);
-
- alphaChannel += 192;
- alphaChannel = (unsigned int)((float)m_alpha * (float)alphaChannel / 255.0f);
- m_imgFocus.SetAlpha((unsigned char)alphaChannel);
- }
- m_imgFocus.SetVisible(true);
- m_imgNoFocus.SetVisible(false);
- m_focusCounter++;
- }
- else
- {
- m_imgFocus.SetVisible(false);
- m_imgNoFocus.SetVisible(true);
- }
- // render both so the visibility settings cause the frame counter to resetcorrectly
- m_imgFocus.Render();
- m_imgNoFocus.Render();
-
- RenderText();
- CGUIControl::Render();
-}
-
-CGUILabel::COLOR CGUIButtonControl::GetTextColor() const
-{
- if (IsDisabled())
- return CGUILabel::COLOR_DISABLED;
- if (HasFocus())
- return CGUILabel::COLOR_FOCUSED;
- return CGUILabel::COLOR_TEXT;
-}
-
-void CGUIButtonControl::RenderText()
-{
- m_label.SetMaxRect(m_posX, m_posY, m_width, m_height);
- m_label.SetText(m_info.GetLabel(m_parentID));
- m_label.SetScrolling(HasFocus());
-
- // render the second label if it exists
- CStdString label2(m_info2.GetLabel(m_parentID));
- if (!label2.IsEmpty())
- {
- m_label2.SetMaxRect(m_posX, m_posY, m_width, m_height);
- m_label2.SetText(label2);
- m_label2.SetAlign(XBFONT_RIGHT | (m_label.GetLabelInfo().align & XBFONT_CENTER_Y) | XBFONT_TRUNCATED);
- m_label2.SetScrolling(HasFocus());
-
- CGUILabel::CheckAndCorrectOverlap(m_label, m_label2);
-
- m_label2.SetColor(GetTextColor());
- m_label2.Render();
- }
- m_label.SetColor(GetTextColor());
- m_label.Render();
-}
-
-bool CGUIButtonControl::OnAction(const CAction &action)
-{
- if (action.GetID() == ACTION_SELECT_ITEM)
- {
- OnClick();
- return true;
- }
- return CGUIControl::OnAction(action);
-}
-
-bool CGUIButtonControl::OnMessage(CGUIMessage& message)
-{
- if (message.GetControlId() == GetID())
- {
- if (message.GetMessage() == GUI_MSG_LABEL_SET)
- {
- SetLabel(message.GetLabel());
- return true;
- }
- if (message.GetMessage() == GUI_MSG_LABEL2_SET)
- {
- SetLabel2(message.GetLabel());
- return true;
- }
- if (message.GetMessage() == GUI_MSG_SELECTED)
- {
- m_bSelected = true;
- return true;
- }
- if (message.GetMessage() == GUI_MSG_DESELECTED)
- {
- m_bSelected = false;
- return true;
- }
- }
-
- return CGUIControl::OnMessage(message);
-}
-
-void CGUIButtonControl::AllocResources()
-{
- CGUIControl::AllocResources();
- m_focusCounter = 0;
- m_imgFocus.AllocResources();
- m_imgNoFocus.AllocResources();
- if (!m_width)
- m_width = m_imgFocus.GetWidth();
- if (!m_height)
- m_height = m_imgFocus.GetHeight();
-}
-
-void CGUIButtonControl::FreeResources(bool immediately)
-{
- CGUIControl::FreeResources(immediately);
- m_imgFocus.FreeResources(immediately);
- m_imgNoFocus.FreeResources(immediately);
-}
-
-void CGUIButtonControl::DynamicResourceAlloc(bool bOnOff)
-{
- CGUIControl::DynamicResourceAlloc(bOnOff);
- m_imgFocus.DynamicResourceAlloc(bOnOff);
- m_imgNoFocus.DynamicResourceAlloc(bOnOff);
-}
-
-void CGUIButtonControl::SetInvalid()
-{
- CGUIControl::SetInvalid();
- m_label.SetInvalid();
- m_label2.SetInvalid();
- m_imgFocus.SetInvalid();
- m_imgNoFocus.SetInvalid();
-}
-
-void CGUIButtonControl::SetLabel(const string &label)
-{ // NOTE: No fallback for buttons at this point
- m_info.SetLabel(label, "");
-}
-
-void CGUIButtonControl::SetLabel2(const string &label2)
-{ // NOTE: No fallback for buttons at this point
- m_info2.SetLabel(label2, "");
-}
-
-void CGUIButtonControl::SetPosition(float posX, float posY)
-{
- CGUIControl::SetPosition(posX, posY);
- m_imgFocus.SetPosition(posX, posY);
- m_imgNoFocus.SetPosition(posX, posY);
-}
-
-void CGUIButtonControl::SetAlpha(unsigned char alpha)
-{
- m_alpha = alpha;
- m_imgFocus.SetAlpha(alpha);
- m_imgNoFocus.SetAlpha(alpha);
-}
-
-void CGUIButtonControl::UpdateColors()
-{
- m_label.UpdateColors();
- CGUIControl::UpdateColors();
- m_imgFocus.SetDiffuseColor(m_diffuseColor);
- m_imgNoFocus.SetDiffuseColor(m_diffuseColor);
-}
-
-EVENT_RESULT CGUIButtonControl::OnMouseEvent(const CPoint &point, const CMouseEvent &event)
-{
- if (event.m_id == ACTION_MOUSE_LEFT_CLICK)
- {
- OnAction(CAction(ACTION_SELECT_ITEM));
- return EVENT_RESULT_HANDLED;
- }
- return EVENT_RESULT_UNHANDLED;
-}
-
-CStdString CGUIButtonControl::GetDescription() const
-{
- CStdString strLabel(m_info.GetLabel(m_parentID));
- return strLabel;
-}
-
-CStdString CGUIButtonControl::GetLabel2() const
-{
- CStdString strLabel(m_info2.GetLabel(m_parentID));
- return strLabel;
-}
-
-void CGUIButtonControl::PythonSetLabel(const CStdString &strFont, const string &strText, color_t textColor, color_t shadowColor, color_t focusedColor)
-{
- m_label.GetLabelInfo().font = g_fontManager.GetFont(strFont);
- m_label.GetLabelInfo().textColor = textColor;
- m_label.GetLabelInfo().focusedColor = focusedColor;
- m_label.GetLabelInfo().shadowColor = shadowColor;
- SetLabel(strText);
-}
-
-void CGUIButtonControl::PythonSetDisabledColor(color_t disabledColor)
-{
- m_label.GetLabelInfo().disabledColor = disabledColor;
-}
-
-void CGUIButtonControl::SettingsCategorySetTextAlign(uint32_t align)
-{
- m_label.SetAlign(align);
-}
-
-void CGUIButtonControl::OnClick()
-{
- // Save values, as the click message may deactivate the window
- int controlID = GetID();
- int parentID = GetParentID();
- vector<CGUIActionDescriptor> clickActions = m_clickActions;
-
- // button selected, send a message
- CGUIMessage msg(GUI_MSG_CLICKED, controlID, parentID, 0);
- SendWindowMessage(msg);
-
- // and execute our actions
- for (unsigned int i = 0; i < clickActions.size(); i++)
- {
- CGUIMessage message(GUI_MSG_EXECUTE, controlID, parentID);
- message.SetAction(clickActions[i]);
- g_windowManager.SendMessage(message);
- }
-}
-
-void CGUIButtonControl::OnFocus()
-{
- for (unsigned int i = 0; i < m_focusActions.size(); i++)
- { // send using a thread message to ensure the UI is updated prior to message firing.
- CGUIMessage message(GUI_MSG_EXECUTE, m_controlID, m_parentID);
- message.SetAction(m_focusActions[i]);
- g_windowManager.SendThreadMessage(message);
- }
-}
-
-void CGUIButtonControl::OnUnFocus()
-{
- for (unsigned int i = 0; i < m_unfocusActions.size(); i++)
- { // send using a thread message to ensure the UI is updated prior to message firing.
- CGUIMessage message(GUI_MSG_EXECUTE, m_controlID, m_parentID);
- message.SetAction(m_unfocusActions[i]);
- g_windowManager.SendThreadMessage(message);
- }
-}
-
-void CGUIButtonControl::SetSelected(bool bSelected)
-{
- if (m_bSelected != bSelected)
- {
- m_bSelected = bSelected;
- SetInvalid();
- }
-}
-
diff --git a/guilib/GUIButtonControl.h b/guilib/GUIButtonControl.h
deleted file mode 100644
index fb7e3c1d3a..0000000000
--- a/guilib/GUIButtonControl.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*!
-\file GUIButtonControl.h
-\brief
-*/
-
-#ifndef GUILIB_GUIBUTTONCONTROL_H
-#define GUILIB_GUIBUTTONCONTROL_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUITexture.h"
-#include "GUILabel.h"
-#include "GUIControl.h"
-
-/*!
- \ingroup controls
- \brief
- */
-class CGUIButtonControl : public CGUIControl
-{
-public:
- CGUIButtonControl(int parentID, int controlID,
- float posX, float posY, float width, float height,
- const CTextureInfo& textureFocus, const CTextureInfo& textureNoFocus,
- const CLabelInfo &label);
-
- virtual ~CGUIButtonControl(void);
- virtual CGUIButtonControl *Clone() const { return new CGUIButtonControl(*this); };
-
- virtual void Render();
- virtual bool OnAction(const CAction &action) ;
- virtual bool OnMessage(CGUIMessage& message);
- virtual void AllocResources();
- virtual void FreeResources(bool immediately = false);
- virtual void DynamicResourceAlloc(bool bOnOff);
- virtual void SetInvalid();
- virtual void SetPosition(float posX, float posY);
- virtual void SetLabel(const std::string & aLabel);
- virtual void SetLabel2(const std::string & aLabel2);
- void SetClickActions(const std::vector<CGUIActionDescriptor>& clickActions) { m_clickActions = clickActions; };
- const std::vector<CGUIActionDescriptor> &GetClickActions() const { return m_clickActions; };
- void SetFocusActions(const std::vector<CGUIActionDescriptor>& focusActions) { m_focusActions = focusActions; };
- void SetUnFocusActions(const std::vector<CGUIActionDescriptor>& unfocusActions) { m_unfocusActions = unfocusActions; };
- const CLabelInfo& GetLabelInfo() const { return m_label.GetLabelInfo(); };
- virtual CStdString GetLabel() const { return GetDescription(); };
- virtual CStdString GetLabel2() const;
- void SetSelected(bool bSelected);
- virtual CStdString GetDescription() const;
- void SetAlpha(unsigned char alpha);
-
- void PythonSetLabel(const CStdString &strFont, const std::string &strText, color_t textColor, color_t shadowColor, color_t focusedColor);
- void PythonSetDisabledColor(color_t disabledColor);
-
- void SettingsCategorySetTextAlign(uint32_t align);
-
- virtual void OnClick();
- bool HasClickActions() { return m_clickActions.size() > 0; };
-
- virtual void UpdateColors();
-protected:
- friend class CGUISpinControlEx;
- virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event);
- void OnFocus();
- void OnUnFocus();
- virtual void RenderText();
- CGUILabel::COLOR GetTextColor() const;
-
- CGUITexture m_imgFocus;
- CGUITexture m_imgNoFocus;
- unsigned int m_focusCounter;
- unsigned char m_alpha;
-
- CGUIInfoLabel m_info;
- CGUIInfoLabel m_info2;
- CGUILabel m_label;
- CGUILabel m_label2;
-
- std::vector<CGUIActionDescriptor> m_clickActions;
- std::vector<CGUIActionDescriptor> m_focusActions;
- std::vector<CGUIActionDescriptor> m_unfocusActions;
-
- bool m_bSelected;
-};
-#endif
diff --git a/guilib/GUIButtonScroller.cpp b/guilib/GUIButtonScroller.cpp
deleted file mode 100644
index afe422b93f..0000000000
--- a/guilib/GUIButtonScroller.cpp
+++ /dev/null
@@ -1,919 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIButtonScroller.h"
-#include "GUITextLayout.h"
-#include "LocalizeStrings.h"
-#include "GUIWindowManager.h"
-#include "utils/CharsetConverter.h"
-#include "utils/GUIInfoManager.h"
-#include "StringUtils.h"
-#include "GUIControlFactory.h"
-#include "tinyXML/tinyxml.h"
-#include "Key.h"
-
-using namespace std;
-
-#define SCROLL_SPEED 6.0f
-#define ANALOG_SCROLL_START 0.8f
-
-CGUIButtonScroller::CGUIButtonScroller(int parentID, int controlID, float posX, float posY, float width, float height, float gap, int iSlots, int iDefaultSlot, int iMovementRange, bool bHorizontal, int iAlpha, bool bWrapAround, bool bSmoothScrolling, const CTextureInfo& textureFocus, const CTextureInfo& textureNoFocus, const CLabelInfo& labelInfo)
- : CGUIControl(parentID, controlID, posX, posY, width, height)
- , m_imgFocus(posX, posY, width, height, textureFocus)
- , m_imgNoFocus(posX, posY, width, height, textureNoFocus)
-{
- m_iXMLNumSlots = iSlots;
- m_iXMLDefaultSlot = iDefaultSlot - 1;
- m_xmlPosX = posX;
- m_xmlPosY = posY;
- m_xmlWidth = width;
- m_xmlHeight = height;
- m_buttonGap = gap;
- m_iNumSlots = iSlots;
- m_bHorizontal = bHorizontal;
- m_iDefaultSlot = iDefaultSlot - 1;
- m_iMovementRange = iMovementRange;
- m_iAlpha = iAlpha;
- m_bWrapAround = bWrapAround;
- m_bSmoothScrolling = bSmoothScrolling;
- m_iSlowScrollCount = 0;
- if (!m_bWrapAround)
- { // force the amount of movement to allow for the number of slots
- if (m_iMovementRange < m_iDefaultSlot) m_iMovementRange = m_iDefaultSlot;
- if (m_iMovementRange < m_iNumSlots - 1 - m_iDefaultSlot) m_iMovementRange = m_iNumSlots - 1 - m_iDefaultSlot;
- }
- // reset other variables to the defaults
- m_iCurrentSlot = -1;
- m_iOffset = 0;
- m_scrollOffset = 0;
- m_bScrollUp = false;
- m_bScrollDown = false;
- m_bMoveUp = false;
- m_bMoveDown = false;
- m_fAnalogScrollSpeed = 0;
- ControlType = GUICONTROL_BUTTONBAR;
- // m_dwFrameCounter = 0;
- m_label = labelInfo;
-}
-
-CGUIButtonScroller::CGUIButtonScroller(const CGUIButtonScroller &from)
-: CGUIControl(from), m_imgFocus(from.m_imgFocus), m_imgNoFocus(from.m_imgNoFocus)
-{
- m_iXMLNumSlots = from.m_iXMLNumSlots;
- m_iXMLDefaultSlot = from.m_iXMLDefaultSlot;
- m_xmlPosX = from.m_xmlPosX;
- m_xmlPosY = from.m_xmlPosY;
- m_xmlWidth = from.m_xmlWidth;
- m_xmlHeight = from.m_xmlHeight;
- m_buttonGap = from.m_buttonGap;
- m_iNumSlots = from.m_iNumSlots;
- m_bHorizontal = from.m_bHorizontal;
- m_iDefaultSlot = from.m_iDefaultSlot;
- m_iMovementRange = from.m_iMovementRange;
- m_iAlpha = from.m_iAlpha;
- m_bWrapAround = from.m_bWrapAround;
- m_bSmoothScrolling = from.m_bSmoothScrolling;
- m_iSlowScrollCount = 0;
- // reset other variables to the defaults
- m_iCurrentSlot = -1;
- m_iOffset = 0;
- m_scrollOffset = 0;
- m_bScrollUp = false;
- m_bScrollDown = false;
- m_bMoveUp = false;
- m_bMoveDown = false;
- m_fAnalogScrollSpeed = 0;
- ControlType = GUICONTROL_BUTTONBAR;
- // m_dwFrameCounter = 0;
- m_label = from.m_label;
- // TODO: Clone - copy the buttons across
-
-}
-
-CGUIButtonScroller::~CGUIButtonScroller(void)
-{}
-
-bool CGUIButtonScroller::OnAction(const CAction &action)
-{
- if (action.GetID() == ACTION_SELECT_ITEM)
- {
- // send the appropriate message to the parent window
- vector<CGUIActionDescriptor> actions = m_vecButtons[GetActiveButton()]->clickActions;
- for (unsigned int i = 0; i < actions.size(); i++)
- {
- CGUIMessage message(GUI_MSG_EXECUTE, GetID(), GetParentID());
- // find our currently highlighted item
- message.SetAction(actions[i]);
- g_windowManager.SendMessage(message);
- }
- return true;
- }
- if (action.GetID() == ACTION_CONTEXT_MENU)
- { // send a click message to our parent
- SEND_CLICK_MESSAGE(GetID(), GetParentID(), action.GetID());
- return true;
- }
- // smooth scrolling (for analog controls)
- if (action.GetID() == ACTION_SCROLL_UP)
- {
- m_fAnalogScrollSpeed += action.GetAmount() * action.GetAmount();
- bool handled = false;
- while (m_fAnalogScrollSpeed > ANALOG_SCROLL_START)
- {
- handled = true;
- m_fAnalogScrollSpeed -= ANALOG_SCROLL_START;
- if (!m_bWrapAround && m_iOffset + m_iCurrentSlot == 0)
- break;
- DoUp();
- }
- return handled;
- }
- if (action.GetID() == ACTION_SCROLL_DOWN)
- {
- m_fAnalogScrollSpeed += action.GetAmount() * action.GetAmount();
- bool handled = false;
- while (m_fAnalogScrollSpeed > ANALOG_SCROLL_START)
- {
- handled = true;
- m_fAnalogScrollSpeed -= ANALOG_SCROLL_START;
- if (!m_bWrapAround && (unsigned int)(m_iOffset + m_iCurrentSlot) == m_vecButtons.size() - 1)
- break;
- DoDown();
- }
- return handled;
- }
- return CGUIControl::OnAction(action);
-}
-
-bool CGUIButtonScroller::OnMessage(CGUIMessage &message)
-{
- if (message.GetMessage() == GUI_MSG_ITEM_SELECT)
- {
- SetActiveButton(message.GetParam1());
- }
- else if (message.GetMessage() == GUI_MSG_ITEM_SELECTED)
- {
- message.SetParam1(GetActiveButton());
- return true;
- }
- return CGUIControl::OnMessage(message);
-}
-
-void CGUIButtonScroller::ClearButtons()
-{
- // destroy our buttons (if we have them from a previous viewing)
- for (int i = 0; i < (int)m_vecButtons.size(); ++i)
- {
- CButton* pButton = m_vecButtons[i];
- delete pButton;
- }
- m_vecButtons.erase(m_vecButtons.begin(), m_vecButtons.end());
-}
-
-void CGUIButtonScroller::LoadButtons(TiXmlNode *node)
-{
- // run through and find all <button> tags
- // Format is:
- // <button id="1">
- // <label>
- // <execute>
- // <texturefocus>
- // <texturenofocus>
- // </button>
-
- // TODO: UTF-8 - what if the XML encoding is in UTF-8?
- TiXmlElement *buttons = node->FirstChildElement("buttons");
- if (!buttons) return;
-
- TiXmlElement *buttonNode = buttons->FirstChildElement("button");
- while (buttonNode)
- {
- CButton *button = new CButton;
- buttonNode->Attribute("id", &button->id);
- const TiXmlNode *childNode = buttonNode->FirstChild("label");
- if (childNode && childNode->FirstChild())
- {
- CStdString strLabel = childNode->FirstChild()->Value();
- if (StringUtils::IsNaturalNumber(strLabel))
- button->strLabel = g_localizeStrings.Get(atoi(strLabel.c_str()));
- else
- { // convert to UTF-8
- CStdString utf8String;
- g_charsetConverter.unknownToUTF8(strLabel, utf8String);
- button->strLabel = utf8String;
- }
- }
- // get info
- childNode = buttonNode->FirstChild("info");
- if (childNode && childNode->FirstChild())
- {
- button->info = g_infoManager.TranslateString(childNode->FirstChild()->Value());
- }
- childNode = buttonNode->FirstChild("execute");
- if (childNode && childNode->FirstChild())
- {
- CGUIActionDescriptor action;
- CGUIControlFactory::GetAction((const TiXmlElement*) childNode, action);
- button->clickActions.push_back(action);
- }
- childNode = buttonNode->FirstChild("onclick");
- while (childNode && childNode->FirstChild())
- {
- CGUIActionDescriptor action;
- CGUIControlFactory::GetAction((const TiXmlElement*) childNode, action);
- button->clickActions.push_back(action);
- childNode = childNode->NextSibling("onclick");
- }
- childNode = buttonNode->FirstChild("texturefocus");
- if (childNode && childNode->FirstChild())
- button->imageFocus = new CGUITexture(m_posX, m_posY, m_width, m_height, (CStdString)childNode->FirstChild()->Value());
- childNode = buttonNode->FirstChild("texturenofocus");
- if (childNode && childNode->FirstChild())
- button->imageNoFocus = new CGUITexture(m_posX, m_posY, m_width, m_height, (CStdString)childNode->FirstChild()->Value());
- m_vecButtons.push_back(button);
- buttonNode = buttonNode->NextSiblingElement("button");
- }
-}
-
-void CGUIButtonScroller::AllocResources()
-{
- CGUIControl::AllocResources();
- // m_dwFrameCounter=0;
- m_imgFocus.AllocResources();
- m_imgNoFocus.AllocResources();
- // calculate our correct width and height
- if (m_bHorizontal)
- {
- m_xmlWidth = (m_iXMLNumSlots * (m_imgFocus.GetWidth() + m_buttonGap) - m_buttonGap);
- m_xmlHeight = m_imgFocus.GetHeight();
- }
- else
- {
- m_xmlWidth = m_imgFocus.GetWidth();
- m_xmlHeight = (m_iXMLNumSlots * (m_imgFocus.GetHeight() + m_buttonGap) - m_buttonGap);
- }
- m_width = m_xmlWidth;
- m_height = m_xmlHeight;
- // update the number of filled slots etc.
- if ((int)m_vecButtons.size() < m_iXMLNumSlots)
- {
- m_iNumSlots = m_vecButtons.size();
- m_iDefaultSlot = (int)((float)m_iXMLDefaultSlot / ((float)m_iXMLNumSlots - 1) * ((float)m_iNumSlots - 1));
- }
- else
- {
- m_iNumSlots = m_iXMLNumSlots;
- m_iDefaultSlot = m_iXMLDefaultSlot;
- }
- SetActiveButton(0);
-}
-
-void CGUIButtonScroller::FreeResources(bool immediately)
-{
- CGUIControl::FreeResources(immediately);
- m_imgFocus.FreeResources(immediately);
- m_imgNoFocus.FreeResources(immediately);
- ClearButtons();
-}
-
-void CGUIButtonScroller::DynamicResourceAlloc(bool bOnOff)
-{
- CGUIControl::DynamicResourceAlloc(bOnOff);
- m_imgFocus.DynamicResourceAlloc(bOnOff);
- m_imgNoFocus.DynamicResourceAlloc(bOnOff);
-}
-
-void CGUIButtonScroller::SetInvalid()
-{
- CGUIControl::SetInvalid();
- m_imgFocus.SetInvalid();
- m_imgNoFocus.SetInvalid();
-}
-
-void CGUIButtonScroller::Render()
-{
- if (m_bInvalidated)
- {
- if (m_bHorizontal)
- {
- m_width = m_iNumSlots * (m_imgFocus.GetWidth() + m_buttonGap) - m_buttonGap;
- m_height = m_imgFocus.GetHeight();
- m_posX = m_xmlPosX + (m_xmlWidth - m_width) * 0.5f;
- m_posY = m_xmlPosY;
- }
- else
- {
- m_width = m_imgFocus.GetWidth();
- m_height = m_iNumSlots * (m_imgFocus.GetHeight() + m_buttonGap) - m_buttonGap;
- m_posX = m_xmlPosX;
- m_posY = m_xmlPosY + (m_xmlHeight - m_height) * 0.5f;
- }
- }
- float posX = m_posX;
- float posY = m_posY;
- // set our viewport
- g_graphicsContext.SetClipRegion(posX, posY, m_width, m_height);
- // if we're scrolling, update our scroll offset
- if (m_bScrollUp || m_bScrollDown)
- {
- float maxScroll = m_bHorizontal ? m_imgFocus.GetWidth() : m_imgFocus.GetHeight();
- maxScroll += m_buttonGap;
- m_scrollOffset += (int)(maxScroll / m_fScrollSpeed) + 1;
- if (m_scrollOffset > maxScroll || !m_bSmoothScrolling)
- {
- m_scrollOffset = 0;
- if (m_bScrollUp)
- {
- if (GetNext(m_iOffset) != -1) m_iOffset = GetNext(m_iOffset);
- }
- else
- {
- if (GetPrevious(m_iOffset) != -1) m_iOffset = GetPrevious(m_iOffset);
- }
- // check for wraparound...
- if (!m_bWrapAround)
- {
- if (m_iOffset + m_iNumSlots > (int)m_vecButtons.size())
- m_iOffset = GetPrevious(m_iOffset);
- }
- m_bScrollUp = false;
- m_bScrollDown = false;
- }
- else
- {
- if (m_bScrollUp)
- {
- if (m_bHorizontal)
- posX -= m_scrollOffset;
- else
- posY -= m_scrollOffset;
- }
- else
- {
- if (m_bHorizontal)
- posX += m_scrollOffset - maxScroll;
- else
- posY += m_scrollOffset - maxScroll;
- }
- }
- }
- float posX3 = posX;
- float posY3 = posY;
- // ok, now check if we're scrolling down
- int iOffset = m_iOffset;
- if (m_bScrollDown)
- {
- iOffset = GetPrevious(iOffset);
- RenderItem(posX, posY, iOffset, false);
- }
- // ok, now render the main block
- for (int i = 0; i < m_iNumSlots; i++)
- RenderItem(posX, posY, iOffset, false);
- // ok, now check if we're scrolling up
- if (m_bScrollUp)
- RenderItem(posX, posY, iOffset, false);
- // ok, now render the background slot...
- if (HasFocus())
- {
- posX = m_posX;
- posY = m_posY;
- // check if we're moving up or down
- if (m_bMoveUp || m_bMoveDown)
- {
- float maxScroll = m_bHorizontal ? m_imgFocus.GetWidth() : m_imgFocus.GetHeight();
- maxScroll += m_buttonGap;
- m_scrollOffset += maxScroll / SCROLL_SPEED + 1;
- if (m_scrollOffset > maxScroll || !m_bSmoothScrolling)
- {
- m_scrollOffset = 0;
- if (m_bMoveUp)
- {
- if (m_iCurrentSlot > 0)
- m_iCurrentSlot--;
- }
- else
- {
- if (m_iCurrentSlot + 1 < m_iNumSlots)
- m_iCurrentSlot++;
- }
- m_bMoveUp = false;
- m_bMoveDown = false;
- }
- else
- {
- if (m_bMoveUp)
- {
- if (m_bHorizontal)
- posX -= m_scrollOffset;
- else
- posY -= m_scrollOffset;
- }
- else
- {
- if (m_bHorizontal)
- posX += m_scrollOffset;
- else
- posY += m_scrollOffset;
- }
- }
- }
- if (m_bHorizontal)
- posX += m_iCurrentSlot * ((int)m_imgFocus.GetWidth() + m_buttonGap);
- else
- posY += m_iCurrentSlot * ((int)m_imgFocus.GetHeight() + m_buttonGap);
- // check if we have a skinner-defined icon image
- CGUITexture *pImage = m_vecButtons[GetActiveButton()]->imageFocus;
- if (pImage && (m_bScrollUp || m_bScrollDown))
- pImage = NULL;
- else if (!pImage)
- pImage = &m_imgFocus;
- if (pImage)
- {
- pImage->SetPosition(posX, posY);
- pImage->SetVisible(true);
- pImage->SetWidth(m_imgFocus.GetWidth());
- pImage->SetHeight(m_imgFocus.GetHeight());
- pImage->Render();
- }
- }
- // Now render the text
- iOffset = m_iOffset;
- posX = posX3;
- posY = posY3;
- if (m_bScrollDown)
- {
- iOffset = GetPrevious(iOffset);
- RenderItem(posX, posY, iOffset, true);
- }
- // ok, now render the main block
- for (int i = 0; i < m_iNumSlots; i++)
- RenderItem(posX, posY, iOffset, true);
- // ok, now check if we're scrolling up
- if (m_bScrollUp)
- RenderItem(posX, posY, iOffset, true);
-
- // reset the viewport
- g_graphicsContext.RestoreClipRegion();
- CGUIControl::Render();
-}
-
-int CGUIButtonScroller::GetNext(int iCurrent) const
-{
- if (iCurrent + 1 >= (int)m_vecButtons.size())
- {
- if (m_bWrapAround)
- return 0;
- else
- return -1;
- }
- else
- return iCurrent + 1;
-}
-
-int CGUIButtonScroller::GetPrevious(int iCurrent)
-{
- if (iCurrent - 1 < 0)
- {
- if (m_bWrapAround)
- return m_vecButtons.size() - 1;
- else
- return -1;
- }
- else
- return iCurrent -1;
-}
-
-int CGUIButtonScroller::GetButton(int iOffset)
-{
- return iOffset % ((int)m_vecButtons.size());
-}
-
-void CGUIButtonScroller::SetActiveButton(int iButton)
-{
- if (iButton >= (int)m_vecButtons.size())
- iButton = 0;
- // set the highlighted button
- m_iCurrentSlot = m_iDefaultSlot;
- // and the appropriate offset
- if (!m_bWrapAround)
- { // check whether there is no wiggle room
- int iMinButton = m_iDefaultSlot - m_iMovementRange;
- if (iMinButton < 0) iMinButton = 0;
- if (iButton < iMinButton)
- {
- m_iOffset = 0;
- m_iCurrentSlot = iMinButton;
- return ;
- }
- int iMaxButton = m_iDefaultSlot + m_iMovementRange;
- if (iMaxButton >= m_iNumSlots) iMaxButton = m_iNumSlots - 1;
- if (iButton > iMaxButton)
- {
- m_iOffset = iButton - iMaxButton;
- m_iCurrentSlot = iMaxButton;
- return ;
- }
- // now change our current slot so that it all fits nicely
- // lastly, make sure we fill the number of slots that we have (if possible)
- int iNumButtonsToShow = m_vecButtons.size() - iButton + m_iCurrentSlot;
- if (iNumButtonsToShow < m_iNumSlots && iNumButtonsToShow < (int)m_vecButtons.size())
- { // we have empty space - try and fill it up
- while (iNumButtonsToShow < (int)m_vecButtons.size() && m_iCurrentSlot + 1 < m_iNumSlots)
- {
- m_iCurrentSlot++;
- iNumButtonsToShow = m_vecButtons.size() - iButton + m_iCurrentSlot;
- }
- }
- }
- m_iOffset = 0;
- for (int i = 0; i < (int)m_vecButtons.size(); i++)
- {
- int iItem = i;
- for (int j = 0; j < m_iCurrentSlot; j++)
- if (GetNext(iItem) != -1) iItem = GetNext(iItem);
- if (iItem == iButton)
- {
- m_iOffset = i;
- break;
- }
- }
-}
-
-void CGUIButtonScroller::OnUp()
-{
- if (m_bHorizontal)
- CGUIControl::OnUp();
- else if (!m_bWrapAround && m_iOffset + m_iCurrentSlot == 0)
- {
- if (m_controlUp != GetID())
- CGUIControl::OnUp(); // not wrapping around, and we're up the top + our next control is different
- else
- SetActiveButton((int)m_vecButtons.size() - 1); // move to the last button in the list
- }
- else
- DoUp();
-}
-
-void CGUIButtonScroller::OnDown()
-{
- if (m_bHorizontal)
- CGUIControl::OnDown();
- else if (!m_bWrapAround && (unsigned int) (m_iOffset + m_iCurrentSlot) == m_vecButtons.size() - 1)
- {
- if (m_controlUp != GetID())
- CGUIControl::OnDown(); // not wrapping around, and we're down the bottom + our next control is different
- else
- SetActiveButton(0); // move to the first button in the list
- }
- else
- DoDown();
-}
-
-void CGUIButtonScroller::OnLeft()
-{
- if (!m_bHorizontal)
- CGUIControl::OnLeft();
- else if (!m_bWrapAround && m_iOffset + m_iCurrentSlot == 0 && m_controlLeft != GetID())
- CGUIControl::OnLeft(); // not wrapping around, and we're at the left + our next control is different
- else
- DoUp();
-}
-
-void CGUIButtonScroller::OnRight()
-{
- if (!m_bHorizontal)
- CGUIControl::OnRight();
- else if (!m_bWrapAround && (unsigned int) (m_iOffset + m_iCurrentSlot) == m_vecButtons.size() - 1 && m_controlRight != GetID())
- CGUIControl::OnRight(); // not wrapping around, and we're at the right + our next control is different
- else
- DoDown();
-}
-
-void CGUIButtonScroller::DoUp()
-{
- if (!m_bScrollUp)
- {
- if (m_iCurrentSlot - 1 < m_iDefaultSlot - m_iMovementRange || m_iCurrentSlot - 1 < 0)
- {
- if (m_bScrollDown)
- { // finish scroll for higher speed
- m_bScrollDown = false;
- m_scrollOffset = 0;
- m_iOffset = GetPrevious(m_iOffset);
- }
- else
- {
- m_bScrollDown = true;
- m_fScrollSpeed = SCROLL_SPEED;
- }
- }
- else
- {
- if (m_bMoveUp)
- {
- m_bMoveUp = false;
- m_scrollOffset = 0;
- if (m_iCurrentSlot > 0) m_iCurrentSlot--;
- }
- m_bMoveUp = true;
- }
- }
-}
-
-void CGUIButtonScroller::DoDown()
-{
- if (!m_bScrollDown)
- {
- if (m_iCurrentSlot + 1 > m_iDefaultSlot + m_iMovementRange || m_iCurrentSlot + 1 >= m_iNumSlots)
- if (m_bScrollUp)
- { // finish scroll for higher speed
- m_bScrollUp = false;
- m_scrollOffset = 0;
- if (GetNext(m_iOffset) != -1) m_iOffset = GetNext(m_iOffset);
- }
- else
- {
- m_bScrollUp = true;
- m_fScrollSpeed = SCROLL_SPEED;
- }
- else
- {
- if (m_bMoveDown)
- {
- m_bMoveDown = false;
- m_scrollOffset = 0;
- if (m_iCurrentSlot + 1 < m_iNumSlots) m_iCurrentSlot++;
- }
- m_bMoveDown = true;
- }
- }
-}
-
-void CGUIButtonScroller::UpdateColors()
-{
- m_label.UpdateColors();
- CGUIControl::UpdateColors();
-}
-
-void CGUIButtonScroller::RenderItem(float &posX, float &posY, int &iOffset, bool bText)
-{
- if (iOffset < 0) return ;
- float fStartAlpha, fEndAlpha;
- GetScrollZone(fStartAlpha, fEndAlpha);
- if (bText)
- {
- if (!m_label.font) return ;
- float fPosX = posX + m_label.offsetX;
- float fPosY = posY + m_label.offsetY;
- if (m_label.align & XBFONT_RIGHT)
- fPosX = posX + m_imgFocus.GetWidth() - m_label.offsetX;
- if (m_label.align & XBFONT_CENTER_X)
- fPosX = posX + m_imgFocus.GetWidth() / 2;
- if (m_label.align & XBFONT_CENTER_Y)
- fPosY = posY + m_imgFocus.GetHeight() / 2;
-
- // label is from <info> tag first, and if that's blank,
- // we use the <label> tag
- CStdString label = g_infoManager.GetLabel(m_vecButtons[iOffset]->info);
- if (label.IsEmpty())
- label = m_vecButtons[iOffset]->strLabel;
-
- float fAlpha = 255.0f;
- if (m_bHorizontal)
- {
- if (fPosX < fStartAlpha)
- fAlpha -= (fStartAlpha - fPosX) / (fStartAlpha - m_posX) * m_iAlpha * 2.55f;
- if (fPosX > fEndAlpha)
- fAlpha -= (fPosX - fEndAlpha) / (m_posX + m_width - fEndAlpha) * m_iAlpha * 2.55f;
- }
- else
- {
- if (fPosY < fStartAlpha)
- fAlpha -= (fStartAlpha - fPosY) / (fStartAlpha - m_posY) * m_iAlpha * 2.55f;
- if (fPosY > fEndAlpha)
- fAlpha -= (fPosY - fEndAlpha) / (m_posY + m_height - fEndAlpha) * m_iAlpha * 2.55f;
- }
- if (fAlpha < 1) fAlpha = 1; // don't quite go all the way transparent,
- // as any shadow colour will not be rendered transparent if
- // it's defined in the font class
- if (fAlpha > 255) fAlpha = 255.0f;
- color_t alpha = (color_t)(fAlpha + 0.5f);
- color_t color = (m_label.focusedColor && iOffset == GetActiveButton()) ? m_label.focusedColor : m_label.textColor;
- color_t blendedAlpha = (alpha * ((color & 0xff000000) >> 24)) / 255;
- color_t blendedColor = (blendedAlpha << 24) | (color & 0xFFFFFF);
- blendedAlpha = (alpha * ((m_label.shadowColor & 0xff000000) >> 24)) / 255;
- color_t shadowColor = (blendedAlpha << 24) | (m_label.shadowColor & 0xFFFFFF);
- CGUITextLayout::DrawText(m_label.font, fPosX, fPosY, blendedColor, shadowColor, label, m_label.align);
- }
- else
- {
- float fAlpha = 255.0f;
- // check if we have a skinner-defined texture...
- CGUITexture *pImage = m_vecButtons[iOffset]->imageNoFocus;
- if (!pImage) pImage = &m_imgNoFocus;
- pImage->SetAlpha(0xFF);
- pImage->SetVisible(true);
- if (m_bHorizontal)
- {
- if (posX < fStartAlpha)
- {
- fAlpha -= (fStartAlpha - posX) / (fStartAlpha - m_posX) * m_iAlpha * 2.55f;
- }
- if (posX >= fEndAlpha)
- {
- fAlpha -= (posX - fEndAlpha) / (m_posX + m_width - fEndAlpha) * m_iAlpha * 2.55f;
- }
- if (fAlpha < 0) fAlpha = 0;
- if (fAlpha > 255) fAlpha = 255.0f;
- pImage->SetAlpha((unsigned char)(fAlpha + 0.5f));
- }
- else
- {
- if (posY < fStartAlpha)
- {
- fAlpha -= (fStartAlpha - posY) / (fStartAlpha - m_posY) * m_iAlpha * 2.55f;
- }
- if (posY > fEndAlpha)
- {
- fAlpha -= (posY - fEndAlpha) / (m_posY + m_height - fEndAlpha) * m_iAlpha * 2.55f;
- }
- if (fAlpha < 0) fAlpha = 0;
- if (fAlpha > 255) fAlpha = 255.0f;
- pImage->SetAlpha((unsigned char)(fAlpha + 0.5f));
- }
- pImage->SetPosition(posX, posY);
- pImage->SetWidth(m_imgNoFocus.GetWidth());
- pImage->SetHeight(m_imgNoFocus.GetHeight());
- pImage->Render();
- }
- iOffset = GetNext(iOffset);
- if (m_bHorizontal)
- posX += m_imgFocus.GetWidth() + m_buttonGap;
- else
- posY += m_imgFocus.GetHeight() + m_buttonGap;
-}
-
-int CGUIButtonScroller::GetActiveButtonID() const
-{
- int iButton = GetActiveButton();
- if (iButton < 0 || iButton >= (int)m_vecButtons.size()) return 0;
- return m_vecButtons[iButton]->id;
-}
-
-int CGUIButtonScroller::GetActiveButton() const
-{
- if (m_iCurrentSlot < 0) return -1;
- int iCurrentItem = m_iOffset;
- for (int i = 0; i < m_iCurrentSlot; i++)
- if (GetNext(iCurrentItem) != -1) iCurrentItem = GetNext(iCurrentItem);
- return iCurrentItem;
-}
-
-void CGUIButtonScroller::GetScrollZone(float &fStartAlpha, float &fEndAlpha)
-{
- // check if we are in the scrollable zone (alpha fade area)
- // calculate our alpha amount
- int iMinSlot = m_iDefaultSlot - m_iMovementRange;
- if (iMinSlot < 0) iMinSlot = 0;
- int iMaxSlot = m_iDefaultSlot + m_iMovementRange + 1;
- if (iMaxSlot > m_iNumSlots) iMaxSlot = m_iNumSlots;
- // calculate the amount of pixels between 0 and iMinSlot
- if (m_bHorizontal)
- {
- fStartAlpha = m_posX + iMinSlot * (m_imgFocus.GetWidth() + m_buttonGap);
- fEndAlpha = m_posX + iMaxSlot * (m_imgFocus.GetWidth() + m_buttonGap) - m_buttonGap;
- }
- else
- {
- fStartAlpha = m_posY + iMinSlot * (m_imgFocus.GetHeight() + m_buttonGap);
- fEndAlpha = m_posY + iMaxSlot * (m_imgFocus.GetHeight() + m_buttonGap) - m_buttonGap;
- }
-}
-
-bool CGUIButtonScroller::OnMouseOver(const CPoint &point)
-{
- float fStartAlpha, fEndAlpha;
- GetScrollZone(fStartAlpha, fEndAlpha);
- if (m_bHorizontal)
- {
- if (point.x < fStartAlpha) // scroll down
- {
- m_bScrollUp = false;
- if (m_iSlowScrollCount > 10) m_iSlowScrollCount = 0;
- if (m_bSmoothScrolling || m_iSlowScrollCount == 0)
- m_bScrollDown = true;
- else
- m_bScrollDown = false;
- m_iSlowScrollCount++;
- m_fScrollSpeed = 50.0f + SCROLL_SPEED - (point.x - fStartAlpha) / (m_posX - fStartAlpha) * 50.0f;
- }
- else if (point.x > fEndAlpha - 1) // scroll up
- {
- m_bScrollDown = false;
- if (m_iSlowScrollCount > 10) m_iSlowScrollCount = 0;
- if (m_bSmoothScrolling || m_iSlowScrollCount == 0)
- m_bScrollUp = true;
- else
- m_bScrollUp = false;
- m_fScrollSpeed = 50.0f + SCROLL_SPEED - (point.x - fEndAlpha) / (m_posX + m_width - fEndAlpha) * 50.0f;
- }
- else // call base class
- { // select the appropriate item, and call the base class (to set focus)
- m_iCurrentSlot = (int)((point.x - m_posX) / (m_imgFocus.GetWidth() + m_buttonGap));
- }
- }
- else
- {
- if (point.y < fStartAlpha) // scroll down
- {
- m_bScrollUp = false;
- if (m_iSlowScrollCount > 10) m_iSlowScrollCount = 0;
- if (m_bSmoothScrolling || m_iSlowScrollCount == 0)
- m_bScrollDown = true;
- else
- m_bScrollDown = false;
- m_iSlowScrollCount++;
- m_fScrollSpeed = 50.0f + SCROLL_SPEED - (point.y - fStartAlpha) / (m_posY - fStartAlpha) * 50.0f;
- }
- else if (point.y > fEndAlpha - 1) // scroll up
- {
- m_bScrollDown = false;
- if (m_iSlowScrollCount > 10) m_iSlowScrollCount = 0;
- if (m_bSmoothScrolling || m_iSlowScrollCount == 0)
- m_bScrollUp = true;
- else
- m_bScrollUp = false;
- m_iSlowScrollCount++; m_fScrollSpeed = 50.0f + SCROLL_SPEED - (point.y - fEndAlpha) / (m_posY + m_height - fEndAlpha) * 50.0f;
- }
- else
- { // select the appropriate item, and call the base class (to set focus)
- m_iCurrentSlot = (int)((point.y - m_posY) / (m_imgFocus.GetHeight() + m_buttonGap));
- }
- }
- return CGUIControl::OnMouseOver(point);
-}
-
-EVENT_RESULT CGUIButtonScroller::OnMouseEvent(const CPoint &point, const CMouseEvent &event)
-{
- float fStartAlpha, fEndAlpha;
- GetScrollZone(fStartAlpha, fEndAlpha);
- if ((m_bHorizontal && point.x >= fStartAlpha && point.x <= fEndAlpha) ||
- (!m_bHorizontal && point.y >= fStartAlpha && point.y <= fEndAlpha))
- {
- if (event.m_id == ACTION_MOUSE_LEFT_CLICK)
- {
- if (m_bHorizontal)
- m_iCurrentSlot = (int)((point.x - m_posX) / (m_imgFocus.GetWidth() + m_buttonGap));
- else
- m_iCurrentSlot = (int)((point.y - m_posY) / (m_imgFocus.GetHeight() + m_buttonGap));
- OnAction(CAction(ACTION_SELECT_ITEM));
- return EVENT_RESULT_HANDLED;
- }
- else if (event.m_id == ACTION_MOUSE_WHEEL_UP)
- {
- m_bScrollDown = true;
- m_fScrollSpeed = SCROLL_SPEED;
- return EVENT_RESULT_HANDLED;
- }
- else if (event.m_id == ACTION_MOUSE_WHEEL_DOWN)
- {
- m_bScrollUp = true;
- m_fScrollSpeed = SCROLL_SPEED;
- return EVENT_RESULT_HANDLED;
- }
- }
- return EVENT_RESULT_UNHANDLED;
-}
-
-CStdString CGUIButtonScroller::GetDescription() const
-{
- if (GetActiveButton() >= 0)
- {
- CStdString strLabel = m_vecButtons[GetActiveButton()]->strLabel;
- return strLabel;
- }
- return "";
-}
-
-void CGUIButtonScroller::SaveStates(vector<CControlState> &states)
-{
- states.push_back(CControlState(GetID(), GetActiveButton()));
-}
diff --git a/guilib/GUIButtonScroller.h b/guilib/GUIButtonScroller.h
deleted file mode 100644
index 1f7c248659..0000000000
--- a/guilib/GUIButtonScroller.h
+++ /dev/null
@@ -1,129 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIControl.h"
-#include "GUITexture.h"
-#include "GUIActionDescriptor.h"
-#include "GUILabel.h"
-
-class TiXmlNode;
-
-class CButton
-{
-public:
- CButton()
- {
- id = 0;
- info = 0;
- imageFocus = imageNoFocus = NULL;
- };
- ~CButton()
- {
- delete imageFocus;
- delete imageNoFocus;
- }
- int id;
- int info;
- std::string strLabel;
- std::vector<CGUIActionDescriptor> clickActions;
- CGUITexture *imageFocus;
- CGUITexture *imageNoFocus;
-};
-
-class CGUIButtonScroller :
- public CGUIControl
-{
-public:
- CGUIButtonScroller(int parentID, int controlID, float posX, float posY, float width, float height, float gap, int iSlots, int iDefaultSlot, int iMovementRange, bool bHorizontal, int iAlpha, bool bWrapAround, bool bSmoothScrolling, const CTextureInfo& textureFocus, const CTextureInfo& textureNoFocus, const CLabelInfo& labelInfo);
- CGUIButtonScroller(const CGUIButtonScroller &from);
- virtual ~CGUIButtonScroller(void);
- virtual CGUIButtonScroller *Clone() const { return new CGUIButtonScroller(*this); };
-
- virtual bool OnAction(const CAction &action);
- virtual bool OnMessage(CGUIMessage &message);
- virtual void OnUp();
- virtual void OnLeft();
- virtual void OnRight();
- virtual void OnDown();
- virtual bool OnMouseOver(const CPoint &point);
- virtual void Render();
- virtual void AllocResources();
- virtual void FreeResources(bool immediately = false);
- virtual void DynamicResourceAlloc(bool bOnOff);
- virtual void SetInvalid();
- void ClearButtons();
- void AddButton(const std::string &strLabel, const CStdString &strExecute, const int iIcon);
- void SetActiveButton(int iButton);
- int GetActiveButton() const;
- int GetActiveButtonID() const;
- virtual CStdString GetDescription() const;
- virtual void SaveStates(std::vector<CControlState> &states);
- void LoadButtons(TiXmlNode *node);
-
-protected:
- virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event);
- virtual void UpdateColors();
- int GetNext(int iCurrent) const;
- int GetPrevious(int iCurrent);
- int GetButton(int iOffset);
- void DoUp();
- void DoDown();
- void RenderItem(float &posX, float &posY, int &iOffset, bool bText);
- void GetScrollZone(float &fStartAlpha, float &fEndAlpha);
-private:
- // saved variables from the xml (as this control is user editable...)
- int m_iXMLNumSlots;
- int m_iXMLDefaultSlot;
- float m_xmlPosX;
- float m_xmlPosY;
- float m_xmlWidth;
- float m_xmlHeight;
-
- float m_buttonGap; // gap between buttons
- int m_iNumSlots; // number of button slots available
- int m_iDefaultSlot; // default highlight position
- int m_iMovementRange; // amoung that we can move the highlight
- bool m_bHorizontal; // true if it's a horizontal button bar
- int m_iAlpha; // amount of alpha (0..100)
- bool m_bWrapAround; // whether the buttons wrap around or not
- bool m_bSmoothScrolling; // whether there is smooth scrolling or not
-
- int m_iCurrentSlot; // currently highlighted slot
-
- int m_iOffset; // first item in the list
- float m_scrollOffset; // offset when scrolling
- bool m_bScrollUp; // true if we're scrolling up (or left)
- bool m_bScrollDown; // true if scrolling down (or right)
- bool m_bMoveUp; // true if we're scrolling up (or left)
- bool m_bMoveDown; // true if scrolling down (or right)
- float m_fScrollSpeed; // speed of scrolling
- float m_fAnalogScrollSpeed; // speed of analog scroll (triggers)
- // stuff we need for the buttons...
- std::vector<CButton*> m_vecButtons;
- typedef std::vector<CButton*>::iterator ivecButtons;
- CGUITexture m_imgFocus;
- CGUITexture m_imgNoFocus;
-
- CLabelInfo m_label;
- int m_iSlowScrollCount;
-};
diff --git a/guilib/GUICallback.h b/guilib/GUICallback.h
deleted file mode 100644
index 9e2deb5767..0000000000
--- a/guilib/GUICallback.h
+++ /dev/null
@@ -1,193 +0,0 @@
-#if !defined(GUICALLBACK_H)
-#define GUICALLBACK_H
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "assert.h"
-#include "memory.h"
-
-#ifndef __GNUC__
-#pragma warning( disable : 4786 )
-#endif
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-// NOTE FROM RUNTiME: An Event holds a weak reference to class method, it acts similar to a //
-// C# delegate method E.g. instantiate an Event and assign it an EventHandler, whenever the //
-// Event is fired the EventHandler is executed. //
-// - There is a 2nd variant of Event called a Callback, this only differs in that a Callback //
-// can return a value after the CallbackHandler has been executed. //
-// - There is a nasty memcpy that gets us over the compiler restriction that prevents us from //
-// casting between two different method pointers, not the cleanest solution granted, but it's //
-// the only way I know how to get around this limitation. //
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-template <class Cookie>
-class GUIEvent
-{
-public:
-
- typedef void (GUIEvent::*MethodPtr)(Cookie);
-
- GUIEvent()
- {
- m_pInstance = NULL;
- m_pMethod = NULL;
- }
-
- // Assign an EventHandler (EventHandler's are derived from Event)
- GUIEvent<Cookie> &operator=(GUIEvent<Cookie> &aEvent)
- {
- if (&aEvent)
- {
- m_pInstance = aEvent.m_pInstance;
- m_pMethod = aEvent.m_pMethod;
- }
- else
- {
- GUIEvent();
- }
-
- return *this;
- }
-
- // Are the class instance and method pointers initialised?
- bool HasAHandler()
- {
- return (m_pInstance && m_pMethod);
- }
-
- // Execute the associated class method
- void Fire(Cookie aCookie)
- {
- if (HasAHandler())
- {
- (m_pInstance->*m_pMethod)(aCookie);
- }
- else
- {
- // Event is uninitialized, no handler has been assigned
- assert(0);
- }
- }
- MethodPtr m_pMethod;
-
-protected:
- GUIEvent* m_pInstance;
-};
-
-template <class Class, class Cookie>
-class GUIEventHandler : public GUIEvent<Cookie>
-{
-public:
- typedef void (Class::*MethodPtr)(Cookie);
-
- GUIEventHandler(Class* pInstance, MethodPtr aMethodPtr)
- {
- GUIEvent<Cookie>::m_pInstance = (GUIEvent<Cookie>*) ((LPVOID) pInstance);
-
-#ifndef _LINUX
- // Its dirty but it works!
- memcpy(&m_pMethod, &aMethodPtr, sizeof(GUIEvent<Cookie>::m_pMethod));
-#else
- // Well, GCC doesn't like that dirty stuff... here's another version of the same thing
- // but even dirtier *grin*
-
-#define my_offsetof(TYPE, MEMBER) \
- ((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10))
-
- void* target = (void*) (((char*) this) + my_offsetof(GUIEvent<Cookie>, m_pMethod));
- memcpy(target, &aMethodPtr, sizeof(GUIEvent<Cookie>::m_pMethod));
-#endif
- }
-};
-
-
-// Callbacks are identical to Events except that a Callback returns a result value
-template <class Result, class Cookie>
-class Callback
-{
-public:
- typedef Result (Callback::*MethodPtr)(Cookie);
-
- Callback()
- {
- m_pInstance = NULL;
- m_pMethod = NULL;
- }
-
- // Assign a CallbackHandler (CallbackHandler's are derived from Callback)
- Callback<Result, Cookie> &operator=(Callback<Result, Cookie> &aCallback)
- {
- if (&aCallback)
- {
- m_pInstance = aCallback.m_pInstance;
- m_pMethod = aCallback.m_pMethod;
- }
- else
- {
- Callback();
- }
-
- return *this;
- }
-
- // Are the class instance and method pointers initialised?
- bool HasAHandler()
- {
- return (m_pInstance && m_pMethod);
- }
-
- // Execute the associated class method and return the result
- Result Fire(Cookie aCookie)
- {
- if (HasAHandler())
- {
- return (m_pInstance->*m_pMethod)(aCookie);
- }
-
- // Callback is uninitialized, no handler has been assigned
- assert(0);
- return 0;
- }
-
-protected:
- Callback* m_pInstance;
- MethodPtr m_pMethod;
-};
-
-
-template <class Class, class Result, class Cookie>
-class CallbackHandler : public Callback<Result, Cookie>
-{
-public:
- typedef Result (Class::*MethodPtr)(Cookie);
-
- CallbackHandler (Class* pInstance, MethodPtr aMethodPtr)
- {
- Callback<Result, Cookie>::m_pInstance = (Callback<Result, Cookie>*) ((LPVOID) pInstance);
- // Its dirty but it works!
- memcpy(&Callback<Result, Cookie>::m_pMethod, &aMethodPtr, sizeof(Callback<Result, Cookie>::m_pMethod));
- }
-};
-
-#endif // GUICALLBACK_H
-
diff --git a/guilib/GUICheckMarkControl.cpp b/guilib/GUICheckMarkControl.cpp
deleted file mode 100644
index 3327c45b20..0000000000
--- a/guilib/GUICheckMarkControl.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUICheckMarkControl.h"
-#include "utils/CharsetConverter.h"
-#include "GUIFontManager.h"
-#include "Key.h"
-
-using namespace std;
-
-CGUICheckMarkControl::CGUICheckMarkControl(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& textureCheckMark, const CTextureInfo& textureCheckMarkNF, float checkWidth, float checkHeight, const CLabelInfo &labelInfo)
- : CGUIControl(parentID, controlID, posX, posY, width, height)
- , m_imgCheckMark(posX, posY, checkWidth, checkHeight, textureCheckMark)
- , m_imgCheckMarkNoFocus(posX, posY, checkWidth, checkHeight, textureCheckMarkNF)
- , m_label(posX, posY, width, height, labelInfo)
-{
- m_strLabel = "";
- m_bSelected = false;
- m_label.GetLabelInfo().align |= XBFONT_CENTER_Y;
- ControlType = GUICONTROL_CHECKMARK;
-}
-
-CGUICheckMarkControl::~CGUICheckMarkControl(void)
-{}
-
-void CGUICheckMarkControl::Render()
-{
- m_label.SetText(m_strLabel);
-
- float textWidth = m_label.GetTextWidth();
- m_width = textWidth + 5 + m_imgCheckMark.GetWidth();
- m_height = m_imgCheckMark.GetHeight();
-
- float textPosX = m_posX;
- float checkMarkPosX = m_posX;
-
- if (m_label.GetLabelInfo().align & (XBFONT_RIGHT | XBFONT_CENTER_X))
- textPosX += m_imgCheckMark.GetWidth() + 5;
- else
- checkMarkPosX += textWidth + 5;
-
- m_label.SetMaxRect(textPosX, m_posY, textWidth, m_height);
- m_label.SetColor(GetTextColor());
- m_label.Render();
-
- if (m_bSelected)
- {
- m_imgCheckMark.SetPosition(checkMarkPosX, m_posY);
- m_imgCheckMark.Render();
- }
- else
- {
- m_imgCheckMarkNoFocus.SetPosition(checkMarkPosX, m_posY);
- m_imgCheckMarkNoFocus.Render();
- }
- CGUIControl::Render();
-}
-
-CGUILabel::COLOR CGUICheckMarkControl::GetTextColor() const
-{
- if (IsDisabled())
- return CGUILabel::COLOR_DISABLED;
- else if (HasFocus())
- return CGUILabel::COLOR_FOCUSED;
- return CGUILabel::COLOR_TEXT;
-}
-
-bool CGUICheckMarkControl::OnAction(const CAction &action)
-{
- if (action.GetID() == ACTION_SELECT_ITEM)
- {
- m_bSelected = !m_bSelected;
- CGUIMessage msg(GUI_MSG_CLICKED, GetID(), GetParentID(), action.GetID());
- SendWindowMessage(msg);
- return true;
- }
- return CGUIControl::OnAction(action);
-}
-
-bool CGUICheckMarkControl::OnMessage(CGUIMessage& message)
-{
- if ( message.GetControlId() == GetID() )
- {
- if (message.GetMessage() == GUI_MSG_LABEL_SET)
- {
- m_strLabel = message.GetLabel();
- return true;
- }
- }
- if (CGUIControl::OnMessage(message)) return true;
- return false;
-}
-
-void CGUICheckMarkControl::AllocResources()
-{
- CGUIControl::AllocResources();
- m_imgCheckMark.AllocResources();
- m_imgCheckMarkNoFocus.AllocResources();
-}
-
-void CGUICheckMarkControl::FreeResources(bool immediately)
-{
- CGUIControl::FreeResources(immediately);
- m_imgCheckMark.FreeResources(immediately);
- m_imgCheckMarkNoFocus.FreeResources(immediately);
-}
-
-void CGUICheckMarkControl::DynamicResourceAlloc(bool bOnOff)
-{
- CGUIControl::DynamicResourceAlloc(bOnOff);
- m_imgCheckMark.DynamicResourceAlloc(bOnOff);
- m_imgCheckMarkNoFocus.DynamicResourceAlloc(bOnOff);
-}
-
-void CGUICheckMarkControl::SetInvalid()
-{
- CGUIControl::SetInvalid();
- m_label.SetInvalid();
- m_imgCheckMark.SetInvalid();
- m_imgCheckMarkNoFocus.SetInvalid();
-}
-
-void CGUICheckMarkControl::SetSelected(bool bOnOff)
-{
- m_bSelected = bOnOff;
-}
-
-bool CGUICheckMarkControl::GetSelected() const
-{
- return m_bSelected;
-}
-
-EVENT_RESULT CGUICheckMarkControl::OnMouseEvent(const CPoint &point, const CMouseEvent &event)
-{
- if (event.m_id == ACTION_MOUSE_LEFT_CLICK)
- {
- OnAction(CAction(ACTION_SELECT_ITEM));
- return EVENT_RESULT_HANDLED;
- }
- return EVENT_RESULT_UNHANDLED;
-}
-
-void CGUICheckMarkControl::SetLabel(const string &label)
-{
- m_strLabel = label;
-}
-
-void CGUICheckMarkControl::PythonSetLabel(const CStdString &strFont, const string &strText, color_t textColor)
-{
- m_label.GetLabelInfo().font = g_fontManager.GetFont(strFont);
- m_label.GetLabelInfo().textColor = textColor;
- m_label.GetLabelInfo().focusedColor = textColor;
- m_strLabel = strText;
-}
-
-void CGUICheckMarkControl::PythonSetDisabledColor(color_t disabledColor)
-{
- m_label.GetLabelInfo().disabledColor = disabledColor;
-}
-
-void CGUICheckMarkControl::UpdateColors()
-{
- m_label.UpdateColors();
- CGUIControl::UpdateColors();
- m_imgCheckMark.SetDiffuseColor(m_diffuseColor);
- m_imgCheckMarkNoFocus.SetDiffuseColor(m_diffuseColor);
-}
diff --git a/guilib/GUICheckMarkControl.h b/guilib/GUICheckMarkControl.h
deleted file mode 100644
index ab80395a89..0000000000
--- a/guilib/GUICheckMarkControl.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*!
-\file GUICheckMarkControl.h
-\brief
-*/
-
-#ifndef CGUILIB_GUICHECKMARK_CONTROL_H
-#define CGUILIB_GUICHECKMARK_CONTROL_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUITexture.h"
-#include "GUILabel.h"
-#include "GUIControl.h"
-
-/*!
- \ingroup controls
- \brief
- */
-class CGUICheckMarkControl: public CGUIControl
-{
-public:
- CGUICheckMarkControl(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& textureCheckMark, const CTextureInfo& textureCheckMarkNF, float checkWidth, float checkHeight, const CLabelInfo &labelInfo);
- virtual ~CGUICheckMarkControl(void);
- virtual CGUICheckMarkControl *Clone() const { return new CGUICheckMarkControl(*this); };
-
- virtual void Render();
- virtual bool OnAction(const CAction &action) ;
- virtual bool OnMessage(CGUIMessage& message);
- virtual void AllocResources();
- virtual void FreeResources(bool immediately = false);
- virtual void DynamicResourceAlloc(bool bOnOff);
- virtual void SetInvalid();
-
- void SetLabel(const std::string& strLabel);
- const std::string GetLabel() const { return m_strLabel; };
- const CLabelInfo& GetLabelInfo() const { return m_label.GetLabelInfo(); };
- void SetSelected(bool bOnOff);
- bool GetSelected() const;
-
- void PythonSetLabel(const CStdString &strFont, const std::string &strText, color_t textColor);
- void PythonSetDisabledColor(color_t disabledColor);
-
-protected:
- virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event);
- virtual void UpdateColors();
- CGUILabel::COLOR GetTextColor() const;
-
- CGUITexture m_imgCheckMark;
- CGUITexture m_imgCheckMarkNoFocus;
-
- CGUILabel m_label;
- std::string m_strLabel;
- bool m_bSelected;
-};
-#endif
diff --git a/guilib/GUIColorManager.cpp b/guilib/GUIColorManager.cpp
deleted file mode 100644
index acd83915fb..0000000000
--- a/guilib/GUIColorManager.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIColorManager.h"
-#include "Util.h"
-#include "FileSystem/SpecialProtocol.h"
-#include "addons/Skin.h"
-#include "utils/log.h"
-#include "tinyXML/tinyxml.h"
-
-CGUIColorManager g_colorManager;
-
-CGUIColorManager::CGUIColorManager(void)
-{
-}
-
-CGUIColorManager::~CGUIColorManager(void)
-{
- Clear();
-}
-
-void CGUIColorManager::Clear()
-{
- m_colors.clear();
-}
-
-// load the color file in
-void CGUIColorManager::Load(const CStdString &colorFile)
-{
- Clear();
-
- // load the global color map if it exists
- TiXmlDocument xmlDoc;
- if (xmlDoc.LoadFile(PTH_IC("special://xbmc/system/colors.xml")))
- LoadXML(xmlDoc);
-
- // first load the default color map if it exists
- CStdString path, basePath;
- CUtil::AddFileToFolder(g_SkinInfo->Path(), "colors", basePath);
- CUtil::AddFileToFolder(basePath, "defaults.xml", path);
-
- if (xmlDoc.LoadFile(PTH_IC(path)))
- LoadXML(xmlDoc);
-
- // now the color map requested
- if (colorFile.CompareNoCase("SKINDEFAULT") == 0)
- return; // nothing to do
-
- CUtil::AddFileToFolder(basePath, colorFile, path);
- CLog::Log(LOGINFO, "Loading colors from %s", path.c_str());
-
- if (xmlDoc.LoadFile(path))
- LoadXML(xmlDoc);
-}
-
-bool CGUIColorManager::LoadXML(TiXmlDocument &xmlDoc)
-{
- TiXmlElement* pRootElement = xmlDoc.RootElement();
-
- CStdString strValue = pRootElement->Value();
- if (strValue != CStdString("colors"))
- {
- CLog::Log(LOGERROR, "color file doesnt start with <colors>");
- return false;
- }
-
- const TiXmlElement *color = pRootElement->FirstChildElement("color");
-
- while (color)
- {
- if (color->FirstChild() && color->Attribute("name"))
- {
- color_t value = 0xffffffff;
- sscanf(color->FirstChild()->Value(), "%x", (unsigned int*) &value);
- CStdString name = color->Attribute("name");
- iColor it = m_colors.find(name);
- if (it != m_colors.end())
- (*it).second = value;
- else
- m_colors.insert(make_pair(name, value));
- }
- color = color->NextSiblingElement("color");
- }
- return true;
-}
-
-// lookup a color and return it's hex value
-color_t CGUIColorManager::GetColor(const CStdString &color) const
-{
- // look in our color map
- CStdString trimmed(color);
- trimmed.TrimLeft("= ");
- icColor it = m_colors.find(trimmed);
- if (it != m_colors.end())
- return (*it).second;
-
- // try converting hex directly
- color_t value = 0;
- sscanf(trimmed.c_str(), "%x", &value);
- return value;
-}
-
diff --git a/guilib/GUIColorManager.h b/guilib/GUIColorManager.h
deleted file mode 100644
index e1f66e82c6..0000000000
--- a/guilib/GUIColorManager.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*!
-\file GUIColorManager.h
-\brief
-*/
-
-#ifndef GUILIB_COLORMANAGER_H
-#define GUILIB_COLORMANAGER_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-/*!
- \ingroup textures
- \brief
- */
-
-#include "StdString.h"
-
-#include <map>
-
-class TiXmlDocument;
-
-typedef uint32_t color_t;
-
-class CGUIColorManager
-{
-public:
- CGUIColorManager(void);
- virtual ~CGUIColorManager(void);
-
- void Load(const CStdString &colorFile);
-
- color_t GetColor(const CStdString &color) const;
-
- void Clear();
-
-protected:
- bool LoadXML(TiXmlDocument &xmlDoc);
-
- std::map<CStdString, color_t> m_colors;
- typedef std::map<CStdString, color_t>::iterator iColor;
- typedef std::map<CStdString, color_t>::const_iterator icColor;
-};
-
-/*!
- \ingroup textures
- \brief
- */
-extern CGUIColorManager g_colorManager;
-#endif
diff --git a/guilib/GUIControl.cpp b/guilib/GUIControl.cpp
deleted file mode 100644
index 7a47cb48f0..0000000000
--- a/guilib/GUIControl.cpp
+++ /dev/null
@@ -1,895 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIControl.h"
-
-#include "utils/GUIInfoManager.h"
-#include "utils/log.h"
-#include "LocalizeStrings.h"
-#include "GUIWindowManager.h"
-#include "GUIControlProfiler.h"
-#include "MouseStat.h"
-#include "Key.h"
-
-using namespace std;
-
-CGUIControl::CGUIControl()
-{
- m_hasRendered = false;
- m_bHasFocus = false;
- m_controlID = 0;
- m_parentID = 0;
- m_visible = VISIBLE;
- m_visibleFromSkinCondition = true;
- m_forceHidden = false;
- m_visibleCondition = 0;
- m_enableCondition = 0;
- m_enabled = true;
- m_diffuseColor = 0xffffffff;
- m_posX = 0;
- m_posY = 0;
- m_width = 0;
- m_height = 0;
- m_controlLeft = 0;
- m_controlRight = 0;
- m_controlUp = 0;
- m_controlDown = 0;
- m_controlNext = 0;
- m_controlPrev = 0;
- ControlType = GUICONTROL_UNKNOWN;
- m_bInvalidated = true;
- m_bAllocated=false;
- m_parentControl = NULL;
- m_hasCamera = false;
- m_pushedUpdates = false;
- m_pulseOnSelect = false;
-}
-
-CGUIControl::CGUIControl(int parentID, int controlID, float posX, float posY, float width, float height)
-: m_hitRect(posX, posY, posX + width, posY + height)
-{
- m_posX = posX;
- m_posY = posY;
- m_width = width;
- m_height = height;
- m_bHasFocus = false;
- m_controlID = controlID;
- m_parentID = parentID;
- m_visible = VISIBLE;
- m_visibleFromSkinCondition = true;
- m_diffuseColor = 0xffffffff;
- m_forceHidden = false;
- m_visibleCondition = 0;
- m_enableCondition = 0;
- m_enabled = true;
- m_controlLeft = 0;
- m_controlRight = 0;
- m_controlUp = 0;
- m_controlDown = 0;
- m_controlNext = 0;
- m_controlPrev = 0;
- ControlType = GUICONTROL_UNKNOWN;
- m_bInvalidated = true;
- m_bAllocated=false;
- m_hasRendered = false;
- m_parentControl = NULL;
- m_hasCamera = false;
- m_pushedUpdates = false;
- m_pulseOnSelect = false;
-}
-
-
-CGUIControl::~CGUIControl(void)
-{
-
-}
-
-void CGUIControl::AllocResources()
-{
- m_hasRendered = false;
- m_bInvalidated = true;
- m_bAllocated=true;
-}
-
-void CGUIControl::FreeResources(bool immediately)
-{
- if (m_bAllocated)
- {
- // Reset our animation states - not conditional anims though.
- // I'm not sure if this is needed for most cases anyway. I believe it's only here
- // because some windows aren't loaded on demand
- for (unsigned int i = 0; i < m_animations.size(); i++)
- {
- CAnimation &anim = m_animations[i];
- if (anim.GetType() != ANIM_TYPE_CONDITIONAL)
- anim.ResetAnimation();
- }
- m_bAllocated=false;
- }
- m_hasRendered = false;
-}
-
-void CGUIControl::DynamicResourceAlloc(bool bOnOff)
-{
-
-}
-
-// the main render routine.
-// 1. animate and set the animation transform
-// 2. if visible, paint
-// 3. reset the animation transform
-void CGUIControl::DoRender(unsigned int currentTime)
-{
- Animate(currentTime);
- if (m_hasCamera)
- g_graphicsContext.SetCameraPosition(m_camera);
- if (IsVisible())
- {
- GUIPROFILER_RENDER_BEGIN(this);
- Render();
- GUIPROFILER_RENDER_END(this);
- }
- if (m_hasCamera)
- g_graphicsContext.RestoreCameraPosition();
- g_graphicsContext.RemoveTransform();
-}
-
-void CGUIControl::Render()
-{
- m_bInvalidated = false;
- m_hasRendered = true;
-}
-
-bool CGUIControl::OnAction(const CAction &action)
-{
- switch (action.GetID())
- {
- case ACTION_MOVE_DOWN:
- if (!HasFocus()) return false;
- OnDown();
- return true;
- break;
-
- case ACTION_MOVE_UP:
- if (!HasFocus()) return false;
- OnUp();
- return true;
- break;
-
- case ACTION_MOVE_LEFT:
- if (!HasFocus()) return false;
- OnLeft();
- return true;
- break;
-
- case ACTION_MOVE_RIGHT:
- if (!HasFocus()) return false;
- OnRight();
- return true;
- break;
-
- case ACTION_NEXT_CONTROL:
- if (!HasFocus()) return false;
- OnNextControl();
- return true;
- break;
-
- case ACTION_PREV_CONTROL:
- if (!HasFocus()) return false;
- OnPrevControl();
- return true;
- break;
- }
- return false;
-}
-
-// Movement controls (derived classes can override)
-void CGUIControl::OnUp()
-{
- if (HasFocus())
- {
- if (m_upActions.size())
- ExecuteActions(m_upActions);
- else if (m_controlID != m_controlUp)
- {
- // Send a message to the window with the sender set as the window
- CGUIMessage msg(GUI_MSG_MOVE, GetParentID(), GetID(), ACTION_MOVE_UP);
- SendWindowMessage(msg);
- }
- }
-}
-
-void CGUIControl::OnDown()
-{
- if (HasFocus())
- {
- if (m_downActions.size())
- ExecuteActions(m_downActions);
- else if (m_controlID != m_controlDown)
- {
- // Send a message to the window with the sender set as the window
- CGUIMessage msg(GUI_MSG_MOVE, GetParentID(), GetID(), ACTION_MOVE_DOWN);
- SendWindowMessage(msg);
- }
- }
-}
-
-void CGUIControl::OnLeft()
-{
- if (HasFocus())
- {
- if (m_leftActions.size())
- ExecuteActions(m_leftActions);
- else if (m_controlID != m_controlLeft)
- {
- // Send a message to the window with the sender set as the window
- CGUIMessage msg(GUI_MSG_MOVE, GetParentID(), GetID(), ACTION_MOVE_LEFT);
- SendWindowMessage(msg);
- }
- }
-}
-
-void CGUIControl::OnRight()
-{
- if (HasFocus())
- {
- if (m_rightActions.size())
- ExecuteActions(m_rightActions);
- else if (m_controlID != m_controlRight)
- {
- // Send a message to the window with the sender set as the window
- CGUIMessage msg(GUI_MSG_MOVE, GetParentID(), GetID(), ACTION_MOVE_RIGHT);
- SendWindowMessage(msg);
- }
- }
-}
-
-void CGUIControl::OnNextControl()
-{
- if (m_controlID != m_controlNext)
- {
- // Send a message to the window with the sender set as the window
- CGUIMessage msg(GUI_MSG_MOVE, GetParentID(), GetID(), ACTION_NEXT_CONTROL, m_controlNext);
- SendWindowMessage(msg);
- }
-}
-
-void CGUIControl::OnPrevControl()
-{
- if (m_controlID != m_controlPrev)
- {
- // Send a message to the window with the sender set as the window
- CGUIMessage msg(GUI_MSG_MOVE, GetParentID(), GetID(), ACTION_PREV_CONTROL, m_controlPrev);
- SendWindowMessage(msg);
- }
-}
-
-bool CGUIControl::SendWindowMessage(CGUIMessage &message)
-{
- CGUIWindow *pWindow = g_windowManager.GetWindow(GetParentID());
- if (pWindow)
- return pWindow->OnMessage(message);
- return g_windowManager.SendMessage(message);
-}
-
-int CGUIControl::GetID(void) const
-{
- return m_controlID;
-}
-
-
-int CGUIControl::GetParentID(void) const
-{
- return m_parentID;
-}
-
-bool CGUIControl::HasFocus(void) const
-{
- return m_bHasFocus;
-}
-
-void CGUIControl::SetFocus(bool focus)
-{
- if (m_bHasFocus && !focus)
- QueueAnimation(ANIM_TYPE_UNFOCUS);
- else if (!m_bHasFocus && focus)
- QueueAnimation(ANIM_TYPE_FOCUS);
- m_bHasFocus = focus;
-}
-
-bool CGUIControl::OnMessage(CGUIMessage& message)
-{
- if ( message.GetControlId() == GetID() )
- {
- switch (message.GetMessage() )
- {
- case GUI_MSG_SETFOCUS:
- // if control is disabled then move 2 the next control
- if ( !CanFocus() )
- {
- CLog::Log(LOGERROR, "Control %u in window %u has been asked to focus, "
- "but it can't",
- GetID(), GetParentID());
- return false;
- }
- SetFocus(true);
- {
- // inform our parent window that this has happened
- CGUIMessage message(GUI_MSG_FOCUSED, GetParentID(), GetID());
- if (m_parentControl)
- m_parentControl->OnMessage(message);
- }
- return true;
- break;
-
- case GUI_MSG_LOSTFOCUS:
- {
- SetFocus(false);
- // and tell our parent so it can unfocus
- if (m_parentControl)
- m_parentControl->OnMessage(message);
- return true;
- }
- break;
-
- case GUI_MSG_VISIBLE:
- if (m_visibleCondition)
- m_visible = g_infoManager.GetBool(m_visibleCondition, m_parentID) ? VISIBLE : HIDDEN;
- else
- m_visible = VISIBLE;
- m_forceHidden = false;
- return true;
- break;
-
- case GUI_MSG_HIDDEN:
- m_forceHidden = true;
- // reset any visible animations that are in process
- if (IsAnimating(ANIM_TYPE_VISIBLE))
- {
-// CLog::DebugLog("Resetting visible animation on control %i (we are %s)", m_controlID, m_visible ? "visible" : "hidden");
- CAnimation *visibleAnim = GetAnimation(ANIM_TYPE_VISIBLE);
- if (visibleAnim) visibleAnim->ResetAnimation();
- }
- return true;
-
- // Note that the skin <enable> tag will override these messages
- case GUI_MSG_ENABLED:
- SetEnabled(true);
- return true;
-
- case GUI_MSG_DISABLED:
- SetEnabled(false);
- return true;
- }
- }
- return false;
-}
-
-bool CGUIControl::CanFocus() const
-{
- if (!IsVisible() && !m_allowHiddenFocus) return false;
- if (IsDisabled()) return false;
- return true;
-}
-
-bool CGUIControl::IsVisible() const
-{
- if (m_forceHidden) return false;
- return m_visible == VISIBLE;
-}
-
-bool CGUIControl::IsDisabled() const
-{
- return !m_enabled;
-}
-
-void CGUIControl::SetEnabled(bool bEnable)
-{
- m_enabled = bEnable;
-}
-
-void CGUIControl::SetEnableCondition(int condition)
-{
- m_enableCondition = condition;
-}
-
-void CGUIControl::SetPosition(float posX, float posY)
-{
- if ((m_posX != posX) || (m_posY != posY))
- {
- m_hitRect += CPoint(posX - m_posX, posY - m_posY);
- m_posX = posX;
- m_posY = posY;
- SetInvalid();
- }
-}
-
-void CGUIControl::SetColorDiffuse(const CGUIInfoColor &color)
-{
- m_diffuseColor = color;
-}
-
-float CGUIControl::GetXPosition() const
-{
- return m_posX;
-}
-
-float CGUIControl::GetYPosition() const
-{
- return m_posY;
-}
-
-float CGUIControl::GetWidth() const
-{
- return m_width;
-}
-
-float CGUIControl::GetHeight() const
-{
- return m_height;
-}
-
-void CGUIControl::SetNavigation(int up, int down, int left, int right)
-{
- m_controlUp = up;
- m_controlDown = down;
- m_controlLeft = left;
- m_controlRight = right;
-}
-
-void CGUIControl::SetTabNavigation(int next, int prev)
-{
- m_controlNext = next;
- m_controlPrev = prev;
-}
-
-void CGUIControl::SetNavigationActions(const vector<CGUIActionDescriptor> &up, const vector<CGUIActionDescriptor> &down,
- const vector<CGUIActionDescriptor> &left, const vector<CGUIActionDescriptor> &right, bool replace)
-{
- if (m_leftActions.empty() || replace) m_leftActions = left;
- if (m_rightActions.empty() || replace) m_rightActions = right;
- if (m_upActions.empty() || replace) m_upActions = up;
- if (m_downActions.empty() || replace) m_downActions = down;
-}
-
-void CGUIControl::SetWidth(float width)
-{
- if (m_width != width)
- {
- m_width = width;
- m_hitRect.x2 = m_hitRect.x1 + width;
- SetInvalid();
- }
-}
-
-void CGUIControl::SetHeight(float height)
-{
- if (m_height != height)
- {
- m_height = height;
- m_hitRect.y2 = m_hitRect.y1 + height;
- SetInvalid();
- }
-}
-
-void CGUIControl::SetVisible(bool bVisible)
-{
- // just force to hidden if necessary
- m_forceHidden = !bVisible;
-/*
- if (m_visibleCondition)
- bVisible = g_infoManager.GetBool(m_visibleCondition, m_parentID);
- if (m_bVisible != bVisible)
- {
- m_visible = bVisible;
- m_visibleFromSkinCondition = bVisible;
- SetInvalid();
- }*/
-}
-
-bool CGUIControl::HitTest(const CPoint &point) const
-{
- return m_hitRect.PtInRect(point);
-}
-
-EVENT_RESULT CGUIControl::SendMouseEvent(const CPoint &point, const CMouseEvent &event)
-{
- CPoint childPoint(point);
- m_transform.InverseTransformPosition(childPoint.x, childPoint.y);
- if (!CanFocusFromPoint(childPoint))
- return EVENT_RESULT_UNHANDLED;
-
- bool handled = OnMouseOver(childPoint);
- EVENT_RESULT ret = OnMouseEvent(childPoint, event);
- if (ret)
- return ret;
- return (handled && (event.m_id == ACTION_MOUSE_MOVE)) ? EVENT_RESULT_HANDLED : EVENT_RESULT_UNHANDLED;
-}
-
-// override this function to implement custom mouse behaviour
-bool CGUIControl::OnMouseOver(const CPoint &point)
-{
- if (g_Mouse.GetState() != MOUSE_STATE_DRAG)
- g_Mouse.SetState(MOUSE_STATE_FOCUS);
- if (!CanFocus()) return false;
- CGUIMessage msg(GUI_MSG_SETFOCUS, GetParentID(), GetID());
- OnMessage(msg);
- return true;
-}
-
-void CGUIControl::UpdateVisibility(const CGUIListItem *item)
-{
- if (m_visibleCondition)
- {
- bool bWasVisible = m_visibleFromSkinCondition;
- m_visibleFromSkinCondition = g_infoManager.GetBool(m_visibleCondition, m_parentID, item);
- if (!bWasVisible && m_visibleFromSkinCondition)
- { // automatic change of visibility - queue the in effect
- // CLog::DebugLog("Visibility changed to visible for control id %i", m_controlID);
- QueueAnimation(ANIM_TYPE_VISIBLE);
- }
- else if (bWasVisible && !m_visibleFromSkinCondition)
- { // automatic change of visibility - do the out effect
- // CLog::DebugLog("Visibility changed to hidden for control id %i", m_controlID);
- QueueAnimation(ANIM_TYPE_HIDDEN);
- }
- }
- // check for conditional animations
- for (unsigned int i = 0; i < m_animations.size(); i++)
- {
- CAnimation &anim = m_animations[i];
- if (anim.GetType() == ANIM_TYPE_CONDITIONAL)
- anim.UpdateCondition(GetParentID(), item);
- }
- // and check for conditional enabling - note this overrides SetEnabled() from the code currently
- // this may need to be reviewed at a later date
- if (m_enableCondition)
- m_enabled = g_infoManager.GetBool(m_enableCondition, m_parentID, item);
- m_allowHiddenFocus.Update(m_parentID, item);
- UpdateColors();
- // and finally, update our control information (if not pushed)
- if (!m_pushedUpdates)
- UpdateInfo(item);
-}
-
-void CGUIControl::UpdateColors()
-{
- m_diffuseColor.Update();
-}
-
-void CGUIControl::SetInitialVisibility()
-{
- if (m_visibleCondition)
- {
- m_visibleFromSkinCondition = g_infoManager.GetBool(m_visibleCondition, m_parentID);
- m_visible = m_visibleFromSkinCondition ? VISIBLE : HIDDEN;
- // CLog::DebugLog("Set initial visibility for control %i: %s", m_controlID, m_visible == VISIBLE ? "visible" : "hidden");
- // no need to enquire every frame if we are always visible or always hidden
- if (m_visibleCondition == SYSTEM_ALWAYS_TRUE || m_visibleCondition == SYSTEM_ALWAYS_FALSE)
- m_visibleCondition = 0;
- }
- // and handle animation conditions as well
- for (unsigned int i = 0; i < m_animations.size(); i++)
- {
- CAnimation &anim = m_animations[i];
- if (anim.GetType() == ANIM_TYPE_CONDITIONAL)
- anim.SetInitialCondition(GetParentID());
- }
- // and check for conditional enabling - note this overrides SetEnabled() from the code currently
- // this may need to be reviewed at a later date
- if (m_enableCondition)
- m_enabled = g_infoManager.GetBool(m_enableCondition, m_parentID);
- m_allowHiddenFocus.Update(m_parentID);
- UpdateColors();
-}
-
-void CGUIControl::SetVisibleCondition(int visible, const CGUIInfoBool &allowHiddenFocus)
-{
- m_visibleCondition = visible;
- m_allowHiddenFocus = allowHiddenFocus;
-}
-
-void CGUIControl::SetAnimations(const vector<CAnimation> &animations)
-{
- m_animations = animations;
-}
-
-void CGUIControl::ResetAnimation(ANIMATION_TYPE type)
-{
- for (unsigned int i = 0; i < m_animations.size(); i++)
- {
- if (m_animations[i].GetType() == type)
- m_animations[i].ResetAnimation();
- }
-}
-
-void CGUIControl::ResetAnimations()
-{
- for (unsigned int i = 0; i < m_animations.size(); i++)
- m_animations[i].ResetAnimation();
-}
-
-bool CGUIControl::CheckAnimation(ANIMATION_TYPE animType)
-{
- // rule out the animations we shouldn't perform
- if (!IsVisible() || !HasRendered())
- { // hidden or never rendered - don't allow exit or entry animations for this control
- if (animType == ANIM_TYPE_WINDOW_CLOSE)
- { // could be animating a (delayed) window open anim, so reset it
- ResetAnimation(ANIM_TYPE_WINDOW_OPEN);
- return false;
- }
- }
- if (!IsVisible())
- { // hidden - only allow hidden anims if we're animating a visible anim
- if (animType == ANIM_TYPE_HIDDEN && !IsAnimating(ANIM_TYPE_VISIBLE))
- {
- // update states to force it hidden
- UpdateStates(animType, ANIM_PROCESS_NORMAL, ANIM_STATE_APPLIED);
- return false;
- }
- if (animType == ANIM_TYPE_WINDOW_OPEN)
- return false;
- }
- return true;
-}
-
-void CGUIControl::QueueAnimation(ANIMATION_TYPE animType)
-{
- if (!CheckAnimation(animType))
- return;
- CAnimation *reverseAnim = GetAnimation((ANIMATION_TYPE)-animType, false);
- CAnimation *forwardAnim = GetAnimation(animType);
- // we first check whether the reverse animation is in progress (and reverse it)
- // then we check for the normal animation, and queue it
- if (reverseAnim && reverseAnim->IsReversible() && (reverseAnim->GetState() == ANIM_STATE_IN_PROCESS || reverseAnim->GetState() == ANIM_STATE_DELAYED))
- {
- reverseAnim->QueueAnimation(ANIM_PROCESS_REVERSE);
- if (forwardAnim) forwardAnim->ResetAnimation();
- }
- else if (forwardAnim)
- {
- forwardAnim->QueueAnimation(ANIM_PROCESS_NORMAL);
- if (reverseAnim) reverseAnim->ResetAnimation();
- }
- else
- { // hidden and visible animations delay the change of state. If there is no animations
- // to perform, then we should just change the state straightaway
- if (reverseAnim) reverseAnim->ResetAnimation();
- UpdateStates(animType, ANIM_PROCESS_NORMAL, ANIM_STATE_APPLIED);
- }
-}
-
-CAnimation *CGUIControl::GetAnimation(ANIMATION_TYPE type, bool checkConditions /* = true */)
-{
- for (unsigned int i = 0; i < m_animations.size(); i++)
- {
- CAnimation &anim = m_animations[i];
- if (anim.GetType() == type)
- {
- if (!checkConditions || !anim.GetCondition() || g_infoManager.GetBool(anim.GetCondition()))
- return &anim;
- }
- }
- return NULL;
-}
-
-bool CGUIControl::HasAnimation(ANIMATION_TYPE type)
-{
- return (NULL != GetAnimation(type, true));
-}
-
-void CGUIControl::UpdateStates(ANIMATION_TYPE type, ANIMATION_PROCESS currentProcess, ANIMATION_STATE currentState)
-{
- // Make sure control is hidden or visible at the appropriate times
- // while processing a visible or hidden animation it needs to be visible,
- // but when finished a hidden operation it needs to be hidden
- if (type == ANIM_TYPE_VISIBLE)
- {
- if (currentProcess == ANIM_PROCESS_REVERSE)
- {
- if (currentState == ANIM_STATE_APPLIED)
- m_visible = HIDDEN;
- }
- else if (currentProcess == ANIM_PROCESS_NORMAL)
- {
- if (currentState == ANIM_STATE_DELAYED)
- m_visible = DELAYED;
- else
- m_visible = m_visibleFromSkinCondition ? VISIBLE : HIDDEN;
- }
- }
- else if (type == ANIM_TYPE_HIDDEN)
- {
- if (currentProcess == ANIM_PROCESS_NORMAL) // a hide animation
- {
- if (currentState == ANIM_STATE_APPLIED)
- m_visible = HIDDEN; // finished
- else
- m_visible = VISIBLE; // have to be visible until we are finished
- }
- else if (currentProcess == ANIM_PROCESS_REVERSE) // a visible animation
- { // no delay involved here - just make sure it's visible
- m_visible = m_visibleFromSkinCondition ? VISIBLE : HIDDEN;
- }
- }
- else if (type == ANIM_TYPE_WINDOW_OPEN)
- {
- if (currentProcess == ANIM_PROCESS_NORMAL)
- {
- if (currentState == ANIM_STATE_DELAYED)
- m_visible = DELAYED; // delayed
- else
- m_visible = m_visibleFromSkinCondition ? VISIBLE : HIDDEN;
- }
- }
- else if (type == ANIM_TYPE_FOCUS)
- {
- // call the focus function if we have finished a focus animation
- // (buttons can "click" on focus)
- if (currentProcess == ANIM_PROCESS_NORMAL && currentState == ANIM_STATE_APPLIED)
- OnFocus();
- }
- else if (type == ANIM_TYPE_UNFOCUS)
- {
- // call the unfocus function if we have finished a focus animation
- // (buttons can "click" on focus)
- if (currentProcess == ANIM_PROCESS_NORMAL && currentState == ANIM_STATE_APPLIED)
- OnUnFocus();
- }
-}
-
-void CGUIControl::Animate(unsigned int currentTime)
-{
- // check visible state outside the loop, as it could change
- GUIVISIBLE visible = m_visible;
- m_transform.Reset();
- CPoint center(m_posX + m_width * 0.5f, m_posY + m_height * 0.5f);
- for (unsigned int i = 0; i < m_animations.size(); i++)
- {
- CAnimation &anim = m_animations[i];
- anim.Animate(currentTime, HasRendered() || visible == DELAYED);
- // Update the control states (such as visibility)
- UpdateStates(anim.GetType(), anim.GetProcess(), anim.GetState());
- // and render the animation effect
- anim.RenderAnimation(m_transform, center);
-
-/* // debug stuff
- if (anim.currentProcess != ANIM_PROCESS_NONE)
- {
- if (anim.effect == EFFECT_TYPE_ZOOM)
- {
- if (IsVisible())
- CLog::DebugLog("Animating control %d with a %s zoom effect %s. Amount is %2.1f, visible=%s", m_controlID, anim.type == ANIM_TYPE_CONDITIONAL ? (anim.lastCondition ? "conditional_on" : "conditional_off") : (anim.type == ANIM_TYPE_VISIBLE ? "visible" : "hidden"), anim.currentProcess == ANIM_PROCESS_NORMAL ? "normal" : "reverse", anim.amount, IsVisible() ? "true" : "false");
- }
- else if (anim.effect == EFFECT_TYPE_FADE)
- {
- if (IsVisible())
- CLog::DebugLog("Animating control %d with a %s fade effect %s. Amount is %2.1f. Visible=%s", m_controlID, anim.type == ANIM_TYPE_CONDITIONAL ? (anim.lastCondition ? "conditional_on" : "conditional_off") : (anim.type == ANIM_TYPE_VISIBLE ? "visible" : "hidden"), anim.currentProcess == ANIM_PROCESS_NORMAL ? "normal" : "reverse", anim.amount, IsVisible() ? "true" : "false");
- }
- }*/
- }
- g_graphicsContext.AddTransform(m_transform);
-}
-
-bool CGUIControl::IsAnimating(ANIMATION_TYPE animType)
-{
- for (unsigned int i = 0; i < m_animations.size(); i++)
- {
- CAnimation &anim = m_animations[i];
- if (anim.GetType() == animType)
- {
- if (anim.GetQueuedProcess() == ANIM_PROCESS_NORMAL)
- return true;
- if (anim.GetProcess() == ANIM_PROCESS_NORMAL)
- return true;
- }
- else if (anim.GetType() == -animType)
- {
- if (anim.GetQueuedProcess() == ANIM_PROCESS_REVERSE)
- return true;
- if (anim.GetProcess() == ANIM_PROCESS_REVERSE)
- return true;
- }
- }
- return false;
-}
-
-int CGUIControl::GetNextControl(int direction) const
-{
- switch (direction)
- {
- case ACTION_MOVE_UP:
- return m_controlUp;
- case ACTION_MOVE_DOWN:
- return m_controlDown;
- case ACTION_MOVE_LEFT:
- return m_controlLeft;
- case ACTION_MOVE_RIGHT:
- return m_controlRight;
- default:
- return -1;
- }
-}
-
-bool CGUIControl::CanFocusFromPoint(const CPoint &point) const
-{
- return CanFocus() && HitTest(point);
-}
-
-void CGUIControl::UnfocusFromPoint(const CPoint &point)
-{
- CPoint controlPoint(point);
- m_transform.InverseTransformPosition(controlPoint.x, controlPoint.y);
- if (!HitTest(controlPoint))
- SetFocus(false);
-}
-
-bool CGUIControl::HasID(int id) const
-{
- return GetID() == id;
-}
-
-bool CGUIControl::HasVisibleID(int id) const
-{
- return GetID() == id && IsVisible();
-}
-
-void CGUIControl::SaveStates(vector<CControlState> &states)
-{
- // empty for now - do nothing with the majority of controls
-}
-
-void CGUIControl::SetHitRect(const CRect &rect)
-{
- m_hitRect = rect;
-}
-
-void CGUIControl::SetCamera(const CPoint &camera)
-{
- m_camera = camera;
- m_hasCamera = true;
-}
-
-void CGUIControl::ExecuteActions(const vector<CGUIActionDescriptor> &actions)
-{
- // we should really save anything we need, as the action may cause the window to close
- int savedID = GetID();
- int savedParent = GetParentID();
- vector<CGUIActionDescriptor> savedActions = actions;
-
- for (unsigned int i = 0; i < savedActions.size(); i++)
- {
- CGUIMessage message(GUI_MSG_EXECUTE, savedID, savedParent);
- message.SetAction(savedActions[i]);
- g_windowManager.SendMessage(message);
- }
-}
-
-CPoint CGUIControl::GetRenderPosition() const
-{
- float z = 0;
- CPoint point(GetPosition());
- m_transform.TransformPosition(point.x, point.y, z);
- if (m_parentControl)
- point += m_parentControl->GetRenderPosition();
- return point;
-}
diff --git a/guilib/GUIControl.h b/guilib/GUIControl.h
deleted file mode 100644
index cd335cc7f8..0000000000
--- a/guilib/GUIControl.h
+++ /dev/null
@@ -1,341 +0,0 @@
-/*!
-\file GUIControl.h
-\brief
-*/
-
-#ifndef GUILIB_GUICONTROL_H
-#define GUILIB_GUICONTROL_H
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GraphicContext.h" // needed by any rendering operation (all controls)
-#include "GUIMessage.h" // needed by practically all controls
-#include "VisibleEffect.h" // needed for the CAnimation members
-#include "GUIInfoTypes.h" // needed for CGUIInfoColor to handle infolabel'ed colors
-#include "GUIActionDescriptor.h"
-
-class CGUIListItem; // forward
-class CAction;
-class CMouseEvent;
-
-enum ORIENTATION { HORIZONTAL = 0, VERTICAL };
-
-class CControlState
-{
-public:
- CControlState(int id, int data)
- {
- m_id = id;
- m_data = data;
- }
- int m_id;
- int m_data;
-};
-
-/*!
- \brief Results of OnMouseEvent()
- Any value not equal to EVENT_RESULT_UNHANDLED indicates that the event was handled.
- */
-enum EVENT_RESULT { EVENT_RESULT_UNHANDLED = 0,
- EVENT_RESULT_HANDLED,
- EVENT_RESULT_PAN_HORIZONTAL,
- EVENT_RESULT_PAN_VERTICAL,
- EVENT_RESULT_ROTATE,
- EVENT_RESULT_ZOOM };
-
-/*!
- \ingroup controls
- \brief Base class for controls
- */
-class CGUIControl
-{
-public:
- CGUIControl();
- CGUIControl(int parentID, int controlID, float posX, float posY, float width, float height);
- virtual ~CGUIControl(void);
- virtual CGUIControl *Clone() const=0;
-
- virtual void DoRender(unsigned int currentTime);
- virtual void Render();
- bool HasRendered() const { return m_hasRendered; };
-
- // OnAction() is called by our window when we are the focused control.
- // We should process any control-specific actions in the derived classes,
- // and return true if we have taken care of the action. Returning false
- // indicates that the message may be handed down to the window or application
- // levels. This base class implementation handles basic movement, and should
- // be called from the derived classes when the action has not been handled.
- // Return true to indicate that the action has been dealt with.
- virtual bool OnAction(const CAction &action);
-
- // Common actions to make the code easier to read (no ugly switch statements in derived controls)
- virtual void OnUp();
- virtual void OnDown();
- virtual void OnLeft();
- virtual void OnRight();
- virtual void OnNextControl();
- virtual void OnPrevControl();
- virtual void OnFocus() {};
- virtual void OnUnFocus() {};
-
- /*! \brief React to a mouse event
-
- Mouse events are sent from the window to all controls, and each control can react based on the event
- and location of the event.
-
- \param point the location in transformed skin coordinates from the upper left corner of the parent control.
- \param event the mouse event to perform
- \return EVENT_RESULT corresponding to whether the control handles this event
- \sa HitTest, CanFocusFromPoint, CMouseEvent, EVENT_RESULT
- */
- virtual EVENT_RESULT SendMouseEvent(const CPoint &point, const CMouseEvent &event);
-
- /*! \brief Perform a mouse action
-
- Mouse actions are sent from the window to all controls, and each control can react based on the event
- and location of the actions.
-
- \param point the location in transformed skin coordinates from the upper left corner of the parent control.
- \param event the mouse event to perform
- \return EVENT_RESULT corresponding to whether the control handles this event
- \sa SendMouseEvent, HitTest, CanFocusFromPoint, CMouseEvent
- */
- virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event) { return EVENT_RESULT_UNHANDLED; };
-
- /*! \brief Unfocus the control if the given point on screen is not within it's boundary
- \param point the location in transformed skin coordinates from the upper left corner of the parent control.
- \sa CanFocusFromPoint
- */
- virtual void UnfocusFromPoint(const CPoint &point);
-
- /*! \brief Used to test whether the point is inside a control.
- \param point location to test
- \return true if the point is inside the bounds of this control.
- \sa SetHitRect
- */
- virtual bool HitTest(const CPoint &point) const;
-
- virtual bool OnMessage(CGUIMessage& message);
- virtual int GetID(void) const;
- void SetID(int id) { m_controlID = id; };
- virtual bool HasID(int id) const;
- virtual bool HasVisibleID(int id) const;
- int GetParentID() const;
- virtual bool HasFocus() const;
- virtual void AllocResources();
- virtual void FreeResources(bool immediately = false);
- virtual void DynamicResourceAlloc(bool bOnOff);
- virtual bool IsDynamicallyAllocated() { return false; };
- virtual bool CanFocus() const;
- virtual bool IsVisible() const;
- bool IsVisibleFromSkin() const { return m_visibleFromSkinCondition; };
- virtual bool IsDisabled() const;
- virtual void SetPosition(float posX, float posY);
- virtual void SetHitRect(const CRect &rect);
- virtual void SetCamera(const CPoint &camera);
- void SetColorDiffuse(const CGUIInfoColor &color);
- CPoint GetRenderPosition() const;
- virtual float GetXPosition() const;
- virtual float GetYPosition() const;
- virtual float GetWidth() const;
- virtual float GetHeight() const;
- virtual void SetNavigation(int up, int down, int left, int right);
- virtual void SetTabNavigation(int next, int prev);
-
- /*! \brief Set actions to perform on navigation
- Navigations are set if replace is true or if there is no previously set action
- \param up vector of CGUIActionDescriptors to execute on up
- \param down vector of CGUIActionDescriptors to execute on down
- \param left vector of CGUIActionDescriptors to execute on left
- \param right vector of CGUIActionDescriptors to execute on right
- \param replace Actions are set only if replace is true or there is no previously set action. Defaults to true
- \sa SetNavigation, ExecuteActions
- */
- virtual void SetNavigationActions(const std::vector<CGUIActionDescriptor> &up, const std::vector<CGUIActionDescriptor> &down,
- const std::vector<CGUIActionDescriptor> &left, const std::vector<CGUIActionDescriptor> &right, bool replace = true);
- void ExecuteActions(const std::vector<CGUIActionDescriptor> &actions);
- int GetControlIdUp() const { return m_controlUp;};
- int GetControlIdDown() const { return m_controlDown;};
- int GetControlIdLeft() const { return m_controlLeft;};
- int GetControlIdRight() const { return m_controlRight;};
- virtual int GetNextControl(int direction) const;
- virtual void SetFocus(bool focus);
- virtual void SetWidth(float width);
- virtual void SetHeight(float height);
- virtual void SetVisible(bool bVisible);
- void SetVisibleCondition(int visible, const CGUIInfoBool &allowHiddenFocus);
- int GetVisibleCondition() const { return m_visibleCondition; };
- void SetEnableCondition(int condition);
- virtual void UpdateVisibility(const CGUIListItem *item = NULL);
- virtual void SetInitialVisibility();
- virtual void SetEnabled(bool bEnable);
- virtual void SetInvalid() { m_bInvalidated = true; };
- virtual void SetPulseOnSelect(bool pulse) { m_pulseOnSelect = pulse; };
- virtual CStdString GetDescription() const { return ""; };
-
- void SetAnimations(const std::vector<CAnimation> &animations);
- const std::vector<CAnimation> &GetAnimations() const { return m_animations; };
-
- virtual void QueueAnimation(ANIMATION_TYPE anim);
- virtual bool IsAnimating(ANIMATION_TYPE anim);
- virtual bool HasAnimation(ANIMATION_TYPE anim);
- CAnimation *GetAnimation(ANIMATION_TYPE type, bool checkConditions = true);
- virtual void ResetAnimation(ANIMATION_TYPE type);
- virtual void ResetAnimations();
-
- // push information updates
- virtual void UpdateInfo(const CGUIListItem *item = NULL) {};
- virtual void SetPushUpdates(bool pushUpdates) { m_pushedUpdates = pushUpdates; };
-
- virtual bool IsGroup() const { return false; };
- virtual bool IsContainer() const { return false; };
- virtual bool GetCondition(int condition, int data) const { return false; };
-
- void SetParentControl(CGUIControl *control) { m_parentControl = control; };
- CGUIControl *GetParentControl(void) const { return m_parentControl; };
- virtual void SaveStates(std::vector<CControlState> &states);
-
- enum GUICONTROLTYPES {
- GUICONTROL_UNKNOWN,
- GUICONTROL_BUTTON,
- GUICONTROL_CHECKMARK,
- GUICONTROL_FADELABEL,
- GUICONTROL_IMAGE,
- GUICONTROL_BORDEREDIMAGE,
- GUICONTROL_LARGE_IMAGE,
- GUICONTROL_LABEL,
- GUICONTROL_LISTGROUP,
- GUICONTROL_PROGRESS,
- GUICONTROL_RADIO,
- GUICONTROL_RSS,
- GUICONTROL_SELECTBUTTON,
- GUICONTROL_SLIDER,
- GUICONTROL_SETTINGS_SLIDER,
- GUICONTROL_SPIN,
- GUICONTROL_SPINEX,
- GUICONTROL_TEXTBOX,
- GUICONTROL_TOGGLEBUTTON,
- GUICONTROL_VIDEO,
- GUICONTROL_MOVER,
- GUICONTROL_RESIZE,
- GUICONTROL_BUTTONBAR,
- GUICONTROL_EDIT,
- GUICONTROL_VISUALISATION,
- GUICONTROL_RENDERADDON,
- GUICONTROL_MULTI_IMAGE,
- GUICONTROL_GROUP,
- GUICONTROL_GROUPLIST,
- GUICONTROL_SCROLLBAR,
- GUICONTROL_LISTLABEL,
- GUICONTROL_MULTISELECT,
- GUICONTAINER_LIST,
- GUICONTAINER_WRAPLIST,
- GUICONTAINER_FIXEDLIST,
- GUICONTAINER_PANEL
- };
- GUICONTROLTYPES GetControlType() const { return ControlType; }
-
- enum GUIVISIBLE { HIDDEN = 0, DELAYED, VISIBLE };
-
-#ifdef _DEBUG
- virtual void DumpTextureUse() {};
-#endif
-protected:
- /*!
- \brief Return the coordinates of the top left of the control, in the control's parent coordinates
- \return The top left coordinates of the control
- */
- virtual CPoint GetPosition() const { return CPoint(GetXPosition(), GetYPosition()); };
-
- /*! \brief Called when the mouse is over the control.
- Default implementation selects the control.
- \param point location of the mouse in transformed skin coordinates
- \return true if handled, false otherwise.
- */
- virtual bool OnMouseOver(const CPoint &point);
-
- /*! \brief Test whether we can focus a control from a point on screen
- \param point the location in vanilla skin coordinates from the upper left corner of the parent control.
- \return true if the control can be focused from this location
- \sa UnfocusFromPoint, HitRect
- */
- virtual bool CanFocusFromPoint(const CPoint &point) const;
-
- virtual void UpdateColors();
- virtual void Animate(unsigned int currentTime);
- virtual bool CheckAnimation(ANIMATION_TYPE animType);
- void UpdateStates(ANIMATION_TYPE type, ANIMATION_PROCESS currentProcess, ANIMATION_STATE currentState);
- bool SendWindowMessage(CGUIMessage &message);
-
- // navigation
- int m_controlLeft;
- int m_controlRight;
- int m_controlUp;
- int m_controlDown;
- int m_controlNext;
- int m_controlPrev;
-
- std::vector<CGUIActionDescriptor> m_leftActions;
- std::vector<CGUIActionDescriptor> m_rightActions;
- std::vector<CGUIActionDescriptor> m_upActions;
- std::vector<CGUIActionDescriptor> m_downActions;
- std::vector<CGUIActionDescriptor> m_nextActions;
- std::vector<CGUIActionDescriptor> m_prevActions;
-
- float m_posX;
- float m_posY;
- float m_height;
- float m_width;
- CRect m_hitRect;
- CGUIInfoColor m_diffuseColor;
- int m_controlID;
- int m_parentID;
- bool m_bHasFocus;
- bool m_bInvalidated;
- bool m_bAllocated;
- bool m_pulseOnSelect;
- GUICONTROLTYPES ControlType;
-
- CGUIControl *m_parentControl; // our parent control if we're part of a group
-
- // visibility condition/state
- int m_visibleCondition;
- GUIVISIBLE m_visible;
- bool m_visibleFromSkinCondition;
- bool m_forceHidden; // set from the code when a hidden operation is given - overrides m_visible
- CGUIInfoBool m_allowHiddenFocus;
- bool m_hasRendered;
- // enable/disable state
- int m_enableCondition;
- bool m_enabled;
-
- bool m_pushedUpdates;
-
- // animation effects
- std::vector<CAnimation> m_animations;
- CPoint m_camera;
- bool m_hasCamera;
- TransformMatrix m_transform;
-};
-
-#endif
diff --git a/guilib/GUIControlFactory.cpp b/guilib/GUIControlFactory.cpp
deleted file mode 100644
index 63bac831cc..0000000000
--- a/guilib/GUIControlFactory.cpp
+++ /dev/null
@@ -1,1356 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIControlFactory.h"
-#include "LocalizeStrings.h"
-#include "GUIButtonControl.h"
-#include "GUIRadioButtonControl.h"
-#include "GUISpinControl.h"
-#include "GUIRSSControl.h"
-#include "GUIImage.h"
-#include "GUIBorderedImage.h"
-#include "GUILabelControl.h"
-#include "GUIEditControl.h"
-#include "GUIFadeLabelControl.h"
-#include "GUICheckMarkControl.h"
-#include "GUIToggleButtonControl.h"
-#include "GUITextBox.h"
-#include "GUIVideoControl.h"
-#include "GUIProgressControl.h"
-#include "GUISliderControl.h"
-#include "GUISelectButtonControl.h"
-#include "GUIMoverControl.h"
-#include "GUIResizeControl.h"
-#include "GUIButtonScroller.h"
-#include "GUISpinControlEx.h"
-#include "GUIVisualisationControl.h"
-#include "GUISettingsSliderControl.h"
-#include "GUIMultiImage.h"
-#include "GUIControlGroup.h"
-#include "GUIControlGroupList.h"
-#include "GUIScrollBarControl.h"
-#include "GUIListContainer.h"
-#include "GUIFixedListContainer.h"
-#include "GUIWrappingListContainer.h"
-#include "GUIPanelContainer.h"
-#include "GUIMultiSelectText.h"
-#include "GUIListLabel.h"
-#include "GUIListGroup.h"
-#include "utils/GUIInfoManager.h"
-#include "utils/CharsetConverter.h"
-#include "utils/log.h"
-#include "ButtonTranslator.h"
-#include "XMLUtils.h"
-#include "GUIFontManager.h"
-#include "GUIColorManager.h"
-#include "Settings.h"
-#include "StringUtils.h"
-
-using namespace std;
-
-typedef struct
-{
- const char* name;
- CGUIControl::GUICONTROLTYPES type;
-} ControlMapping;
-
-static const ControlMapping controls[] =
- {{"button", CGUIControl::GUICONTROL_BUTTON},
- {"checkmark", CGUIControl::GUICONTROL_CHECKMARK},
- {"fadelabel", CGUIControl::GUICONTROL_FADELABEL},
- {"image", CGUIControl::GUICONTROL_IMAGE},
- {"largeimage", CGUIControl::GUICONTROL_IMAGE},
- {"image", CGUIControl::GUICONTROL_BORDEREDIMAGE},
- {"label", CGUIControl::GUICONTROL_LABEL},
- {"label", CGUIControl::GUICONTROL_LISTLABEL},
- {"group", CGUIControl::GUICONTROL_GROUP},
- {"group", CGUIControl::GUICONTROL_LISTGROUP},
- {"progress", CGUIControl::GUICONTROL_PROGRESS},
- {"radiobutton", CGUIControl::GUICONTROL_RADIO},
- {"rss", CGUIControl::GUICONTROL_RSS},
- {"selectbutton", CGUIControl::GUICONTROL_SELECTBUTTON},
- {"slider", CGUIControl::GUICONTROL_SLIDER},
- {"sliderex", CGUIControl::GUICONTROL_SETTINGS_SLIDER},
- {"spincontrol", CGUIControl::GUICONTROL_SPIN},
- {"spincontrolex", CGUIControl::GUICONTROL_SPINEX},
- {"textbox", CGUIControl::GUICONTROL_TEXTBOX},
- {"togglebutton", CGUIControl::GUICONTROL_TOGGLEBUTTON},
- {"videowindow", CGUIControl::GUICONTROL_VIDEO},
- {"mover", CGUIControl::GUICONTROL_MOVER},
- {"resize", CGUIControl::GUICONTROL_RESIZE},
- {"buttonscroller", CGUIControl::GUICONTROL_BUTTONBAR},
- {"edit", CGUIControl::GUICONTROL_EDIT},
- {"visualisation", CGUIControl::GUICONTROL_VISUALISATION},
- {"karvisualisation", CGUIControl::GUICONTROL_VISUALISATION},
- {"renderaddon", CGUIControl::GUICONTROL_RENDERADDON},
- {"multiimage", CGUIControl::GUICONTROL_MULTI_IMAGE},
- {"grouplist", CGUIControl::GUICONTROL_GROUPLIST},
- {"scrollbar", CGUIControl::GUICONTROL_SCROLLBAR},
- {"multiselect", CGUIControl::GUICONTROL_MULTISELECT},
- {"list", CGUIControl::GUICONTAINER_LIST},
- {"wraplist", CGUIControl::GUICONTAINER_WRAPLIST},
- {"fixedlist", CGUIControl::GUICONTAINER_FIXEDLIST},
- {"panel", CGUIControl::GUICONTAINER_PANEL}};
-
-CGUIControl::GUICONTROLTYPES CGUIControlFactory::TranslateControlType(const CStdString &type)
-{
- for (unsigned int i = 0; i < sizeof(controls) / sizeof(controls[0]); ++i)
- if (0 == type.CompareNoCase(controls[i].name))
- return controls[i].type;
- return CGUIControl::GUICONTROL_UNKNOWN;
-}
-
-CStdString CGUIControlFactory::TranslateControlType(CGUIControl::GUICONTROLTYPES type)
-{
- for (unsigned int i = 0; i < sizeof(controls) / sizeof(controls[0]); ++i)
- if (type == controls[i].type)
- return controls[i].name;
- return "";
-}
-
-CGUIControlFactory::CGUIControlFactory(void)
-{}
-
-CGUIControlFactory::~CGUIControlFactory(void)
-{}
-
-bool CGUIControlFactory::GetIntRange(const TiXmlNode* pRootNode, const char* strTag, int& iMinValue, int& iMaxValue, int& iIntervalValue)
-{
- const TiXmlNode* pNode = pRootNode->FirstChild(strTag);
- if (!pNode || !pNode->FirstChild()) return false;
- iMinValue = atoi(pNode->FirstChild()->Value());
- const char* maxValue = strchr(pNode->FirstChild()->Value(), ',');
- if (maxValue)
- {
- maxValue++;
- iMaxValue = atoi(maxValue);
-
- const char* intervalValue = strchr(maxValue, ',');
- if (intervalValue)
- {
- intervalValue++;
- iIntervalValue = atoi(intervalValue);
- }
- }
-
- return true;
-}
-
-bool CGUIControlFactory::GetFloatRange(const TiXmlNode* pRootNode, const char* strTag, float& fMinValue, float& fMaxValue, float& fIntervalValue)
-{
- const TiXmlNode* pNode = pRootNode->FirstChild(strTag);
- if (!pNode || !pNode->FirstChild()) return false;
- fMinValue = (float)atof(pNode->FirstChild()->Value());
- const char* maxValue = strchr(pNode->FirstChild()->Value(), ',');
- if (maxValue)
- {
- maxValue++;
- fMaxValue = (float)atof(maxValue);
-
- const char* intervalValue = strchr(maxValue, ',');
- if (intervalValue)
- {
- intervalValue++;
- fIntervalValue = (float)atof(intervalValue);
- }
- }
-
- return true;
-}
-
-bool CGUIControlFactory::GetDimension(const TiXmlNode *pRootNode, const char* strTag, float &value, float &min)
-{
- const TiXmlElement* pNode = pRootNode->FirstChildElement(strTag);
- if (!pNode || !pNode->FirstChild()) return false;
- if (0 == strnicmp("auto", pNode->FirstChild()->Value(), 4))
- { // auto-width - at least min must be set
- pNode->QueryFloatAttribute("max", &value);
- pNode->QueryFloatAttribute("min", &min);
- if (!min) min = 1;
- return true;
- }
- value = (float)atof(pNode->FirstChild()->Value());
- return true;
-}
-
-bool CGUIControlFactory::GetMultipleString(const TiXmlNode* pRootNode, const char* strTag, std::vector<CGUIActionDescriptor>& vecStringValue)
-{
- const TiXmlNode* pNode = pRootNode->FirstChild(strTag );
- if (!pNode) return false;
- vecStringValue.clear();
- bool bFound = false;
- while (pNode)
- {
- CGUIActionDescriptor action;
- if (CGUIControlFactory::GetAction((const TiXmlElement*) pNode, action))
- {
- vecStringValue.push_back(action);
- bFound = true;
- }
- pNode = pNode->NextSibling(strTag);
- }
- return bFound;
-}
-
-bool CGUIControlFactory::GetAction(const TiXmlElement* pElement, CGUIActionDescriptor &action)
-{
- CStdString langStr = pElement->Attribute("lang");
- if (langStr.CompareNoCase("python") == 0 )
- action.m_lang = CGUIActionDescriptor::LANG_PYTHON;
- else
- action.m_lang = CGUIActionDescriptor::LANG_XBMC;
-
- if (pElement->FirstChild())
- {
- action.m_action = pElement->FirstChild()->Value();
- return true;
- }
- else
- {
- action.m_action = "";
- return false;
- }
-}
-
-bool CGUIControlFactory::GetAspectRatio(const TiXmlNode* pRootNode, const char* strTag, CAspectRatio &aspect)
-{
- CStdString ratio;
- const TiXmlElement *node = pRootNode->FirstChildElement(strTag);
- if (!node || !node->FirstChild())
- return false;
-
- ratio = node->FirstChild()->Value();
- if (ratio.CompareNoCase("keep") == 0) aspect.ratio = CAspectRatio::AR_KEEP;
- else if (ratio.CompareNoCase("scale") == 0) aspect.ratio = CAspectRatio::AR_SCALE;
- else if (ratio.CompareNoCase("center") == 0) aspect.ratio = CAspectRatio::AR_CENTER;
- else if (ratio.CompareNoCase("stretch") == 0) aspect.ratio = CAspectRatio::AR_STRETCH;
-
- const char *attribute = node->Attribute("align");
- if (attribute)
- {
- CStdString align(attribute);
- if (align.CompareNoCase("center") == 0) aspect.align = ASPECT_ALIGN_CENTER | (aspect.align & ASPECT_ALIGNY_MASK);
- else if (align.CompareNoCase("right") == 0) aspect.align = ASPECT_ALIGN_RIGHT | (aspect.align & ASPECT_ALIGNY_MASK);
- else if (align.CompareNoCase("left") == 0) aspect.align = ASPECT_ALIGN_LEFT | (aspect.align & ASPECT_ALIGNY_MASK);
- }
- attribute = node->Attribute("aligny");
- if (attribute)
- {
- CStdString align(attribute);
- if (align.CompareNoCase("center") == 0) aspect.align = ASPECT_ALIGNY_CENTER | (aspect.align & ASPECT_ALIGN_MASK);
- else if (align.CompareNoCase("bottom") == 0) aspect.align = ASPECT_ALIGNY_BOTTOM | (aspect.align & ASPECT_ALIGN_MASK);
- else if (align.CompareNoCase("top") == 0) aspect.align = ASPECT_ALIGNY_TOP | (aspect.align & ASPECT_ALIGN_MASK);
- }
- attribute = node->Attribute("scalediffuse");
- if (attribute)
- {
- CStdString scale(attribute);
- if (scale.CompareNoCase("true") == 0 || scale.CompareNoCase("yes") == 0)
- aspect.scaleDiffuse = true;
- else
- aspect.scaleDiffuse = false;
- }
- return true;
-}
-
-bool CGUIControlFactory::GetInfoTexture(const TiXmlNode* pRootNode, const char* strTag, CTextureInfo &image, CGUIInfoLabel &info)
-{
- GetTexture(pRootNode, strTag, image);
- image.filename = "";
- GetInfoLabel(pRootNode, strTag, info);
- return true;
-}
-
-bool CGUIControlFactory::GetTexture(const TiXmlNode* pRootNode, const char* strTag, CTextureInfo &image)
-{
- const TiXmlElement* pNode = pRootNode->FirstChildElement(strTag);
- if (!pNode) return false;
- const char *border = pNode->Attribute("border");
- if (border)
- GetRectFromString(border, image.border);
- image.orientation = 0;
- const char *flipX = pNode->Attribute("flipx");
- if (flipX && strcmpi(flipX, "true") == 0) image.orientation = 1;
- const char *flipY = pNode->Attribute("flipy");
- if (flipY && strcmpi(flipY, "true") == 0) image.orientation = 3 - image.orientation; // either 3 or 2
- image.diffuse = pNode->Attribute("diffuse");
- const char *background = pNode->Attribute("background");
- if (background && strnicmp(background, "true", 4) == 0)
- image.useLarge = true;
- image.filename = (pNode->FirstChild() && pNode->FirstChild()->ValueStr() != "-") ? pNode->FirstChild()->Value() : "";
- return true;
-}
-
-void CGUIControlFactory::GetRectFromString(const CStdString &string, CRect &rect)
-{
- // format is rect="left[,top,right,bottom]"
- CStdStringArray strRect;
- StringUtils::SplitString(string, ",", strRect);
- if (strRect.size() == 1)
- {
- rect.x1 = (float)atof(strRect[0].c_str());
- rect.y1 = rect.x1;
- rect.x2 = rect.x1;
- rect.y2 = rect.x1;
- }
- else if (strRect.size() == 4)
- {
- rect.x1 = (float)atof(strRect[0].c_str());
- rect.y1 = (float)atof(strRect[1].c_str());
- rect.x2 = (float)atof(strRect[2].c_str());
- rect.y2 = (float)atof(strRect[3].c_str());
- }
-}
-
-bool CGUIControlFactory::GetAlignment(const TiXmlNode* pRootNode, const char* strTag, uint32_t& alignment)
-{
- const TiXmlNode* pNode = pRootNode->FirstChild(strTag);
- if (!pNode || !pNode->FirstChild()) return false;
-
- CStdString strAlign = pNode->FirstChild()->Value();
- if (strAlign == "right" || strAlign == "bottom") alignment = XBFONT_RIGHT;
- else if (strAlign == "center") alignment = XBFONT_CENTER_X;
- else if (strAlign == "justify") alignment = XBFONT_JUSTIFIED;
- else alignment = XBFONT_LEFT;
- return true;
-}
-
-bool CGUIControlFactory::GetAlignmentY(const TiXmlNode* pRootNode, const char* strTag, uint32_t& alignment)
-{
- const TiXmlNode* pNode = pRootNode->FirstChild(strTag );
- if (!pNode || !pNode->FirstChild())
- {
- return false;
- }
-
- CStdString strAlign = pNode->FirstChild()->Value();
-
- alignment = 0;
- if (strAlign == "center")
- {
- alignment = XBFONT_CENTER_Y;
- }
-
- return true;
-}
-
-bool CGUIControlFactory::GetConditionalVisibility(const TiXmlNode* control, int &condition, CGUIInfoBool &allowHiddenFocus)
-{
- const TiXmlElement* node = control->FirstChildElement("visible");
- if (!node) return false;
- vector<CStdString> conditions;
- while (node)
- {
- const char *hidden = node->Attribute("allowhiddenfocus");
- if (hidden)
- allowHiddenFocus.Parse(hidden);
- // add to our condition string
- if (!node->NoChildren())
- conditions.push_back(node->FirstChild()->Value());
- node = node->NextSiblingElement("visible");
- }
- if (!conditions.size())
- return false;
- if (conditions.size() == 1)
- condition = g_infoManager.TranslateString(conditions[0]);
- else
- { // multiple conditions should be anded together
- CStdString conditionString = "[";
- for (unsigned int i = 0; i < conditions.size() - 1; i++)
- conditionString += conditions[i] + "] + [";
- conditionString += conditions[conditions.size() - 1] + "]";
- condition = g_infoManager.TranslateString(conditionString);
- }
- return (condition != 0);
-}
-
-bool CGUIControlFactory::GetCondition(const TiXmlNode *control, const char *tag, int &condition)
-{
- CStdString condString;
- if (XMLUtils::GetString(control, tag, condString))
- {
- condition = g_infoManager.TranslateString(condString);
- return true;
- }
- return false;
-}
-
-bool CGUIControlFactory::GetConditionalVisibility(const TiXmlNode *control, int &condition)
-{
- CGUIInfoBool allowHiddenFocus;
- return GetConditionalVisibility(control, condition, allowHiddenFocus);
-}
-
-bool CGUIControlFactory::GetAnimations(TiXmlNode *control, const CRect &rect, vector<CAnimation> &animations)
-{
- TiXmlElement* node = control->FirstChildElement("animation");
- bool ret = false;
- if (node)
- animations.clear();
- while (node)
- {
- ret = true;
- if (node->FirstChild())
- {
- CAnimation anim;
- anim.Create(node, rect);
- animations.push_back(anim);
- if (strcmpi(node->FirstChild()->Value(), "VisibleChange") == 0)
- { // add the hidden one as well
- TiXmlElement hidden(*node);
- hidden.FirstChild()->SetValue("hidden");
- const char *start = hidden.Attribute("start");
- const char *end = hidden.Attribute("end");
- if (start && end)
- {
- CStdString temp = end;
- hidden.SetAttribute("end", start);
- hidden.SetAttribute("start", temp.c_str());
- }
- else if (start)
- hidden.SetAttribute("end", start);
- else if (end)
- hidden.SetAttribute("start", end);
- CAnimation anim2;
- anim2.Create(&hidden, rect);
- animations.push_back(anim2);
- }
- }
- node = node->NextSiblingElement("animation");
- }
- return ret;
-}
-
-bool CGUIControlFactory::GetHitRect(const TiXmlNode *control, CRect &rect)
-{
- const TiXmlElement* node = control->FirstChildElement("hitrect");
- if (node)
- {
- node->QueryFloatAttribute("x", &rect.x1);
- node->QueryFloatAttribute("y", &rect.y1);
- if (node->Attribute("w"))
- rect.x2 = (float)atof(node->Attribute("w")) + rect.x1;
- if (node->Attribute("h"))
- rect.y2 = (float)atof(node->Attribute("h")) + rect.y1;
- return true;
- }
- return false;
-}
-
-bool CGUIControlFactory::GetColor(const TiXmlNode *control, const char *strTag, color_t &value)
-{
- const TiXmlElement* node = control->FirstChildElement(strTag);
- if (node && node->FirstChild())
- {
- value = g_colorManager.GetColor(node->FirstChild()->Value());
- return true;
- }
- return false;
-}
-
-bool CGUIControlFactory::GetInfoColor(const TiXmlNode *control, const char *strTag, CGUIInfoColor &value)
-{
- const TiXmlElement* node = control->FirstChildElement(strTag);
- if (node && node->FirstChild())
- {
- value.Parse(node->FirstChild()->Value());
- return true;
- }
- return false;
-}
-
-bool CGUIControlFactory::GetNavigation(const TiXmlElement *node, const char *tag, int &direction, vector<CGUIActionDescriptor> &actions)
-{
- if (!GetMultipleString(node, tag, actions))
- return false; // no tag specified
- if (actions.size() == 1 && StringUtils::IsNaturalNumber(actions[0].m_action))
- { // single numeric tag specified
- direction = atol(actions[0].m_action.c_str());
- actions.clear();
- }
- else
- direction = 0;
- return true;
-}
-
-void CGUIControlFactory::GetInfoLabel(const TiXmlNode *pControlNode, const CStdString &labelTag, CGUIInfoLabel &infoLabel)
-{
- vector<CGUIInfoLabel> labels;
- GetInfoLabels(pControlNode, labelTag, labels);
- if (labels.size())
- infoLabel = labels[0];
-}
-
-bool CGUIControlFactory::GetInfoLabelFromElement(const TiXmlElement *element, CGUIInfoLabel &infoLabel)
-{
- if (!element || !element->FirstChild())
- return false;
-
- CStdString label = element->FirstChild()->Value();
- if (label.IsEmpty() || label == "-")
- return false;
-
- CStdString fallback = element->Attribute("fallback");
- if (StringUtils::IsNaturalNumber(label))
- label = g_localizeStrings.Get(atoi(label));
- else // we assume the skin xml's aren't encoded as UTF-8
- g_charsetConverter.unknownToUTF8(label);
- if (StringUtils::IsNaturalNumber(fallback))
- fallback = g_localizeStrings.Get(atoi(fallback));
- else
- g_charsetConverter.unknownToUTF8(fallback);
- infoLabel.SetLabel(label, fallback);
- return true;
-}
-
-void CGUIControlFactory::GetInfoLabels(const TiXmlNode *pControlNode, const CStdString &labelTag, vector<CGUIInfoLabel> &infoLabels)
-{
- // we can have the following infolabels:
- // 1. <number>1234</number> -> direct number
- // 2. <label>number</label> -> lookup in localizestrings
- // 3. <label fallback="blah">$LOCALIZE(blah) $INFO(blah)</label> -> infolabel with given fallback
- // 4. <info>ListItem.Album</info> (uses <label> as fallback)
- int labelNumber = 0;
- if (XMLUtils::GetInt(pControlNode, "number", labelNumber))
- {
- CStdString label;
- label.Format("%i", labelNumber);
- infoLabels.push_back(CGUIInfoLabel(label));
- return; // done
- }
- const TiXmlElement *labelNode = pControlNode->FirstChildElement(labelTag);
- while (labelNode)
- {
- CGUIInfoLabel label;
- if (GetInfoLabelFromElement(labelNode, label))
- infoLabels.push_back(label);
- labelNode = labelNode->NextSiblingElement(labelTag);
- }
- const TiXmlNode *infoNode = pControlNode->FirstChild("info");
- if (infoNode)
- { // <info> nodes override <label>'s (backward compatibility)
- CStdString fallback;
- if (infoLabels.size())
- fallback = infoLabels[0].GetLabel(0);
- infoLabels.clear();
- while (infoNode)
- {
- if (infoNode->FirstChild())
- {
- CStdString info;
- info.Format("$INFO[%s]", infoNode->FirstChild()->Value());
- infoLabels.push_back(CGUIInfoLabel(info, fallback));
- }
- infoNode = infoNode->NextSibling("info");
- }
- }
-}
-
-// Convert a string to a GUI label, by translating/parsing the label for localisable strings
-CStdString CGUIControlFactory::FilterLabel(const CStdString &label)
-{
- CStdString viewLabel = label;
- if (StringUtils::IsNaturalNumber(viewLabel))
- viewLabel = g_localizeStrings.Get(atoi(label));
- else
- g_charsetConverter.unknownToUTF8(viewLabel);
- return viewLabel;
-}
-
-bool CGUIControlFactory::GetString(const TiXmlNode* pRootNode, const char *strTag, CStdString &text)
-{
- if (!XMLUtils::GetString(pRootNode, strTag, text))
- return false;
- if (text == "-")
- text.Empty();
- if (StringUtils::IsNaturalNumber(text))
- text = g_localizeStrings.Get(atoi(text.c_str()));
- else
- g_charsetConverter.unknownToUTF8(text);
- return true;
-}
-
-CStdString CGUIControlFactory::GetType(const TiXmlElement *pControlNode)
-{
- CStdString type;
- const char *szType = pControlNode->Attribute("type");
- if (szType)
- type = szType;
- else // backward compatibility - not desired
- XMLUtils::GetString(pControlNode, "type", type);
- return type;
-}
-
-CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlElement* pControlNode, bool insideContainer)
-{
- // get the control type
- CStdString strType = GetType(pControlNode);
- CGUIControl::GUICONTROLTYPES type = TranslateControlType(strType);
-
- int id = 0;
- float posX = 0, posY = 0;
- float width = 0, height = 0;
- float minWidth = 0;
-
- int left = 0, right = 0, up = 0, down = 0, next = 0, prev = 0;
- vector<CGUIActionDescriptor> leftActions, rightActions, upActions, downActions, nextActions, prevActions;
-
- int pageControl = 0;
- CGUIInfoColor colorDiffuse(0xFFFFFFFF);
- int defaultControl = 0;
- bool defaultAlways = false;
- CStdString strTmp;
- int singleInfo = 0;
- CStdString strLabel;
- int iUrlSet=0;
- int iToggleSelect;
-
- float spinWidth = 16;
- float spinHeight = 16;
- float spinPosX = 0, spinPosY = 0;
- float checkWidth = 0, checkHeight = 0;
- CStdString strSubType;
- int iType = SPIN_CONTROL_TYPE_TEXT;
- int iMin = 0;
- int iMax = 100;
- int iInterval = 1;
- float fMin = 0.0f;
- float fMax = 1.0f;
- float fInterval = 0.1f;
- bool bReverse = true;
- bool bReveal = false;
- CTextureInfo textureBackground, textureLeft, textureRight, textureMid, textureOverlay;
- CTextureInfo textureNib, textureNibFocus, textureBar, textureBarFocus;
- CTextureInfo textureLeftFocus, textureRightFocus;
- CTextureInfo textureUp, textureDown;
- CTextureInfo textureUpFocus, textureDownFocus;
- CTextureInfo texture, borderTexture;
- CGUIInfoLabel textureFile;
- CTextureInfo textureCheckMark, textureCheckMarkNF;
- CTextureInfo textureFocus, textureNoFocus;
- CTextureInfo textureAltFocus, textureAltNoFocus;
- CTextureInfo textureRadioOn, textureRadioOff;
- CTextureInfo imageNoFocus, imageFocus;
- CGUIInfoLabel texturePath;
- CRect borderSize;
-
- float sliderWidth = 150, sliderHeight = 16;
- CPoint offset;
-
- bool bHasPath = false;
- vector<CGUIActionDescriptor> clickActions;
- vector<CGUIActionDescriptor> altclickActions;
- vector<CGUIActionDescriptor> focusActions;
- vector<CGUIActionDescriptor> unfocusActions;
- vector<CGUIActionDescriptor> textChangeActions;
- CStdString strTitle = "";
- CStdString strRSSTags = "";
-
- int iNumSlots = 7;
- float buttonGap = 5;
- int iDefaultSlot = 2;
- int iMovementRange = 0;
- bool bHorizontal = false;
- int iAlpha = 0;
- bool bWrapAround = true;
- bool bSmoothScrolling = true;
- CAspectRatio aspect;
-#ifdef PRE_SKIN_VERSION_9_10_COMPATIBILITY
- if (insideContainer) // default for inside containers is keep
- aspect.ratio = CAspectRatio::AR_KEEP;
-#endif
-
- int iVisibleCondition = 0;
- CGUIInfoBool allowHiddenFocus(false);
- int enableCondition = 0;
-
- vector<CAnimation> animations;
-
- bool bScrollLabel = false;
- bool bPulse = true;
- unsigned int timePerImage = 0;
- unsigned int fadeTime = 0;
- unsigned int timeToPauseAtEnd = 0;
- bool randomized = false;
- bool loop = true;
- bool wrapMultiLine = false;
- ORIENTATION orientation = VERTICAL;
- bool showOnePage = true;
- bool scrollOut = true;
- int preloadItems = 0;
-
- CLabelInfo labelInfo;
- CLabelInfo spinInfo;
-
- CGUIInfoColor textColor3;
- CGUIInfoColor headlineColor;
-
- float radioWidth = 0;
- float radioHeight = 0;
- float radioPosX = 0;
- float radioPosY = 0;
-
- CStdString altLabel;
- CStdString strLabel2;
-
- int focusPosition = 0;
- int scrollTime = 200;
- bool useControlCoords = false;
- bool renderFocusedLast = false;
-
- CRect hitRect;
- CPoint camera;
- bool hasCamera = false;
- bool resetOnLabelChange = true;
- bool bPassword = false;
-
- /////////////////////////////////////////////////////////////////////////////
- // Read control properties from XML
- //
-
- if (!pControlNode->Attribute("id", (int*) &id))
- XMLUtils::GetInt(pControlNode, "id", (int&) id); // backward compatibility - not desired
- // TODO: Perhaps we should check here whether id is valid for focusable controls
- // such as buttons etc. For labels/fadelabels/images it does not matter
-
- XMLUtils::GetFloat(pControlNode, "posx", posX);
- XMLUtils::GetFloat(pControlNode, "posy", posY);
- // Convert these from relative coords
- CStdString pos;
- XMLUtils::GetString(pControlNode, "posx", pos);
- if (pos.Right(1) == "r")
- posX = rect.Width() - posX;
- XMLUtils::GetString(pControlNode, "posy", pos);
- if (pos.Right(1) == "r")
- posY = rect.Height() - posY;
-
- GetDimension(pControlNode, "width", width, minWidth);
- XMLUtils::GetFloat(pControlNode, "height", height);
- XMLUtils::GetFloat(pControlNode, "offsetx", offset.x);
- XMLUtils::GetFloat(pControlNode, "offsety", offset.y);
-
- // adjust width and height accordingly for groups. Groups should
- // take the width/height of the parent (adjusted for positioning)
- // if none is defined.
- if (type == CGUIControl::GUICONTROL_GROUP || type == CGUIControl::GUICONTROL_GROUPLIST)
- {
- if (!width)
- width = max(rect.x2 - posX, 0.0f);
- if (!height)
- height = max(rect.y2 - posY, 0.0f);
- }
-
- hitRect.SetRect(posX, posY, posX + width, posY + height);
- GetHitRect(pControlNode, hitRect);
-
- if (!GetNavigation(pControlNode, "onup", up, upActions)) up = id - 1;
- if (!GetNavigation(pControlNode, "ondown", down, downActions)) down = id + 1;
- if (!GetNavigation(pControlNode, "onleft", left, leftActions)) left = id;
- if (!GetNavigation(pControlNode, "onright", right, rightActions)) right = id;
- if (!GetNavigation(pControlNode, "onnext", next, nextActions)) next = id;
- if (!GetNavigation(pControlNode, "onprev", prev, prevActions)) prev = id;
-
- if (XMLUtils::GetInt(pControlNode, "defaultcontrol", defaultControl))
- {
- const char *always = pControlNode->FirstChildElement("defaultcontrol")->Attribute("always");
- if (always && strnicmp(always, "true", 4) == 0)
- defaultAlways = true;
- }
- XMLUtils::GetInt(pControlNode, "pagecontrol", pageControl);
-
- GetInfoColor(pControlNode, "colordiffuse", colorDiffuse);
-
- GetConditionalVisibility(pControlNode, iVisibleCondition, allowHiddenFocus);
- GetCondition(pControlNode, "enable", enableCondition);
-
- CRect animRect(posX, posY, posX + width, posY + height);
- GetAnimations(pControlNode, animRect, animations);
-
- GetInfoColor(pControlNode, "textcolor", labelInfo.textColor);
- GetInfoColor(pControlNode, "focusedcolor", labelInfo.focusedColor);
- GetInfoColor(pControlNode, "disabledcolor", labelInfo.disabledColor);
- GetInfoColor(pControlNode, "shadowcolor", labelInfo.shadowColor);
- GetInfoColor(pControlNode, "selectedcolor", labelInfo.selectedColor);
- XMLUtils::GetFloat(pControlNode, "textoffsetx", labelInfo.offsetX);
- XMLUtils::GetFloat(pControlNode, "textoffsety", labelInfo.offsetY);
- int angle = 0; // use the negative angle to compensate for our vertically flipped cartesian plane
- if (XMLUtils::GetInt(pControlNode, "angle", angle)) labelInfo.angle = (float)-angle;
- CStdString strFont;
- if (XMLUtils::GetString(pControlNode, "font", strFont))
- labelInfo.font = g_fontManager.GetFont(strFont);
- GetAlignment(pControlNode, "align", labelInfo.align);
- uint32_t alignY = 0;
- if (GetAlignmentY(pControlNode, "aligny", alignY))
- labelInfo.align |= alignY;
- if (XMLUtils::GetFloat(pControlNode, "textwidth", labelInfo.width))
- labelInfo.align |= XBFONT_TRUNCATED;
-
- GetMultipleString(pControlNode, "onclick", clickActions);
- GetMultipleString(pControlNode, "ontextchange", textChangeActions);
- GetMultipleString(pControlNode, "onfocus", focusActions);
- GetMultipleString(pControlNode, "onunfocus", unfocusActions);
- GetMultipleString(pControlNode, "altclick", altclickActions);
-
- CStdString infoString;
- if (XMLUtils::GetString(pControlNode, "info", infoString))
- singleInfo = g_infoManager.TranslateString(infoString);
-
- GetTexture(pControlNode, "texturefocus", textureFocus);
- GetTexture(pControlNode, "texturenofocus", textureNoFocus);
- GetTexture(pControlNode, "alttexturefocus", textureAltFocus);
- GetTexture(pControlNode, "alttexturenofocus", textureAltNoFocus);
- CStdString strToggleSelect;
- XMLUtils::GetString(pControlNode, "usealttexture", strToggleSelect);
- XMLUtils::GetString(pControlNode, "selected", strToggleSelect);
- iToggleSelect = g_infoManager.TranslateString(strToggleSelect);
-
- XMLUtils::GetBoolean(pControlNode, "haspath", bHasPath);
-
- GetTexture(pControlNode, "textureup", textureUp);
- GetTexture(pControlNode, "texturedown", textureDown);
- GetTexture(pControlNode, "textureupfocus", textureUpFocus);
- GetTexture(pControlNode, "texturedownfocus", textureDownFocus);
-
- GetTexture(pControlNode, "textureleft", textureLeft);
- GetTexture(pControlNode, "textureright", textureRight);
- GetTexture(pControlNode, "textureleftfocus", textureLeftFocus);
- GetTexture(pControlNode, "texturerightfocus", textureRightFocus);
-
- GetInfoColor(pControlNode, "spincolor", spinInfo.textColor);
- if (XMLUtils::GetString(pControlNode, "spinfont", strFont))
- spinInfo.font = g_fontManager.GetFont(strFont);
- if (!spinInfo.font) spinInfo.font = labelInfo.font;
-
- XMLUtils::GetFloat(pControlNode, "spinwidth", spinWidth);
- XMLUtils::GetFloat(pControlNode, "spinheight", spinHeight);
- XMLUtils::GetFloat(pControlNode, "spinposx", spinPosX);
- XMLUtils::GetFloat(pControlNode, "spinposy", spinPosY);
-
- XMLUtils::GetFloat(pControlNode, "markwidth", checkWidth);
- XMLUtils::GetFloat(pControlNode, "markheight", checkHeight);
- XMLUtils::GetFloat(pControlNode, "sliderwidth", sliderWidth);
- XMLUtils::GetFloat(pControlNode, "sliderheight", sliderHeight);
- GetTexture(pControlNode, "texturecheckmark", textureCheckMark);
- GetTexture(pControlNode, "texturecheckmarknofocus", textureCheckMarkNF);
- GetTexture(pControlNode, "textureradiofocus", textureRadioOn); // backward compatibility
- GetTexture(pControlNode, "textureradionofocus", textureRadioOff);
- GetTexture(pControlNode, "textureradioon", textureRadioOn);
- GetTexture(pControlNode, "textureradiooff", textureRadioOff);
-
- GetTexture(pControlNode, "texturesliderbackground", textureBackground);
- GetTexture(pControlNode, "texturesliderbar", textureBar);
- GetTexture(pControlNode, "texturesliderbarfocus", textureBarFocus);
- GetTexture(pControlNode, "textureslidernib", textureNib);
- GetTexture(pControlNode, "textureslidernibfocus", textureNibFocus);
-
- XMLUtils::GetString(pControlNode, "title", strTitle);
- XMLUtils::GetString(pControlNode, "tagset", strRSSTags);
- GetInfoColor(pControlNode, "headlinecolor", headlineColor);
- GetInfoColor(pControlNode, "titlecolor", textColor3);
-
- if (XMLUtils::GetString(pControlNode, "subtype", strSubType))
- {
- strSubType.ToLower();
-
- if ( strSubType == "int")
- iType = SPIN_CONTROL_TYPE_INT;
- else if ( strSubType == "page")
- iType = SPIN_CONTROL_TYPE_PAGE;
- else if ( strSubType == "float")
- iType = SPIN_CONTROL_TYPE_FLOAT;
- else
- iType = SPIN_CONTROL_TYPE_TEXT;
- }
-
- if (!GetIntRange(pControlNode, "range", iMin, iMax, iInterval))
- {
- GetFloatRange(pControlNode, "range", fMin, fMax, fInterval);
- }
-
- XMLUtils::GetBoolean(pControlNode, "reverse", bReverse);
- XMLUtils::GetBoolean(pControlNode, "reveal", bReveal);
-
- GetTexture(pControlNode, "texturebg", textureBackground);
- GetTexture(pControlNode, "lefttexture", textureLeft);
- GetTexture(pControlNode, "midtexture", textureMid);
- GetTexture(pControlNode, "righttexture", textureRight);
- GetTexture(pControlNode, "overlaytexture", textureOverlay);
-
- // the <texture> tag can be overridden by the <info> tag
- GetInfoTexture(pControlNode, "texture", texture, textureFile);
-
- GetTexture(pControlNode, "bordertexture", borderTexture);
-
- GetTexture(pControlNode, "imagefolder", imageNoFocus);
- GetTexture(pControlNode, "imagefolderfocus", imageFocus);
-
- // fade label can have a whole bunch, but most just have one
- vector<CGUIInfoLabel> infoLabels;
- GetInfoLabels(pControlNode, "label", infoLabels);
-
- GetString(pControlNode, "label", strLabel);
- GetString(pControlNode, "altlabel", altLabel);
- GetString(pControlNode, "label2", strLabel2);
-
- XMLUtils::GetBoolean(pControlNode, "wrapmultiline", wrapMultiLine);
- XMLUtils::GetInt(pControlNode,"urlset",iUrlSet);
-
- // stuff for button scroller
- if ( XMLUtils::GetString(pControlNode, "orientation", strTmp) )
- {
- if (strTmp.ToLower() == "horizontal")
- {
- bHorizontal = true;
- orientation = HORIZONTAL;
- }
- }
- XMLUtils::GetFloat(pControlNode, "buttongap", buttonGap);
- XMLUtils::GetFloat(pControlNode, "itemgap", buttonGap);
- XMLUtils::GetInt(pControlNode, "numbuttons", iNumSlots);
- XMLUtils::GetInt(pControlNode, "movement", iMovementRange);
- XMLUtils::GetInt(pControlNode, "defaultbutton", iDefaultSlot);
- XMLUtils::GetInt(pControlNode, "alpha", iAlpha);
- XMLUtils::GetBoolean(pControlNode, "wraparound", bWrapAround);
- XMLUtils::GetBoolean(pControlNode, "smoothscrolling", bSmoothScrolling);
- GetAspectRatio(pControlNode, "aspectratio", aspect);
- XMLUtils::GetBoolean(pControlNode, "scroll", bScrollLabel);
- XMLUtils::GetBoolean(pControlNode,"pulseonselect", bPulse);
-
- GetInfoTexture(pControlNode, "imagepath", texture, texturePath);
-
- XMLUtils::GetUInt(pControlNode,"timeperimage", timePerImage);
- XMLUtils::GetUInt(pControlNode,"fadetime", fadeTime);
- XMLUtils::GetUInt(pControlNode,"pauseatend", timeToPauseAtEnd);
- XMLUtils::GetBoolean(pControlNode, "randomize", randomized);
- XMLUtils::GetBoolean(pControlNode, "loop", loop);
- XMLUtils::GetBoolean(pControlNode, "scrollout", scrollOut);
-
- XMLUtils::GetFloat(pControlNode, "radiowidth", radioWidth);
- XMLUtils::GetFloat(pControlNode, "radioheight", radioHeight);
- XMLUtils::GetFloat(pControlNode, "radioposx", radioPosX);
- XMLUtils::GetFloat(pControlNode, "radioposy", radioPosY);
- CStdString borderStr;
- if (XMLUtils::GetString(pControlNode, "bordersize", borderStr))
- GetRectFromString(borderStr, borderSize);
-
- XMLUtils::GetBoolean(pControlNode, "showonepage", showOnePage);
- XMLUtils::GetInt(pControlNode, "focusposition", focusPosition);
- XMLUtils::GetInt(pControlNode, "scrolltime", scrollTime);
- XMLUtils::GetInt(pControlNode, "preloaditems", preloadItems, 0, 2);
-
- XMLUtils::GetBoolean(pControlNode, "usecontrolcoords", useControlCoords);
- XMLUtils::GetBoolean(pControlNode, "renderfocusedlast", renderFocusedLast);
- XMLUtils::GetBoolean(pControlNode, "resetonlabelchange", resetOnLabelChange);
-
- XMLUtils::GetBoolean(pControlNode, "password", bPassword);
-
- // view type
- VIEW_TYPE viewType = VIEW_TYPE_NONE;
- CStdString viewLabel;
- if (type == CGUIControl::GUICONTAINER_PANEL)
- {
- viewType = VIEW_TYPE_ICON;
- viewLabel = g_localizeStrings.Get(536);
- }
- else if (type == CGUIControl::GUICONTAINER_LIST)
- {
- viewType = VIEW_TYPE_LIST;
- viewLabel = g_localizeStrings.Get(535);
- }
- else
- {
- viewType = VIEW_TYPE_WRAP;
- viewLabel = g_localizeStrings.Get(541);
- }
- TiXmlElement *itemElement = pControlNode->FirstChildElement("viewtype");
- if (itemElement && itemElement->FirstChild())
- {
- CStdString type = itemElement->FirstChild()->Value();
- if (type == "list")
- viewType = VIEW_TYPE_LIST;
- else if (type == "icon")
- viewType = VIEW_TYPE_ICON;
- else if (type == "biglist")
- viewType = VIEW_TYPE_BIG_LIST;
- else if (type == "bigicon")
- viewType = VIEW_TYPE_BIG_ICON;
- else if (type == "wide")
- viewType = VIEW_TYPE_WIDE;
- else if (type == "bigwide")
- viewType = VIEW_TYPE_BIG_WIDE;
- else if (type == "wrap")
- viewType = VIEW_TYPE_WRAP;
- else if (type == "bigwrap")
- viewType = VIEW_TYPE_BIG_WRAP;
- const char *label = itemElement->Attribute("label");
- if (label)
- viewLabel = CGUIInfoLabel::GetLabel(FilterLabel(label));
- }
-
- TiXmlElement *cam = pControlNode->FirstChildElement("camera");
- if (cam)
- {
- hasCamera = true;
- cam->QueryFloatAttribute("x", &camera.x);
- cam->QueryFloatAttribute("y", &camera.y);
- }
-
- XMLUtils::GetInt(pControlNode, "scrollspeed", labelInfo.scrollSpeed);
- spinInfo.scrollSpeed = labelInfo.scrollSpeed;
-
- GetString(pControlNode, "scrollsuffix", labelInfo.scrollSuffix);
- spinInfo.scrollSuffix = labelInfo.scrollSuffix;
-
- /////////////////////////////////////////////////////////////////////////////
- // Instantiate a new control using the properties gathered above
- //
-
- CGUIControl *control = NULL;
- if (type == CGUIControl::GUICONTROL_GROUP)
- {
- if (insideContainer)
- {
- control = new CGUIListGroup(parentID, id, posX, posY, width, height);
- }
- else
- {
- control = new CGUIControlGroup(
- parentID, id, posX, posY, width, height);
- ((CGUIControlGroup *)control)->SetDefaultControl(defaultControl, defaultAlways);
- ((CGUIControlGroup *)control)->SetRenderFocusedLast(renderFocusedLast);
- }
- }
- else if (type == CGUIControl::GUICONTROL_GROUPLIST)
- {
- control = new CGUIControlGroupList(
- parentID, id, posX, posY, width, height, buttonGap, pageControl, orientation, useControlCoords, labelInfo.align, scrollTime);
- ((CGUIControlGroup *)control)->SetRenderFocusedLast(renderFocusedLast);
- }
- else if (type == CGUIControl::GUICONTROL_LABEL)
- {
- const CGUIInfoLabel &content = (infoLabels.size()) ? infoLabels[0] : CGUIInfoLabel("");
- if (insideContainer)
- { // inside lists we use CGUIListLabel
- control = new CGUIListLabel(parentID, id, posX, posY, width, height, labelInfo, content, bScrollLabel);
- }
- else
- {
- control = new CGUILabelControl(
- parentID, id, posX, posY, width, height,
- labelInfo, wrapMultiLine, bHasPath);
- ((CGUILabelControl *)control)->SetInfo(content);
- ((CGUILabelControl *)control)->SetWidthControl(minWidth, bScrollLabel);
- }
- }
- else if (type == CGUIControl::GUICONTROL_EDIT)
- {
- control = new CGUIEditControl(
- parentID, id, posX, posY, width, height, textureFocus, textureNoFocus,
- labelInfo, strLabel);
-
- if (bPassword)
- ((CGUIEditControl *) control)->SetInputType(CGUIEditControl::INPUT_TYPE_PASSWORD, 0);
- ((CGUIEditControl *) control)->SetTextChangeActions(textChangeActions);
- }
- else if (type == CGUIControl::GUICONTROL_VIDEO)
- {
- control = new CGUIVideoControl(
- parentID, id, posX, posY, width, height);
- }
- else if (type == CGUIControl::GUICONTROL_FADELABEL)
- {
- control = new CGUIFadeLabelControl(
- parentID, id, posX, posY, width, height,
- labelInfo, scrollOut, timeToPauseAtEnd, resetOnLabelChange);
-
- ((CGUIFadeLabelControl *)control)->SetInfo(infoLabels);
- }
- else if (type == CGUIControl::GUICONTROL_RSS)
- {
- control = new CGUIRSSControl(
- parentID, id, posX, posY, width, height,
- labelInfo, textColor3, headlineColor, strRSSTags);
-
- std::map<int,CSettings::RssSet>::iterator iter=g_settings.m_mapRssUrls.find(iUrlSet);
- if (iter != g_settings.m_mapRssUrls.end())
- {
- ((CGUIRSSControl *)control)->SetUrls(iter->second.url,iter->second.rtl);
- ((CGUIRSSControl *)control)->SetIntervals(iter->second.interval);
- }
- else
- CLog::Log(LOGERROR,"invalid rss url set referenced in skin");
- }
- else if (type == CGUIControl::GUICONTROL_BUTTON)
- {
- control = new CGUIButtonControl(
- parentID, id, posX, posY, width, height,
- textureFocus, textureNoFocus,
- labelInfo);
-
- ((CGUIButtonControl *)control)->SetLabel(strLabel);
- ((CGUIButtonControl *)control)->SetLabel2(strLabel2);
- ((CGUIButtonControl *)control)->SetClickActions(clickActions);
- ((CGUIButtonControl *)control)->SetFocusActions(focusActions);
- ((CGUIButtonControl *)control)->SetUnFocusActions(unfocusActions);
- }
- else if (type == CGUIControl::GUICONTROL_TOGGLEBUTTON)
- {
- control = new CGUIToggleButtonControl(
- parentID, id, posX, posY, width, height,
- textureFocus, textureNoFocus,
- textureAltFocus, textureAltNoFocus, labelInfo);
-
- ((CGUIToggleButtonControl *)control)->SetLabel(strLabel);
- ((CGUIToggleButtonControl *)control)->SetAltLabel(altLabel);
- ((CGUIToggleButtonControl *)control)->SetClickActions(clickActions);
- ((CGUIToggleButtonControl *)control)->SetAltClickActions(altclickActions);
- ((CGUIToggleButtonControl *)control)->SetFocusActions(focusActions);
- ((CGUIToggleButtonControl *)control)->SetUnFocusActions(unfocusActions);
- ((CGUIToggleButtonControl *)control)->SetToggleSelect(iToggleSelect);
- }
- else if (type == CGUIControl::GUICONTROL_CHECKMARK)
- {
- control = new CGUICheckMarkControl(
- parentID, id, posX, posY, width, height,
- textureCheckMark, textureCheckMarkNF,
- checkWidth, checkHeight, labelInfo);
-
- ((CGUICheckMarkControl *)control)->SetLabel(strLabel);
- }
- else if (type == CGUIControl::GUICONTROL_RADIO)
- {
- control = new CGUIRadioButtonControl(
- parentID, id, posX, posY, width, height,
- textureFocus, textureNoFocus,
- labelInfo,
- textureRadioOn, textureRadioOff);
-
- ((CGUIRadioButtonControl *)control)->SetLabel(strLabel);
- ((CGUIRadioButtonControl *)control)->SetRadioDimensions(radioPosX, radioPosY, radioWidth, radioHeight);
- ((CGUIRadioButtonControl *)control)->SetToggleSelect(iToggleSelect);
- ((CGUIRadioButtonControl *)control)->SetClickActions(clickActions);
- ((CGUIRadioButtonControl *)control)->SetFocusActions(focusActions);
- ((CGUIRadioButtonControl *)control)->SetUnFocusActions(unfocusActions);
- }
- else if (type == CGUIControl::GUICONTROL_MULTISELECT)
- {
- CGUIInfoLabel label;
- if (infoLabels.size())
- label = infoLabels[0];
- control = new CGUIMultiSelectTextControl(
- parentID, id, posX, posY, width, height,
- textureFocus, textureNoFocus, labelInfo, label);
- }
- else if (type == CGUIControl::GUICONTROL_SPIN)
- {
- control = new CGUISpinControl(
- parentID, id, posX, posY, width, height,
- textureUp, textureDown, textureUpFocus, textureDownFocus,
- labelInfo, iType);
-
- ((CGUISpinControl *)control)->SetReverse(bReverse);
-
- if (iType == SPIN_CONTROL_TYPE_INT)
- {
- ((CGUISpinControl *)control)->SetRange(iMin, iMax);
- }
- else if (iType == SPIN_CONTROL_TYPE_PAGE)
- {
- ((CGUISpinControl *)control)->SetRange(iMin, iMax);
- ((CGUISpinControl *)control)->SetShowRange(true);
- ((CGUISpinControl *)control)->SetReverse(false);
- ((CGUISpinControl *)control)->SetShowOnePage(showOnePage);
- }
- else if (iType == SPIN_CONTROL_TYPE_FLOAT)
- {
- ((CGUISpinControl *)control)->SetFloatRange(fMin, fMax);
- ((CGUISpinControl *)control)->SetFloatInterval(fInterval);
- }
- }
- else if (type == CGUIControl::GUICONTROL_SLIDER)
- {
- control = new CGUISliderControl(
- parentID, id, posX, posY, width, height,
- textureBar, textureNib, textureNibFocus, SPIN_CONTROL_TYPE_TEXT);
-
- ((CGUISliderControl *)control)->SetInfo(singleInfo);
- }
- else if (type == CGUIControl::GUICONTROL_SETTINGS_SLIDER)
- {
- labelInfo.align |= XBFONT_CENTER_Y; // always center text vertically
- control = new CGUISettingsSliderControl(
- parentID, id, posX, posY, width, height, sliderWidth, sliderHeight, textureFocus, textureNoFocus,
- textureBar, textureNib, textureNibFocus, labelInfo, SPIN_CONTROL_TYPE_TEXT);
-
- ((CGUISettingsSliderControl *)control)->SetText(strLabel);
- ((CGUISettingsSliderControl *)control)->SetInfo(singleInfo);
- }
- else if (type == CGUIControl::GUICONTROL_SCROLLBAR)
- {
- control = new CGUIScrollBar(
- parentID, id, posX, posY, width, height,
- textureBackground, textureBar, textureBarFocus, textureNib, textureNibFocus, orientation, showOnePage);
- }
- else if (type == CGUIControl::GUICONTROL_PROGRESS)
- {
- control = new CGUIProgressControl(
- parentID, id, posX, posY, width, height,
- textureBackground, textureLeft, textureMid, textureRight,
- textureOverlay, bReveal);
- ((CGUIProgressControl *)control)->SetInfo(singleInfo);
- }
- else if (type == CGUIControl::GUICONTROL_IMAGE)
- {
- if (strType == "largeimage")
- texture.useLarge = true;
-
- // use a bordered texture if we have <bordersize> or <bordertexture> specified.
- if (borderTexture.filename.IsEmpty() && borderStr.IsEmpty())
- control = new CGUIImage(
- parentID, id, posX, posY, width, height, texture);
- else
- control = new CGUIBorderedImage(
- parentID, id, posX, posY, width, height, texture, borderTexture, borderSize);
-#ifdef PRE_SKIN_VERSION_9_10_COMPATIBILITY
- if (insideContainer && textureFile.IsConstant())
- aspect.ratio = CAspectRatio::AR_STRETCH;
-#endif
- ((CGUIImage *)control)->SetInfo(textureFile);
- ((CGUIImage *)control)->SetAspectRatio(aspect);
- ((CGUIImage *)control)->SetCrossFade(fadeTime);
- }
- else if (type == CGUIControl::GUICONTROL_MULTI_IMAGE)
- {
- control = new CGUIMultiImage(
- parentID, id, posX, posY, width, height, texture, timePerImage, fadeTime, randomized, loop, timeToPauseAtEnd);
- ((CGUIMultiImage *)control)->SetInfo(texturePath);
- ((CGUIMultiImage *)control)->SetAspectRatio(aspect);
- }
- else if (type == CGUIControl::GUICONTAINER_LIST)
- {
- control = new CGUIListContainer(parentID, id, posX, posY, width, height, orientation, scrollTime, preloadItems);
- ((CGUIListContainer *)control)->LoadLayout(pControlNode);
- ((CGUIListContainer *)control)->LoadContent(pControlNode);
- ((CGUIListContainer *)control)->SetType(viewType, viewLabel);
- ((CGUIListContainer *)control)->SetPageControl(pageControl);
- ((CGUIListContainer *)control)->SetRenderOffset(offset);
- }
- else if (type == CGUIControl::GUICONTAINER_WRAPLIST)
- {
- control = new CGUIWrappingListContainer(parentID, id, posX, posY, width, height, orientation, scrollTime, preloadItems, focusPosition);
- ((CGUIWrappingListContainer *)control)->LoadLayout(pControlNode);
- ((CGUIWrappingListContainer *)control)->LoadContent(pControlNode);
- ((CGUIWrappingListContainer *)control)->SetType(viewType, viewLabel);
- ((CGUIWrappingListContainer *)control)->SetPageControl(pageControl);
- ((CGUIWrappingListContainer *)control)->SetRenderOffset(offset);
- }
- else if (type == CGUIControl::GUICONTAINER_FIXEDLIST)
- {
- control = new CGUIFixedListContainer(parentID, id, posX, posY, width, height, orientation, scrollTime, preloadItems, focusPosition, iMovementRange);
- ((CGUIFixedListContainer *)control)->LoadLayout(pControlNode);
- ((CGUIFixedListContainer *)control)->LoadContent(pControlNode);
- ((CGUIFixedListContainer *)control)->SetType(viewType, viewLabel);
- ((CGUIFixedListContainer *)control)->SetPageControl(pageControl);
- ((CGUIFixedListContainer *)control)->SetRenderOffset(offset);
- }
- else if (type == CGUIControl::GUICONTAINER_PANEL)
- {
- control = new CGUIPanelContainer(parentID, id, posX, posY, width, height, orientation, scrollTime, preloadItems);
- ((CGUIPanelContainer *)control)->LoadLayout(pControlNode);
- ((CGUIPanelContainer *)control)->LoadContent(pControlNode);
- ((CGUIPanelContainer *)control)->SetType(viewType, viewLabel);
- ((CGUIPanelContainer *)control)->SetPageControl(pageControl);
- ((CGUIPanelContainer *)control)->SetRenderOffset(offset);
- }
- else if (type == CGUIControl::GUICONTROL_TEXTBOX)
- {
- control = new CGUITextBox(
- parentID, id, posX, posY, width, height,
- labelInfo, scrollTime);
-
- ((CGUITextBox *)control)->SetPageControl(pageControl);
- if (infoLabels.size())
- ((CGUITextBox *)control)->SetInfo(infoLabels[0]);
- ((CGUITextBox *)control)->SetAutoScrolling(pControlNode);
- }
- else if (type == CGUIControl::GUICONTROL_SELECTBUTTON)
- {
- control = new CGUISelectButtonControl(
- parentID, id, posX, posY,
- width, height, textureFocus, textureNoFocus,
- labelInfo,
- textureBackground, textureLeft, textureLeftFocus, textureRight, textureRightFocus);
-
- ((CGUISelectButtonControl *)control)->SetLabel(strLabel);
- }
- else if (type == CGUIControl::GUICONTROL_MOVER)
- {
- control = new CGUIMoverControl(
- parentID, id, posX, posY, width, height,
- textureFocus, textureNoFocus);
- }
- else if (type == CGUIControl::GUICONTROL_RESIZE)
- {
- control = new CGUIResizeControl(
- parentID, id, posX, posY, width, height,
- textureFocus, textureNoFocus);
- }
- else if (type == CGUIControl::GUICONTROL_BUTTONBAR)
- {
- control = new CGUIButtonScroller(
- parentID, id, posX, posY, width, height, buttonGap, iNumSlots, iDefaultSlot,
- iMovementRange, bHorizontal, iAlpha, bWrapAround, bSmoothScrolling,
- textureFocus, textureNoFocus, labelInfo);
- ((CGUIButtonScroller *)control)->LoadButtons(pControlNode);
- }
- else if (type == CGUIControl::GUICONTROL_SPINEX)
- {
- control = new CGUISpinControlEx(
- parentID, id, posX, posY, width, height, spinWidth, spinHeight,
- labelInfo, textureFocus, textureNoFocus, textureUp, textureDown, textureUpFocus, textureDownFocus,
- labelInfo, iType);
-
- ((CGUISpinControlEx *)control)->SetSpinPosition(spinPosX);
- ((CGUISpinControlEx *)control)->SetText(strLabel);
- ((CGUISpinControlEx *)control)->SetReverse(bReverse);
- }
- else if (type == CGUIControl::GUICONTROL_VISUALISATION)
- {
- control = new CGUIVisualisationControl(parentID, id, posX, posY, width, height);
- }
-
- // things that apply to all controls
- if (control)
- {
- control->SetHitRect(hitRect);
- control->SetVisibleCondition(iVisibleCondition, allowHiddenFocus);
- control->SetEnableCondition(enableCondition);
- control->SetAnimations(animations);
- control->SetColorDiffuse(colorDiffuse);
- control->SetNavigation(up, down, left, right);
- control->SetTabNavigation(next,prev);
- control->SetNavigationActions(upActions, downActions, leftActions, rightActions);
- control->SetPulseOnSelect(bPulse);
- if (hasCamera)
- control->SetCamera(camera);
- }
- return control;
-}
diff --git a/guilib/GUIControlFactory.h b/guilib/GUIControlFactory.h
deleted file mode 100644
index e8060c2188..0000000000
--- a/guilib/GUIControlFactory.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/*!
-\file GuiControlFactory.h
-\brief
-*/
-
-#ifndef GUI_CONTROL_FACTORY_H
-#define GIU_CONTROL_FACTORY_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIControl.h"
-
-class CTextureInfo; // forward
-class CAspectRatio;
-class CGUIInfoLabel;
-class TiXmlNode;
-
-/*!
- \ingroup controls
- \brief
- */
-class CGUIControlFactory
-{
-public:
- CGUIControlFactory(void);
- virtual ~CGUIControlFactory(void);
- CGUIControl* Create(int parentID, const CRect &rect, TiXmlElement* pControlNode, bool insideContainer = false);
-
- /*! \brief translate from control name to control type
- \param type name of the control
- \return type of control
- */
- static CGUIControl::GUICONTROLTYPES TranslateControlType(const CStdString &type);
-
- /*! \brief translate from control type to control name
- \param type type of the control
- \return name of control
- */
- static CStdString TranslateControlType(CGUIControl::GUICONTROLTYPES type);
-
- /*! \brief grab a dimension out of the XML
-
- Supports plain reading of a number (or constant) and, in addition allows "auto" as the value
- for the dimension, whereby value is set to the max attribute (if it exists) and min is set the min
- attribute (if it exists) or 1. Auto values are thus detected by min != 0.
-
- \param pRootNode XML node to read
- \param strTag tag within pRootNode to read
- \param value value to set, or maximum value if using auto
- \param min minimum value - set != 0 if auto is used.
- \return true if we found and read the tag.
- */
- static bool GetDimension(const TiXmlNode* pRootNode, const char* strTag, float &value, float &min);
- static bool GetAspectRatio(const TiXmlNode* pRootNode, const char* strTag, CAspectRatio &aspectRatio);
- static bool GetInfoTexture(const TiXmlNode* pRootNode, const char* strTag, CTextureInfo &image, CGUIInfoLabel &info);
- static bool GetTexture(const TiXmlNode* pRootNode, const char* strTag, CTextureInfo &image);
- static bool GetAlignment(const TiXmlNode* pRootNode, const char* strTag, uint32_t& dwAlignment);
- static bool GetAlignmentY(const TiXmlNode* pRootNode, const char* strTag, uint32_t& dwAlignment);
- static bool GetAnimations(TiXmlNode *control, const CRect &rect, std::vector<CAnimation> &animation);
-
- /*! \brief Create an info label from an XML element
- Processes XML elements of the form
- <xmltag fallback="fallback_value">info_value</xmltag>
- where info_value may use $INFO[], $LOCALIZE[], $NUMBER[] etc.
- If either the fallback_value or info_value are natural numbers they are interpreted
- as ids for lookup in strings.xml. The fallback attribute is optional.
- \param element XML element to process
- \param infoLabel returned infoLabel
- \return true if a valid info label was read, false otherwise
- */
- static bool GetInfoLabelFromElement(const TiXmlElement *element, CGUIInfoLabel &infoLabel);
- static void GetInfoLabel(const TiXmlNode *pControlNode, const CStdString &labelTag, CGUIInfoLabel &infoLabel);
- static void GetInfoLabels(const TiXmlNode *pControlNode, const CStdString &labelTag, std::vector<CGUIInfoLabel> &infoLabels);
- static bool GetColor(const TiXmlNode* pRootNode, const char* strTag, color_t &value);
- static bool GetInfoColor(const TiXmlNode* pRootNode, const char* strTag, CGUIInfoColor &value);
- static CStdString FilterLabel(const CStdString &label);
- static bool GetConditionalVisibility(const TiXmlNode* control, int &condition);
- static bool GetMultipleString(const TiXmlNode* pRootNode, const char* strTag, std::vector<CGUIActionDescriptor>& vecStringValue);
- static void GetRectFromString(const CStdString &string, CRect &rect);
- static bool GetAction(const TiXmlElement* pElement, CGUIActionDescriptor &action);
- static bool GetHitRect(const TiXmlNode* pRootNode, CRect &rect);
-private:
- static CStdString GetType(const TiXmlElement *pControlNode);
- bool GetNavigation(const TiXmlElement *node, const char *tag, int &direction, std::vector<CGUIActionDescriptor> &actions);
- bool GetCondition(const TiXmlNode *control, const char *tag, int &condition);
- static bool GetConditionalVisibility(const TiXmlNode* control, int &condition, CGUIInfoBool &allowHiddenFocus);
- bool GetString(const TiXmlNode* pRootNode, const char* strTag, CStdString& strString);
- bool GetFloatRange(const TiXmlNode* pRootNode, const char* strTag, float& iMinValue, float& iMaxValue, float& iIntervalValue);
- bool GetIntRange(const TiXmlNode* pRootNode, const char* strTag, int& iMinValue, int& iMaxValue, int& iIntervalValue);
-};
-#endif
diff --git a/guilib/GUIControlGroup.cpp b/guilib/GUIControlGroup.cpp
deleted file mode 100644
index 70eaa56f5a..0000000000
--- a/guilib/GUIControlGroup.cpp
+++ /dev/null
@@ -1,649 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIControlGroup.h"
-#include "GUIControlProfiler.h"
-
-using namespace std;
-
-CGUIControlGroup::CGUIControlGroup()
-{
- m_defaultControl = 0;
- m_defaultAlways = false;
- m_focusedControl = 0;
- m_renderTime = 0;
- m_renderFocusedLast = false;
- ControlType = GUICONTROL_GROUP;
-}
-
-CGUIControlGroup::CGUIControlGroup(int parentID, int controlID, float posX, float posY, float width, float height)
-: CGUIControl(parentID, controlID, posX, posY, width, height)
-{
- m_defaultControl = 0;
- m_defaultAlways = false;
- m_focusedControl = 0;
- m_renderTime = 0;
- m_renderFocusedLast = false;
- ControlType = GUICONTROL_GROUP;
-}
-
-CGUIControlGroup::CGUIControlGroup(const CGUIControlGroup &from)
-: CGUIControl(from)
-{
- m_defaultControl = from.m_defaultControl;
- m_defaultAlways = from.m_defaultAlways;
- m_renderFocusedLast = from.m_renderFocusedLast;
-
- // run through and add our controls
- for (ciControls it = from.m_children.begin(); it != from.m_children.end(); ++it)
- AddControl((*it)->Clone());
-
- // defaults
- m_focusedControl = 0;
- m_renderTime = 0;
- ControlType = GUICONTROL_GROUP;
-}
-
-CGUIControlGroup::~CGUIControlGroup(void)
-{
- ClearAll();
-}
-
-void CGUIControlGroup::AllocResources()
-{
- CGUIControl::AllocResources();
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- CGUIControl *control = *it;
- if (!control->IsDynamicallyAllocated())
- control->AllocResources();
- }
-}
-
-void CGUIControlGroup::FreeResources(bool immediately)
-{
- CGUIControl::FreeResources(immediately);
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- CGUIControl *control = *it;
- control->FreeResources(immediately);
- }
-}
-
-void CGUIControlGroup::DynamicResourceAlloc(bool bOnOff)
-{
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- CGUIControl *control = *it;
- control->DynamicResourceAlloc(bOnOff);
- }
-}
-
-void CGUIControlGroup::Render()
-{
- CPoint pos(GetPosition());
- g_graphicsContext.SetOrigin(pos.x, pos.y);
- CGUIControl *focusedControl = NULL;
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- CGUIControl *control = *it;
- GUIPROFILER_VISIBILITY_BEGIN(control);
- control->UpdateVisibility();
- GUIPROFILER_VISIBILITY_END(control);
- if (m_renderFocusedLast && control->HasFocus())
- focusedControl = control;
- else
- control->DoRender(m_renderTime);
- }
- if (focusedControl)
- focusedControl->DoRender(m_renderTime);
- CGUIControl::Render();
- g_graphicsContext.RestoreOrigin();
-}
-
-bool CGUIControlGroup::OnAction(const CAction &action)
-{
- ASSERT(false); // unimplemented
- return false;
-}
-
-bool CGUIControlGroup::HasFocus() const
-{
- for (ciControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- CGUIControl *control = *it;
- if (control->HasFocus())
- return true;
- }
- return false;
-}
-
-bool CGUIControlGroup::OnMessage(CGUIMessage& message)
-{
- switch (message.GetMessage() )
- {
- case GUI_MSG_ITEM_SELECT:
- {
- if (message.GetControlId() == GetID())
- {
- m_focusedControl = message.GetParam1();
- return true;
- }
- break;
- }
- case GUI_MSG_ITEM_SELECTED:
- {
- if (message.GetControlId() == GetID())
- {
- message.SetParam1(m_focusedControl);
- return true;
- }
- break;
- }
- case GUI_MSG_FOCUSED:
- { // a control has been focused
- m_focusedControl = message.GetControlId();
- SetFocus(true);
- // tell our parent thatwe have focus
- if (m_parentControl)
- m_parentControl->OnMessage(message);
- return true;
- }
- case GUI_MSG_SETFOCUS:
- {
- // first try our last focused control...
- if (!m_defaultAlways && m_focusedControl)
- {
- CGUIControl *control = GetFirstFocusableControl(m_focusedControl);
- if (control)
- {
- CGUIMessage msg(GUI_MSG_SETFOCUS, GetParentID(), control->GetID());
- return control->OnMessage(msg);
- }
- }
- // ok, no previously focused control, try the default control first
- if (m_defaultControl)
- {
- CGUIControl *control = GetFirstFocusableControl(m_defaultControl);
- if (control)
- {
- CGUIMessage msg(GUI_MSG_SETFOCUS, GetParentID(), control->GetID());
- return control->OnMessage(msg);
- }
- }
- // no success with the default control, so just find one to focus
- CGUIControl *control = GetFirstFocusableControl(0);
- if (control)
- {
- CGUIMessage msg(GUI_MSG_SETFOCUS, GetParentID(), control->GetID());
- return control->OnMessage(msg);
- }
- // unsuccessful
- return false;
- break;
- }
- case GUI_MSG_LOSTFOCUS:
- {
- // set all subcontrols unfocused
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- (*it)->SetFocus(false);
- if (!HasID(message.GetParam1()))
- { // we don't have the new id, so unfocus
- SetFocus(false);
- if (m_parentControl)
- m_parentControl->OnMessage(message);
- }
- return true;
- }
- break;
- case GUI_MSG_PAGE_CHANGE:
- case GUI_MSG_REFRESH_THUMBS:
- case GUI_MSG_REFRESH_LIST:
- { // send to all child controls (make sure the target is the control id)
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- CGUIMessage msg(message.GetMessage(), message.GetSenderId(), (*it)->GetID(), message.GetParam1());
- (*it)->OnMessage(msg);
- }
- return true;
- }
- break;
- }
- bool handled(false);
- //not intented for any specific control, send to all childs and our base handler.
- if (message.GetControlId() == 0)
- {
- for (iControls it = m_children.begin();it != m_children.end(); ++it)
- {
- CGUIControl* control = *it;
- handled |= control->OnMessage(message);
- }
- return CGUIControl::OnMessage(message) || handled;
- }
- // if it's intended for us, then so be it
- if (message.GetControlId() == GetID())
- return CGUIControl::OnMessage(message);
-
- return SendControlMessage(message);
-}
-
-bool CGUIControlGroup::SendControlMessage(CGUIMessage &message)
-{
- // see if a child matches, and send to the child control if so
- for (iControls it = m_children.begin();it != m_children.end(); ++it)
- {
- CGUIControl* control = *it;
- if (control->HasVisibleID(message.GetControlId()))
- {
- if (control->OnMessage(message))
- return true;
- }
- }
- // Unhandled - send to all matching invisible controls as well
- bool handled(false);
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- CGUIControl* control = *it;
- if (control->HasID(message.GetControlId()))
- {
- if (control->OnMessage(message))
- handled = true;
- }
- }
- return handled;
-}
-
-bool CGUIControlGroup::CanFocus() const
-{
- if (!CGUIControl::CanFocus()) return false;
- // see if we have any children that can be focused
- for (ciControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- if ((*it)->CanFocus())
- return true;
- }
- return false;
-}
-
-void CGUIControlGroup::DoRender(unsigned int currentTime)
-{
- m_renderTime = currentTime;
- CGUIControl::DoRender(currentTime);
-}
-
-void CGUIControlGroup::SetInitialVisibility()
-{
- CGUIControl::SetInitialVisibility();
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- (*it)->SetInitialVisibility();
-}
-
-void CGUIControlGroup::QueueAnimation(ANIMATION_TYPE animType)
-{
- CGUIControl::QueueAnimation(animType);
- // send window level animations to our children as well
- if (animType == ANIM_TYPE_WINDOW_OPEN || animType == ANIM_TYPE_WINDOW_CLOSE)
- {
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- (*it)->QueueAnimation(animType);
- }
-}
-
-void CGUIControlGroup::ResetAnimation(ANIMATION_TYPE animType)
-{
- CGUIControl::ResetAnimation(animType);
- // send window level animations to our children as well
- if (animType == ANIM_TYPE_WINDOW_OPEN || animType == ANIM_TYPE_WINDOW_CLOSE)
- {
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- (*it)->ResetAnimation(animType);
- }
-}
-
-void CGUIControlGroup::ResetAnimations()
-{ // resets all animations, regardless of condition
- CGUIControl::ResetAnimations();
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- (*it)->ResetAnimations();
-}
-
-bool CGUIControlGroup::IsAnimating(ANIMATION_TYPE animType)
-{
- if (CGUIControl::IsAnimating(animType))
- return true;
-
- if (IsVisible())
- {
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- if ((*it)->IsAnimating(animType))
- return true;
- }
- }
- return false;
-}
-
-bool CGUIControlGroup::HasAnimation(ANIMATION_TYPE animType)
-{
- if (CGUIControl::HasAnimation(animType))
- return true;
-
- if (IsVisible())
- {
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- if ((*it)->HasAnimation(animType))
- return true;
- }
- }
- return false;
-}
-
-EVENT_RESULT CGUIControlGroup::SendMouseEvent(const CPoint &point, const CMouseEvent &event)
-{
- // transform our position into child coordinates
- CPoint childPoint(point);
- m_transform.InverseTransformPosition(childPoint.x, childPoint.y);
-
- if (CGUIControl::CanFocus())
- {
- CPoint pos(GetPosition());
- // run through our controls in reverse order (so that last rendered is checked first)
- for (rControls i = m_children.rbegin(); i != m_children.rend(); ++i)
- {
- CGUIControl *child = *i;
- EVENT_RESULT ret = child->SendMouseEvent(childPoint - pos, event);
- if (ret)
- { // we've handled the action, and/or have focused an item
- return ret;
- }
- }
- // none of our children want the event, but we may want it.
- EVENT_RESULT ret;
- if (HitTest(childPoint) && (ret = OnMouseEvent(childPoint, event)))
- return ret;
- }
- m_focusedControl = 0;
- return EVENT_RESULT_UNHANDLED;
-}
-
-void CGUIControlGroup::UnfocusFromPoint(const CPoint &point)
-{
- CPoint controlCoords(point);
- m_transform.InverseTransformPosition(controlCoords.x, controlCoords.y);
- controlCoords -= GetPosition();
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- CGUIControl *child = *it;
- child->UnfocusFromPoint(controlCoords);
- }
- CGUIControl::UnfocusFromPoint(point);
-}
-
-bool CGUIControlGroup::HasID(int id) const
-{
- if (CGUIControl::HasID(id)) return true;
- for (ciControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- CGUIControl *child = *it;
- if (child->HasID(id))
- return true;
- }
- return false;
-}
-
-bool CGUIControlGroup::HasVisibleID(int id) const
-{
- // call base class first as the group may be the requested control
- if (CGUIControl::HasVisibleID(id)) return true;
- // if the group isn't visible, then none of it's children can be
- if (!IsVisible()) return false;
- for (ciControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- CGUIControl *child = *it;
- if (child->HasVisibleID(id))
- return true;
- }
- return false;
-}
-
-const CGUIControl* CGUIControlGroup::GetControl(int iControl) const
-{
- CGUIControl *pPotential = NULL;
- LookupMap::const_iterator first = m_lookup.find(iControl);
- if (first != m_lookup.end())
- {
- LookupMap::const_iterator last = m_lookup.upper_bound(iControl);
- for (LookupMap::const_iterator i = first; i != last; i++)
- {
- CGUIControl *control = i->second;
- if (control->IsVisible())
- return control;
- else if (!pPotential)
- pPotential = control;
- }
- }
- return pPotential;
-}
-
-int CGUIControlGroup::GetFocusedControlID() const
-{
- if (m_focusedControl) return m_focusedControl;
- CGUIControl *control = GetFocusedControl();
- if (control) return control->GetID();
- return 0;
-}
-
-CGUIControl *CGUIControlGroup::GetFocusedControl() const
-{
- for (ciControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- const CGUIControl* control = *it;
- if (control->HasFocus())
- {
- if (control->IsGroup())
- {
- CGUIControlGroup *group = (CGUIControlGroup *)control;
- return group->GetFocusedControl();
- }
- return (CGUIControl *)control;
- }
- }
- return NULL;
-}
-
-// in the case of id == 0, we don't match id
-CGUIControl *CGUIControlGroup::GetFirstFocusableControl(int id)
-{
- if (!CanFocus()) return NULL;
- if (id && id == (int) GetID()) return this; // we're focusable and they want us
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- CGUIControl* pControl = *it;
- if (pControl->IsGroup())
- {
- CGUIControlGroup *group = (CGUIControlGroup *)pControl;
- CGUIControl *control = group->GetFirstFocusableControl(id);
- if (control) return control;
- }
- if ((!id || (int) pControl->GetID() == id) && pControl->CanFocus())
- return pControl;
- }
- return NULL;
-}
-
-void CGUIControlGroup::AddControl(CGUIControl *control, int position /* = -1*/)
-{
- if (!control) return;
- if (position < 0 || position > (int)m_children.size())
- position = (int)m_children.size();
- m_children.insert(m_children.begin() + position, control);
- control->SetParentControl(this);
- control->SetPushUpdates(m_pushedUpdates);
- AddLookup(control);
-}
-
-void CGUIControlGroup::AddLookup(CGUIControl *control)
-{
- if (control->IsGroup())
- { // first add all the subitems of this group (if they exist)
- const LookupMap map = ((CGUIControlGroup *)control)->GetLookup();
- for (LookupMap::const_iterator i = map.begin(); i != map.end(); i++)
- m_lookup.insert(m_lookup.upper_bound(i->first), make_pair(i->first, i->second));
- }
- if (control->GetID())
- m_lookup.insert(m_lookup.upper_bound(control->GetID()), make_pair(control->GetID(), control));
- // ensure that our size is what it should be
- if (m_parentControl)
- ((CGUIControlGroup *)m_parentControl)->AddLookup(control);
-}
-
-void CGUIControlGroup::RemoveLookup(CGUIControl *control)
-{
- if (control->IsGroup())
- { // remove the group's lookup
- const LookupMap &map = ((CGUIControlGroup *)control)->GetLookup();
- for (LookupMap::const_iterator i = map.begin(); i != map.end(); i++)
- { // remove this control
- for (LookupMap::iterator it = m_lookup.begin(); it != m_lookup.end(); it++)
- {
- if (i->second == it->second)
- {
- m_lookup.erase(it);
- break;
- }
- }
- }
- }
- // remove the actual control
- if (control->GetID())
- {
- for (LookupMap::iterator it = m_lookup.begin(); it != m_lookup.end(); it++)
- {
- if (control == it->second)
- {
- m_lookup.erase(it);
- break;
- }
- }
- }
- if (m_parentControl)
- ((CGUIControlGroup *)m_parentControl)->RemoveLookup(control);
-}
-
-bool CGUIControlGroup::IsValidControl(const CGUIControl *control) const
-{
- if (control->GetID())
- {
- for (LookupMap::const_iterator it = m_lookup.begin(); it != m_lookup.end(); it++)
- {
- if (control == it->second)
- return true;
- }
- }
- return false;
-}
-
-bool CGUIControlGroup::InsertControl(CGUIControl *control, const CGUIControl *insertPoint)
-{
- // find our position
- for (unsigned int i = 0; i < m_children.size(); i++)
- {
- CGUIControl *child = m_children[i];
- if (child->IsGroup() && ((CGUIControlGroup *)child)->InsertControl(control, insertPoint))
- return true;
- else if (child == insertPoint)
- {
- AddControl(control, i);
- return true;
- }
- }
- return false;
-}
-
-void CGUIControlGroup::SaveStates(vector<CControlState> &states)
-{
- // save our state, and that of our children
- states.push_back(CControlState(GetID(), m_focusedControl));
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- (*it)->SaveStates(states);
-}
-
-// Note: This routine doesn't delete the control. It just removes it from the control list
-bool CGUIControlGroup::RemoveControl(const CGUIControl *control)
-{
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- CGUIControl *child = *it;
- if (child->IsGroup() && ((CGUIControlGroup *)child)->RemoveControl(control))
- return true;
- if (control == child)
- {
- m_children.erase(it);
- RemoveLookup(child);
- return true;
- }
- }
- return false;
-}
-
-void CGUIControlGroup::ClearAll()
-{
- // first remove from the lookup table
- if (m_parentControl)
- {
- for (iControls it = m_children.begin(); it != m_children.end(); it++)
- ((CGUIControlGroup *)m_parentControl)->RemoveLookup(*it);
- }
- // and delete all our children
- for (iControls it = m_children.begin(); it != m_children.end(); it++)
- {
- CGUIControl *control = *it;
- delete control;
- }
- m_children.clear();
- m_lookup.clear();
-}
-
-void CGUIControlGroup::GetContainers(vector<CGUIControl *> &containers) const
-{
- for (ciControls it = m_children.begin();it != m_children.end(); ++it)
- {
- if ((*it)->IsContainer())
- containers.push_back(*it);
- else if ((*it)->IsGroup())
- ((CGUIControlGroup *)(*it))->GetContainers(containers);
- }
-}
-
-void CGUIControlGroup::SetInvalid()
-{
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- (*it)->SetInvalid();
-}
-
-#ifdef _DEBUG
-void CGUIControlGroup::DumpTextureUse()
-{
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- (*it)->DumpTextureUse();
-}
-#endif
diff --git a/guilib/GUIControlGroup.h b/guilib/GUIControlGroup.h
deleted file mode 100644
index 162e806fdf..0000000000
--- a/guilib/GUIControlGroup.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*!
-\file GUIControlGroup.h
-\brief
-*/
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIControl.h"
-
-/*!
- \ingroup controls
- \brief group of controls, useful for remembering last control + animating/hiding together
- */
-class CGUIControlGroup : public CGUIControl
-{
-public:
- CGUIControlGroup();
- CGUIControlGroup(int parentID, int controlID, float posX, float posY, float width, float height);
- CGUIControlGroup(const CGUIControlGroup &from);
- virtual ~CGUIControlGroup(void);
- virtual CGUIControlGroup *Clone() const { return new CGUIControlGroup(*this); };
-
- virtual void Render();
- virtual bool OnAction(const CAction &action);
- virtual bool OnMessage(CGUIMessage& message);
- virtual bool SendControlMessage(CGUIMessage& message);
- virtual bool HasFocus() const;
- virtual void AllocResources();
- virtual void FreeResources(bool immediately = false);
- virtual void DynamicResourceAlloc(bool bOnOff);
- virtual bool CanFocus() const;
-
- virtual EVENT_RESULT SendMouseEvent(const CPoint &point, const CMouseEvent &event);
- virtual void UnfocusFromPoint(const CPoint &point);
-
- virtual void SetInitialVisibility();
-
- virtual void DoRender(unsigned int currentTime);
- virtual bool IsAnimating(ANIMATION_TYPE anim);
- virtual bool HasAnimation(ANIMATION_TYPE anim);
- virtual void QueueAnimation(ANIMATION_TYPE anim);
- virtual void ResetAnimation(ANIMATION_TYPE anim);
- virtual void ResetAnimations();
-
- virtual bool HasID(int id) const;
- virtual bool HasVisibleID(int id) const;
- virtual void SetInvalid();
-
- int GetFocusedControlID() const;
- CGUIControl *GetFocusedControl() const;
- const CGUIControl *GetControl(int id) const;
- virtual CGUIControl *GetFirstFocusableControl(int id);
- void GetContainers(std::vector<CGUIControl *> &containers) const;
-
- virtual void AddControl(CGUIControl *control, int position = -1);
- bool InsertControl(CGUIControl *control, const CGUIControl *insertPoint);
- virtual bool RemoveControl(const CGUIControl *control);
- virtual void ClearAll();
- void SetDefaultControl(int id, bool always) { m_defaultControl = id; m_defaultAlways = always; };
- void SetRenderFocusedLast(bool renderLast) { m_renderFocusedLast = renderLast; };
-
- virtual void SaveStates(std::vector<CControlState> &states);
-
- virtual bool IsGroup() const { return true; };
-
-#ifdef _DEBUG
- virtual void DumpTextureUse();
-#endif
-protected:
- /*!
- \brief Check whether a given control is valid
- Runs through controls and returns whether this control is valid. Only functional
- for controls with non-zero id.
- \param control to check
- \return true if the control is valid, false otherwise.
- */
- bool IsValidControl(const CGUIControl *control) const;
-
- // sub controls
- std::vector<CGUIControl *> m_children;
- typedef std::vector<CGUIControl *>::iterator iControls;
- typedef std::vector<CGUIControl *>::const_iterator ciControls;
- typedef std::vector<CGUIControl *>::reverse_iterator rControls;
- typedef std::vector<CGUIControl *>::const_reverse_iterator crControls;
-
- // fast lookup by id
- typedef std::multimap<int, CGUIControl *> LookupMap;
- void AddLookup(CGUIControl *control);
- void RemoveLookup(CGUIControl *control);
- const LookupMap &GetLookup() { return m_lookup; };
- LookupMap m_lookup;
-
- int m_defaultControl;
- bool m_defaultAlways;
- int m_focusedControl;
- bool m_renderFocusedLast;
-
- // render time
- unsigned int m_renderTime;
-};
-
diff --git a/guilib/GUIControlGroupList.cpp b/guilib/GUIControlGroupList.cpp
deleted file mode 100644
index 0a370b880c..0000000000
--- a/guilib/GUIControlGroupList.cpp
+++ /dev/null
@@ -1,450 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIControlGroupList.h"
-#include "Key.h"
-#include "utils/GUIInfoManager.h"
-#include "GUIControlProfiler.h"
-#include "GUIFont.h" // for XBFONT_* definitions
-
-CGUIControlGroupList::CGUIControlGroupList(int parentID, int controlID, float posX, float posY, float width, float height, float itemGap, int pageControl, ORIENTATION orientation, bool useControlPositions, uint32_t alignment, unsigned int scrollTime)
-: CGUIControlGroup(parentID, controlID, posX, posY, width, height)
-{
- m_itemGap = itemGap;
- m_pageControl = pageControl;
- m_offset = 0;
- m_totalSize = 10;
- m_orientation = orientation;
- m_alignment = alignment;
- m_scrollOffset = 0;
- m_scrollSpeed = 0;
- m_scrollLastTime = 0;
- m_scrollTime = scrollTime ? scrollTime : 1;
- m_renderTime = 0;
- m_useControlPositions = useControlPositions;
- ControlType = GUICONTROL_GROUPLIST;
-}
-
-CGUIControlGroupList::~CGUIControlGroupList(void)
-{
-}
-
-void CGUIControlGroupList::Render()
-{
- if (m_scrollSpeed != 0)
- {
- m_offset += m_scrollSpeed * (m_renderTime - m_scrollLastTime);
- if ((m_scrollSpeed < 0 && m_offset < m_scrollOffset) ||
- (m_scrollSpeed > 0 && m_offset > m_scrollOffset))
- {
- m_offset = m_scrollOffset;
- m_scrollSpeed = 0;
- }
- }
- m_scrollLastTime = m_renderTime;
-
- // first we update visibility of all our items, to ensure our size and
- // alignment computations are correct.
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- CGUIControl *control = *it;
- GUIPROFILER_VISIBILITY_BEGIN(control);
- control->UpdateVisibility();
- GUIPROFILER_VISIBILITY_END(control);
- }
-
- ValidateOffset();
- if (m_pageControl)
- {
- CGUIMessage message(GUI_MSG_LABEL_RESET, GetParentID(), m_pageControl, (int)m_height, (int)m_totalSize);
- SendWindowMessage(message);
- CGUIMessage message2(GUI_MSG_ITEM_SELECT, GetParentID(), m_pageControl, (int)m_offset);
- SendWindowMessage(message2);
- }
- // we run through the controls, rendering as we go
- bool render(g_graphicsContext.SetClipRegion(m_posX, m_posY, m_width, m_height));
- float pos = GetAlignOffset();
- float focusedPos = 0;
- CGUIControl *focusedControl = NULL;
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- // note we render all controls, even if they're offscreen, as then they'll be updated
- // with respect to animations
- CGUIControl *control = *it;
- if (m_renderFocusedLast && control->HasFocus())
- {
- focusedControl = control;
- focusedPos = pos;
- }
- else
- {
- if (m_orientation == VERTICAL)
- g_graphicsContext.SetOrigin(m_posX, m_posY + pos - m_offset);
- else
- g_graphicsContext.SetOrigin(m_posX + pos - m_offset, m_posY);
- control->DoRender(m_renderTime);
- }
- if (control->IsVisible())
- pos += Size(control) + m_itemGap;
- g_graphicsContext.RestoreOrigin();
- }
- if (focusedControl)
- {
- if (m_orientation == VERTICAL)
- g_graphicsContext.SetOrigin(m_posX, m_posY + focusedPos - m_offset);
- else
- g_graphicsContext.SetOrigin(m_posX + focusedPos - m_offset, m_posY);
- focusedControl->DoRender(m_renderTime);
- }
- if (render) g_graphicsContext.RestoreClipRegion();
- CGUIControl::Render();
-}
-
-bool CGUIControlGroupList::OnMessage(CGUIMessage& message)
-{
- switch (message.GetMessage() )
- {
- case GUI_MSG_FOCUSED:
- { // a control has been focused
- // scroll if we need to and update our page control
- ValidateOffset();
- float offset = 0;
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- CGUIControl *control = *it;
- if (!control->IsVisible())
- continue;
- if (control->HasID(message.GetControlId()))
- {
- // find out whether this is the first or last control
- if (IsFirstFocusableControl(control))
- ScrollTo(0);
- else if (IsLastFocusableControl(control))
- ScrollTo(m_totalSize - Size());
- else if (offset < m_offset)
- ScrollTo(offset);
- else if (offset + Size(control) > m_offset + Size())
- ScrollTo(offset + Size(control) - Size());
- break;
- }
- offset += Size(control) + m_itemGap;
- }
- }
- break;
- case GUI_MSG_SETFOCUS:
- {
- // we've been asked to focus. We focus the last control if it's on this page,
- // else we'll focus the first focusable control from our offset (after verifying it)
- ValidateOffset();
- // now check the focusControl's offset
- float offset = 0;
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- CGUIControl *control = *it;
- if (!control->IsVisible())
- continue;
- if (control->HasID(m_focusedControl))
- {
- if (offset >= m_offset && offset + Size(control) <= m_offset + Size())
- return CGUIControlGroup::OnMessage(message);
- break;
- }
- offset += Size(control) + m_itemGap;
- }
- // find the first control on this page
- offset = 0;
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- CGUIControl *control = *it;
- if (!control->IsVisible())
- continue;
- if (control->CanFocus() && offset >= m_offset && offset + Size(control) <= m_offset + Size())
- {
- m_focusedControl = control->GetID();
- break;
- }
- offset += Size(control) + m_itemGap;
- }
- }
- break;
- case GUI_MSG_PAGE_CHANGE:
- {
- if (message.GetSenderId() == m_pageControl)
- { // it's from our page control
- ScrollTo((float)message.GetParam1());
- return true;
- }
- }
- break;
- }
- return CGUIControlGroup::OnMessage(message);
-}
-
-void CGUIControlGroupList::ValidateOffset()
-{
- // calculate how many items we have on this page
- m_totalSize = 0;
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- CGUIControl *control = *it;
- if (!control->IsVisible()) continue;
- m_totalSize += Size(control) + m_itemGap;
- }
- if (m_totalSize > 0) m_totalSize -= m_itemGap;
- // check our m_offset range
- if (m_offset > m_totalSize - Size())
- m_offset = m_totalSize - Size();
- if (m_offset < 0) m_offset = 0;
-}
-
-void CGUIControlGroupList::AddControl(CGUIControl *control, int position /*= -1*/)
-{
- // NOTE: We override control navigation here, but we don't override the <onleft> etc. builtins
- // if specified.
- if (position < 0 || position > (int)m_children.size()) // add at the end
- position = (int)m_children.size();
-
- if (control)
- { // set the navigation of items so that they form a list
- int beforeID = (m_orientation == VERTICAL) ? GetControlIdUp() : GetControlIdLeft();
- int afterID = (m_orientation == VERTICAL) ? GetControlIdDown() : GetControlIdRight();
- if (m_children.size())
- {
- // we're inserting at the given position, so grab the items above and below and alter
- // their navigation accordingly
- CGUIControl *before = NULL;
- CGUIControl *after = NULL;
- if (position == 0)
- { // inserting at the beginning
- after = m_children[0];
- if (afterID == GetID()) // we're wrapping around bottom->top, so we have to update the last item
- before = m_children[m_children.size() - 1];
- if (beforeID == GetID()) // we're wrapping around top->bottom
- beforeID = m_children[m_children.size() - 1]->GetID();
- afterID = after->GetID();
- }
- else if (position == (int)m_children.size())
- { // inserting at the end
- before = m_children[m_children.size() - 1];
- if (beforeID == GetID()) // we're wrapping around top->bottom, so we have to update the first item
- after = m_children[0];
- if (afterID == GetID()) // we're wrapping around bottom->top
- afterID = m_children[0]->GetID();
- beforeID = before->GetID();
- }
- else
- { // inserting somewhere in the middle
- before = m_children[position - 1];
- after = m_children[position];
- beforeID = before->GetID();
- afterID = after->GetID();
- }
- if (m_orientation == VERTICAL)
- {
- if (before) // update the DOWN action to point to us
- before->SetNavigation(before->GetControlIdUp(), control->GetID(), GetControlIdLeft(), GetControlIdRight());
- if (after) // update the UP action to point to us
- after->SetNavigation(control->GetID(), after->GetControlIdDown(), GetControlIdLeft(), GetControlIdRight());
- }
- else
- {
- if (before) // update the RIGHT action to point to us
- before->SetNavigation(GetControlIdUp(), GetControlIdDown(), before->GetControlIdLeft(), control->GetID());
- if (after) // update the LEFT action to point to us
- after->SetNavigation(GetControlIdUp(), GetControlIdDown(), control->GetID(), after->GetControlIdRight());
- }
- }
- // now the control's nav
- std::vector<CGUIActionDescriptor> empty;
- if (m_orientation == VERTICAL)
- {
- control->SetNavigation(beforeID, afterID, GetControlIdLeft(), GetControlIdRight());
- control->SetNavigationActions(empty, empty, m_leftActions, m_rightActions, false);
- }
- else
- {
- control->SetNavigation(GetControlIdUp(), GetControlIdDown(), beforeID, afterID);
- control->SetNavigationActions(m_upActions, m_downActions, empty, empty, false);
- }
-
- if (!m_useControlPositions)
- control->SetPosition(0,0);
- CGUIControlGroup::AddControl(control, position);
- }
-}
-
-void CGUIControlGroupList::ClearAll()
-{
- CGUIControlGroup::ClearAll();
- m_offset = 0;
-}
-
-inline float CGUIControlGroupList::Size(const CGUIControl *control) const
-{
- return (m_orientation == VERTICAL) ? control->GetYPosition() + control->GetHeight() : control->GetXPosition() + control->GetWidth();
-}
-
-inline float CGUIControlGroupList::Size() const
-{
- return (m_orientation == VERTICAL) ? m_height : m_width;
-}
-
-void CGUIControlGroupList::ScrollTo(float offset)
-{
- m_scrollOffset = offset;
- m_scrollSpeed = (m_scrollOffset - m_offset) / m_scrollTime;
-}
-
-EVENT_RESULT CGUIControlGroupList::SendMouseEvent(const CPoint &point, const CMouseEvent &event)
-{
- // transform our position into child coordinates
- CPoint childPoint(point);
- m_transform.InverseTransformPosition(childPoint.x, childPoint.y);
- if (CGUIControl::CanFocus())
- {
- float pos = 0;
- float alignOffset = GetAlignOffset();
- for (ciControls i = m_children.begin(); i != m_children.end(); ++i)
- {
- CGUIControl *child = *i;
- if (child->IsVisible())
- {
- if (pos + Size(child) > m_offset && pos < m_offset + Size())
- { // we're on screen
- float offsetX = m_orientation == VERTICAL ? m_posX : m_posX + alignOffset + pos - m_offset;
- float offsetY = m_orientation == VERTICAL ? m_posY + alignOffset + pos - m_offset : m_posY;
- EVENT_RESULT ret = child->SendMouseEvent(childPoint - CPoint(offsetX, offsetY), event);
- if (ret)
- { // we've handled the action, and/or have focused an item
- return ret;
- }
- }
- pos += Size(child) + m_itemGap;
- }
- }
- // none of our children want the event, but we may want it.
- EVENT_RESULT ret;
- if (HitTest(childPoint) && (ret = OnMouseEvent(childPoint, event)))
- return ret;
- }
- m_focusedControl = 0;
- return EVENT_RESULT_UNHANDLED;
-}
-
-void CGUIControlGroupList::UnfocusFromPoint(const CPoint &point)
-{
- float pos = 0;
- CPoint controlCoords(point);
- m_transform.InverseTransformPosition(controlCoords.x, controlCoords.y);
- float alignOffset = GetAlignOffset();
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- CGUIControl *child = *it;
- if (child->IsVisible())
- {
- if (pos + Size(child) > m_offset && pos < m_offset + Size())
- { // we're on screen
- CPoint offset = (m_orientation == VERTICAL) ? CPoint(m_posX, m_posY + alignOffset + pos - m_offset) : CPoint(m_posX + alignOffset + pos - m_offset, m_posY);
- child->UnfocusFromPoint(controlCoords - offset);
- }
- pos += Size(child) + m_itemGap;
- }
- }
- CGUIControl::UnfocusFromPoint(point);
-}
-
-bool CGUIControlGroupList::GetCondition(int condition, int data) const
-{
- switch (condition)
- {
- case CONTAINER_HAS_NEXT:
- return (m_totalSize >= Size() && m_offset < m_totalSize - Size());
- case CONTAINER_HAS_PREVIOUS:
- return (m_offset > 0);
- default:
- return false;
- }
-}
-
-bool CGUIControlGroupList::IsFirstFocusableControl(const CGUIControl *control) const
-{
- for (ciControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- CGUIControl *child = *it;
- if (child->IsVisible() && child->CanFocus())
- { // found first focusable
- return child == control;
- }
- }
- return false;
-}
-
-bool CGUIControlGroupList::IsLastFocusableControl(const CGUIControl *control) const
-{
- for (crControls it = m_children.rbegin(); it != m_children.rend(); ++it)
- {
- CGUIControl *child = *it;
- if (child->IsVisible() && child->CanFocus())
- { // found first focusable
- return child == control;
- }
- }
- return false;
-}
-
-float CGUIControlGroupList::GetAlignOffset() const
-{
- if (m_totalSize < Size())
- {
- if (m_alignment & XBFONT_RIGHT)
- return Size() - m_totalSize;
- if (m_alignment & XBFONT_CENTER_X)
- return (Size() - m_totalSize)*0.5f;
- }
- return 0.0f;
-}
-
-EVENT_RESULT CGUIControlGroupList::OnMouseEvent(const CPoint &point, const CMouseEvent &event)
-{
- if (event.m_id == ACTION_MOUSE_WHEEL_UP || event.m_id == ACTION_MOUSE_WHEEL_DOWN)
- {
- // find the current control and move to the next or previous
- float offset = 0;
- for (ciControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- CGUIControl *control = *it;
- if (!control->IsVisible()) continue;
- float nextOffset = offset + Size(control) + m_itemGap;
- if (event.m_id == ACTION_MOUSE_WHEEL_DOWN && nextOffset > m_offset) // past our current offset
- {
- ScrollTo(nextOffset);
- return EVENT_RESULT_HANDLED;
- }
- else if (event.m_id == ACTION_MOUSE_WHEEL_UP && nextOffset >= m_offset) // at least at our current offset
- {
- ScrollTo(offset);
- return EVENT_RESULT_HANDLED;
- }
- offset = nextOffset;
- }
- }
- return EVENT_RESULT_UNHANDLED;
-}
diff --git a/guilib/GUIControlGroupList.h b/guilib/GUIControlGroupList.h
deleted file mode 100644
index f05d5e3c13..0000000000
--- a/guilib/GUIControlGroupList.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*!
-\file GUIControlGroupList.h
-\brief
-*/
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIControlGroup.h"
-
-/*!
- \ingroup controls
- \brief list of controls that is scrollable
- */
-class CGUIControlGroupList : public CGUIControlGroup
-{
-public:
- CGUIControlGroupList(int parentID, int controlID, float posX, float posY, float width, float height, float itemGap, int pageControl, ORIENTATION orientation, bool useControlPositions, uint32_t alignment, unsigned int scrollTime);
- virtual ~CGUIControlGroupList(void);
- virtual CGUIControlGroupList *Clone() const { return new CGUIControlGroupList(*this); };
-
- virtual void Render();
- virtual bool OnMessage(CGUIMessage& message);
-
- virtual EVENT_RESULT SendMouseEvent(const CPoint &point, const CMouseEvent &event);
- virtual void UnfocusFromPoint(const CPoint &point);
-
- virtual void AddControl(CGUIControl *control, int position = -1);
- virtual void ClearAll();
-
- virtual bool GetCondition(int condition, int data) const;
-protected:
- virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event);
- bool IsFirstFocusableControl(const CGUIControl *control) const;
- bool IsLastFocusableControl(const CGUIControl *control) const;
- void ValidateOffset();
- inline float Size(const CGUIControl *control) const;
- inline float Size() const;
- void ScrollTo(float offset);
- float GetAlignOffset() const;
-
- float m_itemGap;
- int m_pageControl;
-
- float m_offset; // measurement in pixels of our origin
- float m_totalSize;
-
- float m_scrollSpeed;
- float m_scrollOffset;
- unsigned int m_scrollLastTime;
- unsigned int m_scrollTime;
-
- bool m_useControlPositions;
- ORIENTATION m_orientation;
- uint32_t m_alignment;
-};
-
diff --git a/guilib/GUIControlProfiler.cpp b/guilib/GUIControlProfiler.cpp
deleted file mode 100644
index 0ffe0f5a01..0000000000
--- a/guilib/GUIControlProfiler.cpp
+++ /dev/null
@@ -1,358 +0,0 @@
-/*
- * Copyright (C) 2005-2009 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIControlProfiler.h"
-#include "tinyXML/tinyxml.h"
-#include "utils/TimeUtils.h"
-
-bool CGUIControlProfiler::m_bIsRunning = false;
-
-CGUIControlProfilerItem::CGUIControlProfilerItem(CGUIControlProfiler *pProfiler, CGUIControlProfilerItem *pParent, CGUIControl *pControl)
-: m_pProfiler(pProfiler), m_pParent(pParent), m_pControl(pControl), m_visTime(0), m_renderTime(0)
-{
- if (m_pControl)
- {
- m_controlID = m_pControl->GetID();
- m_ControlType = m_pControl->GetControlType();
- m_strDescription = m_pControl->GetDescription();
- }
- else
- {
- m_controlID = 0;
- m_ControlType = CGUIControl::GUICONTROL_UNKNOWN;
- }
-}
-
-CGUIControlProfilerItem::~CGUIControlProfilerItem(void)
-{
- Reset(NULL);
-}
-
-void CGUIControlProfilerItem::Reset(CGUIControlProfiler *pProfiler)
-{
- m_controlID = 0;
- m_ControlType = CGUIControl::GUICONTROL_UNKNOWN;
- m_pControl = NULL;
-
- m_visTime = 0;
- m_renderTime = 0;
- const unsigned int dwSize = m_vecChildren.size();
- for (unsigned int i=0; i<dwSize; ++i)
- delete m_vecChildren[i];
- m_vecChildren.clear();
-
- m_pProfiler = pProfiler;
-}
-
-void CGUIControlProfilerItem::BeginVisibility(void)
-{
- m_i64VisStart = CurrentHostCounter();
-}
-
-void CGUIControlProfilerItem::EndVisibility(void)
-{
- m_visTime += (unsigned int)(m_pProfiler->m_fPerfScale * (CurrentHostCounter() - m_i64VisStart));
-}
-
-void CGUIControlProfilerItem::BeginRender(void)
-{
- m_i64RenderStart = CurrentHostCounter();
-}
-
-void CGUIControlProfilerItem::EndRender(void)
-{
- m_renderTime += (unsigned int)(m_pProfiler->m_fPerfScale * (CurrentHostCounter() - m_i64RenderStart));
-}
-
-void CGUIControlProfilerItem::SaveToXML(TiXmlElement *parent)
-{
- TiXmlElement *xmlControl = new TiXmlElement("control");
- parent->LinkEndChild(xmlControl);
-
- const char *lpszType = NULL;
- switch (m_ControlType)
- {
- case CGUIControl::GUICONTROL_BUTTON:
- lpszType = "button"; break;
- case CGUIControl::GUICONTROL_CHECKMARK:
- lpszType = "checkmark"; break;
- case CGUIControl::GUICONTROL_FADELABEL:
- lpszType = "fadelabel"; break;
- case CGUIControl::GUICONTROL_IMAGE:
- case CGUIControl::GUICONTROL_BORDEREDIMAGE:
- lpszType = "image"; break;
- case CGUIControl::GUICONTROL_LARGE_IMAGE:
- lpszType = "largeimage"; break;
- case CGUIControl::GUICONTROL_LABEL:
- lpszType = "label"; break;
- case CGUIControl::GUICONTROL_LISTGROUP:
- lpszType = "group"; break;
- case CGUIControl::GUICONTROL_PROGRESS:
- lpszType = "progress"; break;
- case CGUIControl::GUICONTROL_RADIO:
- lpszType = "radiobutton"; break;
- case CGUIControl::GUICONTROL_RSS:
- lpszType = "rss"; break;
- case CGUIControl::GUICONTROL_SELECTBUTTON:
- lpszType = "selectbutton"; break;
- case CGUIControl::GUICONTROL_SLIDER:
- lpszType = "slider"; break;
- case CGUIControl::GUICONTROL_SETTINGS_SLIDER:
- lpszType = "sliderex"; break;
- case CGUIControl::GUICONTROL_SPIN:
- lpszType = "spincontrol"; break;
- case CGUIControl::GUICONTROL_SPINEX:
- lpszType = "spincontrolex"; break;
- case CGUIControl::GUICONTROL_TEXTBOX:
- lpszType = "textbox"; break;
- case CGUIControl::GUICONTROL_TOGGLEBUTTON:
- lpszType = "togglebutton"; break;
- case CGUIControl::GUICONTROL_VIDEO:
- lpszType = "videowindow"; break;
- case CGUIControl::GUICONTROL_MOVER:
- lpszType = "mover"; break;
- case CGUIControl::GUICONTROL_RESIZE:
- lpszType = "resize"; break;
- case CGUIControl::GUICONTROL_BUTTONBAR:
- lpszType = "buttonscroller"; break;
- case CGUIControl::GUICONTROL_EDIT:
- lpszType = "edit"; break;
- case CGUIControl::GUICONTROL_VISUALISATION:
- lpszType = "visualisation"; break;
- case CGUIControl::GUICONTROL_MULTI_IMAGE:
- lpszType = "multiimage"; break;
- case CGUIControl::GUICONTROL_GROUP:
- lpszType = "group"; break;
- case CGUIControl::GUICONTROL_GROUPLIST:
- lpszType = "grouplist"; break;
- case CGUIControl::GUICONTROL_SCROLLBAR:
- lpszType = "scrollbar"; break;
- case CGUIControl::GUICONTROL_LISTLABEL:
- lpszType = "label"; break;
- case CGUIControl::GUICONTROL_MULTISELECT:
- lpszType = "multiselect"; break;
- case CGUIControl::GUICONTAINER_LIST:
- lpszType = "list"; break;
- case CGUIControl::GUICONTAINER_WRAPLIST:
- lpszType = "wraplist"; break;
- case CGUIControl::GUICONTAINER_FIXEDLIST:
- lpszType = "fixedlist"; break;
- case CGUIControl::GUICONTAINER_PANEL:
- lpszType = "panel"; break;
- //case CGUIControl::GUICONTROL_UNKNOWN:
- default:
- break;
- }
-
- if (lpszType)
- xmlControl->SetAttribute("type", lpszType);
- if (m_controlID != 0)
- {
- CStdString str;
- str.Format("%u", m_controlID);
- xmlControl->SetAttribute("id", str.c_str());
- }
-
- float pct = (float)GetTotalTime() / (float)m_pProfiler->GetTotalTime();
- if (pct > 0.01f)
- {
- CStdString str;
- str.Format("%.0f", pct * 100.0f);
- xmlControl->SetAttribute("percent", str.c_str());
- }
-
- if (!m_strDescription.IsEmpty())
- {
- TiXmlElement *elem = new TiXmlElement("description");
- xmlControl->LinkEndChild(elem);
- TiXmlText *text = new TiXmlText(m_strDescription.c_str());
- elem->LinkEndChild(text);
- }
-
- // Note time is stored in 1/100 milliseconds but reported in ms
- unsigned int vis = m_visTime / 100;
- unsigned int rend = m_renderTime / 100;
- if (vis || rend)
- {
- CStdString val;
- TiXmlElement *elem = new TiXmlElement("rendertime");
- xmlControl->LinkEndChild(elem);
- val.Format("%u", rend);
- TiXmlText *text = new TiXmlText(val.c_str());
- elem->LinkEndChild(text);
-
- elem = new TiXmlElement("visibletime");
- xmlControl->LinkEndChild(elem);
- val.Format("%u", vis);
- text = new TiXmlText(val.c_str());
- elem->LinkEndChild(text);
- }
-
- if (m_vecChildren.size())
- {
- TiXmlElement *xmlChilds = new TiXmlElement("children");
- xmlControl->LinkEndChild(xmlChilds);
- const unsigned int dwSize = m_vecChildren.size();
- for (unsigned int i=0; i<dwSize; ++i)
- m_vecChildren[i]->SaveToXML(xmlChilds);
- }
-}
-
-CGUIControlProfilerItem *CGUIControlProfilerItem::AddControl(CGUIControl *pControl)
-{
- m_vecChildren.push_back(new CGUIControlProfilerItem(m_pProfiler, this, pControl));
- return m_vecChildren.back();
-}
-
-CGUIControlProfilerItem *CGUIControlProfilerItem::FindOrAddControl(CGUIControl *pControl, bool recurse)
-{
- const unsigned int dwSize = m_vecChildren.size();
- for (unsigned int i=0; i<dwSize; ++i)
- {
- CGUIControlProfilerItem *p = m_vecChildren[i];
- if (p->m_pControl == pControl)
- return p;
- if (recurse && (p = p->FindOrAddControl(pControl, true)))
- return p;
- }
-
- if (pControl->GetParentControl() == m_pControl)
- return AddControl(pControl);
-
- return NULL;
-}
-
-CGUIControlProfiler::CGUIControlProfiler(void)
-: m_ItemHead(NULL, NULL, NULL), m_pLastItem(NULL), m_iMaxFrameCount(200)
-// m_bIsRunning(false), no isRunning because it is static
-{
- m_fPerfScale = 100000.0f / CurrentHostFrequency();
-}
-
-CGUIControlProfiler &CGUIControlProfiler::Instance(void)
-{
- static CGUIControlProfiler _instance;
- return _instance;
-}
-
-bool CGUIControlProfiler::IsRunning(void)
-{
- return m_bIsRunning;
-}
-
-void CGUIControlProfiler::Start(void)
-{
- m_iFrameCount = 0;
- m_bIsRunning = true;
- m_pLastItem = NULL;
- m_ItemHead.Reset(this);
-}
-
-void CGUIControlProfiler::BeginVisibility(CGUIControl *pControl)
-{
- CGUIControlProfilerItem *item = FindOrAddControl(pControl);
- item->BeginVisibility();
-}
-
-void CGUIControlProfiler::EndVisibility(CGUIControl *pControl)
-{
- CGUIControlProfilerItem *item = FindOrAddControl(pControl);
- item->EndVisibility();
-}
-
-void CGUIControlProfiler::BeginRender(CGUIControl *pControl)
-{
- CGUIControlProfilerItem *item = FindOrAddControl(pControl);
- item->BeginRender();
-}
-
-void CGUIControlProfiler::EndRender(CGUIControl *pControl)
-{
- CGUIControlProfilerItem *item = FindOrAddControl(pControl);
- item->EndRender();
-}
-
-CGUIControlProfilerItem *CGUIControlProfiler::FindOrAddControl(CGUIControl *pControl)
-{
- if (m_pLastItem)
- {
- // Typically calls come in pairs so the last control we found is probably
- // the one we want again next time
- if (m_pLastItem->m_pControl == pControl)
- return m_pLastItem;
- // If that control is not a match, usually the one we want is the next
- // sibling of that control, or the parent of that control so check
- // the parent first as it is more convenient
- m_pLastItem = m_pLastItem->m_pParent;
- if (m_pLastItem && m_pLastItem->m_pControl == pControl)
- return m_pLastItem;
- // continued from above, this searches the original control's siblings
- if (m_pLastItem)
- m_pLastItem = m_pLastItem->FindOrAddControl(pControl, false);
- if (m_pLastItem)
- return m_pLastItem;
- }
-
- m_pLastItem = m_ItemHead.FindOrAddControl(pControl, true);
- if (!m_pLastItem)
- m_pLastItem = m_ItemHead.AddControl(pControl);
-
- return m_pLastItem;
-}
-
-void CGUIControlProfiler::EndFrame(void)
-{
- m_iFrameCount++;
- if (m_iFrameCount >= m_iMaxFrameCount)
- {
- const unsigned int dwSize = m_ItemHead.m_vecChildren.size();
- for (unsigned int i=0; i<dwSize; ++i)
- {
- CGUIControlProfilerItem *p = m_ItemHead.m_vecChildren[i];
- m_ItemHead.m_visTime += p->m_visTime;
- m_ItemHead.m_renderTime += p->m_renderTime;
- }
-
- m_bIsRunning = false;
- if (SaveResults())
- m_ItemHead.Reset(this);
- }
-}
-
-bool CGUIControlProfiler::SaveResults(void)
-{
- if (m_strOutputFile.IsEmpty())
- return false;
-
- TiXmlDocument doc;
- TiXmlDeclaration decl("1.0", "", "yes");
- doc.InsertEndChild(decl);
-
- TiXmlElement *root = new TiXmlElement("guicontrolprofiler");
- CStdString str;
- str.Format("%d", m_iFrameCount);
- root->SetAttribute("framecount", str.c_str());
- root->SetAttribute("timeunit", "ms");
- doc.LinkEndChild(root);
-
- m_ItemHead.SaveToXML(root);
- return doc.SaveFile(m_strOutputFile);
-}
diff --git a/guilib/GUIControlProfiler.h b/guilib/GUIControlProfiler.h
deleted file mode 100644
index a9f0613943..0000000000
--- a/guilib/GUIControlProfiler.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2005-2009 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#ifndef GUILIB_GUICONTROLPROFILER_H__
-#define GUILIB_GUICONTROLPROFILER_H__
-#pragma once
-
-#include "GUIControl.h"
-
-class CGUIControlProfiler;
-class TiXmlElement;
-
-class CGUIControlProfilerItem
-{
-public:
- CGUIControlProfiler *m_pProfiler;
- CGUIControlProfilerItem * m_pParent;
- CGUIControl *m_pControl;
- std::vector<CGUIControlProfilerItem *> m_vecChildren;
- CStdString m_strDescription;
- int m_controlID;
- CGUIControl::GUICONTROLTYPES m_ControlType;
- unsigned int m_visTime;
- unsigned int m_renderTime;
- int64_t m_i64VisStart;
- int64_t m_i64RenderStart;
-
- CGUIControlProfilerItem(CGUIControlProfiler *pProfiler, CGUIControlProfilerItem *pParent, CGUIControl *pControl);
- ~CGUIControlProfilerItem(void);
-
- void Reset(CGUIControlProfiler *pProfiler);
- void BeginVisibility(void);
- void EndVisibility(void);
- void BeginRender(void);
- void EndRender(void);
- void SaveToXML(TiXmlElement *parent);
- unsigned int GetTotalTime(void) const { return m_visTime + m_renderTime; };
-
- CGUIControlProfilerItem *AddControl(CGUIControl *pControl);
- CGUIControlProfilerItem *FindOrAddControl(CGUIControl *pControl, bool recurse);
-};
-
-class CGUIControlProfiler
-{
-public:
- static CGUIControlProfiler &Instance(void);
- static bool IsRunning(void);
-
- void Start(void);
- void EndFrame(void);
- void BeginVisibility(CGUIControl *pControl);
- void EndVisibility(CGUIControl *pControl);
- void BeginRender(CGUIControl *pControl);
- void EndRender(CGUIControl *pControl);
- int GetMaxFrameCount(void) const { return m_iMaxFrameCount; };
- void SetMaxFrameCount(int iMaxFrameCount) { m_iMaxFrameCount = iMaxFrameCount; };
- void SetOutputFile(const CStdString &strOutputFile) { m_strOutputFile = strOutputFile; };
- const CStdString &GetOutputFile(void) const { return m_strOutputFile; };
- bool SaveResults(void);
- unsigned int GetTotalTime(void) const { return m_ItemHead.GetTotalTime(); };
-
- float m_fPerfScale;
-private:
- CGUIControlProfiler(void);
- ~CGUIControlProfiler(void) {};
- CGUIControlProfiler(const CGUIControlProfiler &that);
- CGUIControlProfiler &operator=(const CGUIControlProfiler &that);
-
- CGUIControlProfilerItem m_ItemHead;
- CGUIControlProfilerItem *m_pLastItem;
- CGUIControlProfilerItem *FindOrAddControl(CGUIControl *pControl);
-
- static bool m_bIsRunning;
- CStdString m_strOutputFile;
- int m_iMaxFrameCount;
- int m_iFrameCount;
-};
-
-#define GUIPROFILER_VISIBILITY_BEGIN(x) { if (CGUIControlProfiler::IsRunning()) CGUIControlProfiler::Instance().BeginVisibility(x); }
-#define GUIPROFILER_VISIBILITY_END(x) { if (CGUIControlProfiler::IsRunning()) CGUIControlProfiler::Instance().EndVisibility(x); }
-#define GUIPROFILER_RENDER_BEGIN(x) { if (CGUIControlProfiler::IsRunning()) CGUIControlProfiler::Instance().BeginRender(x); }
-#define GUIPROFILER_RENDER_END(x) { if (CGUIControlProfiler::IsRunning()) CGUIControlProfiler::Instance().EndRender(x); }
-
-#endif
diff --git a/guilib/GUIDialog.cpp b/guilib/GUIDialog.cpp
deleted file mode 100644
index 4af7c91c5b..0000000000
--- a/guilib/GUIDialog.cpp
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIDialog.h"
-#include "GUIWindowManager.h"
-#include "GUILabelControl.h"
-#include "GUIAudioManager.h"
-#include "utils/SingleLock.h"
-#include "utils/TimeUtils.h"
-#include "Application.h"
-
-CGUIDialog::CGUIDialog(int id, const CStdString &xmlFile)
- : CGUIWindow(id, xmlFile)
-{
- m_bModal = true;
- m_bRunning = false;
- m_dialogClosing = false;
- m_renderOrder = 1;
- m_autoClosing = false;
- m_enableSound = true;
-}
-
-CGUIDialog::~CGUIDialog(void)
-{}
-
-void CGUIDialog::OnWindowLoaded()
-{
- CGUIWindow::OnWindowLoaded();
-
- // Clip labels to extents
- if (m_children.size())
- {
- CGUIControl* pBase = m_children[0];
-
- for (iControls p = m_children.begin() + 1; p != m_children.end(); ++p)
- {
- if ((*p)->GetControlType() == CGUIControl::GUICONTROL_LABEL)
- {
- CGUILabelControl* pLabel = (CGUILabelControl*)(*p);
-
- if (!pLabel->GetWidth())
- {
- float spacing = (pLabel->GetXPosition() - pBase->GetXPosition()) * 2;
- pLabel->SetWidth(pBase->GetWidth() - spacing);
- }
- }
- }
- }
-}
-
-bool CGUIDialog::OnAction(const CAction &action)
-{
- // keyboard or controller movement should prevent autoclosing
- if (!action.IsMouse() && m_autoClosing)
- SetAutoClose(m_showDuration);
-
- if (action.GetID() == ACTION_CLOSE_DIALOG || action.GetID() == ACTION_PREVIOUS_MENU)
- {
- Close();
- return true;
- }
- return CGUIWindow::OnAction(action);
-}
-
-bool CGUIDialog::OnMessage(CGUIMessage& message)
-{
- switch ( message.GetMessage() )
- {
- case GUI_MSG_WINDOW_DEINIT:
- {
- CGUIWindow *pWindow = g_windowManager.GetWindow(g_windowManager.GetActiveWindow());
- if (pWindow)
- g_windowManager.ShowOverlay(pWindow->GetOverlayState());
-
- CGUIWindow::OnMessage(message);
- // if we were running, make sure we remove ourselves from the window manager
- if (m_bRunning)
- {
- g_windowManager.RemoveDialog(GetID());
- m_bRunning = false;
- m_dialogClosing = false;
- m_autoClosing = false;
- }
- return true;
- }
- case GUI_MSG_WINDOW_INIT:
- {
- CGUIWindow::OnMessage(message);
- m_showStartTime = CTimeUtils::GetFrameTime();
- return true;
- }
- }
-
- return CGUIWindow::OnMessage(message);
-}
-
-void CGUIDialog::Close_Internal(bool forceClose /*= false*/)
-{
- //Lock graphic context here as it is sometimes called from non rendering threads
- //maybe we should have a critical section per window instead??
- CSingleLock lock(g_graphicsContext);
-
- if (!m_bRunning) return;
-
- // Play the window specific deinit sound
- if(!m_dialogClosing && m_enableSound)
- g_audioManager.PlayWindowSound(GetID(), SOUND_DEINIT);
-
- // don't close if we should be animating
- if (!forceClose && HasAnimation(ANIM_TYPE_WINDOW_CLOSE))
- {
- if (!m_dialogClosing && !IsAnimating(ANIM_TYPE_WINDOW_CLOSE))
- {
- QueueAnimation(ANIM_TYPE_WINDOW_CLOSE);
- m_dialogClosing = true;
- }
- return;
- }
-
- CGUIMessage msg(GUI_MSG_WINDOW_DEINIT, 0, 0);
- OnMessage(msg);
-}
-
-void CGUIDialog::DoModal_Internal(int iWindowID /*= WINDOW_INVALID */, const CStdString &param /* = "" */)
-{
- //Lock graphic context here as it is sometimes called from non rendering threads
- //maybe we should have a critical section per window instead??
- CSingleLock lock(g_graphicsContext);
-
- if (!g_windowManager.Initialized())
- return; // don't do anything
-
- m_dialogClosing = false;
- m_bModal = true;
- // set running before it's added to the window manager, else the auto-show code
- // could show it as well if we are in a different thread from
- // the main rendering thread (this should really be handled via
- // a thread message though IMO)
- m_bRunning = true;
- g_windowManager.RouteToWindow(this);
-
- // Play the window specific init sound
- if (m_enableSound)
- g_audioManager.PlayWindowSound(GetID(), SOUND_INIT);
-
- // active this window...
- CGUIMessage msg(GUI_MSG_WINDOW_INIT, 0, 0, WINDOW_INVALID, iWindowID);
- msg.SetStringParam(param);
- OnMessage(msg);
-
-// m_bRunning = true;
-
- if (!m_windowLoaded)
- Close(true);
-
- lock.Leave();
-
- while (m_bRunning && !g_application.m_bStop)
- {
- g_windowManager.Process();
- }
-}
-
-void CGUIDialog::Show_Internal()
-{
- //Lock graphic context here as it is sometimes called from non rendering threads
- //maybe we should have a critical section per window instead??
- CSingleLock lock(g_graphicsContext);
-
- if (m_bRunning && !m_dialogClosing && !IsAnimating(ANIM_TYPE_WINDOW_CLOSE)) return;
-
- if (!g_windowManager.Initialized())
- return; // don't do anything
-
- m_bModal = false;
-
- // set running before it's added to the window manager, else the auto-show code
- // could show it as well if we are in a different thread from
- // the main rendering thread (this should really be handled via
- // a thread message though IMO)
- m_bRunning = true;
- m_dialogClosing = false;
- g_windowManager.AddModeless(this);
-
- // Play the window specific init sound
- if (m_enableSound)
- g_audioManager.PlayWindowSound(GetID(), SOUND_INIT);
-
- // active this window...
- CGUIMessage msg(GUI_MSG_WINDOW_INIT, 0, 0);
- OnMessage(msg);
-
-// m_bRunning = true;
-}
-
-void CGUIDialog::Close(bool forceClose /* = false */)
-{
- if (!g_application.IsCurrentThread())
- {
- // make sure graphics lock is not held
- int nCount = ExitCriticalSection(g_graphicsContext);
- g_application.getApplicationMessenger().Close(this, forceClose);
- RestoreCriticalSection(g_graphicsContext, nCount);
- }
- else
- g_application.getApplicationMessenger().Close(this, forceClose);
-}
-
-void CGUIDialog::DoModal(int iWindowID /*= WINDOW_INVALID */, const CStdString &param)
-{
- g_application.getApplicationMessenger().DoModal(this, iWindowID, param);
-}
-
-void CGUIDialog::Show()
-{
- g_application.getApplicationMessenger().Show(this);
-}
-
-bool CGUIDialog::RenderAnimation(unsigned int time)
-{
- CGUIWindow::RenderAnimation(time);
- return m_bRunning;
-}
-
-void CGUIDialog::FrameMove()
-{
- if (m_autoClosing && m_showStartTime + m_showDuration < CTimeUtils::GetFrameTime() && !m_dialogClosing)
- Close();
- CGUIWindow::FrameMove();
-}
-
-void CGUIDialog::Render()
-{
- CGUIWindow::Render();
- // Check to see if we should close at this point
- // We check after the controls have finished rendering, as we may have to close due to
- // the controls rendering after the window has finished it's animation
- // we call the base class instead of this class so that we can find the change
- if (m_dialogClosing && !CGUIWindow::IsAnimating(ANIM_TYPE_WINDOW_CLOSE))
- {
- Close(true);
- }
-}
-
-bool CGUIDialog::IsAnimating(ANIMATION_TYPE animType)
-{
- if (animType == ANIM_TYPE_WINDOW_CLOSE)
- return m_dialogClosing;
- return CGUIWindow::IsAnimating(animType);
-}
-
-void CGUIDialog::SetDefaults()
-{
- CGUIWindow::SetDefaults();
- m_renderOrder = 1;
-}
-
-void CGUIDialog::SetAutoClose(unsigned int timeoutMs)
-{
- m_autoClosing = true;
- m_showDuration = timeoutMs;
- if (m_bRunning)
- m_showStartTime = CTimeUtils::GetFrameTime();
-}
-
-
diff --git a/guilib/GUIDialog.h b/guilib/GUIDialog.h
deleted file mode 100644
index 3213513759..0000000000
--- a/guilib/GUIDialog.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*!
-\file GUIDialog.h
-\brief
-*/
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIWindow.h"
-#include "Key.h"
-
-/*!
- \ingroup winmsg
- \brief
- */
-class CGUIDialog :
- public CGUIWindow
-{
-public:
- CGUIDialog(int id, const CStdString &xmlFile);
- virtual ~CGUIDialog(void);
-
- virtual bool OnAction(const CAction &action);
- virtual bool OnMessage(CGUIMessage& message);
- virtual void FrameMove();
- virtual void Render();
-
- void DoModal(int iWindowID = WINDOW_INVALID, const CStdString &param = ""); // modal
- void Show(); // modeless
-
- virtual void Close(bool forceClose = false);
- virtual bool IsDialogRunning() const { return m_bRunning; };
- virtual bool IsDialog() const { return true;};
- virtual bool IsModalDialog() const { return m_bModal; };
-
- virtual bool IsAnimating(ANIMATION_TYPE animType);
-
- void SetAutoClose(unsigned int timeoutMs);
- void SetSound(bool OnOff) { m_enableSound = OnOff; };
-
-protected:
- virtual bool RenderAnimation(unsigned int time);
- virtual void SetDefaults();
- virtual void OnWindowLoaded();
-
- friend class CApplicationMessenger;
- void DoModal_Internal(int iWindowID = WINDOW_INVALID, const CStdString &param = ""); // modal
- void Show_Internal(); // modeless
- void Close_Internal(bool forceClose = false);
-
- bool m_bRunning;
- bool m_bModal;
- bool m_dialogClosing;
- bool m_autoClosing;
- bool m_enableSound;
- unsigned int m_showStartTime;
- unsigned int m_showDuration;
-};
diff --git a/guilib/GUIEditControl.cpp b/guilib/GUIEditControl.cpp
deleted file mode 100644
index ded9e1fa17..0000000000
--- a/guilib/GUIEditControl.cpp
+++ /dev/null
@@ -1,555 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIEditControl.h"
-#include "GUIWindowManager.h"
-#include "utils/CharsetConverter.h"
-#include "GUIDialogKeyboard.h"
-#include "GUIDialogNumeric.h"
-#include "LocalizeStrings.h"
-#include "DateTime.h"
-#include "utils/md5.h"
-
-#ifdef __APPLE__
-#include "CocoaInterface.h"
-#endif
-
-const char* CGUIEditControl::smsLetters[10] = { " !@#$%^&*()[]{}<>/\\|0", ".,;:\'\"-+_=?`~1", "abc2", "def3", "ghi4", "jkl5", "mno6", "pqrs7", "tuv8", "wxyz9" };
-const unsigned int CGUIEditControl::smsDelay = 1000;
-
-using namespace std;
-
-#ifdef WIN32
-extern HWND g_hWnd;
-#endif
-
-CGUIEditControl::CGUIEditControl(int parentID, int controlID, float posX, float posY,
- float width, float height, const CTextureInfo &textureFocus, const CTextureInfo &textureNoFocus,
- const CLabelInfo& labelInfo, const std::string &text)
- : CGUIButtonControl(parentID, controlID, posX, posY, width, height, textureFocus, textureNoFocus, labelInfo)
-{
- DefaultConstructor();
- SetLabel(text);
-}
-
-void CGUIEditControl::DefaultConstructor()
-{
- ControlType = GUICONTROL_EDIT;
- m_textOffset = 0;
- m_textWidth = GetWidth();
- m_cursorPos = 0;
- m_cursorBlink = 0;
- m_inputHeading = 0;
- m_inputType = INPUT_TYPE_TEXT;
- m_smsLastKey = 0;
- m_smsKeyIndex = 0;
- m_label.SetAlign(m_label.GetLabelInfo().align & XBFONT_CENTER_Y); // left align
- m_label2.GetLabelInfo().offsetX = 0;
- m_isMD5 = false;
-}
-
-CGUIEditControl::CGUIEditControl(const CGUIButtonControl &button)
- : CGUIButtonControl(button)
-{
- DefaultConstructor();
-}
-
-CGUIEditControl::~CGUIEditControl(void)
-{
-}
-
-bool CGUIEditControl::OnMessage(CGUIMessage &message)
-{
- if (message.GetMessage() == GUI_MSG_SET_TYPE)
- {
- SetInputType((INPUT_TYPE)message.GetParam1(), (int)message.GetParam2());
- return true;
- }
- else if (message.GetMessage() == GUI_MSG_ITEM_SELECTED)
- {
- message.SetLabel(GetLabel2());
- return true;
- }
- else if (message.GetMessage() == GUI_MSG_SETFOCUS ||
- message.GetMessage() == GUI_MSG_LOSTFOCUS)
- {
- m_smsTimer.Stop();
- }
- return CGUIButtonControl::OnMessage(message);
-}
-
-bool CGUIEditControl::OnAction(const CAction &action)
-{
- ValidateCursor();
-
- if (action.GetID() == ACTION_BACKSPACE)
- {
- // backspace
- if (m_cursorPos)
- {
- if (!ClearMD5())
- m_text2.erase(--m_cursorPos, 1);
- UpdateText();
- }
- return true;
- }
- else if (action.GetID() == ACTION_MOVE_LEFT)
- {
- if (m_cursorPos > 0)
- {
- m_cursorPos--;
- UpdateText(false);
- return true;
- }
- }
- else if (action.GetID() == ACTION_MOVE_RIGHT)
- {
- if ((unsigned int) m_cursorPos < m_text2.size())
- {
- m_cursorPos++;
- UpdateText(false);
- return true;
- }
- }
- else if (action.GetID() == ACTION_PASTE)
- {
- ClearMD5();
- OnPasteClipboard();
- }
- else if (action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII)
- {
- // input from the keyboard (vkey, not ascii)
- BYTE b = action.GetID() & 0xFF;
- if (b == 0x24) // home
- {
- m_cursorPos = 0;
- UpdateText(false);
- return true;
- }
- else if (b == 0x23) // end
- {
- m_cursorPos = m_text2.length();
- UpdateText(false);
- return true;
- }
- if (b == 0x25 && m_cursorPos > 0)
- { // left
- m_cursorPos--;
- UpdateText(false);
- return true;
- }
- if (b == 0x27 && m_cursorPos < m_text2.length())
- { // right
- m_cursorPos++;
- UpdateText(false);
- return true;
- }
- if (b == 0x2e)
- {
- if (m_cursorPos < m_text2.length())
- { // delete
- if (!ClearMD5())
- m_text2.erase(m_cursorPos, 1);
- UpdateText();
- return true;
- }
- }
- if (b == 0x8)
- {
- if (m_cursorPos > 0)
- { // backspace
- if (!ClearMD5())
- m_text2.erase(--m_cursorPos, 1);
- UpdateText();
- }
- return true;
- }
- }
- else if (action.GetID() >= KEY_ASCII)
- {
- // input from the keyboard
- switch (action.GetUnicode())
- {
- case '\t':
- break;
- case 10:
- case 13:
- {
- // enter - send click message, but otherwise ignore
- SEND_CLICK_MESSAGE(GetID(), GetParentID(), 1);
- return true;
- }
- case 27:
- { // escape - fallthrough to default action
- return CGUIButtonControl::OnAction(action);
- }
- case 8:
- {
- // backspace
- if (m_cursorPos)
- {
- if (!ClearMD5())
- m_text2.erase(--m_cursorPos, 1);
- }
- break;
- }
- default:
- {
- ClearMD5();
- m_text2.insert(m_text2.begin() + m_cursorPos++, (WCHAR)action.GetUnicode());
- break;
- }
- }
- UpdateText();
- return true;
- }
- else if (action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9)
- { // input from the remote
- ClearMD5();
- if (m_inputType == INPUT_TYPE_FILTER)
- { // filtering - use single number presses
- m_text2.insert(m_text2.begin() + m_cursorPos++, L'0' + (action.GetID() - REMOTE_0));
- UpdateText();
- }
- else
- OnSMSCharacter(action.GetID() - REMOTE_0);
- return true;
- }
- return CGUIButtonControl::OnAction(action);
-}
-
-void CGUIEditControl::OnClick()
-{
- // we received a click - it's not from the keyboard, so pop up the virtual keyboard, unless
- // that is where we reside!
- if (GetParentID() == WINDOW_DIALOG_KEYBOARD)
- return;
-
- CStdString utf8;
- g_charsetConverter.wToUTF8(m_text2, utf8);
- bool textChanged = false;
- CStdString heading = g_localizeStrings.Get(m_inputHeading ? m_inputHeading : 16028);
- switch (m_inputType)
- {
- case INPUT_TYPE_NUMBER:
- textChanged = CGUIDialogNumeric::ShowAndGetNumber(utf8, heading);
- break;
- case INPUT_TYPE_SECONDS:
- textChanged = CGUIDialogNumeric::ShowAndGetSeconds(utf8, g_localizeStrings.Get(21420));
- break;
- case INPUT_TYPE_DATE:
- {
- CDateTime dateTime;
- dateTime.SetFromDBDate(utf8);
- if (dateTime < CDateTime(2000,1, 1, 0, 0, 0))
- dateTime = CDateTime(2000, 1, 1, 0, 0, 0);
- SYSTEMTIME date;
- dateTime.GetAsSystemTime(date);
- if (CGUIDialogNumeric::ShowAndGetDate(date, g_localizeStrings.Get(21420)))
- {
- dateTime = CDateTime(date);
- utf8 = dateTime.GetAsDBDate();
- textChanged = true;
- }
- break;
- }
- case INPUT_TYPE_IPADDRESS:
- textChanged = CGUIDialogNumeric::ShowAndGetIPAddress(utf8, heading);
- break;
- case INPUT_TYPE_SEARCH:
- textChanged = CGUIDialogKeyboard::ShowAndGetFilter(utf8, true);
- break;
- case INPUT_TYPE_FILTER:
- textChanged = CGUIDialogKeyboard::ShowAndGetFilter(utf8, false);
- break;
- case INPUT_TYPE_PASSWORD_MD5:
- utf8 = ""; // TODO: Ideally we'd send this to the keyboard and tell the keyboard we have this type of input
- // fallthrough
- case INPUT_TYPE_TEXT:
- default:
- textChanged = CGUIDialogKeyboard::ShowAndGetInput(utf8, heading, true, m_inputType == INPUT_TYPE_PASSWORD || m_inputType == INPUT_TYPE_PASSWORD_MD5);
- break;
- }
- if (textChanged)
- {
- ClearMD5();
- g_charsetConverter.utf8ToW(utf8, m_text2);
- m_cursorPos = m_text2.size();
- UpdateText();
- m_cursorPos = m_text2.size();
- }
-}
-
-void CGUIEditControl::UpdateText(bool sendUpdate)
-{
- m_smsTimer.Stop();
- if (sendUpdate)
- {
- SEND_CLICK_MESSAGE(GetID(), GetParentID(), 0);
-
- vector<CGUIActionDescriptor> textChangeActions = m_textChangeActions;
- for (unsigned int i = 0; i < textChangeActions.size(); i++)
- {
- CGUIMessage message(GUI_MSG_EXECUTE, GetID(), GetParentID());
- message.SetAction(textChangeActions[i]);
- g_windowManager.SendMessage(message);
- }
- }
- SetInvalid();
-}
-
-void CGUIEditControl::SetInputType(CGUIEditControl::INPUT_TYPE type, int heading)
-{
- m_inputType = type;
- m_inputHeading = heading;
- // TODO: Verify the current input string?
-}
-
-void CGUIEditControl::RecalcLabelPosition()
-{
- // ensure that our cursor is within our width
- ValidateCursor();
-
- CStdStringW text = GetDisplayedText();
- m_textWidth = m_label.CalcTextWidth(text + L'|');
- float beforeCursorWidth = m_label.CalcTextWidth(text.Left(m_cursorPos));
- float afterCursorWidth = m_label.CalcTextWidth(text.Left(m_cursorPos) + L'|');
- float leftTextWidth = m_label.GetRenderRect().Width();
- float maxTextWidth = m_label.GetMaxWidth();
- if (leftTextWidth > 0)
- maxTextWidth -= leftTextWidth + spaceWidth;
-
- // if skinner forgot to set height :p
- if (m_height == 0 && m_label.GetLabelInfo().font)
- m_height = m_label.GetLabelInfo().font->GetTextHeight(1);
-
- if (m_textWidth > maxTextWidth)
- { // we render taking up the full width, so make sure our cursor position is
- // within the render window
- if (m_textOffset + afterCursorWidth > maxTextWidth)
- {
- // move the position to the left (outside of the viewport)
- m_textOffset = maxTextWidth - afterCursorWidth;
- }
- else if (m_textOffset + beforeCursorWidth < 0) // offscreen to the left
- {
- // otherwise use original position
- m_textOffset = -beforeCursorWidth;
- }
- else if (m_textOffset + m_textWidth < maxTextWidth)
- { // we have more text than we're allowed, but we aren't filling all the space
- m_textOffset = maxTextWidth - m_textWidth;
- }
- }
- else
- m_textOffset = 0;
-}
-
-void CGUIEditControl::RenderText()
-{
- if (m_smsTimer.GetElapsedMilliseconds() > smsDelay)
- UpdateText();
-
- if (m_bInvalidated)
- {
- m_label.SetMaxRect(m_posX, m_posY, m_width, m_height);
- m_label.SetText(m_info.GetLabel(GetParentID()));
- RecalcLabelPosition();
- }
-
-
- float posX = m_label.GetRenderRect().x1;
- float maxTextWidth = m_label.GetMaxWidth();
-
- // start by rendering the normal text
- float leftTextWidth = m_label.GetRenderRect().Width();
- if (leftTextWidth > 0)
- {
- // render the text on the left
- m_label.SetColor(GetTextColor());
- m_label.Render();
-
- posX += leftTextWidth + spaceWidth;
- maxTextWidth -= leftTextWidth + spaceWidth;
- }
-
- if (g_graphicsContext.SetClipRegion(posX, m_posY, maxTextWidth, m_height))
- {
- uint32_t align = m_label.GetLabelInfo().align & XBFONT_CENTER_Y; // start aligned left
- if (m_label2.GetTextWidth() < maxTextWidth)
- { // align text as our text fits
- if (leftTextWidth > 0)
- { // right align as we have 2 labels
- align |= XBFONT_RIGHT;
- }
- else
- { // align by whatever the skinner requests
- align |= (m_label2.GetLabelInfo().align & 3);
- }
- }
- CStdStringW text = GetDisplayedText();
- // add the cursor if we're focused
- if (HasFocus())
- {
- CStdStringW col;
- if ((m_focusCounter % 64) > 32)
- col = L"|";
- else
- col = L"[COLOR 00FFFFFF]|[/COLOR]";
- text.Insert(m_cursorPos, col);
- }
-
- m_label2.SetMaxRect(posX + m_textOffset, m_posY, maxTextWidth - m_textOffset, m_height);
- m_label2.SetTextW(text);
- m_label2.SetAlign(align);
- m_label2.SetColor(GetTextColor());
- m_label2.Render();
- g_graphicsContext.RestoreClipRegion();
- }
-}
-
-CStdStringW CGUIEditControl::GetDisplayedText() const
-{
- if (m_inputType == INPUT_TYPE_PASSWORD || m_inputType == INPUT_TYPE_PASSWORD_MD5)
- {
- CStdStringW text;
- text.append(m_text2.size(), L'*');
- return text;
- }
- return m_text2;
-}
-
-void CGUIEditControl::ValidateCursor()
-{
- if (m_cursorPos > m_text2.size())
- m_cursorPos = m_text2.size();
-}
-
-void CGUIEditControl::SetLabel(const std::string &text)
-{
- CGUIButtonControl::SetLabel(text);
- SetInvalid();
-}
-
-void CGUIEditControl::SetLabel2(const std::string &text)
-{
- CStdStringW newText;
- g_charsetConverter.utf8ToW(text, newText);
- if (newText != m_text2)
- {
- m_isMD5 = m_inputType == INPUT_TYPE_PASSWORD_MD5;
- m_text2 = newText;
- m_cursorPos = m_text2.size();
- SetInvalid();
- }
-}
-
-CStdString CGUIEditControl::GetLabel2() const
-{
- CStdString text;
- g_charsetConverter.wToUTF8(m_text2, text);
- if (m_inputType == INPUT_TYPE_PASSWORD_MD5 && !m_isMD5)
- return XBMC::XBMC_MD5::GetMD5(text);
- return text;
-}
-
-bool CGUIEditControl::ClearMD5()
-{
- if (m_inputType != INPUT_TYPE_PASSWORD_MD5 || !m_isMD5)
- return false;
-
- m_text2.Empty();
- m_cursorPos = 0;
- m_isMD5 = false;
- return true;
-}
-
-unsigned int CGUIEditControl::GetCursorPosition() const
-{
- return m_cursorPos;
-}
-
-void CGUIEditControl::SetCursorPosition(unsigned int iPosition)
-{
- m_cursorPos = iPosition;
-}
-
-void CGUIEditControl::OnSMSCharacter(unsigned int key)
-{
- assert(key < 10);
- bool sendUpdate = false;
- if (m_smsTimer.IsRunning())
- {
- // we're already entering an SMS character
- if (key != m_smsLastKey || m_smsTimer.GetElapsedMilliseconds() > smsDelay)
- { // a different key was clicked than last time, or we have timed out
- m_smsLastKey = key;
- m_smsKeyIndex = 0;
- sendUpdate = true;
- }
- else
- { // same key as last time within the appropriate time period
- m_smsKeyIndex++;
- if (m_cursorPos)
- m_text2.erase(--m_cursorPos, 1);
- }
- }
- else
- { // key is pressed for the first time
- m_smsLastKey = key;
- m_smsKeyIndex = 0;
- }
-
- m_smsKeyIndex = m_smsKeyIndex % strlen(smsLetters[key]);
-
- m_text2.insert(m_text2.begin() + m_cursorPos++, smsLetters[key][m_smsKeyIndex]);
- UpdateText(sendUpdate);
- m_smsTimer.StartZero();
-}
-
-void CGUIEditControl::OnPasteClipboard()
-{
-#ifdef __APPLE__
- const char *szStr = Cocoa_Paste();
- if (szStr)
- {
- m_text2 += szStr;
- m_cursorPos+=strlen(szStr);
- UpdateText();
- }
-#elif defined _WIN32
- if (OpenClipboard(g_hWnd))
- {
- HGLOBAL hglb = GetClipboardData(CF_TEXT);
- if (hglb != NULL)
- {
- LPTSTR lptstr = (LPTSTR)GlobalLock(hglb);
- if (lptstr != NULL)
- {
- m_text2 = (char*)lptstr;
- GlobalUnlock(hglb);
- }
- }
- CloseClipboard();
- UpdateText();
- }
-#endif
-}
diff --git a/guilib/GUIEditControl.h b/guilib/GUIEditControl.h
deleted file mode 100644
index ada7bd8f79..0000000000
--- a/guilib/GUIEditControl.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*!
-\file GUIEditControl.h
-\brief
-*/
-
-#ifndef GUILIB_GUIEditControl_H
-#define GUILIB_GUIEditControl_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIButtonControl.h"
-#include "utils/Stopwatch.h"
-
-/*!
- \ingroup controls
- \brief
- */
-
-class CGUIEditControl : public CGUIButtonControl
-{
-public:
- enum INPUT_TYPE {
- INPUT_TYPE_TEXT = 0,
- INPUT_TYPE_NUMBER,
- INPUT_TYPE_SECONDS,
- INPUT_TYPE_DATE,
- INPUT_TYPE_IPADDRESS,
- INPUT_TYPE_PASSWORD,
- INPUT_TYPE_PASSWORD_MD5,
- INPUT_TYPE_SEARCH,
- INPUT_TYPE_FILTER
- };
-
- CGUIEditControl(int parentID, int controlID, float posX, float posY,
- float width, float height, const CTextureInfo &textureFocus, const CTextureInfo &textureNoFocus,
- const CLabelInfo& labelInfo, const std::string &text);
- CGUIEditControl(const CGUIButtonControl &button);
- virtual ~CGUIEditControl(void);
- virtual CGUIEditControl *Clone() const { return new CGUIEditControl(*this); };
-
- virtual bool OnMessage(CGUIMessage &message);
- virtual bool OnAction(const CAction &action);
- virtual void OnClick();
-
- virtual void SetLabel(const std::string &text);
- virtual void SetLabel2(const std::string &text);
-
- virtual CStdString GetLabel2() const;
-
- unsigned int GetCursorPosition() const;
- void SetCursorPosition(unsigned int iPosition);
-
- void SetInputType(INPUT_TYPE type, int heading);
-
- void SetTextChangeActions(const std::vector<CGUIActionDescriptor>& textChangeActions) { m_textChangeActions = textChangeActions; };
-
- bool HasTextChangeActions() { return m_textChangeActions.size() > 0; };
-
-protected:
- virtual void RenderText();
- CStdStringW GetDisplayedText() const;
- void RecalcLabelPosition();
- void ValidateCursor();
- void UpdateText(bool sendUpdate = true);
- void OnPasteClipboard();
- void OnSMSCharacter(unsigned int key);
- void DefaultConstructor();
-
- /*! \brief Clear out the current text input if it's an MD5 password.
- \return true if the password is cleared, false otherwise.
- */
- bool ClearMD5();
-
- CStdStringW m_text2;
- CStdString m_text;
- float m_textOffset;
- float m_textWidth;
-
- static const int spaceWidth = 5;
-
- unsigned int m_cursorPos;
- unsigned int m_cursorBlink;
-
- int m_inputHeading;
- INPUT_TYPE m_inputType;
- bool m_isMD5;
-
- std::vector<CGUIActionDescriptor> m_textChangeActions;
-
-
- unsigned int m_smsKeyIndex;
- unsigned int m_smsLastKey;
- CStopWatch m_smsTimer;
-
- static const char* smsLetters[10];
- static const unsigned int smsDelay;
-};
-#endif
diff --git a/guilib/GUIFadeLabelControl.cpp b/guilib/GUIFadeLabelControl.cpp
deleted file mode 100644
index 3e1a779661..0000000000
--- a/guilib/GUIFadeLabelControl.cpp
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIFadeLabelControl.h"
-#include "utils/CharsetConverter.h"
-
-using namespace std;
-
-CGUIFadeLabelControl::CGUIFadeLabelControl(int parentID, int controlID, float posX, float posY, float width, float height, const CLabelInfo& labelInfo, bool scrollOut, unsigned int timeToDelayAtEnd, bool resetOnLabelChange)
- : CGUIControl(parentID, controlID, posX, posY, width, height), m_scrollInfo(50, labelInfo.offsetX, labelInfo.scrollSpeed)
- , m_textLayout(labelInfo.font, false)
-{
- m_label = labelInfo;
- m_currentLabel = 0;
- ControlType = GUICONTROL_FADELABEL;
- m_scrollOut = scrollOut;
- m_fadeAnim = CAnimation::CreateFader(100, 0, timeToDelayAtEnd, 200);
- if (m_fadeAnim)
- m_fadeAnim->ApplyAnimation();
- m_renderTime = 0;
- m_lastLabel = -1;
- m_scrollSpeed = labelInfo.scrollSpeed; // save it for later
- m_resetOnLabelChange = resetOnLabelChange;
- m_shortText = false;
-}
-
-CGUIFadeLabelControl::CGUIFadeLabelControl(const CGUIFadeLabelControl &from)
-: CGUIControl(from), m_infoLabels(from.m_infoLabels), m_scrollInfo(from.m_scrollInfo), m_textLayout(from.m_textLayout)
-{
- m_label = from.m_label;
- m_scrollOut = from.m_scrollOut;
- m_scrollSpeed = from.m_scrollSpeed;
- m_resetOnLabelChange = from.m_resetOnLabelChange;
-
- if (from.m_fadeAnim)
- m_fadeAnim = new CAnimation(*from.m_fadeAnim);
- if (m_fadeAnim)
- m_fadeAnim->ApplyAnimation();
- m_currentLabel = 0;
- m_renderTime = 0;
- m_lastLabel = -1;
- ControlType = GUICONTROL_FADELABEL;
-}
-
-CGUIFadeLabelControl::~CGUIFadeLabelControl(void)
-{
- delete m_fadeAnim;
-}
-
-void CGUIFadeLabelControl::SetInfo(const vector<CGUIInfoLabel> &infoLabels)
-{
- m_lastLabel = -1;
- m_infoLabels = infoLabels;
-}
-
-void CGUIFadeLabelControl::AddLabel(const string &label)
-{
- m_infoLabels.push_back(CGUIInfoLabel(label));
-}
-
-void CGUIFadeLabelControl::DoRender(unsigned int currentTime)
-{
- m_renderTime = currentTime;
- CGUIControl::DoRender(currentTime);
-}
-
-void CGUIFadeLabelControl::UpdateColors()
-{
- m_label.UpdateColors();
- CGUIControl::UpdateColors();
-}
-
-void CGUIFadeLabelControl::Render()
-{
- if (m_infoLabels.size() == 0 || !m_label.font)
- { // nothing to render
- CGUIControl::Render();
- return ;
- }
-
- if (m_currentLabel >= m_infoLabels.size() )
- m_currentLabel = 0;
-
- if (m_textLayout.Update(GetLabel()))
- { // changed label - update our suffix based on length of available text
- float width, height;
- m_textLayout.GetTextExtent(width, height);
- float spaceWidth = m_label.font->GetCharWidth(L' ');
- unsigned int numSpaces = (unsigned int)(m_width / spaceWidth) + 1;
- if (width < m_width) // append spaces for scrolling
- numSpaces += (unsigned int)((m_width - width) / spaceWidth) + 1;
- m_shortText = (width + m_label.offsetX) < m_width;
- m_scrollInfo.suffix.assign(numSpaces, ' ');
- if (m_resetOnLabelChange)
- {
- m_scrollInfo.Reset();
- m_fadeAnim->ResetAnimation();
- }
- }
- if (m_currentLabel != m_lastLabel)
- { // new label - reset scrolling
- m_scrollInfo.Reset();
- m_fadeAnim->QueueAnimation(ANIM_PROCESS_REVERSE);
- m_lastLabel = m_currentLabel;
- }
-
- float posY = m_posY;
- if (m_label.align & XBFONT_CENTER_Y)
- posY += m_height * 0.5f;
- if (m_infoLabels.size() == 1 && m_shortText)
- { // single label set and no scrolling required - just display
- float posX = m_posX + m_label.offsetX;
- if (m_label.align & XBFONT_CENTER_X)
- posX = m_posX + m_width * 0.5f;
- else if (m_label.align & XBFONT_RIGHT)
- posX = m_posX + m_width;
- m_textLayout.Render(posX, posY, 0, m_label.textColor, m_label.shadowColor, m_label.align, m_width - m_label.offsetX);
- CGUIControl::Render();
- return;
- }
-
- bool moveToNextLabel = false;
- if (!m_scrollOut)
- {
- vecText text;
- m_textLayout.GetFirstText(text);
- if (m_scrollInfo.characterPos && m_scrollInfo.characterPos < text.size())
- text.erase(text.begin(), text.begin() + min((int)m_scrollInfo.characterPos - 1, (int)text.size()));
- if (m_label.font->GetTextWidth(text) < m_width)
- {
- if (m_fadeAnim->GetProcess() != ANIM_PROCESS_NORMAL)
- m_fadeAnim->QueueAnimation(ANIM_PROCESS_NORMAL);
- moveToNextLabel = true;
- }
- }
- else if (m_scrollInfo.characterPos > m_textLayout.GetTextLength())
- moveToNextLabel = true;
-
- // apply the fading animation
- TransformMatrix matrix;
- m_fadeAnim->Animate(m_renderTime, true);
- m_fadeAnim->RenderAnimation(matrix);
- g_graphicsContext.AddTransform(matrix);
-
- if (m_fadeAnim->GetState() == ANIM_STATE_APPLIED)
- m_fadeAnim->ResetAnimation();
-
- m_scrollInfo.SetSpeed((m_fadeAnim->GetProcess() == ANIM_PROCESS_NONE) ? m_scrollSpeed : 0);
-
- if (!m_scrollOut && m_shortText)
- {
- float posX = m_posX + m_label.offsetX;
- if (m_label.align & XBFONT_CENTER_X)
- posX = m_posX + m_width * 0.5f;
- else if (m_label.align & XBFONT_RIGHT)
- posX = m_posX + m_width;
- m_textLayout.Render(posX, posY, 0, m_label.textColor, m_label.shadowColor, m_label.align, m_width);
- }
- else
- m_textLayout.RenderScrolling(m_posX, posY, 0, m_label.textColor, m_label.shadowColor, (m_label.align & ~3), m_width, m_scrollInfo);
-
- if (moveToNextLabel)
- { // increment the label and reset scrolling
- if (m_fadeAnim->GetProcess() != ANIM_PROCESS_NORMAL)
- {
- if (++m_currentLabel >= m_infoLabels.size())
- m_currentLabel = 0;
- m_scrollInfo.Reset();
- m_fadeAnim->QueueAnimation(ANIM_PROCESS_REVERSE);
- }
- }
-
- g_graphicsContext.RemoveTransform();
-
- CGUIControl::Render();
-}
-
-
-bool CGUIFadeLabelControl::CanFocus() const
-{
- return false;
-}
-
-
-bool CGUIFadeLabelControl::OnMessage(CGUIMessage& message)
-{
- if ( message.GetControlId() == GetID() )
- {
- if (message.GetMessage() == GUI_MSG_LABEL_ADD)
- {
- AddLabel(message.GetLabel());
- }
- if (message.GetMessage() == GUI_MSG_LABEL_RESET)
- {
- m_lastLabel = -1;
- m_infoLabels.clear();
- m_scrollInfo.Reset();
- }
- if (message.GetMessage() == GUI_MSG_LABEL_SET)
- {
- m_lastLabel = -1;
- m_infoLabels.clear();
- m_scrollInfo.Reset();
- AddLabel(message.GetLabel());
- }
- }
- return CGUIControl::OnMessage(message);
-}
-
-CStdString CGUIFadeLabelControl::GetDescription() const
-{
- return (m_currentLabel < m_infoLabels.size()) ? m_infoLabels[m_currentLabel].GetLabel(m_parentID) : "";
-}
-
-CStdString CGUIFadeLabelControl::GetLabel()
-{
- if (m_currentLabel > m_infoLabels.size())
- m_currentLabel = 0;
-
- unsigned int numTries = 0;
- CStdString label(m_infoLabels[m_currentLabel].GetLabel(m_parentID));
- while (label.IsEmpty() && ++numTries < m_infoLabels.size())
- {
- if (++m_currentLabel >= m_infoLabels.size())
- m_currentLabel = 0;
- label = m_infoLabels[m_currentLabel].GetLabel(m_parentID);
- }
- return label;
-} \ No newline at end of file
diff --git a/guilib/GUIFadeLabelControl.h b/guilib/GUIFadeLabelControl.h
deleted file mode 100644
index f71c6249d9..0000000000
--- a/guilib/GUIFadeLabelControl.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*!
-\file GUIFadeLabelControl.h
-\brief
-*/
-
-#ifndef GUILIB_GUIFADELABELCONTROL_H
-#define GUILIB_GUIFADELABELCONTROL_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIControl.h"
-#include "GUILabel.h"
-
-/*!
- \ingroup controls
- \brief
- */
-class CGUIFadeLabelControl : public CGUIControl
-{
-public:
- CGUIFadeLabelControl(int parentID, int controlID, float posX, float posY, float width, float height, const CLabelInfo& labelInfo, bool scrollOut, unsigned int timeToDelayAtEnd, bool resetOnLabelChange);
- CGUIFadeLabelControl(const CGUIFadeLabelControl &from);
- virtual ~CGUIFadeLabelControl(void);
- virtual CGUIFadeLabelControl *Clone() const { return new CGUIFadeLabelControl(*this); };
-
- virtual void DoRender(unsigned int currentTime);
- virtual void Render();
- virtual bool CanFocus() const;
- virtual bool OnMessage(CGUIMessage& message);
-
- void SetInfo(const std::vector<CGUIInfoLabel> &vecInfo);
-
-protected:
- virtual void UpdateColors();
- virtual CStdString GetDescription() const;
- void AddLabel(const std::string &label);
-
- /*! \brief retrieve the current label for display
-
- The fadelabel has multiple labels which it cycles through. This routine retrieves the current label.
- It first checks the current label and if non-empty returns it. Otherwise it will iterate through all labels
- until it has a non-empty label to return.
-
- \return the label that should be displayed. If empty, there is no label available.
- */
- CStdString GetLabel();
-
- std::vector< CGUIInfoLabel > m_infoLabels;
- unsigned int m_currentLabel;
- unsigned int m_lastLabel;
-
- CLabelInfo m_label;
-
- bool m_scrollOut; // true if we scroll the text all the way to the left before fading in the next label
- bool m_shortText; // true if the text we have is shorter than the width of the control
-
- CScrollInfo m_scrollInfo;
- CGUITextLayout m_textLayout;
- CAnimation *m_fadeAnim;
- unsigned int m_renderTime;
- unsigned int m_scrollSpeed;
- bool m_resetOnLabelChange;
-};
-#endif
diff --git a/guilib/GUIFixedListContainer.cpp b/guilib/GUIFixedListContainer.cpp
deleted file mode 100644
index 6e1453a9b5..0000000000
--- a/guilib/GUIFixedListContainer.cpp
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIFixedListContainer.h"
-#include "GUIListItem.h"
-#include "utils/GUIInfoManager.h"
-#include "Key.h"
-
-CGUIFixedListContainer::CGUIFixedListContainer(int parentID, int controlID, float posX, float posY, float width, float height, ORIENTATION orientation, int scrollTime, int preloadItems, int fixedPosition, int cursorRange)
- : CGUIBaseContainer(parentID, controlID, posX, posY, width, height, orientation, scrollTime, preloadItems)
-{
- ControlType = GUICONTAINER_FIXEDLIST;
- m_type = VIEW_TYPE_LIST;
- m_fixedCursor = fixedPosition;
- m_cursorRange = std::max(0, cursorRange);
- m_cursor = m_fixedCursor;
-}
-
-CGUIFixedListContainer::~CGUIFixedListContainer(void)
-{
-}
-
-bool CGUIFixedListContainer::OnAction(const CAction &action)
-{
- switch (action.GetID())
- {
- case ACTION_PAGE_UP:
- {
- Scroll(-m_itemsPerPage);
- return true;
- }
- break;
- case ACTION_PAGE_DOWN:
- {
- Scroll(m_itemsPerPage);
- return true;
- }
- break;
- // smooth scrolling (for analog controls)
- case ACTION_SCROLL_UP:
- {
- m_analogScrollCount += action.GetAmount() * action.GetAmount();
- bool handled = false;
- while (m_analogScrollCount > 0.4)
- {
- handled = true;
- m_analogScrollCount -= 0.4f;
- Scroll(-1);
- }
- return handled;
- }
- break;
- case ACTION_SCROLL_DOWN:
- {
- m_analogScrollCount += action.GetAmount() * action.GetAmount();
- bool handled = false;
- while (m_analogScrollCount > 0.4)
- {
- handled = true;
- m_analogScrollCount -= 0.4f;
- Scroll(1);
- }
- return handled;
- }
- break;
- }
- return CGUIBaseContainer::OnAction(action);
-}
-
-bool CGUIFixedListContainer::OnMessage(CGUIMessage& message)
-{
- if (message.GetControlId() == GetID() )
- {
- if (message.GetMessage() == GUI_MSG_ITEM_SELECT)
- {
- SelectItem(message.GetParam1());
- return true;
- }
- }
- return CGUIBaseContainer::OnMessage(message);
-}
-
-bool CGUIFixedListContainer::MoveUp(bool wrapAround)
-{
- int item = GetSelectedItem();
- if (item > 0)
- SelectItem(item - 1);
- else if (wrapAround)
- {
- SelectItem((int)m_items.size() - 1);
- SetContainerMoving(-1);
- }
- else
- return false;
- return true;
-}
-
-bool CGUIFixedListContainer::MoveDown(bool wrapAround)
-{
- int item = GetSelectedItem();
- if (item < (int)m_items.size() - 1)
- SelectItem(item + 1);
- else if (wrapAround)
- { // move first item in list
- SelectItem(0);
- SetContainerMoving(1);
- }
- else
- return false;
- return true;
-}
-
-// scrolls the said amount
-void CGUIFixedListContainer::Scroll(int amount)
-{
- // increase or decrease the offset
- int item = m_offset + m_cursor + amount;
- // check for our end points
- if (item >= (int)m_items.size() - 1)
- item = (int)m_items.size() - 1;
- if (item < 0)
- item = 0;
- SelectItem(item);
-}
-
-void CGUIFixedListContainer::ValidateOffset()
-{
- if (!m_layout) return;
- // ensure our fixed cursor position is valid
- if (m_fixedCursor >= m_itemsPerPage)
- m_fixedCursor = m_itemsPerPage - 1;
- if (m_fixedCursor < 0)
- m_fixedCursor = 0;
- // compute our minimum and maximum cursor positions
- int minCursor, maxCursor;
- GetCursorRange(minCursor, maxCursor);
- // assure our cursor is between these limits
- m_cursor = std::max(m_cursor, minCursor);
- m_cursor = std::min(m_cursor, maxCursor);
- // and finally ensure our offset is valid
- if (m_offset + maxCursor >= (int)m_items.size() || m_scrollOffset > ((int)m_items.size() - maxCursor - 1) * m_layout->Size(m_orientation))
- {
- m_offset = m_items.size() - maxCursor - 1;
- m_scrollOffset = m_offset * m_layout->Size(m_orientation);
- }
- if (m_offset < -minCursor || m_scrollOffset < -minCursor * m_layout->Size(m_orientation))
- {
- m_offset = -minCursor;
- m_scrollOffset = m_offset * m_layout->Size(m_orientation);
- }
-}
-
-int CGUIFixedListContainer::GetCursorFromPoint(const CPoint &point, CPoint *itemPoint) const
-{
- if (!m_focusedLayout || !m_layout)
- return -1;
- int minCursor, maxCursor;
- GetCursorRange(minCursor, maxCursor);
- // see if the point is either side of our focus range
- float start = (minCursor + 0.2f) * m_layout->Size(m_orientation);
- float end = (maxCursor - 0.2f) * m_layout->Size(m_orientation) + m_focusedLayout->Size(m_orientation);
- float pos = (m_orientation == VERTICAL) ? point.y : point.x;
- if (pos >= start && pos <= end)
- { // select the appropriate item
- pos -= minCursor * m_layout->Size(m_orientation);
- for (int row = minCursor; row <= maxCursor; row++)
- {
- const CGUIListItemLayout *layout = (row == m_cursor) ? m_focusedLayout : m_layout;
- if (pos < layout->Size(m_orientation))
- {
- if (!InsideLayout(layout, point))
- return -1;
- return row;
- }
- pos -= layout->Size(m_orientation);
- }
- }
- return -1;
-}
-
-bool CGUIFixedListContainer::SelectItemFromPoint(const CPoint &point)
-{
- if (!m_focusedLayout || !m_layout)
- return false;
-
- const float mouse_scroll_speed = 0.25f;
- const float mouse_max_amount = 1.5f;
- float sizeOfItem = m_layout->Size(m_orientation);
- int minCursor, maxCursor;
- GetCursorRange(minCursor, maxCursor);
- // see if the point is either side of our focus range
- float start = (minCursor + 0.2f) * sizeOfItem;
- float end = (maxCursor - 0.2f) * sizeOfItem + m_focusedLayout->Size(m_orientation);
- float pos = (m_orientation == VERTICAL) ? point.y : point.x;
- if (pos < start && m_offset > -minCursor)
- { // scroll backward
- if (!InsideLayout(m_layout, point))
- return false;
- float amount = std::min((start - pos) / sizeOfItem, mouse_max_amount);
- m_analogScrollCount += amount * amount * mouse_scroll_speed;
- if (m_analogScrollCount > 1)
- {
- ScrollToOffset(m_offset - 1);
- m_analogScrollCount = 0;
- }
- return true;
- }
- else if (pos > end && m_offset + maxCursor < (int)m_items.size() - 1)
- {
- if (!InsideLayout(m_layout, point))
- return false;
- // scroll forward
- float amount = std::min((pos - end) / sizeOfItem, mouse_max_amount);
- m_analogScrollCount += amount * amount * mouse_scroll_speed;
- if (m_analogScrollCount > 1)
- {
- ScrollToOffset(m_offset + 1);
- m_analogScrollCount = 0;
- }
- return true;
- }
- else
- { // select the appropriate item
- int cursor = GetCursorFromPoint(point);
- if (cursor < 0)
- return false;
- // calling SelectItem() here will focus the item and scroll, which isn't really what we're after
- m_cursor = cursor;
- return true;
- }
- return InsideLayout(m_focusedLayout, point);
-}
-
-void CGUIFixedListContainer::SelectItem(int item)
-{
- // Check that m_offset is valid
- ValidateOffset();
- // only select an item if it's in a valid range
- if (item >= 0 && item < (int)m_items.size())
- {
- // Select the item requested - we first set the cursor position
- // which may be different at either end of the list, then the offset
- int minCursor, maxCursor;
- GetCursorRange(minCursor, maxCursor);
-
- int cursor;
- if ((int)m_items.size() - 1 - item <= maxCursor - m_fixedCursor)
- cursor = std::max(m_fixedCursor, maxCursor + item - (int)m_items.size() + 1);
- else if (item <= m_fixedCursor - minCursor)
- cursor = std::min(m_fixedCursor, minCursor + item);
- else
- cursor = m_fixedCursor;
- if (cursor != m_cursor)
- SetContainerMoving(cursor - m_cursor);
- m_cursor = cursor;
- ScrollToOffset(item - m_cursor);
- }
-}
-
-bool CGUIFixedListContainer::HasPreviousPage() const
-{
- return (m_offset > 0);
-}
-
-bool CGUIFixedListContainer::HasNextPage() const
-{
- return (m_offset != (int)m_items.size() - m_itemsPerPage && (int)m_items.size() >= m_itemsPerPage);
-}
-
-int CGUIFixedListContainer::GetCurrentPage() const
-{
- int offset = CorrectOffset(m_offset, m_cursor);
- if (offset + m_itemsPerPage - m_cursor >= (int)GetRows()) // last page
- return (GetRows() + m_itemsPerPage - 1) / m_itemsPerPage;
- return offset / m_itemsPerPage + 1;
-}
-
-void CGUIFixedListContainer::GetCursorRange(int &minCursor, int &maxCursor) const
-{
- minCursor = std::max(m_fixedCursor - m_cursorRange, 0);
- maxCursor = std::min(m_fixedCursor + m_cursorRange, m_itemsPerPage);
-
- if (!m_items.size())
- {
- minCursor = m_fixedCursor;
- maxCursor = m_fixedCursor;
- return;
- }
-
- while (maxCursor - minCursor > (int)m_items.size() - 1)
- {
- if (maxCursor - m_fixedCursor > m_fixedCursor - minCursor)
- maxCursor--;
- else
- minCursor++;
- }
-}
-
diff --git a/guilib/GUIFixedListContainer.h b/guilib/GUIFixedListContainer.h
deleted file mode 100644
index 78ee3ba7b7..0000000000
--- a/guilib/GUIFixedListContainer.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*!
-\file GUIFixedListContainer.h
-\brief
-*/
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIBaseContainer.h"
-
-/*!
- \ingroup controls
- \brief
- */
-class CGUIFixedListContainer : public CGUIBaseContainer
-{
-public:
- CGUIFixedListContainer(int parentID, int controlID, float posX, float posY, float width, float height, ORIENTATION orientation, int scrollTime, int preloadItems, int fixedPosition, int cursorRange);
- virtual ~CGUIFixedListContainer(void);
- virtual CGUIFixedListContainer *Clone() const { return new CGUIFixedListContainer(*this); };
-
- virtual bool OnAction(const CAction &action);
- virtual bool OnMessage(CGUIMessage& message);
-
-protected:
- virtual void Scroll(int amount);
- virtual bool MoveDown(bool wrapAround);
- virtual bool MoveUp(bool wrapAround);
- virtual void ValidateOffset();
- virtual bool SelectItemFromPoint(const CPoint &point);
- virtual int GetCursorFromPoint(const CPoint &point, CPoint *itemPoint = NULL) const;
- virtual void SelectItem(int item);
- virtual bool HasNextPage() const;
- virtual bool HasPreviousPage() const;
- virtual int GetCurrentPage() const;
-
-private:
- /*!
- \brief Get the minimal and maximal cursor positions in the list
-
- As the fixed list cursor position may vary at the ends of the list based
- on the cursor range, this function computes the minimal and maximal positions
- based on the number of items in the list
- \param minCursor the minimal cursor position
- \param maxCursor the maximal cursor position
- \sa m_fixedCursor, m_cursorRange
- */
- void GetCursorRange(int &minCursor, int &maxCursor) const;
-
- int m_fixedCursor; ///< default position the skinner wishes to use for the focused item
- int m_cursorRange; ///< range that the focused item can vary when at the ends of the list
-};
-
diff --git a/guilib/GUIFont.cpp b/guilib/GUIFont.cpp
deleted file mode 100644
index f52f3c65fd..0000000000
--- a/guilib/GUIFont.cpp
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIFont.h"
-#include "GUIFontTTF.h"
-#include "GraphicContext.h"
-
-#include "utils/SingleLock.h"
-#include "utils/TimeUtils.h"
-#include "MathUtils.h"
-
-#define ROUND(x) (float)(MathUtils::round_int(x))
-
-float CScrollInfo::GetPixelsPerFrame()
-{
- static const float alphaEMA = 0.05f;
-
- if (0 == pixelSpeed)
- return 0; // not scrolling
- unsigned int currentTime = CTimeUtils::GetFrameTime();
- float delta = m_lastFrameTime ? (float)(currentTime - m_lastFrameTime) : m_averageFrameTime;
- if (delta > 100)
- delta = 100; // assume a minimum of 10 fps
- m_lastFrameTime = currentTime;
- // do an exponential moving average of the frame time
- m_averageFrameTime = m_averageFrameTime + (delta - m_averageFrameTime) * alphaEMA;
- // and multiply by pixel speed (per ms) to get number of pixels to move this frame
- return pixelSpeed * m_averageFrameTime;
-}
-
-CGUIFont::CGUIFont(const CStdString& strFontName, uint32_t style, color_t textColor,
- color_t shadowColor, float lineSpacing, float origHeight, CGUIFontTTFBase *font)
-{
- m_strFontName = strFontName;
- m_style = style & 3;
- m_textColor = textColor;
- m_shadowColor = shadowColor;
- m_lineSpacing = lineSpacing;
- m_origHeight = origHeight;
- m_font = font;
-
- if (m_font)
- m_font->AddReference();
-}
-
-CGUIFont::~CGUIFont()
-{
- if (m_font)
- m_font->RemoveReference();
-}
-
-CStdString& CGUIFont::GetFontName()
-{
- return m_strFontName;
-}
-
-void CGUIFont::DrawText( float x, float y, const vecColors &colors, color_t shadowColor,
- const vecText &text, uint32_t alignment, float maxPixelWidth)
-{
- if (!m_font) return;
-
- bool clip = maxPixelWidth > 0;
- if (clip && ClippedRegionIsEmpty(x, y, maxPixelWidth, alignment))
- return;
-
- maxPixelWidth = ROUND(maxPixelWidth / g_graphicsContext.GetGUIScaleX());
- vecColors renderColors;
- for (unsigned int i = 0; i < colors.size(); i++)
- renderColors.push_back(g_graphicsContext.MergeAlpha(colors[i] ? colors[i] : m_textColor));
- if (!shadowColor) shadowColor = m_shadowColor;
- if (shadowColor)
- {
- shadowColor = g_graphicsContext.MergeAlpha(shadowColor);
- vecColors shadowColors;
- for (unsigned int i = 0; i < renderColors.size(); i++)
- shadowColors.push_back((renderColors[i] & 0xff000000) != 0 ? shadowColor : 0);
- m_font->DrawTextInternal(x + 1, y + 1, shadowColors, text, alignment, maxPixelWidth, false);
- }
- m_font->DrawTextInternal( x, y, renderColors, text, alignment, maxPixelWidth, false);
-
- if (clip)
- g_graphicsContext.RestoreClipRegion();
-}
-
-void CGUIFont::DrawScrollingText(float x, float y, const vecColors &colors, color_t shadowColor,
- const vecText &text, uint32_t alignment, float maxWidth, CScrollInfo &scrollInfo)
-{
- if (!m_font) return;
- if (!shadowColor) shadowColor = m_shadowColor;
-
- float spaceWidth = GetCharWidth(L' ');
- // max chars on screen + extra margin chars
- vecText::size_type maxChars =
- std::min<vecText::size_type>(
- (text.size() + (vecText::size_type)scrollInfo.suffix.size()),
- (vecText::size_type)((maxWidth * 1.05f) / spaceWidth));
-
- if (!text.size() || ClippedRegionIsEmpty(x, y, maxWidth, alignment))
- return; // nothing to render
-
- maxWidth = ROUND(maxWidth / g_graphicsContext.GetGUIScaleX());
-
- // draw at our scroll position
- // we handle the scrolling as follows:
- // We scroll on a per-pixel basis up until we have scrolled the first character outside
- // of our viewport, whereby we cycle the string around, and reset the scroll position.
- //
- // pixelPos is the amount in pixels to move the string by.
- // characterPos is the amount in characters to rotate the string by.
- //
- float offset = scrollInfo.pixelPos;
- if (!scrollInfo.waitTime)
- {
- // move along by the appropriate scroll amount
- float scrollAmount = fabs(scrollInfo.GetPixelsPerFrame() * g_graphicsContext.GetGUIScaleX());
-
- if (scrollInfo.pixelSpeed > 0)
- {
- // we want to move scrollAmount, grab the next character
- float charWidth = GetCharWidth(scrollInfo.GetCurrentChar(text));
- if (scrollInfo.pixelPos + scrollAmount < charWidth)
- scrollInfo.pixelPos += scrollAmount; // within the current character
- else
- { // past the current character, decrement scrollAmount by the charWidth and move to the next character
- while (scrollInfo.pixelPos + scrollAmount >= charWidth)
- {
- scrollAmount -= (charWidth - scrollInfo.pixelPos);
- scrollInfo.pixelPos = 0;
- scrollInfo.characterPos++;
- if (scrollInfo.characterPos >= text.size() + scrollInfo.suffix.size())
- {
- scrollInfo.Reset();
- break;
- }
- charWidth = GetCharWidth(scrollInfo.GetCurrentChar(text));
- }
- }
- offset = scrollInfo.pixelPos;
- }
- else if (scrollInfo.pixelSpeed < 0)
- { // scrolling backwards
- // we want to move scrollAmount, grab the next character
- float charWidth = GetCharWidth(scrollInfo.GetCurrentChar(text));
- if (scrollInfo.pixelPos + scrollAmount < charWidth)
- scrollInfo.pixelPos += scrollAmount; // within the current character
- else
- { // past the current character, decrement scrollAmount by the charWidth and move to the next character
- while (scrollInfo.pixelPos + scrollAmount >= charWidth)
- {
- scrollAmount -= (charWidth - scrollInfo.pixelPos);
- scrollInfo.pixelPos = 0;
- if (scrollInfo.characterPos == 0)
- {
- scrollInfo.Reset();
- scrollInfo.characterPos = text.size() + scrollInfo.suffix.size() - 1;
- break;
- }
- scrollInfo.characterPos--;
- charWidth = GetCharWidth(scrollInfo.GetCurrentChar(text));
- }
- }
- offset = charWidth - scrollInfo.pixelPos;
- }
- }
- else
- scrollInfo.waitTime--;
-
- // Now rotate our string as needed, only take a slightly larger then visible part of the text.
- unsigned int pos = scrollInfo.characterPos;
- vecText renderText;
- renderText.reserve(maxChars);
- for (vecText::size_type i = 0; i < maxChars; i++)
- {
- if (pos >= text.size() + scrollInfo.suffix.size())
- pos = 0;
- if (pos < text.size())
- renderText.push_back(text[pos]);
- else
- renderText.push_back(scrollInfo.suffix[pos - text.size()]);
- pos++;
- }
-
- vecColors renderColors;
- for (unsigned int i = 0; i < colors.size(); i++)
- renderColors.push_back(g_graphicsContext.MergeAlpha(colors[i] ? colors[i] : m_textColor));
-
- bool scroll = !scrollInfo.waitTime && scrollInfo.pixelSpeed;
- if (shadowColor)
- {
- shadowColor = g_graphicsContext.MergeAlpha(shadowColor);
- vecColors shadowColors;
- for (unsigned int i = 0; i < renderColors.size(); i++)
- shadowColors.push_back((renderColors[i] & 0xff000000) != 0 ? shadowColor : 0);
- m_font->DrawTextInternal(x - offset + 1, y + 1, shadowColors, renderText, alignment, maxWidth + scrollInfo.pixelPos + m_font->GetLineHeight(2.0f), scroll);
- }
- m_font->DrawTextInternal(x - offset, y, renderColors, renderText, alignment, maxWidth + scrollInfo.pixelPos + m_font->GetLineHeight(2.0f), scroll);
-
- g_graphicsContext.RestoreClipRegion();
-}
-
-// remaps unsupported font glpyhs to other suitable ones
-wchar_t CGUIFont::RemapGlyph(wchar_t letter)
-{
- if (letter == 0x2019 || letter == 0x2018) return 0x0027; // single quotes
- else if (letter == 0x201c || letter == 0x201d) return 0x0022;
- return 0; // no decent character map
-}
-
-bool CGUIFont::ClippedRegionIsEmpty(float x, float y, float width, uint32_t alignment) const
-{
- if (alignment & XBFONT_CENTER_X)
- x -= width * 0.5f;
- else if (alignment & XBFONT_RIGHT)
- x -= width;
- if (alignment & XBFONT_CENTER_Y)
- y -= m_font->GetLineHeight(m_lineSpacing);
-
- return !g_graphicsContext.SetClipRegion(x, y, width, m_font->GetLineHeight(2.0f) * g_graphicsContext.GetGUIScaleY());
-}
-
-float CGUIFont::GetTextWidth( const vecText &text )
-{
- if (!m_font) return 0;
- CSingleLock lock(g_graphicsContext);
- return m_font->GetTextWidthInternal(text.begin(), text.end()) * g_graphicsContext.GetGUIScaleX();
-}
-
-float CGUIFont::GetCharWidth( character_t ch )
-{
- if (!m_font) return 0;
- CSingleLock lock(g_graphicsContext);
- return m_font->GetCharWidthInternal(ch) * g_graphicsContext.GetGUIScaleX();
-}
-
-float CGUIFont::GetTextHeight(int numLines) const
-{
- if (!m_font) return 0;
- return m_font->GetTextHeight(m_lineSpacing, numLines) * g_graphicsContext.GetGUIScaleY();
-}
-
-float CGUIFont::GetLineHeight() const
-{
- if (!m_font) return 0;
- return m_font->GetLineHeight(m_lineSpacing) * g_graphicsContext.GetGUIScaleY();
-}
-
-float CGUIFont::GetScaleFactor() const
-{
- if (!m_font) return 1.0f;
- return m_font->GetFontHeight() / m_origHeight;
-}
-
-void CGUIFont::Begin()
-{
- if (!m_font) return;
- m_font->Begin();
-}
-
-void CGUIFont::End()
-{
- if (!m_font) return;
- m_font->End();
-}
-
-void CGUIFont::SetFont(CGUIFontTTFBase *font)
-{
- if (m_font == font)
- return; // no need to update the font if we already have it
- if (m_font)
- m_font->RemoveReference();
- m_font = font;
- if (m_font)
- m_font->AddReference();
-}
diff --git a/guilib/GUIFont.h b/guilib/GUIFont.h
deleted file mode 100644
index 935dfad9e9..0000000000
--- a/guilib/GUIFont.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/*!
-\file GUIFont.h
-\brief
-*/
-
-#ifndef CGUILIB_GUIFONT_H
-#define CGUILIB_GUIFONT_H
-#pragma once
-
-/*
- * Copyright (C) 2003-2010 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "StdString.h"
-#include <assert.h>
-
-typedef uint32_t character_t;
-typedef uint32_t color_t;
-typedef std::vector<character_t> vecText;
-typedef std::vector<color_t> vecColors;
-
-class CGUIFontTTFBase;
-
-// flags for alignment
-#define XBFONT_LEFT 0x00000000
-#define XBFONT_RIGHT 0x00000001
-#define XBFONT_CENTER_X 0x00000002
-#define XBFONT_CENTER_Y 0x00000004
-#define XBFONT_TRUNCATED 0x00000008
-#define XBFONT_JUSTIFIED 0x00000010
-
-#define FONT_STYLE_NORMAL 0
-#define FONT_STYLE_BOLD 1
-#define FONT_STYLE_ITALICS 2
-#define FONT_STYLE_BOLD_ITALICS 3
-
-class CScrollInfo
-{
-public:
- CScrollInfo(unsigned int wait = 50, float pos = 0, int speed = defaultSpeed, const CStdString &scrollSuffix = " | ")
- {
- initialWait = wait;
- initialPos = pos;
- SetSpeed(speed ? speed : defaultSpeed);
- suffix = scrollSuffix;
- Reset();
- };
- void SetSpeed(int speed)
- {
- pixelSpeed = speed * 0.001f;
- }
- void Reset()
- {
- waitTime = initialWait;
- characterPos = 0;
- // pixelPos is where we start the current letter, so is measured
- // to the left of the text rendering's left edge. Thus, a negative
- // value will mean the text starts to the right
- pixelPos = -initialPos;
- // privates:
- m_averageFrameTime = 1000.f / abs(defaultSpeed);
- m_lastFrameTime = 0;
- }
- uint32_t GetCurrentChar(const vecText &text) const
- {
- assert(text.size());
- if (characterPos < text.size())
- return text[characterPos];
- else if (characterPos < text.size() + suffix.size())
- return suffix[characterPos - text.size()];
- return text[0];
- }
- float GetPixelsPerFrame();
-
- float pixelPos;
- float pixelSpeed;
- unsigned int waitTime;
- unsigned int characterPos;
- unsigned int initialWait;
- float initialPos;
- CStdString suffix;
-
- static const int defaultSpeed = 60;
-private:
- float m_averageFrameTime;
- uint32_t m_lastFrameTime;
-};
-
-/*!
- \ingroup textures
- \brief
- */
-class CGUIFont
-{
-public:
- CGUIFont(const CStdString& strFontName, uint32_t style, color_t textColor,
- color_t shadowColor, float lineSpacing, float origHeight, CGUIFontTTFBase *font);
- virtual ~CGUIFont();
-
- CStdString& GetFontName();
-
- void DrawText( float x, float y, color_t color, color_t shadowColor,
- const vecText &text, uint32_t alignment, float maxPixelWidth)
- {
- vecColors colors;
- colors.push_back(color);
- DrawText(x, y, colors, shadowColor, text, alignment, maxPixelWidth);
- };
-
- void DrawText( float x, float y, const vecColors &colors, color_t shadowColor,
- const vecText &text, uint32_t alignment, float maxPixelWidth);
-
- void DrawScrollingText( float x, float y, const vecColors &colors, color_t shadowColor,
- const vecText &text, uint32_t alignment, float maxPixelWidth, CScrollInfo &scrollInfo);
-
- float GetTextWidth( const vecText &text );
- float GetCharWidth( character_t ch );
- float GetTextHeight(int numLines) const;
- float GetLineHeight() const;
-
- //! get font scale factor (rendered height / original height)
- float GetScaleFactor() const;
-
- void Begin();
- void End();
-
- uint32_t GetStyle() const { return m_style; };
-
- static wchar_t RemapGlyph(wchar_t letter);
-
- CGUIFontTTFBase* GetFont() const
- {
- return m_font;
- }
-
- void SetFont(CGUIFontTTFBase* font);
-
-protected:
- CStdString m_strFontName;
- uint32_t m_style;
- color_t m_shadowColor;
- color_t m_textColor;
- float m_lineSpacing;
- float m_origHeight;
- CGUIFontTTFBase *m_font; // the font object has the size information
-
-private:
- bool ClippedRegionIsEmpty(float x, float y, float width, uint32_t alignment) const;
-};
-
-#endif
diff --git a/guilib/GUIFontManager.cpp b/guilib/GUIFontManager.cpp
deleted file mode 100644
index f544e1b207..0000000000
--- a/guilib/GUIFontManager.cpp
+++ /dev/null
@@ -1,553 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIFontManager.h"
-#include "GraphicContext.h"
-#include "GUIWindowManager.h"
-#include "addons/Skin.h"
-#include "GUIFontTTF.h"
-#include "GUIFont.h"
-#include "XMLUtils.h"
-#include "GUIControlFactory.h"
-#include "../xbmc/Util.h"
-#include "../xbmc/FileSystem/File.h"
-#include "../xbmc/FileSystem/SpecialProtocol.h"
-#include "utils/log.h"
-#include "WindowingFactory.h"
-
-using namespace std;
-
-GUIFontManager g_fontManager;
-
-GUIFontManager::GUIFontManager(void)
-{
- m_skinResolution=RES_INVALID;
- m_fontsetUnicode=false;
- m_canReload = true;
-}
-
-GUIFontManager::~GUIFontManager(void)
-{
- Clear();
-}
-
-void GUIFontManager::RescaleFontSizeAndAspect(float *size, float *aspect, RESOLUTION sourceRes, bool preserveAspect) const
-{
- // set scaling resolution so that we can scale our font sizes correctly
- // as fonts aren't scaled at render time (due to aliasing) we must scale
- // the size of the fonts before they are drawn to bitmaps
- g_graphicsContext.SetScalingResolution(sourceRes, true);
-
- if (preserveAspect)
- {
- // font always displayed in the aspect specified by the aspect parameter
- *aspect /= g_graphicsContext.GetPixelRatio(g_graphicsContext.GetVideoResolution());
- }
- else
- {
- // font streched like the rest of the UI, aspect parameter being the original aspect
-
- // adjust aspect ratio
- if (sourceRes == RES_PAL_16x9 || sourceRes == RES_PAL60_16x9 || sourceRes == RES_NTSC_16x9 || sourceRes == RES_HDTV_480p_16x9)
- *aspect *= 0.75f;
-
- *aspect *= g_graphicsContext.GetGUIScaleY() / g_graphicsContext.GetGUIScaleX();
- }
-
- *size /= g_graphicsContext.GetGUIScaleY();
-}
-
-CGUIFont* GUIFontManager::LoadTTF(const CStdString& strFontName, const CStdString& strFilename, color_t textColor, color_t shadowColor, const int iSize, const int iStyle, bool border, float lineSpacing, float aspect, RESOLUTION sourceRes, bool preserveAspect)
-{
- float originalAspect = aspect;
-
- //check if font already exists
- CGUIFont* pFont = GetFont(strFontName, false);
- if (pFont)
- return pFont;
-
- if (sourceRes == RES_INVALID) // no source res specified, so assume the skin res
- sourceRes = m_skinResolution;
-
- float newSize = (float)iSize;
- RescaleFontSizeAndAspect(&newSize, &aspect, sourceRes, preserveAspect);
-
- // First try to load the font from the skin
- CStdString strPath;
- if (!CURL::IsFullPath(strFilename))
- {
- strPath = CUtil::AddFileToFolder(g_graphicsContext.GetMediaDir(), "fonts");
- strPath = CUtil::AddFileToFolder(strPath, strFilename);
- }
- else
- strPath = strFilename;
-
-#ifdef _LINUX
- strPath = PTH_IC(strPath);
-#endif
-
- // Check if the file exists, otherwise try loading it from the global media dir
- if (!XFILE::CFile::Exists(strPath))
- {
- strPath = CUtil::AddFileToFolder("special://xbmc/media/Fonts", CUtil::GetFileName(strFilename));
-#ifdef _LINUX
- strPath = PTH_IC(strPath);
-#endif
- }
-
- // check if we already have this font file loaded (font object could differ only by color or style)
- CStdString TTFfontName;
- TTFfontName.Format("%s_%f_%f%s", strFilename, newSize, aspect, border ? "_border" : "");
-
- CGUIFontTTFBase* pFontFile = GetFontFile(TTFfontName);
- if (!pFontFile)
- {
- pFontFile = new CGUIFontTTF(TTFfontName);
- bool bFontLoaded = pFontFile->Load(strPath, newSize, aspect, 1.0f, border);
-
- if (!bFontLoaded)
- {
- delete pFontFile;
-
- // font could not be loaded - try Arial.ttf, which we distribute
- if (strFilename != "arial.ttf")
- {
- CLog::Log(LOGERROR, "Couldn't load font name: %s(%s), trying to substitute arial.ttf", strFontName.c_str(), strFilename.c_str());
- return LoadTTF(strFontName, "arial.ttf", textColor, shadowColor, iSize, iStyle, border, lineSpacing, originalAspect);
- }
- CLog::Log(LOGERROR, "Couldn't load font name:%s file:%s", strFontName.c_str(), strPath.c_str());
-
- return NULL;
- }
-
- m_vecFontFiles.push_back(pFontFile);
- }
-
- // font file is loaded, create our CGUIFont
- CGUIFont *pNewFont = new CGUIFont(strFontName, iStyle, textColor, shadowColor, lineSpacing, (float)iSize, pFontFile);
- m_vecFonts.push_back(pNewFont);
-
- // Store the original TTF font info in case we need to reload it in a different resolution
- OrigFontInfo fontInfo;
- fontInfo.size = iSize;
- fontInfo.aspect = originalAspect;
- fontInfo.fontFilePath = strPath;
- fontInfo.fileName = strFilename;
- fontInfo.sourceRes = sourceRes;
- fontInfo.preserveAspect = preserveAspect;
- fontInfo.border = border;
- m_vecFontInfo.push_back(fontInfo);
-
- return pNewFont;
-}
-
-bool GUIFontManager::OnMessage(CGUIMessage &message)
-{
- if (message.GetMessage() != GUI_MSG_NOTIFY_ALL)
- return false;
-
- if (message.GetParam1() == GUI_MSG_RENDERER_LOST)
- {
- m_canReload = false;
- return true;
- }
-
- if (message.GetParam1() == GUI_MSG_RENDERER_RESET)
- { // our device has been reset - we have to reload our ttf fonts, and send
- // a message to controls that we have done so
- ReloadTTFFonts();
- g_windowManager.SendMessage(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_WINDOW_RESIZE);
- m_canReload = true;
- return true;
- }
-
- if (message.GetParam1() == GUI_MSG_WINDOW_RESIZE)
- { // we need to reload our fonts
- if (m_canReload)
- {
- ReloadTTFFonts();
- // no need to send a resize message, as this message will do the rounds
- return true;
- }
- }
- return false;
-}
-
-void GUIFontManager::ReloadTTFFonts(void)
-{
- if (!m_vecFonts.size())
- return; // we haven't even loaded fonts in yet
-
- for (unsigned int i = 0; i < m_vecFonts.size(); i++)
- {
- CGUIFont* font = m_vecFonts[i];
- OrigFontInfo fontInfo = m_vecFontInfo[i];
-
- float aspect = fontInfo.aspect;
- float newSize = (float)fontInfo.size;
- CStdString& strPath = fontInfo.fontFilePath;
- CStdString& strFilename = fontInfo.fileName;
-
- RescaleFontSizeAndAspect(&newSize, &aspect, fontInfo.sourceRes, fontInfo.preserveAspect);
-
- CStdString TTFfontName;
- TTFfontName.Format("%s_%f_%f%s", strFilename, newSize, aspect, fontInfo.border ? "_border" : "");
- CGUIFontTTFBase* pFontFile = GetFontFile(TTFfontName);
- if (!pFontFile)
- {
- pFontFile = new CGUIFontTTF(TTFfontName);
- if (!pFontFile || !pFontFile->Load(strPath, newSize, aspect, 1.0f, fontInfo.border))
- {
- delete pFontFile;
- // font could not be loaded
- CLog::Log(LOGERROR, "Couldn't re-load font file:%s", strPath.c_str());
- return;
- }
-
- m_vecFontFiles.push_back(pFontFile);
- }
-
- font->SetFont(pFontFile);
- }
-}
-
-void GUIFontManager::Unload(const CStdString& strFontName)
-{
- for (vector<CGUIFont*>::iterator iFont = m_vecFonts.begin(); iFont != m_vecFonts.end(); ++iFont)
- {
- if ((*iFont)->GetFontName() == strFontName)
- {
- delete (*iFont);
- m_vecFonts.erase(iFont);
- return;
- }
- }
-}
-
-void GUIFontManager::FreeFontFile(CGUIFontTTFBase *pFont)
-{
- for (vector<CGUIFontTTFBase*>::iterator it = m_vecFontFiles.begin(); it != m_vecFontFiles.end(); ++it)
- {
- if (pFont == *it)
- {
- m_vecFontFiles.erase(it);
- delete pFont;
- return;
- }
- }
-}
-
-CGUIFontTTFBase* GUIFontManager::GetFontFile(const CStdString& strFileName)
-{
- for (int i = 0; i < (int)m_vecFontFiles.size(); ++i)
- {
- CGUIFontTTFBase* pFont = (CGUIFontTTFBase *)m_vecFontFiles[i];
- if (pFont->GetFileName() == strFileName)
- return pFont;
- }
- return NULL;
-}
-
-CGUIFont* GUIFontManager::GetFont(const CStdString& strFontName, bool fallback /*= true*/)
-{
- for (int i = 0; i < (int)m_vecFonts.size(); ++i)
- {
- CGUIFont* pFont = m_vecFonts[i];
- if (pFont->GetFontName() == strFontName)
- return pFont;
- }
- // fall back to "font13" if we have none
- if (fallback && !strFontName.IsEmpty() && !strFontName.Equals("-") && !strFontName.Equals("font13"))
- return GetFont("font13");
- return NULL;
-}
-
-CGUIFont* GUIFontManager::GetDefaultFont(bool border)
-{
- // first find "font13" or "__defaultborder__"
- unsigned int font13index = m_vecFonts.size();
- CGUIFont *font13border = NULL;
- for (unsigned int i = 0; i < m_vecFonts.size(); i++)
- {
- CGUIFont* font = m_vecFonts[i];
- if (font->GetFontName() == "font13")
- font13index = i;
- else if (font->GetFontName() == "__defaultborder__")
- font13border = font;
- }
- // no "font13" means no default font is found - use the first font found.
- if (font13index == m_vecFonts.size())
- {
- if (m_vecFonts.empty())
- return NULL;
- font13index = 0;
- }
-
- if (border)
- {
- if (!font13border)
- { // create it
- CGUIFont *font13 = m_vecFonts[font13index];
- OrigFontInfo fontInfo = m_vecFontInfo[font13index];
- font13border = LoadTTF("__defaultborder__", fontInfo.fileName, 0xFF000000, 0, fontInfo.size, font13->GetStyle(), true, 1.0f, fontInfo.aspect, fontInfo.sourceRes, fontInfo.preserveAspect);
- }
- return font13border;
- }
- return m_vecFonts[font13index];
-}
-
-void GUIFontManager::Clear()
-{
- for (int i = 0; i < (int)m_vecFonts.size(); ++i)
- {
- CGUIFont* pFont = m_vecFonts[i];
- delete pFont;
- }
-
- m_vecFonts.clear();
- m_vecFontFiles.clear();
- m_vecFontInfo.clear();
- m_fontsetUnicode=false;
-}
-
-void GUIFontManager::LoadFonts(const CStdString& strFontSet)
-{
- TiXmlDocument xmlDoc;
- if (!OpenFontFile(xmlDoc))
- return;
-
- TiXmlElement* pRootElement = xmlDoc.RootElement();
- const TiXmlNode *pChild = pRootElement->FirstChild();
-
- // If there are no fontset's defined in the XML (old skin format) run in backward compatibility
- // and ignore the fontset request
- CStdString strValue = pChild->Value();
- if (strValue == "fontset")
- {
- CStdString foundTTF;
- while (pChild)
- {
- strValue = pChild->Value();
- if (strValue == "fontset")
- {
- const char* idAttr = ((TiXmlElement*) pChild)->Attribute("id");
-
- const char* unicodeAttr = ((TiXmlElement*) pChild)->Attribute("unicode");
-
- if (foundTTF.IsEmpty() && idAttr != NULL && unicodeAttr != NULL && stricmp(unicodeAttr, "true") == 0)
- foundTTF = idAttr;
-
- // Check if this is the fontset that we want
- if (idAttr != NULL && stricmp(strFontSet.c_str(), idAttr) == 0)
- {
- m_fontsetUnicode=false;
- // Check if this is the a ttf fontset
- if (unicodeAttr != NULL && stricmp(unicodeAttr, "true") == 0)
- m_fontsetUnicode=true;
-
- if (m_fontsetUnicode)
- {
- LoadFonts(pChild->FirstChild());
- break;
- }
- }
-
- }
-
- pChild = pChild->NextSibling();
- }
-
- // If no fontset was loaded
- if (pChild == NULL)
- {
- CLog::Log(LOGWARNING, "file doesnt have <fontset> with name '%s', defaulting to first fontset", strFontSet.c_str());
- if (!foundTTF.IsEmpty())
- LoadFonts(foundTTF);
- }
- }
- else
- {
- CLog::Log(LOGERROR, "file doesnt have <fontset> in <fonts>, but rather %s", strValue.c_str());
- return ;
- }
-}
-
-void GUIFontManager::LoadFonts(const TiXmlNode* fontNode)
-{
- while (fontNode)
- {
- CStdString strValue = fontNode->Value();
- if (strValue == "font")
- {
- const TiXmlNode *pNode = fontNode->FirstChild("name");
- if (pNode)
- {
- CStdString strFontName = pNode->FirstChild()->Value();
- color_t shadowColor = 0;
- color_t textColor = 0;
- CGUIControlFactory::GetColor(fontNode, "shadow", shadowColor);
- CGUIControlFactory::GetColor(fontNode, "color", textColor);
- const TiXmlNode *pNode = fontNode->FirstChild("filename");
- if (pNode)
- {
- CStdString strFontFileName = pNode->FirstChild()->Value();
- if (strFontFileName.Find(".ttf") >= 0)
- {
- int iSize = 20;
- int iStyle = FONT_STYLE_NORMAL;
- float aspect = 1.0f;
- float lineSpacing = 1.0f;
-
- XMLUtils::GetInt(fontNode, "size", iSize);
- if (iSize <= 0) iSize = 20;
-
- pNode = fontNode->FirstChild("style");
- if (pNode)
- {
- CStdString style = pNode->FirstChild()->Value();
- iStyle = FONT_STYLE_NORMAL;
- if (style == "bold")
- iStyle = FONT_STYLE_BOLD;
- else if (style == "italics")
- iStyle = FONT_STYLE_ITALICS;
- else if (style == "bolditalics")
- iStyle = FONT_STYLE_BOLD_ITALICS;
- }
-
- XMLUtils::GetFloat(fontNode, "linespacing", lineSpacing);
- XMLUtils::GetFloat(fontNode, "aspect", aspect);
-
- LoadTTF(strFontName, strFontFileName, textColor, shadowColor, iSize, iStyle, false, lineSpacing, aspect);
- }
- }
- }
- }
-
- fontNode = fontNode->NextSibling();
- }
-}
-
-bool GUIFontManager::OpenFontFile(TiXmlDocument& xmlDoc)
-{
- // Get the file to load fonts from:
- CStdString strPath = g_SkinInfo->GetSkinPath("Font.xml", &m_skinResolution);
- CLog::Log(LOGINFO, "Loading fonts from %s", strPath.c_str());
-
- // first try our preferred file
- if ( !xmlDoc.LoadFile(strPath) )
- {
- CLog::Log(LOGERROR, "Couldn't load %s", strPath.c_str());
- return false;
- }
- TiXmlElement* pRootElement = xmlDoc.RootElement();
-
- CStdString strValue = pRootElement->Value();
- if (strValue != CStdString("fonts"))
- {
- CLog::Log(LOGERROR, "file %s doesnt start with <fonts>", strPath.c_str());
- return false;
- }
-
- return true;
-}
-
-bool GUIFontManager::GetFirstFontSetUnicode(CStdString& strFontSet)
-{
- strFontSet.Empty();
-
- // Load our font file
- TiXmlDocument xmlDoc;
- if (!OpenFontFile(xmlDoc))
- return false;
-
- TiXmlElement* pRootElement = xmlDoc.RootElement();
- const TiXmlNode *pChild = pRootElement->FirstChild();
-
- CStdString strValue = pChild->Value();
- if (strValue == "fontset")
- {
- while (pChild)
- {
- strValue = pChild->Value();
- if (strValue == "fontset")
- {
- const char* idAttr = ((TiXmlElement*) pChild)->Attribute("id");
-
- const char* unicodeAttr = ((TiXmlElement*) pChild)->Attribute("unicode");
-
- // Check if this is a fontset with a ttf attribute set to true
- if (unicodeAttr != NULL && stricmp(unicodeAttr, "true") == 0)
- {
- // This is the first ttf fontset
- strFontSet=idAttr;
- break;
- }
-
- }
-
- pChild = pChild->NextSibling();
- }
-
- // If no fontset was loaded
- if (pChild == NULL)
- CLog::Log(LOGWARNING, "file doesnt have <fontset> with with attibute unicode=\"true\"");
- }
- else
- {
- CLog::Log(LOGERROR, "file doesnt have <fontset> in <fonts>, but rather %s", strValue.c_str());
- }
-
- return !strFontSet.IsEmpty();
-}
-
-bool GUIFontManager::IsFontSetUnicode(const CStdString& strFontSet)
-{
- TiXmlDocument xmlDoc;
- if (!OpenFontFile(xmlDoc))
- return false;
-
- TiXmlElement* pRootElement = xmlDoc.RootElement();
- const TiXmlNode *pChild = pRootElement->FirstChild();
-
- CStdString strValue = pChild->Value();
- if (strValue == "fontset")
- {
- while (pChild)
- {
- strValue = pChild->Value();
- if (strValue == "fontset")
- {
- const char* idAttr = ((TiXmlElement*) pChild)->Attribute("id");
-
- const char* unicodeAttr = ((TiXmlElement*) pChild)->Attribute("unicode");
-
- // Check if this is the fontset that we want
- if (idAttr != NULL && stricmp(strFontSet.c_str(), idAttr) == 0)
- return (unicodeAttr != NULL && stricmp(unicodeAttr, "true") == 0);
-
- }
-
- pChild = pChild->NextSibling();
- }
- }
-
- return false;
-}
diff --git a/guilib/GUIFontManager.h b/guilib/GUIFontManager.h
deleted file mode 100644
index acdc46b2d3..0000000000
--- a/guilib/GUIFontManager.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*!
-\file GUIFontManager.h
-\brief
-*/
-
-#ifndef GUILIB_FONTMANAGER_H
-#define GUILIB_FONTMANAGER_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GraphicContext.h"
-#include "IMsgTargetCallback.h"
-
-// Forward
-class CGUIFont;
-class CGUIFontTTFBase;
-class TiXmlDocument;
-class TiXmlNode;
-
-struct OrigFontInfo
-{
- int size;
- float aspect;
- CStdString fontFilePath;
- CStdString fileName;
- RESOLUTION sourceRes;
- bool preserveAspect;
- bool border;
-};
-
-/*!
- \ingroup textures
- \brief
- */
-class GUIFontManager : public IMsgTargetCallback
-{
-public:
- GUIFontManager(void);
- virtual ~GUIFontManager(void);
-
- virtual bool OnMessage(CGUIMessage &message);
-
- void Unload(const CStdString& strFontName);
- void LoadFonts(const CStdString& strFontSet);
- CGUIFont* LoadTTF(const CStdString& strFontName, const CStdString& strFilename, color_t textColor, color_t shadowColor, const int iSize, const int iStyle, bool border = false, float lineSpacing = 1.0f, float aspect = 1.0f, RESOLUTION res = RES_INVALID, bool preserveAspect = false);
- CGUIFont* GetFont(const CStdString& strFontName, bool fallback = true);
-
- /*! \brief return a default font
- \param border whether the font should be a font with an outline
- \return the font. NULL if no default font can be found.
- */
- CGUIFont* GetDefaultFont(bool border = false);
-
- void Clear();
- void FreeFontFile(CGUIFontTTFBase *pFont);
-
- bool IsFontSetUnicode() { return m_fontsetUnicode; }
- bool IsFontSetUnicode(const CStdString& strFontSet);
- bool GetFirstFontSetUnicode(CStdString& strFontSet);
-
-protected:
- void RescaleFontSizeAndAspect(float *size, float *aspect, RESOLUTION sourceRes, bool preserveAspect) const;
- void ReloadTTFFonts();
- void LoadFonts(const TiXmlNode* fontNode);
- CGUIFontTTFBase* GetFontFile(const CStdString& strFontFile);
- bool OpenFontFile(TiXmlDocument& xmlDoc);
-
- std::vector<CGUIFont*> m_vecFonts;
- std::vector<CGUIFontTTFBase*> m_vecFontFiles;
- std::vector<OrigFontInfo> m_vecFontInfo;
- bool m_fontsetUnicode;
- RESOLUTION m_skinResolution;
- bool m_canReload;
-};
-
-/*!
- \ingroup textures
- \brief
- */
-extern GUIFontManager g_fontManager;
-#endif
diff --git a/guilib/GUIFontTTF.cpp b/guilib/GUIFontTTF.cpp
deleted file mode 100644
index 50e5eb213b..0000000000
--- a/guilib/GUIFontTTF.cpp
+++ /dev/null
@@ -1,834 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIFont.h"
-#include "GUIFontTTF.h"
-#include "GUIFontManager.h"
-#include "Texture.h"
-#include "GraphicContext.h"
-#include "FileSystem/SpecialProtocol.h"
-#include "MathUtils.h"
-#include "utils/log.h"
-#include "WindowingFactory.h"
-
-#include <math.h>
-
-// stuff for freetype
-#ifndef _LINUX
-#include "ft2build.h"
-#else
-#include <ft2build.h>
-#endif
-#include FT_FREETYPE_H
-#include FT_GLYPH_H
-#include FT_OUTLINE_H
-#include FT_STROKER_H
-
-#define USE_RELEASE_LIBS
-
-using namespace std;
-
-
-#define CHARS_PER_TEXTURE_LINE 20 // number of characters to cache per texture line
-#define CHAR_CHUNK 64 // 64 chars allocated at a time (1024 bytes)
-
-int CGUIFontTTFBase::justification_word_weight = 6; // weight of word spacing over letter spacing when justifying.
- // A larger number means more of the "dead space" is placed between
- // words rather than between letters.
-
-class CFreeTypeLibrary
-{
-public:
- CFreeTypeLibrary()
- {
- m_library = NULL;
- }
-
- virtual ~CFreeTypeLibrary()
- {
- if (m_library)
- FT_Done_FreeType(m_library);
- }
-
- FT_Face GetFont(const CStdString &filename, float size, float aspect)
- {
- // don't have it yet - create it
- if (!m_library)
- FT_Init_FreeType(&m_library);
- if (!m_library)
- {
- CLog::Log(LOGERROR, "Unable to initialize freetype library");
- return NULL;
- }
-
- FT_Face face;
-
- // ok, now load the font face
- if (FT_New_Face( m_library, _P(filename).c_str(), 0, &face ))
- return NULL;
-
- unsigned int ydpi = GetDPI();
- unsigned int xdpi = (unsigned int)MathUtils::round_int(ydpi * aspect);
-
- // we set our screen res currently to 96dpi in both directions (windows default)
- // we cache our characters (for rendering speed) so it's probably
- // not a good idea to allow free scaling of fonts - rather, just
- // scaling to pixel ratio on screen perhaps?
- if (FT_Set_Char_Size( face, 0, (int)(size*64 + 0.5f), xdpi, ydpi ))
- {
- FT_Done_Face(face);
- return NULL;
- }
-
- return face;
- };
-
- FT_Stroker GetStroker()
- {
- if (!m_library)
- return NULL;
-
- FT_Stroker stroker;
- if (FT_Stroker_New(m_library, &stroker))
- return NULL;
-
- return stroker;
- };
-
- void ReleaseFont(FT_Face face)
- {
- assert(face);
- FT_Done_Face(face);
- };
-
- void ReleaseStroker(FT_Stroker stroker)
- {
- assert(stroker);
- FT_Stroker_Done(stroker);
- }
-
- unsigned int GetDPI() const
- {
- return 72; // default dpi, matches what XPR fonts used to use for sizing
- };
-
-private:
- FT_Library m_library;
-};
-
-CFreeTypeLibrary g_freeTypeLibrary; // our freetype library
-
-CGUIFontTTFBase::CGUIFontTTFBase(const CStdString& strFileName)
-{
- m_texture = NULL;
- m_char = NULL;
- m_maxChars = 0;
- m_nestedBeginCount = 0;
-
- m_bTextureLoaded = false;
- m_vertex_size = 4*1024;
- m_vertex = (SVertex*)malloc(m_vertex_size * sizeof(SVertex));
-
- m_face = NULL;
- m_stroker = NULL;
- memset(m_charquick, 0, sizeof(m_charquick));
- m_strFileName = strFileName;
- m_referenceCount = 0;
- m_originX = m_originY = 0.0f;
- m_cellBaseLine = m_cellHeight = 0;
- m_numChars = 0;
- m_posX = m_posY = 0;
- m_textureHeight = m_textureWidth = 0;
- m_textureScaleX = m_textureScaleY = 0.0;
- m_ellipsesWidth = m_height = 0.0f;
- m_color = 0;
- m_vertex_count = 0;
- m_nTexture = 0;
-}
-
-CGUIFontTTFBase::~CGUIFontTTFBase(void)
-{
- Clear();
-}
-
-void CGUIFontTTFBase::AddReference()
-{
- m_referenceCount++;
-}
-
-void CGUIFontTTFBase::RemoveReference()
-{
- // delete this object when it's reference count hits zero
- m_referenceCount--;
- if (!m_referenceCount)
- g_fontManager.FreeFontFile(this);
-}
-
-
-void CGUIFontTTFBase::ClearCharacterCache()
-{
- delete(m_texture);
-
- DeleteHardwareTexture();
-
- m_texture = NULL;
- delete[] m_char;
- m_char = new Character[CHAR_CHUNK];
- memset(m_charquick, 0, sizeof(m_charquick));
- m_numChars = 0;
- m_maxChars = CHAR_CHUNK;
- // set the posX and posY so that our texture will be created on first character write.
- m_posX = m_textureWidth;
- m_posY = -(int)m_cellHeight;
- m_textureHeight = 0;
-}
-
-void CGUIFontTTFBase::Clear()
-{
- delete(m_texture);
- m_texture = NULL;
- delete[] m_char;
- memset(m_charquick, 0, sizeof(m_charquick));
- m_char = NULL;
- m_maxChars = 0;
- m_numChars = 0;
- m_posX = 0;
- m_posY = 0;
- m_nestedBeginCount = 0;
-
- if (m_face)
- g_freeTypeLibrary.ReleaseFont(m_face);
- m_face = NULL;
- if (m_stroker)
- g_freeTypeLibrary.ReleaseStroker(m_stroker);
- m_stroker = NULL;
-
- free(m_vertex);
- m_vertex = NULL;
- m_vertex_count = 0;
-}
-
-bool CGUIFontTTFBase::Load(const CStdString& strFilename, float height, float aspect, float lineSpacing, bool border)
-{
- // we now know that this object is unique - only the GUIFont objects are non-unique, so no need
- // for reference tracking these fonts
- m_face = g_freeTypeLibrary.GetFont(strFilename, height, aspect);
-
- if (!m_face)
- return false;
-
- // grab the maximum cell height and width
- unsigned int m_cellWidth = m_face->bbox.xMax - m_face->bbox.xMin;
- m_cellHeight = std::max<unsigned int>(m_face->bbox.yMax - m_face->bbox.yMin, m_face->ascender - m_face->descender);
- m_cellBaseLine = std::max<unsigned int>(m_face->bbox.yMax, m_face->ascender);
-
- if (border)
- {
- m_stroker = g_freeTypeLibrary.GetStroker();
-
- FT_Pos strength = FT_MulFix( m_face->units_per_EM, m_face->size->metrics.y_scale) / 12;
- if (strength < 128)
- strength = 128;
- m_cellHeight += 2*strength;
-
- if (m_stroker)
- FT_Stroker_Set(m_stroker, strength, FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0);
- }
-
-
- unsigned int ydpi = g_freeTypeLibrary.GetDPI();
- unsigned int xdpi = (unsigned int)MathUtils::round_int(ydpi * aspect);
-
- m_cellWidth *= (unsigned int)(height * xdpi);
- m_cellWidth /= (72 * m_face->units_per_EM);
-
- m_cellHeight *= (unsigned int)(height * ydpi);
- m_cellHeight /= (72 * m_face->units_per_EM);
-
- m_cellBaseLine *= (unsigned int)(height * ydpi);
- m_cellBaseLine /= (72 * m_face->units_per_EM);
-
- // increment for good measure to give space in our texture
- m_cellWidth++;
- m_cellHeight+=2;
- m_cellBaseLine++;
-
-// CLog::Log(LOGDEBUG, "%s Scaled size of font %s (%f): width = %i, height = %i, lineheight = %li",
-// __FUNCTION__, strFilename.c_str(), height, m_cellWidth, m_cellHeight, m_face->size->metrics.height / 64);
-
- m_height = height;
-
- delete(m_texture);
- m_texture = NULL;
- delete[] m_char;
- m_char = NULL;
-
- m_maxChars = 0;
- m_numChars = 0;
-
- m_strFilename = strFilename;
-
- m_textureHeight = 0;
- m_textureWidth = ((m_cellHeight * CHARS_PER_TEXTURE_LINE) & ~63) + 64;
-
- m_textureWidth = CBaseTexture::PadPow2(m_textureWidth);
-
- if (m_textureWidth > g_Windowing.GetMaxTextureSize())
- m_textureWidth = g_Windowing.GetMaxTextureSize();
-
- // set the posX and posY so that our texture will be created on first character write.
- m_posX = m_textureWidth;
- m_posY = -(int)m_cellHeight;
-
- // cache the ellipses width
- Character *ellipse = GetCharacter(L'.');
- if (ellipse) m_ellipsesWidth = ellipse->advance;
-
- return true;
-}
-
-void CGUIFontTTFBase::DrawTextInternal(float x, float y, const vecColors &colors, const vecText &text, uint32_t alignment, float maxPixelWidth, bool scrolling)
-{
- Begin();
-
- // save the origin, which is scaled separately
- m_originX = x;
- m_originY = y;
-
- // Check if we will really need to truncate or justify the text
- if ( alignment & XBFONT_TRUNCATED )
- {
- if ( maxPixelWidth <= 0.0f || GetTextWidthInternal(text.begin(), text.end()) <= maxPixelWidth)
- alignment &= ~XBFONT_TRUNCATED;
- }
- else if ( alignment & XBFONT_JUSTIFIED )
- {
- if ( maxPixelWidth <= 0.0f )
- alignment &= ~XBFONT_JUSTIFIED;
- }
-
- // calculate sizing information
- float startX = 0;
- float startY = (alignment & XBFONT_CENTER_Y) ? -0.5f*(m_cellHeight-2) : 0; // vertical centering
-
- if ( alignment & (XBFONT_RIGHT | XBFONT_CENTER_X) )
- {
- // Get the extent of this line
- float w = GetTextWidthInternal( text.begin(), text.end() );
-
- if ( alignment & XBFONT_TRUNCATED && w > maxPixelWidth + 0.5f ) // + 0.5f due to rounding issues
- w = maxPixelWidth;
-
- if ( alignment & XBFONT_CENTER_X)
- w *= 0.5f;
- // Offset this line's starting position
- startX -= w;
- }
-
- float spacePerLetter = 0; // for justification effects
- if ( alignment & XBFONT_JUSTIFIED )
- {
- // first compute the size of the text to render in both characters and pixels
- unsigned int lineChars = 0;
- float linePixels = 0;
- for (vecText::const_iterator pos = text.begin(); pos != text.end(); pos++)
- {
- Character *ch = GetCharacter(*pos);
- if (ch)
- { // spaces have multiple times the justification spacing of normal letters
- lineChars += ((*pos & 0xffff) == L' ') ? justification_word_weight : 1;
- linePixels += ch->advance;
- }
- }
- if (lineChars > 1)
- spacePerLetter = (maxPixelWidth - linePixels) / (lineChars - 1);
- }
- float cursorX = 0; // current position along the line
-
- for (vecText::const_iterator pos = text.begin(); pos != text.end(); pos++)
- {
- // If starting text on a new line, determine justification effects
- // Get the current letter in the CStdString
- color_t color = (*pos & 0xff0000) >> 16;
- if (color >= colors.size())
- color = 0;
- color = colors[color];
-
- // grab the next character
- Character *ch = GetCharacter(*pos);
- if (!ch) continue;
-
- if ( alignment & XBFONT_TRUNCATED )
- {
- // Check if we will be exceeded the max allowed width
- if ( cursorX + ch->advance + 3 * m_ellipsesWidth > maxPixelWidth )
- {
- // Yup. Let's draw the ellipses, then bail
- // Perhaps we should really bail to the next line in this case??
- Character *period = GetCharacter(L'.');
- if (!period)
- break;
-
- for (int i = 0; i < 3; i++)
- {
- RenderCharacter(startX + cursorX, startY, period, color, !scrolling);
- cursorX += period->advance;
- }
- break;
- }
- }
- else if (maxPixelWidth > 0 && cursorX > maxPixelWidth)
- break; // exceeded max allowed width - stop rendering
-
- RenderCharacter(startX + cursorX, startY, ch, color, !scrolling);
- if ( alignment & XBFONT_JUSTIFIED )
- {
- if ((*pos & 0xffff) == L' ')
- cursorX += ch->advance + spacePerLetter * justification_word_weight;
- else
- cursorX += ch->advance + spacePerLetter;
- }
- else
- cursorX += ch->advance;
- }
-
- End();
-}
-
-// this routine assumes a single line (i.e. it was called from GUITextLayout)
-float CGUIFontTTFBase::GetTextWidthInternal(vecText::const_iterator start, vecText::const_iterator end)
-{
- float width = 0;
- while (start != end)
- {
- Character *c = GetCharacter(*start++);
- if (c) width += c->advance;
- }
- return width;
-}
-
-float CGUIFontTTFBase::GetCharWidthInternal(character_t ch)
-{
- Character *c = GetCharacter(ch);
- if (c) return c->advance;
- return 0;
-}
-
-float CGUIFontTTFBase::GetTextHeight(float lineSpacing, int numLines) const
-{
- return (float)(numLines - 1) * GetLineHeight(lineSpacing) + (m_cellHeight - 2); // -2 as we increment this for space in our texture
-}
-
-float CGUIFontTTFBase::GetLineHeight(float lineSpacing) const
-{
- if (m_face)
- return lineSpacing * m_face->size->metrics.height / 64.0f;
- return 0.0f;
-}
-
-CGUIFontTTFBase::Character* CGUIFontTTFBase::GetCharacter(character_t chr)
-{
- wchar_t letter = (wchar_t)(chr & 0xffff);
- character_t style = (chr & 0x3000000) >> 24;
-
- // ignore linebreaks
- if (letter == L'\r')
- return NULL;
-
- // quick access to ascii chars
- if (letter < 255)
- {
- character_t ch = (style << 8) | letter;
- if (m_charquick[ch])
- return m_charquick[ch];
- }
-
- // letters are stored based on style and letter
- character_t ch = (style << 16) | letter;
-
- int low = 0;
- int high = m_numChars - 1;
- int mid;
- while (low <= high)
- {
- mid = (low + high) >> 1;
- if (ch > m_char[mid].letterAndStyle)
- low = mid + 1;
- else if (ch < m_char[mid].letterAndStyle)
- high = mid - 1;
- else
- return &m_char[mid];
- }
- // if we get to here, then low is where we should insert the new character
-
- // increase the size of the buffer if we need it
- if (m_numChars >= m_maxChars)
- { // need to increase the size of the buffer
- Character *newTable = new Character[m_maxChars + CHAR_CHUNK];
- if (m_char)
- {
- memcpy(newTable, m_char, low * sizeof(Character));
- memcpy(newTable + low + 1, m_char + low, (m_numChars - low) * sizeof(Character));
- delete[] m_char;
- }
- m_char = newTable;
- m_maxChars += CHAR_CHUNK;
-
- }
- else
- { // just move the data along as necessary
- memmove(m_char + low + 1, m_char + low, (m_numChars - low) * sizeof(Character));
- }
- // render the character to our texture
- // must End() as we can't render text to our texture during a Begin(), End() block
- unsigned int nestedBeginCount = m_nestedBeginCount;
- m_nestedBeginCount = 1;
- if (nestedBeginCount) End();
- if (!CacheCharacter(letter, style, m_char + low))
- { // unable to cache character - try clearing them all out and starting over
- CLog::Log(LOGDEBUG, "GUIFontTTF::GetCharacter: Unable to cache character. Clearing character cache of %i characters", m_numChars);
- ClearCharacterCache();
- low = 0;
- if (!CacheCharacter(letter, style, m_char + low))
- {
- CLog::Log(LOGERROR, "GUIFontTTF::GetCharacter: Unable to cache character (out of memory?)");
- if (nestedBeginCount) Begin();
- m_nestedBeginCount = nestedBeginCount;
- return NULL;
- }
- }
- if (nestedBeginCount) Begin();
- m_nestedBeginCount = nestedBeginCount;
-
- // fixup quick access
- memset(m_charquick, 0, sizeof(m_charquick));
- for(int i=0;i<m_numChars;i++)
- {
- if ((m_char[i].letterAndStyle & 0xffff) < 255)
- {
- character_t ch = ((m_char[i].letterAndStyle & 0xffff0000) >> 8) | (m_char[i].letterAndStyle & 0xff);
- m_charquick[ch] = m_char+i;
- }
- }
-
- return m_char + low;
-}
-
-bool CGUIFontTTFBase::CacheCharacter(wchar_t letter, uint32_t style, Character *ch)
-{
- int glyph_index = FT_Get_Char_Index( m_face, letter );
-
- FT_Glyph glyph = NULL;
- if (FT_Load_Glyph( m_face, glyph_index, FT_LOAD_TARGET_LIGHT ))
- {
- CLog::Log(LOGDEBUG, "%s Failed to load glyph %x", __FUNCTION__, letter);
- return false;
- }
- // make bold if applicable
- if (style & FONT_STYLE_BOLD)
- EmboldenGlyph(m_face->glyph);
- // and italics if applicable
- if (style & FONT_STYLE_ITALICS)
- ObliqueGlyph(m_face->glyph);
- // grab the glyph
- if (FT_Get_Glyph(m_face->glyph, &glyph))
- {
- CLog::Log(LOGDEBUG, "%s Failed to get glyph %x", __FUNCTION__, letter);
- return false;
- }
- if (m_stroker)
- FT_Glyph_StrokeBorder(&glyph, m_stroker, 0, 1);
- // render the glyph
- if (FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, NULL, 1))
- {
- CLog::Log(LOGDEBUG, "%s Failed to render glyph %x to a bitmap", __FUNCTION__, letter);
- return false;
- }
- FT_BitmapGlyph bitGlyph = (FT_BitmapGlyph)glyph;
- FT_Bitmap bitmap = bitGlyph->bitmap;
- if (bitGlyph->left < 0)
- m_posX += -bitGlyph->left;
-
- // check we have enough room for the character
- if (m_posX + bitGlyph->left + bitmap.width > (int)m_textureWidth)
- { // no space - gotta drop to the next line (which means creating a new texture and copying it across)
- m_posX = 0;
- m_posY += m_cellHeight;
- if (bitGlyph->left < 0)
- m_posX += -bitGlyph->left;
-
- if(m_posY + m_cellHeight >= m_textureHeight)
- {
- // create the new larger texture
- unsigned int newHeight = m_posY + m_cellHeight;
- // check for max height
- if (newHeight > g_Windowing.GetMaxTextureSize())
- {
- CLog::Log(LOGDEBUG, "GUIFontTTF::CacheCharacter: New cache texture is too large (%u > %u pixels long)", newHeight, g_Windowing.GetMaxTextureSize());
- FT_Done_Glyph(glyph);
- return false;
- }
-
- CBaseTexture* newTexture = NULL;
- newTexture = ReallocTexture(newHeight);
- if(newTexture == NULL)
- {
- FT_Done_Glyph(glyph);
- CLog::Log(LOGDEBUG, "GUIFontTTF::CacheCharacter: Failed to allocate new texture of height %u", newHeight);
- return false;
- }
- m_texture = newTexture;
- }
- }
-
- if(m_texture == NULL)
- {
- CLog::Log(LOGDEBUG, "GUIFontTTF::CacheCharacter: no texture to cache character to");
- return false;
- }
-
- // set the character in our table
- ch->letterAndStyle = (style << 16) | letter;
- ch->offsetX = (short)bitGlyph->left;
- ch->offsetY = (short)max((short)m_cellBaseLine - bitGlyph->top, 0);
- ch->left = (float)m_posX + ch->offsetX;
- ch->top = (float)m_posY + ch->offsetY;
- ch->right = ch->left + bitmap.width;
- ch->bottom = ch->top + bitmap.rows;
- ch->advance = (float)MathUtils::round_int( (float)m_face->glyph->advance.x / 64 );
-
- // we need only render if we actually have some pixels
- if (bitmap.width * bitmap.rows)
- {
- CopyCharToTexture(bitGlyph, ch);
- }
- m_posX += 1 + (unsigned short)max(ch->right - ch->left + ch->offsetX, ch->advance);
- m_numChars++;
-
- m_textureScaleX = 1.0f / m_textureWidth;
- m_textureScaleY = 1.0f / m_textureHeight;
-
- // free the glyph
- FT_Done_Glyph(glyph);
-
- return true;
-}
-
-void CGUIFontTTFBase::RenderCharacter(float posX, float posY, const Character *ch, color_t color, bool roundX)
-{
- // actual image width isn't same as the character width as that is
- // just baseline width and height should include the descent
- const float width = ch->right - ch->left;
- const float height = ch->bottom - ch->top;
-
- // posX and posY are relative to our origin, and the textcell is offset
- // from our (posX, posY). Plus, these are unscaled quantities compared to the underlying GUI resolution
- CRect vertex((posX + ch->offsetX) * g_graphicsContext.GetGUIScaleX(),
- (posY + ch->offsetY) * g_graphicsContext.GetGUIScaleY(),
- (posX + ch->offsetX + width) * g_graphicsContext.GetGUIScaleX(),
- (posY + ch->offsetY + height) * g_graphicsContext.GetGUIScaleY());
- vertex += CPoint(m_originX, m_originY);
- CRect texture(ch->left, ch->top, ch->right, ch->bottom);
- g_graphicsContext.ClipRect(vertex, texture);
-
- // transform our positions - note, no scaling due to GUI calibration/resolution occurs
- float x[4];
-
- x[0] = g_graphicsContext.ScaleFinalXCoord(vertex.x1, vertex.y1);
- x[1] = g_graphicsContext.ScaleFinalXCoord(vertex.x2, vertex.y1);
- x[2] = g_graphicsContext.ScaleFinalXCoord(vertex.x2, vertex.y2);
- x[3] = g_graphicsContext.ScaleFinalXCoord(vertex.x1, vertex.y2);
-
- if (roundX)
- {
- // We only round the "left" side of the character, and then use the direction of rounding to
- // move the "right" side of the character. This ensures that a constant width is kept when rendering
- // the same letter at the same size at different places of the screen, avoiding the problem
- // of the "left" side rounding one way while the "right" side rounds the other way, thus getting
- // altering the width of thin characters substantially. This only really works for positive
- // coordinates (due to the direction of truncation for negatives) but this is the only case that
- // really interests us anyway.
- float rx0 = (float)MathUtils::round_int(x[0]);
- float rx3 = (float)MathUtils::round_int(x[3]);
- x[1] = (float)MathUtils::truncate_int(x[1]);
- x[2] = (float)MathUtils::truncate_int(x[2]);
- if (rx0 > x[0])
- x[1] += 1;
- if (rx3 > x[3])
- x[2] += 1;
- x[0] = rx0;
- x[3] = rx3;
- }
-
- float y1 = (float)MathUtils::round_int(g_graphicsContext.ScaleFinalYCoord(vertex.x1, vertex.y1));
- float y2 = (float)MathUtils::round_int(g_graphicsContext.ScaleFinalYCoord(vertex.x2, vertex.y1));
- float y3 = (float)MathUtils::round_int(g_graphicsContext.ScaleFinalYCoord(vertex.x2, vertex.y2));
- float y4 = (float)MathUtils::round_int(g_graphicsContext.ScaleFinalYCoord(vertex.x1, vertex.y2));
-
- float z1 = (float)MathUtils::round_int(g_graphicsContext.ScaleFinalZCoord(vertex.x1, vertex.y1));
- float z2 = (float)MathUtils::round_int(g_graphicsContext.ScaleFinalZCoord(vertex.x2, vertex.y1));
- float z3 = (float)MathUtils::round_int(g_graphicsContext.ScaleFinalZCoord(vertex.x2, vertex.y2));
- float z4 = (float)MathUtils::round_int(g_graphicsContext.ScaleFinalZCoord(vertex.x1, vertex.y2));
-
- // tex coords converted to 0..1 range
- float tl = texture.x1 * m_textureScaleX;
- float tr = texture.x2 * m_textureScaleX;
- float tt = texture.y1 * m_textureScaleY;
- float tb = texture.y2 * m_textureScaleY;
-
- // grow the vertex buffer if required
- if(m_vertex_count >= m_vertex_size)
- {
- m_vertex_size *= 2;
- void* old = m_vertex;
- m_vertex = (SVertex*)realloc(m_vertex, m_vertex_size * sizeof(SVertex));
- if (!m_vertex)
- {
- free(old);
- printf("realloc failed in CGUIFontTTF::RenderCharacter. aborting\n");
- abort();
- }
- }
-
- m_color = color;
- SVertex* v = m_vertex + m_vertex_count;
-
- for(int i = 0; i < 4; i++)
- {
- v[i].r = GET_R(color);
- v[i].g = GET_G(color);
- v[i].b = GET_B(color);
- v[i].a = GET_A(color);
- }
-
-#if defined(HAS_GL) || defined(HAS_DX)
- v[0].u = tl;
- v[0].v = tt;
- v[0].x = x[0];
- v[0].y = y1;
- v[0].z = z1;
-
- v[1].u = tr;
- v[1].v = tt;
- v[1].x = x[1];
- v[1].y = y2;
- v[1].z = z2;
-
- v[2].u = tr;
- v[2].v = tb;
- v[2].x = x[2];
- v[2].y = y3;
- v[2].z = z3;
-
- v[3].u = tl;
- v[3].v = tb;
- v[3].x = x[3];
- v[3].y = y4;
- v[3].z = z4;
-#else
- // GLES uses triangle strips, not quads, so have to rearrange the vertex order
- v[0].u = tl;
- v[0].v = tt;
- v[0].x = x[0];
- v[0].y = y1;
- v[0].z = z1;
-
- v[1].u = tl;
- v[1].v = tb;
- v[1].x = x[3];
- v[1].y = y4;
- v[1].z = z4;
-
- v[2].u = tr;
- v[2].v = tt;
- v[2].x = x[1];
- v[2].y = y2;
- v[2].z = z2;
-
- v[3].u = tr;
- v[3].v = tb;
- v[3].x = x[2];
- v[3].y = y3;
- v[3].z = z3;
-#endif
-
- RenderInternal(v);
-
- m_vertex_count+=4;
-}
-
-// Oblique code - original taken from freetype2 (ftsynth.c)
-void CGUIFontTTFBase::ObliqueGlyph(FT_GlyphSlot slot)
-{
- /* only oblique outline glyphs */
- if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
- return;
-
- /* we don't touch the advance width */
-
- /* For italic, simply apply a shear transform, with an angle */
- /* of about 12 degrees. */
-
- FT_Matrix transform;
- transform.xx = 0x10000L;
- transform.yx = 0x00000L;
-
- transform.xy = 0x06000L;
- transform.yy = 0x10000L;
-
- FT_Outline_Transform( &slot->outline, &transform );
-}
-
-
-// Embolden code - original taken from freetype2 (ftsynth.c)
-void CGUIFontTTFBase::EmboldenGlyph(FT_GlyphSlot slot)
-{
- if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
- return;
-
- /* some reasonable strength */
- FT_Pos strength = FT_MulFix( m_face->units_per_EM,
- m_face->size->metrics.y_scale ) / 24;
-
- FT_BBox bbox_before, bbox_after;
- FT_Outline_Get_CBox( &slot->outline, &bbox_before );
- FT_Outline_Embolden( &slot->outline, strength ); // ignore error
- FT_Outline_Get_CBox( &slot->outline, &bbox_after );
-
- FT_Pos dx = bbox_after.xMax - bbox_before.xMax;
- FT_Pos dy = bbox_after.yMax - bbox_before.yMax;
-
- if ( slot->advance.x )
- slot->advance.x += dx;
-
- if ( slot->advance.y )
- slot->advance.y += dy;
-
- slot->metrics.width += dx;
- slot->metrics.height += dy;
- slot->metrics.horiBearingY += dy;
- slot->metrics.horiAdvance += dx;
- slot->metrics.vertBearingX -= dx / 2;
- slot->metrics.vertBearingY += dy;
- slot->metrics.vertAdvance += dy;
-}
-
-
diff --git a/guilib/GUIFontTTF.h b/guilib/GUIFontTTF.h
deleted file mode 100644
index c509ad0552..0000000000
--- a/guilib/GUIFontTTF.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/*!
-\file GUIFont.h
-\brief
-*/
-
-#ifndef CGUILIB_GUIFONTTTF_H
-#define CGUILIB_GUIFONTTTF_H
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-// forward definition
-class CBaseTexture;
-
-struct FT_FaceRec_;
-struct FT_LibraryRec_;
-struct FT_GlyphSlotRec_;
-struct FT_BitmapGlyphRec_;
-struct FT_StrokerRec_;
-
-typedef struct FT_FaceRec_ *FT_Face;
-typedef struct FT_LibraryRec_ *FT_Library;
-typedef struct FT_GlyphSlotRec_ *FT_GlyphSlot;
-typedef struct FT_BitmapGlyphRec_ *FT_BitmapGlyph;
-typedef struct FT_StrokerRec_ *FT_Stroker;
-
-typedef uint32_t character_t;
-typedef uint32_t color_t;
-typedef std::vector<character_t> vecText;
-typedef std::vector<color_t> vecColors;
-
-/*!
- \ingroup textures
- \brief
- */
-
-typedef struct _SVertex
-{
- float u, v;
- unsigned char r, g, b, a;
- float x, y, z;
-} SVertex;
-
-
-class CGUIFontTTFBase
-{
- friend class CGUIFont;
-
-public:
-
- CGUIFontTTFBase(const CStdString& strFileName);
- virtual ~CGUIFontTTFBase(void);
-
- void Clear();
-
- bool Load(const CStdString& strFilename, float height = 20.0f, float aspect = 1.0f, float lineSpacing = 1.0f, bool border = false);
-
- virtual void Begin() = 0;
- virtual void End() = 0;
-
- const CStdString& GetFileName() const { return m_strFileName; };
-
-protected:
- struct Character
- {
- short offsetX, offsetY;
- float left, top, right, bottom;
- float advance;
- character_t letterAndStyle;
- };
- void AddReference();
- void RemoveReference();
-
- float GetTextWidthInternal(vecText::const_iterator start, vecText::const_iterator end);
- float GetCharWidthInternal(character_t ch);
- float GetTextHeight(float lineSpacing, int numLines) const;
- float GetLineHeight(float lineSpacing) const;
- float GetFontHeight() const { return m_height; }
-
- void DrawTextInternal(float x, float y, const vecColors &colors, const vecText &text,
- uint32_t alignment, float maxPixelWidth, bool scrolling);
-
- float m_height;
- CStdString m_strFilename;
-
- // Stuff for pre-rendering for speed
- inline Character *GetCharacter(character_t letter);
- bool CacheCharacter(wchar_t letter, uint32_t style, Character *ch);
- void RenderCharacter(float posX, float posY, const Character *ch, color_t color, bool roundX);
- void ClearCharacterCache();
-
- virtual CBaseTexture* ReallocTexture(unsigned int& newHeight) = 0;
- virtual bool CopyCharToTexture(FT_BitmapGlyph bitGlyph, Character *ch) = 0;
- virtual void DeleteHardwareTexture() = 0;
- virtual void RenderInternal(SVertex* v) = 0;
-
- // modifying glyphs
- void EmboldenGlyph(FT_GlyphSlot slot);
- void ObliqueGlyph(FT_GlyphSlot slot);
-
- CBaseTexture* m_texture; // texture that holds our rendered characters (8bit alpha only)
-
- unsigned int m_textureWidth; // width of our texture
- unsigned int m_textureHeight; // heigth of our texture
- int m_posX; // current position in the texture
- int m_posY;
-
- color_t m_color;
-
- Character *m_char; // our characters
- Character *m_charquick[256*4]; // ascii chars (4 styles) here
- int m_maxChars; // size of character array (can be incremented)
- int m_numChars; // the current number of cached characters
-
- float m_ellipsesWidth; // this is used every character (width of '.')
-
- unsigned int m_cellBaseLine;
- unsigned int m_cellHeight;
-
- unsigned int m_nestedBeginCount; // speedups
-
- // freetype stuff
- FT_Face m_face;
- FT_Stroker m_stroker;
-
- float m_originX;
- float m_originY;
-
- bool m_bTextureLoaded;
- unsigned int m_nTexture;
-
- SVertex* m_vertex;
- int m_vertex_count;
- int m_vertex_size;
-
- float m_textureScaleX;
- float m_textureScaleY;
-
- static int justification_word_weight;
-
- CStdString m_strFileName;
-
-private:
- int m_referenceCount;
-};
-
-#if defined(HAS_GL) || defined(HAS_GLES)
-#include "GUIFontTTFGL.h"
-#define CGUIFontTTF CGUIFontTTFGL
-#elif defined(HAS_DX)
-#include "GUIFontTTFDX.h"
-#define CGUIFontTTF CGUIFontTTFDX
-#endif
-
-#endif
diff --git a/guilib/GUIFontTTFDX.cpp b/guilib/GUIFontTTFDX.cpp
deleted file mode 100644
index 9d425dc339..0000000000
--- a/guilib/GUIFontTTFDX.cpp
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#ifdef HAS_DX
-
-#include "GUIFont.h"
-#include "GUIFontTTFDX.h"
-#include "GUIFontManager.h"
-#include "Texture.h"
-#include "gui3d.h"
-#include "WindowingFactory.h"
-#include "utils/log.h"
-
-// stuff for freetype
-#include "ft2build.h"
-
-#include FT_FREETYPE_H
-#include FT_GLYPH_H
-#include FT_OUTLINE_H
-
-using namespace std;
-
-struct CUSTOMVERTEX
-{
- FLOAT x, y, z;
- DWORD color;
- FLOAT tu, tv; // Texture coordinates
-};
-
-
-CGUIFontTTFDX::CGUIFontTTFDX(const CStdString& strFileName)
-: CGUIFontTTFBase(strFileName)
-{
- m_speedupTexture = NULL;
-}
-
-CGUIFontTTFDX::~CGUIFontTTFDX(void)
-{
- SAFE_DELETE(m_speedupTexture);
-}
-
-void CGUIFontTTFDX::RenderInternal(SVertex* v)
-{
- CUSTOMVERTEX verts[4] = {
- { v[0].x-0.5f, v[0].y-0.5f, v[0].z, m_color, v[0].u, v[0].v},
- { v[1].x-0.5f, v[1].y-0.5f, v[1].z, m_color, v[1].u, v[1].v},
- { v[2].x-0.5f, v[2].y-0.5f, v[2].z, m_color, v[2].u, v[2].v},
- { v[3].x-0.5f, v[3].y-0.5f, v[3].z, m_color, v[3].u, v[3].v}
- };
-
- g_Windowing.Get3DDevice()->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts, sizeof(CUSTOMVERTEX));
-}
-
-void CGUIFontTTFDX::Begin()
-{
- LPDIRECT3DDEVICE9 pD3DDevice = g_Windowing.Get3DDevice();
-
- if (m_nestedBeginCount == 0)
- {
- // just have to blit from our texture.
- pD3DDevice->SetTexture( 0, m_texture->GetTextureObject() );
-
- pD3DDevice->SetSamplerState( 0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP );
- pD3DDevice->SetSamplerState( 0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP );
- pD3DDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
- pD3DDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
- pD3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ); // only use diffuse
- pD3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
- pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
- pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
- pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
-
- // no other texture stages needed
- pD3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE);
- pD3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
-
- pD3DDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
- pD3DDevice->SetRenderState( D3DRS_FOGENABLE, FALSE );
- pD3DDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
- pD3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
- pD3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
- pD3DDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
- pD3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
- pD3DDevice->SetRenderState( D3DRS_LIGHTING, FALSE);
-
- pD3DDevice->SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
- }
- // Keep track of the nested begin/end calls.
- m_vertex_count = 0;
- m_nestedBeginCount++;
-}
-
-void CGUIFontTTFDX::End()
-{
- LPDIRECT3DDEVICE9 pD3DDevice = g_Windowing.Get3DDevice();
-
- if (m_nestedBeginCount == 0)
- return;
-
- if (--m_nestedBeginCount > 0)
- return;
-
- pD3DDevice->SetTexture(0, NULL);
- pD3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
-}
-
-CBaseTexture* CGUIFontTTFDX::ReallocTexture(unsigned int& newHeight)
-{
- CBaseTexture* pNewTexture = new CDXTexture(m_textureWidth, newHeight, XB_FMT_A8);
- pNewTexture->CreateTextureObject();
- LPDIRECT3DTEXTURE9 newTexture = pNewTexture->GetTextureObject();
-
- if (newTexture == NULL)
- {
- CLog::Log(LOGERROR, __FUNCTION__" - failed to create the new texture h=%d w=%d", m_textureWidth, newHeight);
- SAFE_DELETE(pNewTexture);
- return NULL;
- }
-
- // Use a speedup texture in system memory when main texture in default pool+dynamic
- // Otherwise the texture would have to be copied from vid mem to sys mem, which is too slow for subs while playing video.
- CD3DTexture* newSpeedupTexture = NULL;
- if (g_Windowing.DefaultD3DPool() == D3DPOOL_DEFAULT && g_Windowing.DefaultD3DUsage() == D3DUSAGE_DYNAMIC)
- {
- newSpeedupTexture = new CD3DTexture();
-
- if (!newSpeedupTexture->Create(m_textureWidth, newHeight, 1, 0, D3DFMT_A8, D3DPOOL_SYSTEMMEM))
- {
- SAFE_DELETE(newSpeedupTexture);
- SAFE_DELETE(pNewTexture);
- return NULL;
- }
- }
-
- LPDIRECT3DSURFACE9 pSource, pTarget;
- HRESULT hr;
- // There might be data to copy from the previous texture
- if ((newSpeedupTexture && m_speedupTexture) || (newTexture && m_texture))
- {
- if (m_speedupTexture)
- {
- m_speedupTexture->GetSurfaceLevel(0, &pSource);
- newSpeedupTexture->GetSurfaceLevel(0, &pTarget);
- }
- else
- {
- m_texture->GetTextureObject()->GetSurfaceLevel(0, &pSource);
- newTexture->GetSurfaceLevel(0, &pTarget);
- }
-
- D3DLOCKED_RECT srclr, dstlr;
- if(FAILED(pSource->LockRect( &srclr, NULL, 0 ))
- || FAILED(pTarget->LockRect( &dstlr, NULL, 0 )))
- {
- CLog::Log(LOGERROR, __FUNCTION__" - failed to lock surfaces");
- SAFE_DELETE(newSpeedupTexture);
- SAFE_DELETE(pNewTexture);
- pSource->Release();
- pTarget->Release();
- return NULL;
- }
-
- unsigned char *dst = (unsigned char *)dstlr.pBits;
- unsigned char *src = (unsigned char *)srclr.pBits;
- unsigned int dstPitch = dstlr.Pitch;
- unsigned int srcPitch = srclr.Pitch;
- unsigned int minPitch = std::min(srcPitch, dstPitch);
-
- if (srcPitch == dstPitch)
- {
- memcpy(dst, src, srcPitch * m_textureHeight);
- }
- else
- {
- for (unsigned int y = 0; y < m_textureHeight; y++)
- {
- memcpy(dst, src, minPitch);
- src += srcPitch;
- dst += dstPitch;
- }
- }
- pSource->UnlockRect();
- pTarget->UnlockRect();
-
- pSource->Release();
- pTarget->Release();
- }
-
- // Upload from speedup texture to main texture
- if (newSpeedupTexture && m_speedupTexture)
- {
- LPDIRECT3DSURFACE9 pSource, pTarget;
- newSpeedupTexture->GetSurfaceLevel(0, &pSource);
- newTexture->GetSurfaceLevel(0, &pTarget);
- const RECT rect = { 0, 0, m_textureWidth, m_textureHeight };
- const POINT point = { 0, 0 };
-
- hr = g_Windowing.Get3DDevice()->UpdateSurface(pSource, &rect, pTarget, &point);
- SAFE_RELEASE(pSource);
- SAFE_RELEASE(pTarget);
-
- if (FAILED(hr))
- {
- CLog::Log(LOGERROR, __FUNCTION__": Failed to upload from sysmem to vidmem (0x%08X)", hr);
- SAFE_DELETE(newSpeedupTexture);
- SAFE_DELETE(pNewTexture);
- return NULL;
- }
- }
-
- SAFE_DELETE(m_texture);
- SAFE_DELETE(m_speedupTexture);
- m_textureHeight = newHeight;
- m_speedupTexture = newSpeedupTexture;
-
- return pNewTexture;
-}
-
-bool CGUIFontTTFDX::CopyCharToTexture(FT_BitmapGlyph bitGlyph, Character* ch)
-{
- FT_Bitmap bitmap = bitGlyph->bitmap;
-
- LPDIRECT3DSURFACE9 target;
- if (m_speedupTexture)
- m_speedupTexture->GetSurfaceLevel(0, &target);
- else
- m_texture->GetTextureObject()->GetSurfaceLevel(0, &target);
-
- RECT sourcerect = { 0, 0, bitmap.width, bitmap.rows };
- RECT targetrect;
- targetrect.top = m_posY + ch->offsetY;
- targetrect.left = m_posX + bitGlyph->left;
- targetrect.bottom = targetrect.top + bitmap.rows;
- targetrect.right = targetrect.left + bitmap.width;
-
- HRESULT hr = D3DXLoadSurfaceFromMemory( target, NULL, &targetrect,
- bitmap.buffer, D3DFMT_LIN_A8, bitmap.pitch, NULL, &sourcerect,
- D3DX_FILTER_NONE, 0x00000000);
-
- SAFE_RELEASE(target);
-
- if (FAILED(hr))
- {
- CLog::Log(LOGERROR, __FUNCTION__": Failed to copy the new character (0x%08X)", hr);
- return false;
- }
-
- if (m_speedupTexture)
- {
- // Upload to GPU - the automatic dirty region tracking takes care of the rect.
- HRESULT hr = g_Windowing.Get3DDevice()->UpdateTexture(m_speedupTexture->Get(), m_texture->GetTextureObject());
- if (FAILED(hr))
- {
- CLog::Log(LOGERROR, __FUNCTION__": Failed to upload from sysmem to vidmem (0x%08X)", hr);
- return false;
- }
- }
- return TRUE;
-}
-
-
-void CGUIFontTTFDX::DeleteHardwareTexture()
-{
-
-}
-
-
-#endif
diff --git a/guilib/GUIFontTTFDX.h b/guilib/GUIFontTTFDX.h
deleted file mode 100644
index 72e20a9dae..0000000000
--- a/guilib/GUIFontTTFDX.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-* Copyright (C) 2005-2008 Team XBMC
-* http://www.xbmc.org
-*
-* This Program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, 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 General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with XBMC; see the file COPYING. If not, write to
-* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-* http://www.gnu.org/copyleft/gpl.html
-*
-*/
-
-/*!
-\file GUIFont.h
-\brief
-*/
-
-#ifndef CGUILIB_GUIFONTTTF_DX_H
-#define CGUILIB_GUIFONTTTF_DX_H
-#pragma once
-
-
-#include "GUIFontTTF.h"
-#include "D3DResource.h"
-
-/*!
- \ingroup textures
- \brief
- */
-class CGUIFontTTFDX : public CGUIFontTTFBase
-{
-public:
- CGUIFontTTFDX(const CStdString& strFileName);
- virtual ~CGUIFontTTFDX(void);
-
- virtual void Begin();
- virtual void End();
-
-protected:
- virtual CBaseTexture* ReallocTexture(unsigned int& newHeight);
- virtual bool CopyCharToTexture(FT_BitmapGlyph bitGlyph, Character *ch);
- virtual void DeleteHardwareTexture();
- virtual void RenderInternal(SVertex* v);
- CD3DTexture *m_speedupTexture; // extra texture to speed up reallocations when the main texture is in d3dpool_default.
- // that's the typical situation of Windows Vista and above.
-};
-
-#endif
diff --git a/guilib/GUIFontTTFGL.cpp b/guilib/GUIFontTTFGL.cpp
deleted file mode 100644
index a05ed9df8b..0000000000
--- a/guilib/GUIFontTTFGL.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "system.h"
-#include "GUIFont.h"
-#include "GUIFontTTFGL.h"
-#include "GUIFontManager.h"
-#include "Texture.h"
-#include "GraphicContext.h"
-#include "gui3d.h"
-#include "utils/log.h"
-#if HAS_GLES == 2
-#include "WindowingFactory.h"
-#endif
-
-// stuff for freetype
-#ifndef _LINUX
-#include "ft2build.h"
-#else
-#include <ft2build.h>
-#endif
-#include FT_FREETYPE_H
-#include FT_GLYPH_H
-#include FT_OUTLINE_H
-
-using namespace std;
-
-#if defined(HAS_GL) || defined(HAS_GLES)
-
-
-CGUIFontTTFGL::CGUIFontTTFGL(const CStdString& strFileName)
-: CGUIFontTTFBase(strFileName)
-{
-}
-
-CGUIFontTTFGL::~CGUIFontTTFGL(void)
-{
-}
-
-void CGUIFontTTFGL::Begin()
-{
- if (m_nestedBeginCount == 0)
- {
- if (!m_bTextureLoaded)
- {
- // Have OpenGL generate a texture object handle for us
- glGenTextures(1, (GLuint*) &m_nTexture);
-
- // Bind the texture object
- glBindTexture(GL_TEXTURE_2D, m_nTexture);
- glEnable(GL_TEXTURE_2D);
-
- // Set the texture's stretching properties
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
- // Set the texture image -- THIS WORKS, so the pixels must be wrong.
- glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, m_texture->GetWidth(), m_texture->GetHeight(), 0,
- GL_ALPHA, GL_UNSIGNED_BYTE, m_texture->GetPixels());
-
- VerifyGLState();
- m_bTextureLoaded = true;
- }
-
- // Turn Blending On
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, m_nTexture);
-
-#ifdef HAS_GL
- glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE);
- glTexEnvi(GL_TEXTURE_ENV,GL_COMBINE_RGB,GL_REPLACE);
- glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR);
- glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
- glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
- glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE0);
- glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
- glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_PRIMARY_COLOR);
- glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- VerifyGLState();
-#else
- g_Windowing.EnableGUIShader(SM_FONTS);
-#endif
-
- m_vertex_count = 0;
- }
- // Keep track of the nested begin/end calls.
- m_nestedBeginCount++;
-}
-
-void CGUIFontTTFGL::End()
-{
- if (m_nestedBeginCount == 0)
- return;
-
- if (--m_nestedBeginCount > 0)
- return;
-
-#ifdef HAS_GL
- glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
-
- glColorPointer (4, GL_UNSIGNED_BYTE, sizeof(SVertex), (char*)m_vertex + offsetof(SVertex, r));
- glVertexPointer (3, GL_FLOAT , sizeof(SVertex), (char*)m_vertex + offsetof(SVertex, x));
- glTexCoordPointer(2, GL_FLOAT , sizeof(SVertex), (char*)m_vertex + offsetof(SVertex, u));
- glEnableClientState(GL_COLOR_ARRAY);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glDrawArrays(GL_QUADS, 0, m_vertex_count);
- glPopClientAttrib();
-#else
- // GLES 2.0 version. Cannot draw quads. Convert to triangles.
- GLint posLoc = g_Windowing.GUIShaderGetPos();
- GLint colLoc = g_Windowing.GUIShaderGetCol();
- GLint tex0Loc = g_Windowing.GUIShaderGetCoord0();
-
- // stack object until VBOs will be used
- std::vector<SVertex> vecVertices( 6 * (m_vertex_count / 4) );
- SVertex *vertices = &vecVertices[0];
-
- for (int i=0; i<m_vertex_count; i+=4)
- {
- *vertices++ = m_vertex[i];
- *vertices++ = m_vertex[i+1];
- *vertices++ = m_vertex[i+2];
-
- *vertices++ = m_vertex[i+1];
- *vertices++ = m_vertex[i+3];
- *vertices++ = m_vertex[i+2];
- }
-
- vertices = &vecVertices[0];
-
- glVertexAttribPointer(posLoc, 3, GL_FLOAT, GL_FALSE, sizeof(SVertex), (char*)vertices + offsetof(SVertex, x));
- // Normalize color values. Does not affect Performance at all.
- glVertexAttribPointer(colLoc, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(SVertex), (char*)vertices + offsetof(SVertex, r));
- glVertexAttribPointer(tex0Loc, 2, GL_FLOAT, GL_FALSE, sizeof(SVertex), (char*)vertices + offsetof(SVertex, u));
-
- glEnableVertexAttribArray(posLoc);
- glEnableVertexAttribArray(colLoc);
- glEnableVertexAttribArray(tex0Loc);
-
- glDrawArrays(GL_TRIANGLES, 0, vecVertices.size());
-
- glDisableVertexAttribArray(posLoc);
- glDisableVertexAttribArray(colLoc);
- glDisableVertexAttribArray(tex0Loc);
-
- g_Windowing.DisableGUIShader();
-#endif
-}
-
-CBaseTexture* CGUIFontTTFGL::ReallocTexture(unsigned int& newHeight)
-{
- newHeight = CBaseTexture::PadPow2(newHeight);
-
- CBaseTexture* newTexture = new CTexture(m_textureWidth, newHeight, XB_FMT_A8);
-
- if (!newTexture || newTexture->GetPixels() == NULL)
- {
- CLog::Log(LOGERROR, "GUIFontTTFGL::CacheCharacter: Error creating new cache texture for size %f", m_height);
- return NULL;
- }
- m_textureHeight = newTexture->GetHeight();
- m_textureWidth = newTexture->GetWidth();
-
- memset(newTexture->GetPixels(), 0, m_textureHeight * newTexture->GetPitch());
- if (m_texture)
- {
- unsigned char* src = (unsigned char*) m_texture->GetPixels();
- unsigned char* dst = (unsigned char*) newTexture->GetPixels();
- for (unsigned int y = 0; y < m_texture->GetHeight(); y++)
- {
- memcpy(dst, src, m_texture->GetPitch());
- src += m_texture->GetPitch();
- dst += newTexture->GetPitch();
- }
- delete m_texture;
- }
-
- return newTexture;
-}
-
-bool CGUIFontTTFGL::CopyCharToTexture(FT_BitmapGlyph bitGlyph, Character* ch)
-{
- FT_Bitmap bitmap = bitGlyph->bitmap;
-
- unsigned char* source = (unsigned char*) bitmap.buffer;
- unsigned char* target = (unsigned char*) m_texture->GetPixels() + (m_posY + ch->offsetY) * m_texture->GetPitch() + m_posX + bitGlyph->left;
-
- for (int y = 0; y < bitmap.rows; y++)
- {
- memcpy(target, source, bitmap.width);
- source += bitmap.width;
- target += m_texture->GetPitch();
- }
- // THE SOURCE VALUES ARE THE SAME IN BOTH SITUATIONS.
-
- // Since we have a new texture, we need to delete the old one
- // the Begin(); End(); stuff is handled by whoever called us
- if (m_bTextureLoaded)
- {
- g_graphicsContext.BeginPaint(); //FIXME
- DeleteHardwareTexture();
- g_graphicsContext.EndPaint();
- m_bTextureLoaded = false;
- }
-
- return TRUE;
-}
-
-
-void CGUIFontTTFGL::DeleteHardwareTexture()
-{
- if (m_bTextureLoaded)
- {
- if (glIsTexture(m_nTexture))
- glDeleteTextures(1, (GLuint*) &m_nTexture);
- m_bTextureLoaded = false;
- }
-}
-
-#endif
diff --git a/guilib/GUIFontTTFGL.h b/guilib/GUIFontTTFGL.h
deleted file mode 100644
index c4dc88ec6a..0000000000
--- a/guilib/GUIFontTTFGL.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
-* Copyright (C) 2005-2008 Team XBMC
-* http://www.xbmc.org
-*
-* This Program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, 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 General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with XBMC; see the file COPYING. If not, write to
-* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-* http://www.gnu.org/copyleft/gpl.html
-*
-*/
-
-/*!
-\file GUIFont.h
-\brief
-*/
-
-#ifndef CGUILIB_GUIFONTTTF_GL_H
-#define CGUILIB_GUIFONTTTF_GL_H
-#pragma once
-
-
-#include "GUIFontTTF.h"
-
-
-/*!
- \ingroup textures
- \brief
- */
-class CGUIFontTTFGL : public CGUIFontTTFBase
-{
-public:
- CGUIFontTTFGL(const CStdString& strFileName);
- virtual ~CGUIFontTTFGL(void);
-
- virtual void Begin();
- virtual void End();
-
-protected:
- virtual CBaseTexture* ReallocTexture(unsigned int& newHeight);
- virtual bool CopyCharToTexture(FT_BitmapGlyph bitGlyph, Character *ch);
- virtual void DeleteHardwareTexture();
- virtual void RenderInternal(SVertex* v) {}
-
-};
-
-#endif
diff --git a/guilib/GUIImage.cpp b/guilib/GUIImage.cpp
deleted file mode 100644
index 28c9dc8959..0000000000
--- a/guilib/GUIImage.cpp
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIImage.h"
-#include "TextureManager.h"
-#include "utils/log.h"
-#include "utils/TimeUtils.h"
-
-using namespace std;
-
-CGUIImage::CGUIImage(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& texture)
- : CGUIControl(parentID, controlID, posX, posY, width, height)
- , m_texture(posX, posY, width, height, texture)
-{
- m_crossFadeTime = 0;
- m_currentFadeTime = 0;
- m_lastRenderTime = 0;
- ControlType = GUICONTROL_IMAGE;
- m_bDynamicResourceAlloc=false;
-}
-
-CGUIImage::CGUIImage(const CGUIImage &left)
- : CGUIControl(left), m_texture(left.m_texture)
-{
- m_info = left.m_info;
- m_crossFadeTime = left.m_crossFadeTime;
- // defaults
- m_currentFadeTime = 0;
- m_lastRenderTime = 0;
- ControlType = GUICONTROL_IMAGE;
- m_bDynamicResourceAlloc=false;
-}
-
-CGUIImage::~CGUIImage(void)
-{
-
-}
-
-void CGUIImage::UpdateVisibility(const CGUIListItem *item)
-{
- CGUIControl::UpdateVisibility(item);
-
- // now that we've checked for conditional info, we can
- // check for allocation
- AllocateOnDemand();
-}
-
-void CGUIImage::UpdateInfo(const CGUIListItem *item)
-{
- if (m_info.IsConstant())
- return; // nothing to do
-
- // don't allow image to change while animating out
- if (HasRendered() && IsAnimating(ANIM_TYPE_HIDDEN) && !IsVisibleFromSkin())
- return;
-
- if (item)
- SetFileName(m_info.GetItemLabel(item, true));
- else
- SetFileName(m_info.GetLabel(m_parentID, true));
-}
-
-void CGUIImage::AllocateOnDemand()
-{
- // if we're hidden, we can free our resources and return
- if (!IsVisible() && m_visible != DELAYED)
- {
- if (m_bDynamicResourceAlloc && m_texture.IsAllocated())
- FreeResourcesButNotAnims();
- return;
- }
-
- // either visible or delayed - we need the resources allocated in either case
- if (!m_texture.IsAllocated())
- AllocResources();
-}
-
-void CGUIImage::Render()
-{
- if (!IsVisible()) return;
-
- // check whether our image failed to allocate, and if so drop back to the fallback image
- if (m_texture.FailedToAlloc() && !m_texture.GetFileName().Equals(m_info.GetFallback()))
- m_texture.SetFileName(m_info.GetFallback());
-
- if (m_crossFadeTime)
- {
- // make sure our texture has started allocating
- m_texture.AllocResources();
-
- // compute the frame time
- unsigned int frameTime = 0;
- unsigned int currentTime = CTimeUtils::GetFrameTime();
- if (m_lastRenderTime)
- frameTime = currentTime - m_lastRenderTime;
- m_lastRenderTime = currentTime;
-
- if (m_fadingTextures.size()) // have some fading images
- { // anything other than the last old texture needs to be faded out as per usual
- for (vector<CFadingTexture *>::iterator i = m_fadingTextures.begin(); i != m_fadingTextures.end() - 1;)
- {
- if (!RenderFading(*i, frameTime))
- i = m_fadingTextures.erase(i);
- else
- i++;
- }
-
- if (m_texture.ReadyToRender() || m_texture.GetFileName().IsEmpty())
- { // fade out the last one as well
- if (!RenderFading(m_fadingTextures[m_fadingTextures.size() - 1], frameTime))
- m_fadingTextures.erase(m_fadingTextures.end() - 1);
- }
- else
- { // keep the last one fading in
- CFadingTexture *texture = m_fadingTextures[m_fadingTextures.size() - 1];
- texture->m_fadeTime += frameTime;
- if (texture->m_fadeTime > m_crossFadeTime)
- texture->m_fadeTime = m_crossFadeTime;
- texture->m_texture->SetAlpha(GetFadeLevel(texture->m_fadeTime));
- texture->m_texture->SetDiffuseColor(m_diffuseColor);
- texture->m_texture->Render();
- }
- }
-
- if (m_texture.ReadyToRender() || m_texture.GetFileName().IsEmpty())
- { // fade the new one in
- m_currentFadeTime += frameTime;
- if (m_currentFadeTime > m_crossFadeTime || frameTime == 0) // for if we allocate straight away on creation
- m_currentFadeTime = m_crossFadeTime;
- }
- m_texture.SetAlpha(GetFadeLevel(m_currentFadeTime));
- }
-
- m_texture.SetDiffuseColor(m_diffuseColor);
- m_texture.Render();
-
- CGUIControl::Render();
-}
-
-bool CGUIImage::RenderFading(CGUIImage::CFadingTexture *texture, unsigned int frameTime)
-{
- assert(texture);
- if (texture->m_fadeTime <= frameTime)
- { // time to kill off the texture
- delete texture;
- return false;
- }
- // render this texture
- texture->m_fadeTime -= frameTime;
- texture->m_texture->SetAlpha(GetFadeLevel(texture->m_fadeTime));
- texture->m_texture->SetDiffuseColor(m_diffuseColor);
- texture->m_texture->Render();
- return true;
-}
-
-bool CGUIImage::OnAction(const CAction &action)
-{
- return false;
-}
-
-bool CGUIImage::OnMessage(CGUIMessage& message)
-{
- if (message.GetMessage() == GUI_MSG_REFRESH_THUMBS)
- {
- if (!m_info.IsConstant())
- FreeTextures(true); // true as we want to free the texture immediately
- return true;
- }
- return CGUIControl::OnMessage(message);
-}
-
-void CGUIImage::AllocResources()
-{
- if (m_texture.GetFileName().IsEmpty())
- return;
-
- CGUIControl::AllocResources();
- m_texture.AllocResources();
-}
-
-void CGUIImage::FreeTextures(bool immediately /* = false */)
-{
- m_texture.FreeResources(immediately);
- for (unsigned int i = 0; i < m_fadingTextures.size(); i++)
- delete m_fadingTextures[i];
- m_fadingTextures.clear();
- m_currentTexture.Empty();
-}
-
-void CGUIImage::FreeResources(bool immediately)
-{
- FreeTextures(immediately);
- CGUIControl::FreeResources(immediately);
-}
-
-void CGUIImage::SetInvalid()
-{
- m_texture.SetInvalid();
- CGUIControl::SetInvalid();
-}
-
-// WORKAROUND - we are currently resetting all animations when this is called, which shouldn't be the case
-// see CGUIControl::FreeResources() - this needs remedying.
-void CGUIImage::FreeResourcesButNotAnims()
-{
- FreeTextures();
- m_bAllocated=false;
- m_hasRendered = false;
-}
-
-void CGUIImage::DynamicResourceAlloc(bool bOnOff)
-{
- m_bDynamicResourceAlloc = bOnOff;
- m_texture.DynamicResourceAlloc(bOnOff);
- CGUIControl::DynamicResourceAlloc(bOnOff);
-}
-
-bool CGUIImage::CanFocus() const
-{
- return false;
-}
-
-float CGUIImage::GetTextureWidth() const
-{
- return m_texture.GetTextureWidth();
-}
-
-float CGUIImage::GetTextureHeight() const
-{
- return m_texture.GetTextureHeight();
-}
-
-const CStdString &CGUIImage::GetFileName() const
-{
- return m_texture.GetFileName();
-}
-
-void CGUIImage::SetAspectRatio(const CAspectRatio &aspect)
-{
- m_texture.SetAspectRatio(aspect);
-}
-
-void CGUIImage::SetCrossFade(unsigned int time)
-{
- m_crossFadeTime = time;
- if (!m_crossFadeTime && m_texture.IsLazyLoaded() && !m_info.GetFallback().IsEmpty())
- m_crossFadeTime = 1;
-}
-
-void CGUIImage::SetFileName(const CStdString& strFileName, bool setConstant)
-{
- if (setConstant)
- m_info.SetLabel(strFileName, "");
-
- if (m_crossFadeTime)
- {
- // set filename on the next texture
- if (m_currentTexture.Equals(strFileName))
- return; // nothing to do - we already have this image
-
- if (m_texture.ReadyToRender() || m_texture.GetFileName().IsEmpty())
- { // save the current image
- m_fadingTextures.push_back(new CFadingTexture(m_texture, m_currentFadeTime));
- }
- m_currentFadeTime = 0;
- }
- if (!m_currentTexture.Equals(strFileName))
- { // texture is changing - attempt to load it, and save the name in m_currentTexture.
- // we'll check whether it loaded or not in Render()
- m_currentTexture = strFileName;
- m_texture.SetFileName(m_currentTexture);
- }
-}
-
-#ifdef _DEBUG
-void CGUIImage::DumpTextureUse()
-{
- if (m_texture.IsAllocated())
- {
- if (GetID())
- CLog::Log(LOGDEBUG, "Image control %u using texture %s",
- GetID(), m_texture.GetFileName().c_str());
- else
- CLog::Log(LOGDEBUG, "Using texture %s", m_texture.GetFileName().c_str());
- }
-}
-#endif
-
-void CGUIImage::SetWidth(float width)
-{
- m_texture.SetWidth(width);
- CGUIControl::SetWidth(m_texture.GetWidth());
-}
-
-void CGUIImage::SetHeight(float height)
-{
- m_texture.SetHeight(height);
- CGUIControl::SetHeight(m_texture.GetHeight());
-}
-
-void CGUIImage::SetPosition(float posX, float posY)
-{
- m_texture.SetPosition(posX, posY);
- CGUIControl::SetPosition(posX, posY);
-}
-
-void CGUIImage::SetInfo(const CGUIInfoLabel &info)
-{
- m_info = info;
- // a constant image never needs updating
- if (m_info.IsConstant())
- m_texture.SetFileName(m_info.GetLabel(0));
-}
-
-unsigned char CGUIImage::GetFadeLevel(unsigned int time) const
-{
- float amount = (float)time / m_crossFadeTime;
- // we want a semi-transparent image, so we need to use a more complicated
- // fade technique. Assuming a black background (not generally true, but still...)
- // we have
- // b(t) = [a - b(1-t)*a] / a*(1-b(1-t)*a),
- // where a = alpha, and b(t):[0,1] -> [0,1] is the blend function.
- // solving, we get
- // b(t) = [1 - (1-a)^t] / a
- const float alpha = 0.7f;
- return (unsigned char)(255.0f * (1 - pow(1-alpha, amount))/alpha);
-}
-
-CStdString CGUIImage::GetDescription(void) const
-{
- return GetFileName();
-}
-
diff --git a/guilib/GUIImage.h b/guilib/GUIImage.h
deleted file mode 100644
index eb576fe266..0000000000
--- a/guilib/GUIImage.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*!
-\file guiImage.h
-\brief
-*/
-
-#ifndef GUILIB_GUIIMAGECONTROL_H
-#define GUILIB_GUIIMAGECONTROL_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIControl.h"
-#include "GUITexture.h"
-
-/*!
- \ingroup controls
- \brief
- */
-
-class CGUIImage : public CGUIControl
-{
-public:
- class CFadingTexture
- {
- public:
- CFadingTexture(const CGUITexture &texture, unsigned int fadeTime)
- {
- // create a copy of our texture, and allocate resources
- m_texture = new CGUITexture(texture);
- m_texture->AllocResources();
- m_fadeTime = fadeTime;
- m_fading = false;
- };
- ~CFadingTexture()
- {
- m_texture->FreeResources();
- delete m_texture;
- };
-
- CGUITexture *m_texture; ///< texture to fade out
- unsigned int m_fadeTime; ///< time to fade out (ms)
- bool m_fading; ///< whether we're fading out
- };
-
- CGUIImage(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& texture);
- CGUIImage(const CGUIImage &left);
- virtual ~CGUIImage(void);
- virtual CGUIImage *Clone() const { return new CGUIImage(*this); };
-
- virtual void Render();
- virtual void UpdateVisibility(const CGUIListItem *item = NULL);
- virtual bool OnAction(const CAction &action) ;
- virtual bool OnMessage(CGUIMessage& message);
- virtual void AllocResources();
- virtual void FreeResources(bool immediately = false);
- virtual void DynamicResourceAlloc(bool bOnOff);
- virtual bool IsDynamicallyAllocated() { return m_bDynamicResourceAlloc; };
- virtual void SetInvalid();
- virtual bool CanFocus() const;
- virtual void UpdateInfo(const CGUIListItem *item = NULL);
-
- virtual void SetInfo(const CGUIInfoLabel &info);
- virtual void SetFileName(const CStdString& strFileName, bool setConstant = false);
- virtual void SetAspectRatio(const CAspectRatio &aspect);
- virtual void SetWidth(float width);
- virtual void SetHeight(float height);
- virtual void SetPosition(float posX, float posY);
- virtual CStdString GetDescription() const;
- void SetCrossFade(unsigned int time);
-
- const CStdString& GetFileName() const;
- float GetTextureWidth() const;
- float GetTextureHeight() const;
-
-#ifdef _DEBUG
- virtual void DumpTextureUse();
-#endif
-protected:
- virtual void AllocateOnDemand();
- virtual void FreeTextures(bool immediately = false);
- void FreeResourcesButNotAnims();
- unsigned char GetFadeLevel(unsigned int time) const;
- bool RenderFading(CFadingTexture *texture, unsigned int frameTime);
-
- bool m_bDynamicResourceAlloc;
-
- // border + conditional info
- CTextureInfo m_image;
- CGUIInfoLabel m_info;
-
- CGUITexture m_texture;
- std::vector<CFadingTexture *> m_fadingTextures;
- CStdString m_currentTexture;
-
- unsigned int m_crossFadeTime;
- unsigned int m_currentFadeTime;
- unsigned int m_lastRenderTime;
-};
-#endif
diff --git a/guilib/GUIIncludes.cpp b/guilib/GUIIncludes.cpp
deleted file mode 100644
index 558ee8ee3e..0000000000
--- a/guilib/GUIIncludes.cpp
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIIncludes.h"
-#include "addons/Skin.h"
-#include "utils/GUIInfoManager.h"
-#include "utils/log.h"
-#include "tinyXML/tinyxml.h"
-#include "StringUtils.h"
-
-using namespace std;
-
-CGUIIncludes::CGUIIncludes()
-{
- m_constantAttributes.insert("x");
- m_constantAttributes.insert("y");
- m_constantAttributes.insert("width");
- m_constantAttributes.insert("height");
- m_constantAttributes.insert("center");
- m_constantAttributes.insert("max");
- m_constantAttributes.insert("min");
- m_constantAttributes.insert("w");
- m_constantAttributes.insert("h");
- m_constantAttributes.insert("time");
- m_constantAttributes.insert("acceleration");
- m_constantAttributes.insert("delay");
- m_constantAttributes.insert("start");
- m_constantAttributes.insert("end");
- m_constantAttributes.insert("center");
- m_constantAttributes.insert("border");
-
- m_constantNodes.insert("posx");
- m_constantNodes.insert("posy");
- m_constantNodes.insert("width");
- m_constantNodes.insert("height");
- m_constantNodes.insert("offsetx");
- m_constantNodes.insert("offsety");
- m_constantNodes.insert("textoffsetx");
- m_constantNodes.insert("textoffsety");
- m_constantNodes.insert("textwidth");
- m_constantNodes.insert("spinposx");
- m_constantNodes.insert("spinposy");
- m_constantNodes.insert("spinwidth");
- m_constantNodes.insert("spinheight");
- m_constantNodes.insert("radioposx");
- m_constantNodes.insert("radioposy");
- m_constantNodes.insert("radiowidth");
- m_constantNodes.insert("radioheight");
- m_constantNodes.insert("markwidth");
- m_constantNodes.insert("markheight");
- m_constantNodes.insert("sliderwidth");
- m_constantNodes.insert("sliderheight");
- m_constantNodes.insert("itemgap");
- m_constantNodes.insert("bordersize");
- m_constantNodes.insert("timeperimage");
- m_constantNodes.insert("fadetime");
- m_constantNodes.insert("pauseatend");
-}
-
-CGUIIncludes::~CGUIIncludes()
-{
-}
-
-void CGUIIncludes::ClearIncludes()
-{
- m_includes.clear();
- m_defaults.clear();
- m_constants.clear();
- m_files.clear();
-}
-
-bool CGUIIncludes::LoadIncludes(const CStdString &includeFile)
-{
- // check to see if we already have this loaded
- if (HasIncludeFile(includeFile))
- return true;
-
- TiXmlDocument doc;
- if (!doc.LoadFile(includeFile))
- {
- CLog::Log(LOGINFO, "Error loading includes.xml file (%s): %s (row=%i, col=%i)", includeFile.c_str(), doc.ErrorDesc(), doc.ErrorRow(), doc.ErrorCol());
- return false;
- }
- // success, load the tags
- if (LoadIncludesFromXML(doc.RootElement()))
- {
- m_files.push_back(includeFile);
- return true;
- }
- return false;
-}
-
-bool CGUIIncludes::LoadIncludesFromXML(const TiXmlElement *root)
-{
- if (!root || strcmpi(root->Value(), "includes"))
- {
- CLog::Log(LOGERROR, "Skin includes must start with the <includes> tag");
- return false;
- }
- const TiXmlElement* node = root->FirstChildElement("include");
- while (node)
- {
- if (node->Attribute("name") && node->FirstChild())
- {
- CStdString tagName = node->Attribute("name");
- m_includes.insert(pair<CStdString, TiXmlElement>(tagName, *node));
- }
- else if (node->Attribute("file"))
- { // load this file in as well
- LoadIncludes(g_SkinInfo->GetSkinPath(node->Attribute("file")));
- }
- node = node->NextSiblingElement("include");
- }
- // now defaults
- node = root->FirstChildElement("default");
- while (node)
- {
- if (node->Attribute("type") && node->FirstChild())
- {
- CStdString tagName = node->Attribute("type");
- m_defaults.insert(pair<CStdString, TiXmlElement>(tagName, *node));
- }
- node = node->NextSiblingElement("default");
- }
- // and finally constants
- node = root->FirstChildElement("constant");
- while (node)
- {
- if (node->Attribute("name") && node->FirstChild())
- {
- CStdString tagName = node->Attribute("name");
- m_constants.insert(make_pair(tagName, node->FirstChild()->ValueStr()));
- }
- node = node->NextSiblingElement("constant");
- }
- return true;
-}
-
-bool CGUIIncludes::HasIncludeFile(const CStdString &file) const
-{
- for (iFiles it = m_files.begin(); it != m_files.end(); ++it)
- if (*it == file) return true;
- return false;
-}
-
-void CGUIIncludes::ResolveIncludes(TiXmlElement *node)
-{
- if (!node)
- return;
- ResolveIncludesForNode(node);
-
- TiXmlElement *child = node->FirstChildElement();
- while (child)
- {
- ResolveIncludes(child);
- child = child->NextSiblingElement();
- }
-}
-
-void CGUIIncludes::ResolveIncludesForNode(TiXmlElement *node)
-{
- // we have a node, find any <include file="fileName">tagName</include> tags and replace
- // recursively with their real includes
- if (!node) return;
-
- // First add the defaults if this is for a control
- CStdString type;
- if (node->ValueStr() == "control")
- {
- type = node->Attribute("type");
- map<CStdString, TiXmlElement>::const_iterator it = m_defaults.find(type);
- if (it != m_defaults.end())
- {
- const TiXmlElement &element = (*it).second;
- const TiXmlElement *tag = element.FirstChildElement();
- while (tag)
- {
- // we insert at the end of block
- node->InsertEndChild(*tag);
- tag = tag->NextSiblingElement();
- }
- }
- }
-
- TiXmlElement *include = node->FirstChildElement("include");
- while (include && include->FirstChild())
- {
- // have an include tag - grab it's tag name and replace it with the real tag contents
- const char *file = include->Attribute("file");
- if (file)
- { // we need to load this include from the alternative file
- LoadIncludes(g_SkinInfo->GetSkinPath(file));
- }
- const char *condition = include->Attribute("condition");
- if (condition)
- { // check this condition
- if (!g_infoManager.GetBool(g_infoManager.TranslateString(condition)))
- {
- include = include->NextSiblingElement("include");
- continue;
- }
- }
- CStdString tagName = include->FirstChild()->Value();
- map<CStdString, TiXmlElement>::const_iterator it = m_includes.find(tagName);
- if (it != m_includes.end())
- { // found the tag(s) to include - let's replace it
- const TiXmlElement &element = (*it).second;
- const TiXmlElement *tag = element.FirstChildElement();
- while (tag)
- {
- // we insert before the <include> element to keep the correct
- // order (we render in the order given in the xml file)
- node->InsertBeforeChild(include, *tag);
- tag = tag->NextSiblingElement();
- }
- // remove the <include>tagName</include> element
- node->RemoveChild(include);
- include = node->FirstChildElement("include");
- }
- else
- { // invalid include
- CLog::Log(LOGWARNING, "Skin has invalid include: %s", tagName.c_str());
- include = include->NextSiblingElement("include");
- }
- }
-
- // run through this element's attributes, resolving any constants
- TiXmlAttribute *attribute = node->FirstAttribute();
- while (attribute)
- { // check the attribute against our set
- if (m_constantAttributes.count(attribute->NameStr()))
- attribute->SetValue(ResolveConstant(attribute->ValueStr()));
- attribute = attribute->Next();
- }
- // also do the value
- if (node->FirstChild() && node->FirstChild()->Type() == TiXmlNode::TEXT && m_constantNodes.count(node->ValueStr()))
- node->FirstChild()->SetValue(ResolveConstant(node->FirstChild()->ValueStr()));
-}
-
-CStdString CGUIIncludes::ResolveConstant(const CStdString &constant) const
-{
- CStdStringArray values;
- StringUtils::SplitString(constant, ",", values);
- for (unsigned int i = 0; i < values.size(); ++i)
- {
- map<CStdString, CStdString>::const_iterator it = m_constants.find(values[i]);
- if (it != m_constants.end())
- values[i] = it->second;
- }
- CStdString value;
- StringUtils::JoinString(values, ",", value);
- return value;
-}
diff --git a/guilib/GUIIncludes.h b/guilib/GUIIncludes.h
deleted file mode 100644
index 9805a4e862..0000000000
--- a/guilib/GUIIncludes.h
+++ /dev/null
@@ -1,62 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "StdString.h"
-
-#include <map>
-#include <set>
-
-// forward definitions
-class TiXmlElement;
-
-class CGUIIncludes
-{
-public:
- CGUIIncludes();
- ~CGUIIncludes();
-
- void ClearIncludes();
- bool LoadIncludes(const CStdString &includeFile);
- bool LoadIncludesFromXML(const TiXmlElement *root);
-
- /*! \brief Resolve <include>name</include> tags recursively for the given XML element
- Replaces any instances of <include file="foo">bar</include> with the value of the include
- "bar" from the include file "foo".
- \param node an XML Element - all child elements are traversed.
- */
- void ResolveIncludes(TiXmlElement *node);
-
-private:
- void ResolveIncludesForNode(TiXmlElement *node);
- CStdString ResolveConstant(const CStdString &constant) const;
- bool HasIncludeFile(const CStdString &includeFile) const;
- std::map<CStdString, TiXmlElement> m_includes;
- std::map<CStdString, TiXmlElement> m_defaults;
- std::map<CStdString, CStdString> m_constants;
- std::vector<CStdString> m_files;
- typedef std::vector<CStdString>::const_iterator iFiles;
-
- std::set<std::string> m_constantAttributes;
- std::set<std::string> m_constantNodes;
-};
-
diff --git a/guilib/GUIInfoTypes.cpp b/guilib/GUIInfoTypes.cpp
deleted file mode 100644
index 45768929fb..0000000000
--- a/guilib/GUIInfoTypes.cpp
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIInfoTypes.h"
-#include "utils/CharsetConverter.h"
-#include "utils/GUIInfoManager.h"
-#include "addons/AddonManager.h"
-#include "utils/log.h"
-#include "LocalizeStrings.h"
-#include "GUIColorManager.h"
-#include "GUIListItem.h"
-#include "StringUtils.h"
-
-using namespace std;
-using ADDON::CAddonMgr;
-
-CGUIInfoBool::CGUIInfoBool(bool value)
-{
- m_info = 0;
- m_value = value;
-}
-
-void CGUIInfoBool::Parse(const CStdString &info)
-{
- m_info = g_infoManager.TranslateString(info);
- if (m_info == SYSTEM_ALWAYS_TRUE)
- {
- m_value = true;
- m_info = 0;
- }
- else if (m_info == SYSTEM_ALWAYS_FALSE)
- {
- m_value = false;
- m_info = 0;
- }
- else
- m_info = g_infoManager.GetBool(m_info);
-}
-
-void CGUIInfoBool::Update(int parentID, const CGUIListItem *item)
-{
- if (m_info)
- m_value = g_infoManager.GetBool(m_info, parentID, item);
-}
-
-
-CGUIInfoColor::CGUIInfoColor(uint32_t color)
-{
- m_color = color;
- m_info = 0;
-}
-
-const CGUIInfoColor &CGUIInfoColor::operator=(color_t color)
-{
- m_color = color;
- m_info = 0;
- return *this;
-}
-
-const CGUIInfoColor &CGUIInfoColor::operator=(const CGUIInfoColor &color)
-{
- m_color = color.m_color;
- m_info = color.m_info;
- return *this;
-}
-
-void CGUIInfoColor::Update()
-{
- if (!m_info)
- return; // no infolabel
-
- // Expand the infolabel, and then convert it to a color
- CStdString infoLabel(g_infoManager.GetLabel(m_info));
- if (!infoLabel.IsEmpty())
- m_color = g_colorManager.GetColor(infoLabel.c_str());
- else
- m_color = 0;
-}
-
-void CGUIInfoColor::Parse(const CStdString &label)
-{
- // Check for the standard $INFO[] block layout, and strip it if present
- CStdString label2 = label;
- if (label.Equals("-", false))
- return;
-
- if (label.Left(5).Equals("$INFO", false))
- label2 = label.Mid(6, label.length()-7);
-
- m_info = g_infoManager.TranslateString(label2);
- if (!m_info)
- m_color = g_colorManager.GetColor(label);
-}
-
-CGUIInfoLabel::CGUIInfoLabel()
-{
-}
-
-CGUIInfoLabel::CGUIInfoLabel(const CStdString &label, const CStdString &fallback)
-{
- SetLabel(label, fallback);
-}
-
-void CGUIInfoLabel::SetLabel(const CStdString &label, const CStdString &fallback)
-{
- m_fallback = fallback;
- Parse(label);
-}
-
-CStdString CGUIInfoLabel::GetLabel(int contextWindow, bool preferImage) const
-{
- CStdString label;
- for (unsigned int i = 0; i < m_info.size(); i++)
- {
- const CInfoPortion &portion = m_info[i];
- if (portion.m_info)
- {
- CStdString infoLabel;
- if (preferImage)
- infoLabel = g_infoManager.GetImage(portion.m_info, contextWindow);
- if (infoLabel.IsEmpty())
- infoLabel = g_infoManager.GetLabel(portion.m_info, contextWindow);
- if (!infoLabel.IsEmpty())
- {
- label += portion.m_prefix;
- label += infoLabel;
- label += portion.m_postfix;
- }
- }
- else
- { // no info, so just append the prefix
- label += portion.m_prefix;
- }
- }
- if (label.IsEmpty()) // empty label, use the fallback
- return m_fallback;
- return label;
-}
-
-CStdString CGUIInfoLabel::GetItemLabel(const CGUIListItem *item, bool preferImages) const
-{
- if (!item->IsFileItem()) return "";
- CStdString label;
- for (unsigned int i = 0; i < m_info.size(); i++)
- {
- const CInfoPortion &portion = m_info[i];
- if (portion.m_info)
- {
- CStdString infoLabel;
- if (preferImages)
- infoLabel = g_infoManager.GetItemImage((const CFileItem *)item, portion.m_info);
- else
- infoLabel = g_infoManager.GetItemLabel((const CFileItem *)item, portion.m_info);
- if (!infoLabel.IsEmpty())
- {
- label += portion.m_prefix;
- label += infoLabel;
- label += portion.m_postfix;
- }
- }
- else
- { // no info, so just append the prefix
- label += portion.m_prefix;
- }
- }
- if (label.IsEmpty())
- return m_fallback;
- return label;
-}
-
-bool CGUIInfoLabel::IsEmpty() const
-{
- return m_info.size() == 0;
-}
-
-bool CGUIInfoLabel::IsConstant() const
-{
- return m_info.size() == 0 || (m_info.size() == 1 && m_info[0].m_info == 0);
-}
-
-CStdString CGUIInfoLabel::ReplaceLocalize(const CStdString &label)
-{
- CStdString work(label);
- // Replace all $LOCALIZE[number] with the real string
- int pos1 = work.Find("$LOCALIZE[");
- while (pos1 >= 0)
- {
- int pos2 = StringUtils::FindEndBracket(work, '[', ']', pos1 + 10);
- if (pos2 > pos1)
- {
- CStdString left = work.Left(pos1);
- CStdString right = work.Mid(pos2 + 1);
- CStdString replace = g_localizeStringsTemp.Get(atoi(work.Mid(pos1 + 10).c_str()));
- if (replace == "")
- replace = g_localizeStrings.Get(atoi(work.Mid(pos1 + 10).c_str()));
- work = left + replace + right;
- }
- else
- {
- CLog::Log(LOGERROR, "Error parsing label - missing ']'");
- return "";
- }
- pos1 = work.Find("$LOCALIZE[", pos1);
- }
- return work;
-}
-
-CStdString CGUIInfoLabel::ReplaceAddonStrings(const CStdString &label)
-{
- CStdString work(label);
- //FIXME why not use RE here?
- // Replace all $ADDON[id number] with the real string
- int pos1 = work.Find("$ADDON[");
- while (pos1 >= 0)
- {
- int pos2 = StringUtils::FindEndBracket(work, '[', ']', pos1 + 7);
- if (pos2 > pos1)
- {
- CStdString left = work.Left(pos1);
- CStdString right = work.Mid(pos2 + 1);
- int length = work.Find(" ", pos1 + 7) - (pos1 + 7);
- CStdString id = work.substr(pos1+7, length);
- int stringid = atoi(work.substr(pos1+7+id.length()+1, 5).c_str());
- CStdString replace = CAddonMgr::Get().GetString(id, stringid);
- work = left + replace + right;
- }
- else
- {
- CLog::Log(LOGERROR, "Error parsing label - missing ']'");
- return "";
- }
- pos1 = work.Find("$ADDON[", pos1);
- }
- return work;
-}
-
-void CGUIInfoLabel::Parse(const CStdString &label)
-{
- m_info.clear();
- // Step 1: Replace all $LOCALIZE[number] with the real string
- CStdString work = ReplaceLocalize(label);
- // Step 2: Replace all $ADDON[id number] with the real string
- work = ReplaceAddonStrings(work);
- // Step 3: Find all $INFO[info,prefix,postfix] blocks
- int pos1 = work.Find("$INFO[");
- while (pos1 >= 0)
- {
- // output the first block (contents before first $INFO)
- if (pos1 > 0)
- m_info.push_back(CInfoPortion(0, work.Left(pos1), ""));
-
- // ok, now decipher the $INFO block
- int pos2 = StringUtils::FindEndBracket(work, '[', ']', pos1 + 6);
- if (pos2 > pos1)
- {
- // decipher the block
- CStdString block = work.Mid(pos1 + 6, pos2 - pos1 - 6);
- CStdStringArray params;
- StringUtils::SplitString(block, ",", params);
- int info = g_infoManager.TranslateString(params[0]);
- CStdString prefix, postfix;
- if (params.size() > 1)
- prefix = params[1];
- if (params.size() > 2)
- postfix = params[2];
- m_info.push_back(CInfoPortion(info, prefix, postfix));
- // and delete it from our work string
- work = work.Mid(pos2 + 1);
- }
- else
- {
- CLog::Log(LOGERROR, "Error parsing label - missing ']'");
- return;
- }
- pos1 = work.Find("$INFO[");
- }
- // add any last block
- if (!work.IsEmpty())
- m_info.push_back(CInfoPortion(0, work, ""));
-}
-
-CGUIInfoLabel::CInfoPortion::CInfoPortion(int info, const CStdString &prefix, const CStdString &postfix)
-{
- m_info = info;
- m_prefix = prefix;
- m_postfix = postfix;
- // filter our prefix and postfix for comma's
- m_prefix.Replace("$COMMA", ",");
- m_postfix.Replace("$COMMA", ",");
- m_prefix.Replace("$LBRACKET", "["); m_prefix.Replace("$RBRACKET", "]");
- m_postfix.Replace("$LBRACKET", "["); m_postfix.Replace("$RBRACKET", "]");
-}
-
-CStdString CGUIInfoLabel::GetLabel(const CStdString &label, int contextWindow, bool preferImage)
-{ // translate the label
- CGUIInfoLabel info(label, "");
- return info.GetLabel(contextWindow, preferImage);
-}
diff --git a/guilib/GUIInfoTypes.h b/guilib/GUIInfoTypes.h
deleted file mode 100644
index 20fb4de9f0..0000000000
--- a/guilib/GUIInfoTypes.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*!
-\file GUIInfoTypes.h
-\brief
-*/
-
-#ifndef GUILIB_GUIINFOTYPES_H
-#define GUILIB_GUIINFOTYPES_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "StdString.h"
-
-class CGUIListItem;
-
-class CGUIInfoBool
-{
-public:
- CGUIInfoBool(bool value = false);
- operator bool() const { return m_value; };
-
- void Update(int parentID = 0, const CGUIListItem *item = NULL);
- void Parse(const CStdString &info);
-private:
- int m_info;
- bool m_value;
-};
-
-typedef uint32_t color_t;
-
-class CGUIInfoColor
-{
-public:
- CGUIInfoColor(color_t color = 0);
-
- const CGUIInfoColor &operator=(const CGUIInfoColor &color);
- const CGUIInfoColor &operator=(color_t color);
- operator color_t() const { return m_color; };
-
- void Update();
- void Parse(const CStdString &label);
-
-private:
- color_t GetColor() const;
- int m_info;
- color_t m_color;
-};
-
-class CGUIInfoLabel
-{
-public:
- CGUIInfoLabel();
- CGUIInfoLabel(const CStdString &label, const CStdString &fallback = "");
-
- void SetLabel(const CStdString &label, const CStdString &fallback);
- CStdString GetLabel(int contextWindow, bool preferImage = false) const;
- CStdString GetItemLabel(const CGUIListItem *item, bool preferImage = false) const;
- bool IsConstant() const;
- bool IsEmpty() const;
-
- const CStdString GetFallback() const { return m_fallback; };
-
- static CStdString GetLabel(const CStdString &label, int contextWindow = 0, bool preferImage = false);
-
- /*!
- \brief Replaces instances of $LOCALIZE[number] with the appropriate localized string
- \param label text to replace
- \return text with any localized strings filled in.
- */
- static CStdString ReplaceLocalize(const CStdString &label);
-
- /*!
- \brief Replaces instances of $ADDON[id number] with the appropriate localized addon string
- \param label text to replace
- \return text with any localized strings filled in.
- */
- static CStdString ReplaceAddonStrings(const CStdString &label);
-
-private:
- void Parse(const CStdString &label);
-
- class CInfoPortion
- {
- public:
- CInfoPortion(int info, const CStdString &prefix, const CStdString &postfix);
- int m_info;
- CStdString m_prefix;
- CStdString m_postfix;
- };
-
- CStdString m_fallback;
- std::vector<CInfoPortion> m_info;
-};
-
-#endif
diff --git a/guilib/GUILabel.cpp b/guilib/GUILabel.cpp
deleted file mode 100644
index 088fcaebce..0000000000
--- a/guilib/GUILabel.cpp
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright (C) 2005-2010 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUILabel.h"
-#include "utils/CharsetConverter.h"
-#include <limits>
-
-CGUILabel::CGUILabel(float posX, float posY, float width, float height, const CLabelInfo& labelInfo, CGUILabel::OVER_FLOW overflow)
- : m_textLayout(labelInfo.font, overflow == OVER_FLOW_WRAP, height)
- , m_scrollInfo(50, 0, labelInfo.scrollSpeed, labelInfo.scrollSuffix)
- , m_maxRect(posX, posY, posX + width, posY + height)
-{
- m_selected = false;
- m_overflowType = overflow;
- m_scrolling = (overflow == OVER_FLOW_SCROLL);
- m_label = labelInfo;
- m_invalid = true;
-}
-
-CGUILabel::~CGUILabel(void)
-{
-}
-
-void CGUILabel::SetScrolling(bool scrolling)
-{
- m_scrolling = scrolling;
- if (!m_scrolling)
- m_scrollInfo.Reset();
-}
-
-void CGUILabel::SetColor(CGUILabel::COLOR color)
-{
- m_color = color;
-}
-
-color_t CGUILabel::GetColor() const
-{
- switch (m_color)
- {
- case COLOR_SELECTED:
- return m_label.selectedColor;
- case COLOR_DISABLED:
- return m_label.disabledColor;
- case COLOR_FOCUSED:
- return m_label.focusedColor ? m_label.focusedColor : m_label.textColor;
- default:
- break;
- }
- return m_label.textColor;
-}
-
-void CGUILabel::Render()
-{
- color_t color = GetColor();
- bool renderSolid = (m_color == COLOR_DISABLED);
- bool overFlows = (m_renderRect.Width() + 0.5f < m_textLayout.GetTextWidth()); // 0.5f to deal with floating point rounding issues
- if (overFlows && m_scrolling && !renderSolid)
- m_textLayout.RenderScrolling(m_renderRect.x1, m_renderRect.y1, m_label.angle, color, m_label.shadowColor, 0, m_renderRect.Width(), m_scrollInfo);
- else
- {
- float posX = m_renderRect.x1;
- float posY = m_renderRect.y1;
- uint32_t align = 0;
- if (!overFlows)
- { // hack for right and centered multiline text, as GUITextLayout::Render() treats posX as the right hand
- // or center edge of the text (see GUIFontTTF::DrawTextInternal), and this has already been taken care of
- // in UpdateRenderRect(), but we wish to still pass the horizontal alignment info through (so that multiline text
- // is aligned correctly), so we must undo the UpdateRenderRect() changes for horizontal alignment.
- if (m_label.align & XBFONT_RIGHT)
- posX += m_renderRect.Width();
- else if (m_label.align & XBFONT_CENTER_X)
- posX += m_renderRect.Width() * 0.5f;
- if (m_label.align & XBFONT_CENTER_Y) // need to pass a centered Y so that <angle> will rotate around the correct point.
- posY += m_renderRect.Height() * 0.5f;
- align = m_label.align;
- }
- else
- align |= XBFONT_TRUNCATED;
- m_textLayout.Render(posX, posY, m_label.angle, color, m_label.shadowColor, align, m_renderRect.Width(), renderSolid);
- }
-}
-
-void CGUILabel::SetInvalid()
-{
- m_invalid = true;
-}
-
-void CGUILabel::UpdateColors()
-{
- m_label.UpdateColors();
-}
-
-void CGUILabel::SetMaxRect(float x, float y, float w, float h)
-{
- m_maxRect.SetRect(x, y, x + w, y + h);
- UpdateRenderRect();
-}
-
-void CGUILabel::SetAlign(uint32_t align)
-{
- m_label.align = align;
- UpdateRenderRect();
-}
-
-void CGUILabel::SetText(const CStdString &label)
-{
- if (m_textLayout.Update(label, m_maxRect.Width(), m_invalid))
- { // needed an update - reset scrolling and update our text layout
- m_scrollInfo.Reset();
- UpdateRenderRect();
- m_invalid = false;
- }
-}
-
-void CGUILabel::SetTextW(const CStdStringW &label)
-{
- m_textLayout.SetText(label);
- m_scrollInfo.Reset();
- UpdateRenderRect();
- m_invalid = false;
-}
-
-void CGUILabel::UpdateRenderRect()
-{
- // recalculate our text layout
- float width, height;
- m_textLayout.GetTextExtent(width, height);
- width = std::min(width, GetMaxWidth());
- if (m_label.align & XBFONT_CENTER_Y)
- m_renderRect.y1 = m_maxRect.y1 + (m_maxRect.Height() - height) * 0.5f;
- else
- m_renderRect.y1 = m_maxRect.y1 + m_label.offsetY;
- if (m_label.align & XBFONT_RIGHT)
- m_renderRect.x1 = m_maxRect.x2 - width - m_label.offsetX;
- else if (m_label.align & XBFONT_CENTER_X)
- m_renderRect.x1 = m_maxRect.x1 + (m_maxRect.Width() - width) * 0.5f;
- else
- m_renderRect.x1 = m_maxRect.x1 + m_label.offsetX;
- m_renderRect.x2 = m_renderRect.x1 + width;
- m_renderRect.y2 = m_renderRect.y1 + height;
-}
-
-float CGUILabel::GetMaxWidth() const
-{
- if (m_label.width) return m_label.width;
- return m_maxRect.Width() - 2*m_label.offsetX;
-}
-
-void CGUILabel::CheckAndCorrectOverlap(CGUILabel &label1, CGUILabel &label2)
-{
- CRect rect(label1.m_renderRect);
- if (rect.Intersect(label2.m_renderRect).IsEmpty())
- return; // nothing to do (though it could potentially encroach on the min_space requirement)
-
- static const float min_space = 10;
- // overlap vertically and horizontally - check alignment
- CGUILabel &left = label1.m_renderRect.x1 <= label2.m_renderRect.x1 ? label1 : label2;
- CGUILabel &right = label1.m_renderRect.x1 <= label2.m_renderRect.x1 ? label2 : label1;
- if ((left.m_label.align & 3) == 0 && right.m_label.align & XBFONT_RIGHT)
- {
- float chopPoint = (left.m_maxRect.x1 + left.GetMaxWidth() + right.m_maxRect.x2 - right.GetMaxWidth()) * 0.5f;
- // [1 [2...[2 1].|..........1] 2]
- // [1 [2.....[2 | 1]..1] 2]
- // [1 [2..........|.[2 1]..1] 2]
- if (right.m_renderRect.x1 > chopPoint)
- chopPoint = right.m_renderRect.x1 - min_space;
- else if (left.m_renderRect.x2 < chopPoint)
- chopPoint = left.m_renderRect.x2 + min_space;
- left.m_renderRect.x2 = chopPoint - min_space;
- right.m_renderRect.x1 = chopPoint + min_space;
- }
-}
diff --git a/guilib/GUILabel.h b/guilib/GUILabel.h
deleted file mode 100644
index 4fc1ad2be8..0000000000
--- a/guilib/GUILabel.h
+++ /dev/null
@@ -1,219 +0,0 @@
-/*!
-\file GUILabel.h
-\brief
-*/
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2010 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUITextLayout.h"
-#include "GUIInfoTypes.h"
-#include "GUIFont.h"
-#include "Geometry.h"
-
-class CLabelInfo
-{
-public:
- CLabelInfo()
- {
- font = NULL;
- align = XBFONT_LEFT;
- offsetX = offsetY = 0;
- width = 0;
- angle = 0;
- scrollSpeed = CScrollInfo::defaultSpeed;
- scrollSuffix = " | ";
- };
- void UpdateColors()
- {
- textColor.Update();
- shadowColor.Update();
- selectedColor.Update();
- disabledColor.Update();
- focusedColor.Update();
- };
-
- CGUIInfoColor textColor;
- CGUIInfoColor shadowColor;
- CGUIInfoColor selectedColor;
- CGUIInfoColor disabledColor;
- CGUIInfoColor focusedColor;
- uint32_t align;
- float offsetX;
- float offsetY;
- float width;
- float angle;
- CGUIFont *font;
- int scrollSpeed;
- CStdString scrollSuffix;
-};
-
-/*!
- \ingroup controls, labels
- \brief Class for rendering text labels. Handles alignment and rendering of text within a control.
- */
-class CGUILabel
-{
-public:
- /*! \brief allowed color categories for labels, as defined by the skin
- */
- enum COLOR { COLOR_TEXT = 0,
- COLOR_SELECTED,
- COLOR_FOCUSED,
- COLOR_DISABLED };
-
- /*! \brief allowed overflow handling techniques for labels, as defined by the skin
- */
- enum OVER_FLOW { OVER_FLOW_TRUNCATE = 0,
- OVER_FLOW_SCROLL,
- OVER_FLOW_WRAP };
-
- CGUILabel(float posX, float posY, float width, float height, const CLabelInfo& labelInfo, OVER_FLOW overflow = OVER_FLOW_TRUNCATE);
- virtual ~CGUILabel(void);
-
- /*! \brief Render the label on screen
- */
- void Render();
-
- /*! \brief Set the maximal extent of the label
- Sets the maximal size and positioning that the label may render in. Note that <textwidth> can override
- this, and <textoffsetx> and <textoffsety> may also allow the label to be moved outside this rectangle.
- */
- void SetMaxRect(float x, float y, float w, float h);
-
- void SetAlign(uint32_t align);
-
- /*! \brief Set the text to be displayed in the label
- Updates the label control and recomputes final position and size
- \param text CStdString to set as this labels text
- \sa SetTextW
- */
- void SetText(const CStdString &label);
-
- /*! \brief Set the text to be displayed in the label
- Updates the label control and recomputes final position and size
- \param text CStdStringW to set as this labels text
- \sa SetText
- */
- void SetTextW(const CStdStringW &label);
-
- /*! \brief Set the color to use for the label
- Sets the color to be used for this label. Takes effect at the next render
- \param color color to be used for the label
- */
- void SetColor(COLOR color);
-
- /*! \brief Set the final layout of the current text
- Overrides the calculated layout of the current text, forcing a particular size and position
- \param rect CRect containing the extents of the current text
- \sa GetRenderRect, UpdateRenderRect
- */
- void SetRenderRect(const CRect &rect) { m_renderRect = rect; };
-
- /*! \brief Set whether or not this label control should scroll
- \param scrolling true if this label should scroll.
- */
- void SetScrolling(bool scrolling);
-
- /*! \brief Set this label invalid. Forces an update of the control
- */
- void SetInvalid();
-
- /*! \brief Update this labels colors
- */
- void UpdateColors();
-
- /*! \brief Returns the precalculated final layout of the current text
- \return CRect containing the extents of the current text
- \sa SetRenderRect, UpdateRenderRect
- */
- const CRect &GetRenderRect() const { return m_renderRect; };
-
- /*! \brief Returns the precalculated full width of the current text, regardless of layout
- \return full width of the current text
- \sa CalcTextWidth
- */
- float GetTextWidth() const { return m_textLayout.GetTextWidth(); };
-
- /*! \brief Returns the maximal width that this label can render into
- \return Maximal width that this label can render into. Note that this may differ from the
- amount given in SetMaxRect as offsets and text width overrides have been taken into account.
- \sa SetMaxRect
- */
- float GetMaxWidth() const;
-
- /*! \brief Calculates the width of some text
- \param text CStdStringW of text whose width we want
- \return width of the given text
- \sa GetTextWidth
- */
- float CalcTextWidth(const CStdStringW &text) const { return m_textLayout.GetTextWidth(text); };
-
- const CLabelInfo& GetLabelInfo() const { return m_label; };
- CLabelInfo &GetLabelInfo() { return m_label; };
-
- /*! \brief Check a left aligned and right aligned label for overlap and cut the labels off so that no overlap occurs
-
- If a left-aligned label occupies some of the same space on screen as a right-aligned label, then we may be able to
- correct for this by restricting the width of one or both of them. This routine checks two labels to see whether they
- satisfy this assumption and, if so, adjusts the render rect of both labels so that they no longer do so. The order
- of the two labels is not important, but we do assume that the left-aligned label is also the left-most on screen, and
- that the right-aligned label is the right most on-screen, so that they overlap due to the fact that one or both of
- the labels are longer than anticipated. In the following diagram, [R...[R R] refers to the maximal allowed and
- actual space occupied by the right label. Similarly, [L L]...L] refers to the maximal and actual space occupied
- by the left label. | refers to the central cutting point, i.e. the point that would divide the maximal allowed
- overlap perfectly in two. There are 3 scenarios to consider:
-
- cut
- [L [R...[R L].|..........L] R] left label ends to the left of the cut -> just crop the left label.
- [L [R.....[R | L]..L] R] both left and right labels occupy more than the cut allows, so crop both.
- [L [R..........|.[R L]..L] R] right label ends to the right of the cut -> just crop the right label.
-
- \param label1 First label to check
- \param label2 Second label to check
- */
- static void CheckAndCorrectOverlap(CGUILabel &label1, CGUILabel &label2);
-
-protected:
- color_t GetColor() const;
-
- /*! \brief Computes the final layout of the text
- Uses the maximal position and width of the text, as well as the text length
- and alignment to compute the final render rect of the text.
- \sa GetRenderRect, SetRenderRect
- */
- void UpdateRenderRect();
-
-private:
- CLabelInfo m_label;
- CGUITextLayout m_textLayout;
-
- bool m_scrolling;
- OVER_FLOW m_overflowType;
- bool m_selected;
- CScrollInfo m_scrollInfo;
- CRect m_renderRect; ///< actual sizing of text
- CRect m_maxRect; ///< maximum sizing of text
- bool m_invalid; ///< if true, the label needs recomputing
- COLOR m_color; ///< color to render text \sa SetColor, GetColor
-};
diff --git a/guilib/GUILabelControl.cpp b/guilib/GUILabelControl.cpp
deleted file mode 100644
index f7e53b3ce4..0000000000
--- a/guilib/GUILabelControl.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUILabelControl.h"
-#include "utils/CharsetConverter.h"
-
-using namespace std;
-
-CGUILabelControl::CGUILabelControl(int parentID, int controlID, float posX, float posY, float width, float height, const CLabelInfo& labelInfo, bool wrapMultiLine, bool bHasPath)
- : CGUIControl(parentID, controlID, posX, posY, width, height)
- , m_label(posX, posY, width, height, labelInfo, wrapMultiLine ? CGUILabel::OVER_FLOW_WRAP : CGUILabel::OVER_FLOW_TRUNCATE)
-{
- m_bHasPath = bHasPath;
- m_iCursorPos = 0;
- m_bShowCursor = false;
- m_dwCounter = 0;
- ControlType = GUICONTROL_LABEL;
- m_startHighlight = m_endHighlight = 0;
- m_minWidth = 0;
- if ((labelInfo.align & XBFONT_RIGHT) && m_width)
- m_posX -= m_width;
-}
-
-CGUILabelControl::~CGUILabelControl(void)
-{
-}
-
-void CGUILabelControl::ShowCursor(bool bShow)
-{
- m_bShowCursor = bShow;
-}
-
-void CGUILabelControl::SetCursorPos(int iPos)
-{
- CStdString label = m_infoLabel.GetLabel(m_parentID);
- if (iPos > (int)label.length()) iPos = label.length();
- if (iPos < 0) iPos = 0;
- m_iCursorPos = iPos;
-}
-
-void CGUILabelControl::SetInfo(const CGUIInfoLabel &infoLabel)
-{
- m_infoLabel = infoLabel;
-}
-
-void CGUILabelControl::UpdateColors()
-{
- m_label.UpdateColors();
- CGUIControl::UpdateColors();
-}
-
-void CGUILabelControl::UpdateInfo(const CGUIListItem *item)
-{
- CStdString label(m_infoLabel.GetLabel(m_parentID));
-
- if (m_bShowCursor)
- { // cursor location assumes utf16 text, so deal with that (inefficient, but it's not as if it's a high-use area
- // virtual keyboard only)
- CStdStringW utf16;
- g_charsetConverter.utf8ToW(label, utf16);
- CStdStringW col;
- if ((++m_dwCounter % 50) > 25)
- col = L"|";
- else
- col = L"[COLOR 00FFFFFF]|[/COLOR]";
- utf16.Insert(m_iCursorPos, col);
- g_charsetConverter.wToUTF8(utf16, label);
- }
- else if (m_startHighlight || m_endHighlight)
- { // this is only used for times/dates, so working in ascii (utf8) is fine
- CStdString colorLabel;
- colorLabel.Format("[COLOR %x]%s[/COLOR]%s[COLOR %x]%s[/COLOR]", (color_t)m_label.GetLabelInfo().disabledColor, label.Left(m_startHighlight),
- label.Mid(m_startHighlight, m_endHighlight - m_startHighlight), (color_t)m_label.GetLabelInfo().disabledColor, label.Mid(m_endHighlight));
- label = colorLabel;
- }
- else if (m_bHasPath)
- label = ShortenPath(label);
-
- m_label.SetMaxRect(m_posX, m_posY, m_width, m_height);
- m_label.SetText(label);
-}
-
-void CGUILabelControl::Render()
-{
- m_label.SetColor(IsDisabled() ? CGUILabel::COLOR_DISABLED : CGUILabel::COLOR_TEXT);
- m_label.SetMaxRect(m_posX, m_posY, m_width, m_height);
- m_label.Render();
- CGUIControl::Render();
-}
-
-
-bool CGUILabelControl::CanFocus() const
-{
- return false;
-}
-
-void CGUILabelControl::SetLabel(const string &strLabel)
-{
- m_infoLabel.SetLabel(strLabel, "");
- if (m_iCursorPos > (int)strLabel.size())
- m_iCursorPos = strLabel.size();
-}
-
-void CGUILabelControl::SetWidthControl(float minWidth, bool bScroll)
-{
- m_minWidth = minWidth;
- m_label.SetScrolling(bScroll);
-}
-
-void CGUILabelControl::SetAlignment(uint32_t align)
-{
- m_label.GetLabelInfo().align = align;
-}
-
-#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
-
-float CGUILabelControl::GetWidth() const
-{
- if (m_minWidth && m_minWidth != m_width)
- return CLAMP(m_label.GetTextWidth(), m_minWidth, m_width);
- return m_width;
-}
-
-bool CGUILabelControl::OnMessage(CGUIMessage& message)
-{
- if ( message.GetControlId() == GetID() )
- {
- if (message.GetMessage() == GUI_MSG_LABEL_SET)
- {
- SetLabel(message.GetLabel());
- return true;
- }
- }
-
- return CGUIControl::OnMessage(message);
-}
-
-CStdString CGUILabelControl::ShortenPath(const CStdString &path)
-{
- if (m_width == 0 || path.IsEmpty())
- return path;
-
- char cDelim = '\0';
- size_t nPos;
-
- nPos = path.find_last_of( '\\' );
- if ( nPos != std::string::npos )
- cDelim = '\\';
- else
- {
- nPos = path.find_last_of( '/' );
- if ( nPos != std::string::npos )
- cDelim = '/';
- }
- if ( cDelim == '\0' )
- return path;
-
- CStdString workPath(path);
- // remove trailing slashes
- if (workPath.size() > 3)
- if (workPath.Right(3).Compare("://") != 0 && workPath.Right(2).Compare(":\\") != 0)
- if (nPos == workPath.size() - 1)
- {
- workPath.erase(workPath.size() - 1);
- nPos = workPath.find_last_of( cDelim );
- }
-
- m_label.SetText(workPath);
- float textWidth = m_label.GetTextWidth();
-
- while ( textWidth > m_width )
- {
- size_t nGreaterDelim = workPath.find_last_of( cDelim, nPos );
- if (nGreaterDelim == std::string::npos)
- break;
-
- nPos = workPath.find_last_of( cDelim, nGreaterDelim - 1 );
- if ( nPos == std::string::npos )
- break;
-
- workPath.replace( nPos + 1, nGreaterDelim - nPos - 1, "..." );
-
- m_label.SetText(workPath);
- textWidth = m_label.GetTextWidth();
- }
- return workPath;
-}
-
-void CGUILabelControl::SetHighlight(unsigned int start, unsigned int end)
-{
- m_startHighlight = start;
- m_endHighlight = end;
-}
-
-CStdString CGUILabelControl::GetDescription() const
-{
- return m_infoLabel.GetLabel(m_parentID);
-}
diff --git a/guilib/GUILabelControl.h b/guilib/GUILabelControl.h
deleted file mode 100644
index c82e89c891..0000000000
--- a/guilib/GUILabelControl.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*!
-\file GUILabelControl.h
-\brief
-*/
-
-#ifndef GUILIB_GUILABELCONTROL_H
-#define GUILIB_GUILABELCONTROL_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIControl.h"
-#include "GUILabel.h"
-
-/*!
- \ingroup controls
- \brief
- */
-class CGUILabelControl :
- public CGUIControl
-{
-public:
- CGUILabelControl(int parentID, int controlID, float posX, float posY, float width, float height, const CLabelInfo& labelInfo, bool wrapMultiLine, bool bHasPath);
- virtual ~CGUILabelControl(void);
- virtual CGUILabelControl *Clone() const { return new CGUILabelControl(*this); };
-
- virtual void Render();
- virtual void UpdateInfo(const CGUIListItem *item = NULL);
- virtual bool CanFocus() const;
- virtual bool OnMessage(CGUIMessage& message);
- virtual CStdString GetDescription() const;
- virtual float GetWidth() const;
-
- const CLabelInfo& GetLabelInfo() const { return m_label.GetLabelInfo(); };
- void SetLabel(const std::string &strLabel);
- void ShowCursor(bool bShow = true);
- void SetCursorPos(int iPos);
- int GetCursorPos() const { return m_iCursorPos;};
- void SetInfo(const CGUIInfoLabel&labelInfo);
- void SetWidthControl(float minWidth, bool bScroll);
- void SetAlignment(uint32_t align);
- void SetHighlight(unsigned int start, unsigned int end);
-
-protected:
- void UpdateColors();
- CStdString ShortenPath(const CStdString &path);
-
- CGUILabel m_label;
-
- bool m_bHasPath;
- bool m_bShowCursor;
- int m_iCursorPos;
- unsigned int m_dwCounter;
-
- // stuff for autowidth
- bool m_autoWidth;
- float m_minWidth;
-
- // multi-info stuff
- CGUIInfoLabel m_infoLabel;
-
- unsigned int m_startHighlight;
- unsigned int m_endHighlight;
-};
-#endif
diff --git a/guilib/GUIListContainer.cpp b/guilib/GUIListContainer.cpp
deleted file mode 100644
index 306f9ce7a6..0000000000
--- a/guilib/GUIListContainer.cpp
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIListContainer.h"
-#include "GUIListItem.h"
-#include "GUIInfoManager.h"
-#include "Key.h"
-
-CGUIListContainer::CGUIListContainer(int parentID, int controlID, float posX, float posY, float width, float height, ORIENTATION orientation, int scrollTime, int preloadItems)
- : CGUIBaseContainer(parentID, controlID, posX, posY, width, height, orientation, scrollTime, preloadItems)
-{
- ControlType = GUICONTAINER_LIST;
- m_type = VIEW_TYPE_LIST;
-}
-
-CGUIListContainer::~CGUIListContainer(void)
-{
-}
-
-bool CGUIListContainer::OnAction(const CAction &action)
-{
- switch (action.GetID())
- {
- case ACTION_PAGE_UP:
- {
- if (m_offset == 0)
- { // already on the first page, so move to the first item
- SetCursor(0);
- }
- else
- { // scroll up to the previous page
- Scroll( -m_itemsPerPage);
- }
- return true;
- }
- break;
- case ACTION_PAGE_DOWN:
- {
- if (m_offset == (int)m_items.size() - m_itemsPerPage || (int)m_items.size() < m_itemsPerPage)
- { // already at the last page, so move to the last item.
- SetCursor(m_items.size() - m_offset - 1);
- }
- else
- { // scroll down to the next page
- Scroll(m_itemsPerPage);
- }
- return true;
- }
- break;
- // smooth scrolling (for analog controls)
- case ACTION_SCROLL_UP:
- {
- m_analogScrollCount += action.GetAmount() * action.GetAmount();
- bool handled = false;
- while (m_analogScrollCount > 0.4)
- {
- handled = true;
- m_analogScrollCount -= 0.4f;
- if (m_offset > 0 && m_cursor <= m_itemsPerPage / 2)
- {
- Scroll(-1);
- }
- else if (m_cursor > 0)
- {
- SetCursor(m_cursor - 1);
- }
- }
- return handled;
- }
- break;
- case ACTION_SCROLL_DOWN:
- {
- m_analogScrollCount += action.GetAmount() * action.GetAmount();
- bool handled = false;
- while (m_analogScrollCount > 0.4)
- {
- handled = true;
- m_analogScrollCount -= 0.4f;
- if (m_offset + m_itemsPerPage < (int)m_items.size() && m_cursor >= m_itemsPerPage / 2)
- {
- Scroll(1);
- }
- else if (m_cursor < m_itemsPerPage - 1 && m_offset + m_cursor < (int)m_items.size() - 1)
- {
- SetCursor(m_cursor + 1);
- }
- }
- return handled;
- }
- break;
- }
- return CGUIBaseContainer::OnAction(action);
-}
-
-bool CGUIListContainer::OnMessage(CGUIMessage& message)
-{
- if (message.GetControlId() == GetID() )
- {
- if (message.GetMessage() == GUI_MSG_LABEL_RESET)
- {
- SetCursor(0);
- }
- else if (message.GetMessage() == GUI_MSG_ITEM_SELECT)
- {
- SelectItem(message.GetParam1());
- return true;
- }
- else if (message.GetMessage() == GUI_MSG_SETFOCUS)
- {
- if (message.GetParam1()) // subfocus item is specified, so set the offset appropriately
- {
- int item = std::min(m_offset + (int)message.GetParam1() - 1, (int)m_items.size() - 1);
- SelectItem(item);
- }
- }
- }
- return CGUIBaseContainer::OnMessage(message);
-}
-
-bool CGUIListContainer::MoveUp(bool wrapAround)
-{
- if (m_cursor > 0)
- {
- SetCursor(m_cursor - 1);
- }
- else if (m_cursor == 0 && m_offset)
- {
- ScrollToOffset(m_offset - 1);
- }
- else if (wrapAround)
- {
- if (m_items.size() > 0)
- { // move 2 last item in list, and set our container moving up
- int offset = m_items.size() - m_itemsPerPage;
- if (offset < 0) offset = 0;
- SetCursor(m_items.size() - offset - 1);
- ScrollToOffset(offset);
- SetContainerMoving(-1);
- }
- }
- else
- return false;
- return true;
-}
-
-bool CGUIListContainer::MoveDown(bool wrapAround)
-{
- if (m_offset + m_cursor + 1 < (int)m_items.size())
- {
- if (m_cursor + 1 < m_itemsPerPage)
- {
- SetCursor(m_cursor + 1);
- }
- else
- {
- ScrollToOffset(m_offset + 1);
- }
- }
- else if(wrapAround)
- { // move first item in list, and set our container moving in the "down" direction
- SetCursor(0);
- ScrollToOffset(0);
- SetContainerMoving(1);
- }
- else
- return false;
- return true;
-}
-
-// scrolls the said amount
-void CGUIListContainer::Scroll(int amount)
-{
- // increase or decrease the offset
- int offset = m_offset + amount;
- if (offset > (int)m_items.size() - m_itemsPerPage)
- {
- offset = m_items.size() - m_itemsPerPage;
- }
- if (offset < 0) offset = 0;
- ScrollToOffset(offset);
-}
-
-void CGUIListContainer::ValidateOffset()
-{ // first thing is we check the range of m_offset
- if (!m_layout) return;
- if (m_offset > (int)m_items.size() - m_itemsPerPage || m_scrollOffset > ((int)m_items.size() - m_itemsPerPage) * m_layout->Size(m_orientation))
- {
- m_offset = m_items.size() - m_itemsPerPage;
- m_scrollOffset = m_offset * m_layout->Size(m_orientation);
- }
- if (m_offset < 0 || m_scrollOffset < 0)
- {
- m_offset = 0;
- m_scrollOffset = 0;
- }
-}
-
-void CGUIListContainer::SetCursor(int cursor)
-{
- if (cursor > m_itemsPerPage - 1) cursor = m_itemsPerPage - 1;
- if (cursor < 0) cursor = 0;
- if (!m_wasReset)
- SetContainerMoving(cursor - m_cursor);
- m_cursor = cursor;
-}
-
-void CGUIListContainer::SelectItem(int item)
-{
- // Check that m_offset is valid
- ValidateOffset();
- // only select an item if it's in a valid range
- if (item >= 0 && item < (int)m_items.size())
- {
- // Select the item requested
- if (item >= m_offset && item < m_offset + m_itemsPerPage)
- { // the item is on the current page, so don't change it.
- SetCursor(item - m_offset);
- }
- else if (item < m_offset)
- { // item is on a previous page - make it the first item on the page
- SetCursor(0);
- ScrollToOffset(item);
- }
- else // (item >= m_offset+m_itemsPerPage)
- { // item is on a later page - make it the last item on the page
- SetCursor(m_itemsPerPage - 1);
- ScrollToOffset(item - m_cursor);
- }
- }
-}
-
-int CGUIListContainer::GetCursorFromPoint(const CPoint &point, CPoint *itemPoint) const
-{
- if (!m_focusedLayout || !m_layout)
- return -1;
-
- int row = 0;
- float pos = (m_orientation == VERTICAL) ? point.y : point.x;
- while (row < m_itemsPerPage + 1) // 1 more to ensure we get the (possible) half item at the end.
- {
- const CGUIListItemLayout *layout = (row == m_cursor) ? m_focusedLayout : m_layout;
- if (pos < layout->Size(m_orientation) && row + m_offset < (int)m_items.size())
- { // found correct "row" -> check horizontal
- if (!InsideLayout(layout, point))
- return -1;
-
- if (itemPoint)
- *itemPoint = m_orientation == VERTICAL ? CPoint(point.x, pos) : CPoint(pos, point.y);
- return row;
- }
- row++;
- pos -= layout->Size(m_orientation);
- }
- return -1;
-}
-
-bool CGUIListContainer::SelectItemFromPoint(const CPoint &point)
-{
- CPoint itemPoint;
- int row = GetCursorFromPoint(point, &itemPoint);
- if (row < 0)
- return false;
-
- SetContainerMoving(row - m_cursor);
- m_cursor = row;
- CGUIListItemLayout *focusedLayout = GetFocusedLayout();
- if (focusedLayout)
- focusedLayout->SelectItemFromPoint(itemPoint);
- return true;
-}
-
-//#ifdef PRE_SKIN_VERSION_9_10_COMPATIBILITY
-CGUIListContainer::CGUIListContainer(int parentID, int controlID, float posX, float posY, float width, float height,
- const CLabelInfo& labelInfo, const CLabelInfo& labelInfo2,
- const CTextureInfo& textureButton, const CTextureInfo& textureButtonFocus,
- float textureHeight, float itemWidth, float itemHeight, float spaceBetweenItems)
-: CGUIBaseContainer(parentID, controlID, posX, posY, width, height, VERTICAL, 200, 0)
-{
- CGUIListItemLayout layout;
- layout.CreateListControlLayouts(width, textureHeight + spaceBetweenItems, false, labelInfo, labelInfo2, textureButton, textureButtonFocus, textureHeight, itemWidth, itemHeight, 0, 0);
- m_layouts.push_back(layout);
- CStdString condition;
- condition.Format("control.hasfocus(%i)", controlID);
- CStdString condition2 = "!" + condition;
- CGUIListItemLayout focusLayout;
- focusLayout.CreateListControlLayouts(width, textureHeight + spaceBetweenItems, true, labelInfo, labelInfo2, textureButton, textureButtonFocus, textureHeight, itemWidth, itemHeight, g_infoManager.TranslateString(condition2), g_infoManager.TranslateString(condition));
- m_focusedLayouts.push_back(focusLayout);
- m_height = floor(m_height / (textureHeight + spaceBetweenItems)) * (textureHeight + spaceBetweenItems);
- ControlType = GUICONTAINER_LIST;
-}
-//#endif
-
-bool CGUIListContainer::HasNextPage() const
-{
- return (m_offset != (int)m_items.size() - m_itemsPerPage && (int)m_items.size() >= m_itemsPerPage);
-}
-
-bool CGUIListContainer::HasPreviousPage() const
-{
- return (m_offset > 0);
-}
diff --git a/guilib/GUIListContainer.h b/guilib/GUIListContainer.h
deleted file mode 100644
index cb650e1653..0000000000
--- a/guilib/GUIListContainer.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*!
-\file GUIListContainer.h
-\brief
-*/
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIBaseContainer.h"
-
-/*!
- \ingroup controls
- \brief
- */
-class CGUIListContainer : public CGUIBaseContainer
-{
-public:
- CGUIListContainer(int parentID, int controlID, float posX, float posY, float width, float height, ORIENTATION orientation, int scrollTime, int preloadItems);
-//#ifdef PRE_SKIN_VERSION_9_10_COMPATIBILITY
- CGUIListContainer(int parentID, int controlID, float posX, float posY, float width, float height,
- const CLabelInfo& labelInfo, const CLabelInfo& labelInfo2,
- const CTextureInfo& textureButton, const CTextureInfo& textureButtonFocus,
- float textureHeight, float itemWidth, float itemHeight, float spaceBetweenItems);
-//#endif
- virtual ~CGUIListContainer(void);
- virtual CGUIListContainer *Clone() const { return new CGUIListContainer(*this); };
-
- virtual bool OnAction(const CAction &action);
- virtual bool OnMessage(CGUIMessage& message);
-
- virtual bool HasNextPage() const;
- virtual bool HasPreviousPage() const;
-
-protected:
- virtual void Scroll(int amount);
- void SetCursor(int cursor);
- virtual bool MoveDown(bool wrapAround);
- virtual bool MoveUp(bool wrapAround);
- virtual void ValidateOffset();
- virtual void SelectItem(int item);
- virtual bool SelectItemFromPoint(const CPoint &point);
- virtual int GetCursorFromPoint(const CPoint &point, CPoint *itemPoint = NULL) const;
-};
-
diff --git a/guilib/GUIListGroup.cpp b/guilib/GUIListGroup.cpp
deleted file mode 100644
index 215e2212f2..0000000000
--- a/guilib/GUIListGroup.cpp
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIListGroup.h"
-#include "GUIListLabel.h"
-#include "GUIMultiSelectText.h"
-#include "GUIBorderedImage.h"
-#include "GUIControlProfiler.h"
-#include "utils/log.h"
-
-CGUIListGroup::CGUIListGroup(int parentID, int controlID, float posX, float posY, float width, float height)
-: CGUIControlGroup(parentID, controlID, posX, posY, width, height)
-{
- m_item = NULL;
- ControlType = GUICONTROL_LISTGROUP;
-}
-
-CGUIListGroup::CGUIListGroup(const CGUIListGroup &right)
-: CGUIControlGroup(right)
-{
- m_item = NULL;
- ControlType = GUICONTROL_LISTGROUP;
-}
-
-CGUIListGroup::~CGUIListGroup(void)
-{
- FreeResources();
-}
-
-void CGUIListGroup::AddControl(CGUIControl *control, int position /*= -1*/)
-{
- if (control)
- {
- if (!(control->GetControlType() == CGUIControl::GUICONTROL_LISTLABEL ||
- control->GetControlType() == CGUIControl::GUICONTROL_LISTGROUP ||
- control->GetControlType() == CGUIControl::GUICONTROL_IMAGE ||
- control->GetControlType() == CGUIControl::GUICONTROL_BORDEREDIMAGE ||
- control->GetControlType() == CGUIControl::GUICONTROL_MULTI_IMAGE ||
- control->GetControlType() == CGUIControl::GUICONTROL_MULTISELECT ||
- control->GetControlType() == CGUIControl::GUICONTROL_TEXTBOX))
- CLog::Log(LOGWARNING, "Trying to add unsupported control type %d", control->GetControlType());
- }
- CGUIControlGroup::AddControl(control, position);
-}
-
-void CGUIListGroup::Render()
-{
- g_graphicsContext.SetOrigin(m_posX, m_posY);
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- CGUIControl *control = *it;
- GUIPROFILER_VISIBILITY_BEGIN(control);
- control->UpdateVisibility(m_item);
- GUIPROFILER_VISIBILITY_END(control);
- control->DoRender(m_renderTime);
- }
- CGUIControl::Render();
- g_graphicsContext.RestoreOrigin();
- m_item = NULL;
-}
-
-void CGUIListGroup::ResetAnimation(ANIMATION_TYPE type)
-{
- CGUIControl::ResetAnimation(type);
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- (*it)->ResetAnimation(type);
-}
-
-void CGUIListGroup::UpdateVisibility(const CGUIListItem *item)
-{
- CGUIControlGroup::UpdateVisibility(item);
- m_item = item;
-}
-
-void CGUIListGroup::UpdateInfo(const CGUIListItem *item)
-{
- for (iControls it = m_children.begin(); it != m_children.end(); it++)
- {
- (*it)->UpdateInfo(item);
- (*it)->UpdateVisibility(item);
- }
- // now we have to check our overlapping label pairs
- for (unsigned int i = 0; i < m_children.size(); i++)
- {
- if (m_children[i]->GetControlType() == CGUIControl::GUICONTROL_LISTLABEL && m_children[i]->IsVisible())
- {
- for (unsigned int j = i + 1; j < m_children.size(); j++)
- {
- if (m_children[j]->GetControlType() == CGUIControl::GUICONTROL_LISTLABEL && m_children[j]->IsVisible())
- CGUIListLabel::CheckAndCorrectOverlap(*(CGUIListLabel *)m_children[i], *(CGUIListLabel *)m_children[j]);
- }
- }
- }
-}
-
-void CGUIListGroup::SetFocusedItem(unsigned int focus)
-{
- for (iControls it = m_children.begin(); it != m_children.end(); it++)
- {
- if ((*it)->GetControlType() == CGUIControl::GUICONTROL_MULTISELECT)
- ((CGUIMultiSelectTextControl *)(*it))->SetFocusedItem(focus);
- else if ((*it)->GetControlType() == CGUIControl::GUICONTROL_LISTGROUP)
- ((CGUIListGroup *)(*it))->SetFocusedItem(focus);
- else
- (*it)->SetFocus(focus > 0);
- }
- SetFocus(focus > 0);
-}
-
-unsigned int CGUIListGroup::GetFocusedItem() const
-{
- for (ciControls it = m_children.begin(); it != m_children.end(); it++)
- {
- if ((*it)->GetControlType() == CGUIControl::GUICONTROL_MULTISELECT && ((CGUIMultiSelectTextControl *)(*it))->GetFocusedItem())
- return ((CGUIMultiSelectTextControl *)(*it))->GetFocusedItem();
- else if ((*it)->GetControlType() == CGUIControl::GUICONTROL_LISTGROUP && ((CGUIListGroup *)(*it))->GetFocusedItem())
- return ((CGUIListGroup *)(*it))->GetFocusedItem();
- }
- return 0;
-}
-
-bool CGUIListGroup::MoveLeft()
-{
- for (iControls it = m_children.begin(); it != m_children.end(); it++)
- {
- if ((*it)->GetControlType() == CGUIControl::GUICONTROL_MULTISELECT && ((CGUIMultiSelectTextControl *)(*it))->MoveLeft())
- return true;
- else if ((*it)->GetControlType() == CGUIControl::GUICONTROL_LISTGROUP && ((CGUIListGroup *)(*it))->MoveLeft())
- return true;
- }
- return false;
-}
-
-bool CGUIListGroup::MoveRight()
-{
- for (iControls it = m_children.begin(); it != m_children.end(); it++)
- {
- if ((*it)->GetControlType() == CGUIControl::GUICONTROL_MULTISELECT && ((CGUIMultiSelectTextControl *)(*it))->MoveLeft())
- return true;
- else if ((*it)->GetControlType() == CGUIControl::GUICONTROL_LISTGROUP && ((CGUIListGroup *)(*it))->MoveLeft())
- return true;
- }
- return false;
-}
-
-void CGUIListGroup::SetState(bool selected, bool focused)
-{
- for (iControls it = m_children.begin(); it != m_children.end(); it++)
- {
- if ((*it)->GetControlType() == CGUIControl::GUICONTROL_LISTLABEL)
- {
- CGUIListLabel *label = (CGUIListLabel *)(*it);
- label->SetSelected(selected);
- label->SetScrolling(focused);
- }
- }
-}
-
-void CGUIListGroup::SelectItemFromPoint(const CPoint &point)
-{
- CPoint controlCoords(point);
- m_transform.InverseTransformPosition(controlCoords.x, controlCoords.y);
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- CGUIControl *child = *it;
- if (child->GetControlType() == CGUIControl::GUICONTROL_MULTISELECT)
- ((CGUIMultiSelectTextControl *)child)->SelectItemFromPoint(point);
- else if (child->GetControlType() == CGUIControl::GUICONTROL_LISTGROUP)
- ((CGUIListGroup *)child)->SelectItemFromPoint(point);
- }
-}
diff --git a/guilib/GUIListGroup.h b/guilib/GUIListGroup.h
deleted file mode 100644
index 241ca229f4..0000000000
--- a/guilib/GUIListGroup.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*!
-\file GUIListGroup.h
-\brief
-*/
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIControlGroup.h"
-
-/*!
- \ingroup controls
- \brief a group of controls within a list/panel container
- */
-class CGUIListGroup : public CGUIControlGroup
-{
-public:
- CGUIListGroup(int parentID, int controlID, float posX, float posY, float width, float height);
- CGUIListGroup(const CGUIListGroup &right);
- virtual ~CGUIListGroup(void);
- virtual CGUIListGroup *Clone() const { return new CGUIListGroup(*this); };
-
- virtual void AddControl(CGUIControl *control, int position = -1);
-
- virtual void Render();
- virtual void ResetAnimation(ANIMATION_TYPE type);
- virtual void UpdateVisibility(const CGUIListItem *item = NULL);
- virtual void UpdateInfo(const CGUIListItem *item);
-
- void SetFocusedItem(unsigned int subfocus);
- unsigned int GetFocusedItem() const;
- bool MoveLeft();
- bool MoveRight();
- void SetState(bool selected, bool focused);
- void SelectItemFromPoint(const CPoint &point);
-
-protected:
- const CGUIListItem *m_item;
-};
-
diff --git a/guilib/GUIListItem.cpp b/guilib/GUIListItem.cpp
deleted file mode 100644
index ec3b627bbf..0000000000
--- a/guilib/GUIListItem.cpp
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIListItem.h"
-#include "GUIListItemLayout.h"
-#include "utils/Archive.h"
-#include "utils/CharsetConverter.h"
-#include "utils/Variant.h"
-
-CGUIListItem::CGUIListItem(const CGUIListItem& item)
-{
- m_layout = NULL;
- m_focusedLayout = NULL;
- *this = item;
- SetInvalid();
-}
-
-CGUIListItem::CGUIListItem(void)
-{
- m_bIsFolder = false;
- m_strLabel2 = "";
- m_strLabel = "";
- m_bSelected = false;
- m_strIcon = "";
- m_strThumbnailImage = "";
- m_overlayIcon = ICON_OVERLAY_NONE;
- m_layout = NULL;
- m_focusedLayout = NULL;
-}
-
-CGUIListItem::CGUIListItem(const CStdString& strLabel)
-{
- m_bIsFolder = false;
- m_strLabel2 = "";
- m_strLabel = strLabel;
- SetSortLabel(strLabel);
- m_bSelected = false;
- m_strIcon = "";
- m_strThumbnailImage = "";
- m_overlayIcon = ICON_OVERLAY_NONE;
- m_layout = NULL;
- m_focusedLayout = NULL;
-}
-
-CGUIListItem::~CGUIListItem(void)
-{
- FreeMemory();
-}
-
-void CGUIListItem::SetLabel(const CStdString& strLabel)
-{
- if (m_strLabel == strLabel)
- return;
- m_strLabel = strLabel;
- if (m_sortLabel.IsEmpty())
- SetSortLabel(strLabel);
- SetInvalid();
-}
-
-const CStdString& CGUIListItem::GetLabel() const
-{
- return m_strLabel;
-}
-
-
-void CGUIListItem::SetLabel2(const CStdString& strLabel2)
-{
- if (m_strLabel2 == strLabel2)
- return;
- m_strLabel2 = strLabel2;
- SetInvalid();
-}
-
-const CStdString& CGUIListItem::GetLabel2() const
-{
- return m_strLabel2;
-}
-
-void CGUIListItem::SetSortLabel(const CStdString &label)
-{
- g_charsetConverter.utf8ToW(label, m_sortLabel);
- // no need to invalidate - this is never shown in the UI
-}
-
-const CStdStringW& CGUIListItem::GetSortLabel() const
-{
- return m_sortLabel;
-}
-
-void CGUIListItem::SetThumbnailImage(const CStdString& strThumbnail)
-{
- if (m_strThumbnailImage == strThumbnail)
- return;
- m_strThumbnailImage = strThumbnail;
- SetInvalid();
-}
-
-const CStdString& CGUIListItem::GetThumbnailImage() const
-{
- return m_strThumbnailImage;
-}
-
-void CGUIListItem::SetIconImage(const CStdString& strIcon)
-{
- if (m_strIcon == strIcon)
- return;
- m_strIcon = strIcon;
- SetInvalid();
-}
-
-const CStdString& CGUIListItem::GetIconImage() const
-{
- return m_strIcon;
-}
-
-void CGUIListItem::SetOverlayImage(GUIIconOverlay icon, bool bOnOff)
-{
- GUIIconOverlay newIcon = (bOnOff) ? GUIIconOverlay((int)(icon)+1) : icon;
- if (m_overlayIcon == newIcon)
- return;
- m_overlayIcon = newIcon;
- SetInvalid();
-}
-
-CStdString CGUIListItem::GetOverlayImage() const
-{
- switch (m_overlayIcon)
- {
- case ICON_OVERLAY_RAR:
- return "OverlayRAR.png";
- case ICON_OVERLAY_ZIP:
- return "OverlayZIP.png";
- case ICON_OVERLAY_TRAINED:
- return "OverlayTrained.png";
- case ICON_OVERLAY_HAS_TRAINER:
- return "OverlayHasTrainer.png";
- case ICON_OVERLAY_LOCKED:
- return "OverlayLocked.png";
- case ICON_OVERLAY_UNWATCHED:
- return "OverlayUnwatched.png";
- case ICON_OVERLAY_WATCHED:
- return "OverlayWatched.png";
- case ICON_OVERLAY_HD:
- return "OverlayHD.png";
- default:
- return "";
- }
-}
-
-void CGUIListItem::Select(bool bOnOff)
-{
- m_bSelected = bOnOff;
-}
-
-bool CGUIListItem::HasIcon() const
-{
- return (m_strIcon.size() != 0);
-}
-
-
-bool CGUIListItem::HasThumbnail() const
-{
- return (m_strThumbnailImage.size() != 0);
-}
-
-bool CGUIListItem::HasOverlay() const
-{
- return (m_overlayIcon != CGUIListItem::ICON_OVERLAY_NONE);
-}
-
-bool CGUIListItem::IsSelected() const
-{
- return m_bSelected;
-}
-
-const CGUIListItem& CGUIListItem::operator =(const CGUIListItem& item)
-{
- if (&item == this) return * this;
- m_strLabel2 = item.m_strLabel2;
- m_strLabel = item.m_strLabel;
- m_sortLabel = item.m_sortLabel;
- FreeMemory();
- m_bSelected = item.m_bSelected;
- m_strIcon = item.m_strIcon;
- m_strThumbnailImage = item.m_strThumbnailImage;
- m_overlayIcon = item.m_overlayIcon;
- m_bIsFolder = item.m_bIsFolder;
- m_mapProperties = item.m_mapProperties;
- SetInvalid();
- return *this;
-}
-
-void CGUIListItem::Archive(CArchive &ar)
-{
- if (ar.IsStoring())
- {
- ar << m_bIsFolder;
- ar << m_strLabel;
- ar << m_strLabel2;
- ar << m_sortLabel;
- ar << m_strThumbnailImage;
- ar << m_strIcon;
- ar << m_bSelected;
- ar << m_overlayIcon;
- ar << (int)m_mapProperties.size();
- for (std::map<CStdString, CStdString, icompare>::const_iterator it = m_mapProperties.begin(); it != m_mapProperties.end(); it++)
- {
- ar << it->first;
- ar << it->second;
- }
- }
- else
- {
- ar >> m_bIsFolder;
- ar >> m_strLabel;
- ar >> m_strLabel2;
- ar >> m_sortLabel;
- ar >> m_strThumbnailImage;
- ar >> m_strIcon;
- ar >> m_bSelected;
-
- int overlayIcon;
- ar >> overlayIcon;
- m_overlayIcon = GUIIconOverlay(overlayIcon);
-
- int mapSize;
- ar >> mapSize;
- for (int i = 0; i < mapSize; i++)
- {
- CStdString key, value;
- ar >> key;
- ar >> value;
- SetProperty(key, value);
- }
- }
-}
-void CGUIListItem::Serialize(CVariant &value)
-{
- value["isFolder"] = m_bIsFolder;
- value["strLabel"] = m_strLabel;
- value["strLabel2"] = m_strLabel2;
- value["sortLabel"] = CStdString(m_sortLabel);
- value["strThumbnailImage"] = m_strThumbnailImage;
- value["strIcon"] = m_strIcon;
- value["selected"] = m_bSelected;
-
- for (std::map<CStdString, CStdString, icompare>::const_iterator it = m_mapProperties.begin(); it != m_mapProperties.end(); it++)
- {
- value["properties"][it->first] = it->second;
- }
-}
-
-void CGUIListItem::FreeIcons()
-{
- FreeMemory();
- m_strThumbnailImage = "";
- m_strIcon = "";
- SetInvalid();
-}
-
-void CGUIListItem::FreeMemory(bool immediately)
-{
- if (m_layout)
- {
- m_layout->FreeResources(immediately);
- delete m_layout;
- m_layout = NULL;
- }
- if (m_focusedLayout)
- {
- m_focusedLayout->FreeResources(immediately);
- delete m_focusedLayout;
- m_focusedLayout = NULL;
- }
-}
-
-void CGUIListItem::SetLayout(CGUIListItemLayout *layout)
-{
- delete m_layout;
- m_layout = layout;
-}
-
-CGUIListItemLayout *CGUIListItem::GetLayout()
-{
- return m_layout;
-}
-
-void CGUIListItem::SetFocusedLayout(CGUIListItemLayout *layout)
-{
- delete m_focusedLayout;
- m_focusedLayout = layout;
-}
-
-CGUIListItemLayout *CGUIListItem::GetFocusedLayout()
-{
- return m_focusedLayout;
-}
-
-void CGUIListItem::SetInvalid()
-{
- if (m_layout) m_layout->SetInvalid();
- if (m_focusedLayout) m_focusedLayout->SetInvalid();
-}
-
-void CGUIListItem::SetProperty(const CStdString &strKey, const char *strValue)
-{
- m_mapProperties[strKey] = strValue;
-}
-
-void CGUIListItem::SetProperty(const CStdString &strKey, const CStdString &strValue)
-{
- m_mapProperties[strKey] = strValue;
-}
-
-CStdString CGUIListItem::GetProperty(const CStdString &strKey) const
-{
- PropertyMap::const_iterator iter = m_mapProperties.find(strKey);
- if (iter == m_mapProperties.end())
- return "";
-
- return iter->second;
-}
-
-bool CGUIListItem::HasProperty(const CStdString &strKey) const
-{
- PropertyMap::const_iterator iter = m_mapProperties.find(strKey);
- if (iter == m_mapProperties.end())
- return false;
-
- return true;
-}
-
-void CGUIListItem::ClearProperty(const CStdString &strKey)
-{
- PropertyMap::iterator iter = m_mapProperties.find(strKey);
- if (iter != m_mapProperties.end())
- m_mapProperties.erase(iter);
-}
-
-void CGUIListItem::ClearProperties()
-{
- m_mapProperties.clear();
-}
-
-void CGUIListItem::SetProperty(const CStdString &strKey, int nVal)
-{
- CStdString strVal;
- strVal.Format("%d",nVal);
- SetProperty(strKey, strVal);
-}
-
-void CGUIListItem::IncrementProperty(const CStdString &strKey, int nVal)
-{
- int i = GetPropertyInt(strKey);
- i += nVal;
- SetProperty(strKey, i);
-}
-
-void CGUIListItem::SetProperty(const CStdString &strKey, bool bVal)
-{
- SetProperty(strKey, bVal?"1":"0");
-}
-
-void CGUIListItem::SetProperty(const CStdString &strKey, double dVal)
-{
- CStdString strVal;
- strVal.Format("%f",dVal);
- SetProperty(strKey, strVal);
-}
-
-void CGUIListItem::IncrementProperty(const CStdString &strKey, double dVal)
-{
- double d = GetPropertyDouble(strKey);
- d += dVal;
- SetProperty(strKey, d);
-}
-
-bool CGUIListItem::GetPropertyBOOL(const CStdString &strKey) const
-{
- return GetProperty(strKey) == "1";
-}
-
-int CGUIListItem::GetPropertyInt(const CStdString &strKey) const
-{
- return atoi(GetProperty(strKey).c_str()) ;
-}
-
-double CGUIListItem::GetPropertyDouble(const CStdString &strKey) const
-{
- return atof(GetProperty(strKey).c_str()) ;
-}
-
-
diff --git a/guilib/GUIListItem.h b/guilib/GUIListItem.h
deleted file mode 100644
index 0f55357e9c..0000000000
--- a/guilib/GUIListItem.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/*!
-\file GUIListItem.h
-\brief
-*/
-
-#ifndef GUILIB_GUILISTITEM_H
-#define GUILIB_GUILISTITEM_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "StdString.h"
-
-#include <map>
-#include <string>
-
-// Forward
-class CGUIListItemLayout;
-class CArchive;
-class CVariant;
-
-/*!
- \ingroup controls
- \brief
- */
-class CGUIListItem
-{
-public:
- enum GUIIconOverlay { ICON_OVERLAY_NONE = 0,
- ICON_OVERLAY_RAR,
- ICON_OVERLAY_ZIP,
- ICON_OVERLAY_LOCKED,
- ICON_OVERLAY_HAS_TRAINER,
- ICON_OVERLAY_TRAINED,
- ICON_OVERLAY_UNWATCHED,
- ICON_OVERLAY_WATCHED,
- ICON_OVERLAY_HD};
-
- CGUIListItem(void);
- CGUIListItem(const CGUIListItem& item);
- CGUIListItem(const CStdString& strLabel);
- virtual ~CGUIListItem(void);
- virtual CGUIListItem *Clone() const { return new CGUIListItem(*this); };
-
- const CGUIListItem& operator =(const CGUIListItem& item);
-
- virtual void SetLabel(const CStdString& strLabel);
- const CStdString& GetLabel() const;
-
- void SetLabel2(const CStdString& strLabel);
- const CStdString& GetLabel2() const;
-
- void SetIconImage(const CStdString& strIcon);
- const CStdString& GetIconImage() const;
-
- void SetThumbnailImage(const CStdString& strThumbnail);
- const CStdString& GetThumbnailImage() const;
-
- void SetOverlayImage(GUIIconOverlay icon, bool bOnOff=false);
- CStdString GetOverlayImage() const;
-
- void SetSortLabel(const CStdString &label);
- const CStdStringW &GetSortLabel() const;
-
- void Select(bool bOnOff);
- bool IsSelected() const;
-
- bool HasIcon() const;
- bool HasThumbnail() const;
- bool HasOverlay() const;
- virtual bool IsFileItem() const { return false; };
-
- void SetLayout(CGUIListItemLayout *layout);
- CGUIListItemLayout *GetLayout();
-
- void SetFocusedLayout(CGUIListItemLayout *layout);
- CGUIListItemLayout *GetFocusedLayout();
-
- void FreeIcons();
- void FreeMemory(bool immediately = false);
- void SetInvalid();
-
- bool m_bIsFolder; ///< is item a folder or a file
-
- void SetProperty(const CStdString &strKey, const char *strValue);
- void SetProperty(const CStdString &strKey, const CStdString &strValue);
- void SetProperty(const CStdString &strKey, int nVal);
- void SetProperty(const CStdString &strKey, bool bVal);
- void SetProperty(const CStdString &strKey, double dVal);
-
- void IncrementProperty(const CStdString &strKey, int nVal);
- void IncrementProperty(const CStdString &strKey, double dVal);
-
- void ClearProperties();
-
- void Archive(CArchive& ar);
- void Serialize(CVariant& value);
-
- bool HasProperty(const CStdString &strKey) const;
- bool HasProperties() const { return m_mapProperties.size() > 0; };
- void ClearProperty(const CStdString &strKey);
-
- CStdString GetProperty(const CStdString &strKey) const;
- bool GetPropertyBOOL(const CStdString &strKey) const;
- int GetPropertyInt(const CStdString &strKey) const;
- double GetPropertyDouble(const CStdString &strKey) const;
-
-protected:
- CStdString m_strLabel2; // text of column2
- CStdString m_strThumbnailImage; // filename of thumbnail
- CStdString m_strIcon; // filename of icon
- GUIIconOverlay m_overlayIcon; // type of overlay icon
-
- CGUIListItemLayout *m_layout;
- CGUIListItemLayout *m_focusedLayout;
- bool m_bSelected; // item is selected or not
-
- struct icompare
- {
- bool operator()(const CStdString &s1, const CStdString &s2) const
- {
- return s1.CompareNoCase(s2) < 0;
- }
- };
-
- typedef std::map<CStdString, CStdString, icompare> PropertyMap;
- PropertyMap m_mapProperties;
-private:
- CStdStringW m_sortLabel; // text for sorting. Need to be UTF16 for proper sorting
- CStdString m_strLabel; // text of column1
-};
-#endif
-
diff --git a/guilib/GUIListItemLayout.cpp b/guilib/GUIListItemLayout.cpp
deleted file mode 100644
index ac44392996..0000000000
--- a/guilib/GUIListItemLayout.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIListItemLayout.h"
-#include "FileItem.h"
-#include "GUIControlFactory.h"
-#include "utils/GUIInfoManager.h"
-#include "GUIListLabel.h"
-#include "GUIImage.h"
-#include "tinyXML/tinyxml.h"
-
-using namespace std;
-
-CGUIListItemLayout::CGUIListItemLayout()
-: m_group(0, 0, 0, 0, 0, 0)
-{
- m_width = 0;
- m_height = 0;
- m_condition = 0;
- m_focused = false;
- m_invalidated = true;
- m_isPlaying = false;
- m_group.SetPushUpdates(true);
-}
-
-CGUIListItemLayout::CGUIListItemLayout(const CGUIListItemLayout &from)
-: m_group(from.m_group)
-{
- m_width = from.m_width;
- m_height = from.m_height;
- m_focused = from.m_focused;
- m_condition = from.m_condition;
- m_invalidated = true;
- m_isPlaying = false;
-}
-
-CGUIListItemLayout::~CGUIListItemLayout()
-{
-}
-
-bool CGUIListItemLayout::IsAnimating(ANIMATION_TYPE animType)
-{
- return m_group.IsAnimating(animType);
-}
-
-void CGUIListItemLayout::ResetAnimation(ANIMATION_TYPE animType)
-{
- return m_group.ResetAnimation(animType);
-}
-
-float CGUIListItemLayout::Size(ORIENTATION orientation) const
-{
- return (orientation == HORIZONTAL) ? m_width : m_height;
-}
-
-void CGUIListItemLayout::Render(CGUIListItem *item, int parentID, unsigned int time)
-{
- if (m_invalidated)
- { // need to update our item
- // could use a dynamic cast here if RTTI was enabled. As it's not,
- // let's use a static cast with a virtual base function
- CFileItem *fileItem = item->IsFileItem() ? (CFileItem *)item : new CFileItem(*item);
- m_isPlaying = g_infoManager.GetBool(LISTITEM_ISPLAYING, parentID, item);
- m_group.SetInvalid();
- m_group.UpdateInfo(fileItem);
- m_invalidated = false;
- // delete our temporary fileitem
- if (!item->IsFileItem())
- delete fileItem;
- }
-
- // update visibility, and render
- m_group.SetState(item->IsSelected() || m_isPlaying, m_focused);
- m_group.UpdateVisibility(item);
- m_group.DoRender(time);
-}
-
-void CGUIListItemLayout::SetFocusedItem(unsigned int focus)
-{
- m_group.SetFocusedItem(focus);
-}
-
-unsigned int CGUIListItemLayout::GetFocusedItem() const
-{
- return m_group.GetFocusedItem();
-}
-
-void CGUIListItemLayout::SelectItemFromPoint(const CPoint &point)
-{
- m_group.SelectItemFromPoint(point);
-}
-
-bool CGUIListItemLayout::MoveLeft()
-{
- return m_group.MoveLeft();
-}
-
-bool CGUIListItemLayout::MoveRight()
-{
- return m_group.MoveRight();
-}
-
-void CGUIListItemLayout::LoadControl(TiXmlElement *child, CGUIControlGroup *group)
-{
- if (!group) return;
-
- CRect rect(group->GetXPosition(), group->GetYPosition(), group->GetXPosition() + group->GetWidth(), group->GetYPosition() + group->GetHeight());
-
- CGUIControlFactory factory;
- CGUIControl *control = factory.Create(0, rect, child, true); // true indicating we're inside a list for the
- // different label control + defaults.
- if (control)
- {
- group->AddControl(control);
- if (control->IsGroup())
- {
- TiXmlElement *grandChild = child->FirstChildElement("control");
- while (grandChild)
- {
- LoadControl(grandChild, (CGUIControlGroup *)control);
- grandChild = grandChild->NextSiblingElement("control");
- }
- }
- }
-}
-
-void CGUIListItemLayout::LoadLayout(TiXmlElement *layout, bool focused)
-{
- m_focused = focused;
- layout->QueryFloatAttribute("width", &m_width);
- layout->QueryFloatAttribute("height", &m_height);
- const char *condition = layout->Attribute("condition");
- if (condition)
- m_condition = g_infoManager.TranslateString(condition);
- TiXmlElement *child = layout->FirstChildElement("control");
- m_group.SetWidth(m_width);
- m_group.SetHeight(m_height);
- while (child)
- {
- LoadControl(child, &m_group);
- child = child->NextSiblingElement("control");
- }
- // ensure width and height are valid
- m_width = std::max(1.0f, m_width);
- m_height = std::max(1.0f, m_height);
-}
-
-//#ifdef PRE_SKIN_VERSION_9_10_COMPATIBILITY
-void CGUIListItemLayout::CreateListControlLayouts(float width, float height, bool focused, const CLabelInfo &labelInfo, const CLabelInfo &labelInfo2, const CTextureInfo &texture, const CTextureInfo &textureFocus, float texHeight, float iconWidth, float iconHeight, int nofocusCondition, int focusCondition)
-{
- m_width = width;
- m_height = height;
- m_focused = focused;
- CGUIImage *tex = new CGUIImage(0, 0, 0, 0, width, texHeight, texture);
- tex->SetVisibleCondition(nofocusCondition, false);
- m_group.AddControl(tex);
- if (focused)
- {
- CGUIImage *tex = new CGUIImage(0, 0, 0, 0, width, texHeight, textureFocus);
- tex->SetVisibleCondition(focusCondition, false);
- m_group.AddControl(tex);
- }
- CGUIImage *image = new CGUIImage(0, 0, 8, 0, iconWidth, texHeight, CTextureInfo(""));
- image->SetInfo(CGUIInfoLabel("$INFO[ListItem.Icon]"));
- image->SetAspectRatio(CAspectRatio::AR_KEEP);
- m_group.AddControl(image);
- float x = iconWidth + labelInfo.offsetX + 10;
- CGUIListLabel *label = new CGUIListLabel(0, 0, x, labelInfo.offsetY, width - x - 18, height, labelInfo, CGUIInfoLabel("$INFO[ListItem.Label]"), false);
- m_group.AddControl(label);
- x = labelInfo2.offsetX ? labelInfo2.offsetX : m_width - 16;
- label = new CGUIListLabel(0, 0, x, labelInfo2.offsetY, x - iconWidth - 20, height, labelInfo2, CGUIInfoLabel("$INFO[ListItem.Label2]"), false);
- m_group.AddControl(label);
-}
-//#endif
-
-void CGUIListItemLayout::FreeResources(bool immediately)
-{
- m_group.FreeResources(immediately);
-}
-
-#ifdef _DEBUG
-void CGUIListItemLayout::DumpTextureUse()
-{
- m_group.DumpTextureUse();
-}
-#endif
diff --git a/guilib/GUIListItemLayout.h b/guilib/GUIListItemLayout.h
deleted file mode 100644
index e934841425..0000000000
--- a/guilib/GUIListItemLayout.h
+++ /dev/null
@@ -1,73 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIListGroup.h"
-#include "GUITexture.h"
-
-class CGUIListItem;
-class CFileItem;
-class CLabelInfo;
-
-class CGUIListItemLayout
-{
-public:
- CGUIListItemLayout();
- CGUIListItemLayout(const CGUIListItemLayout &from);
- virtual ~CGUIListItemLayout();
- void LoadLayout(TiXmlElement *layout, bool focused);
- void Render(CGUIListItem *item, int parentID, unsigned int time = 0);
- float Size(ORIENTATION orientation) const;
- unsigned int GetFocusedItem() const;
- void SetFocusedItem(unsigned int focus);
- bool IsAnimating(ANIMATION_TYPE animType);
- void ResetAnimation(ANIMATION_TYPE animType);
- void SetInvalid() { m_invalidated = true; };
- void FreeResources(bool immediately = false);
-
-//#ifdef PRE_SKIN_VERSION_9_10_COMPATIBILITY
- void CreateListControlLayouts(float width, float height, bool focused, const CLabelInfo &labelInfo, const CLabelInfo &labelInfo2, const CTextureInfo &texture, const CTextureInfo &textureFocus, float texHeight, float iconWidth, float iconHeight, int nofocusCondition, int focusCondition);
-//#endif
-
- void SelectItemFromPoint(const CPoint &point);
- bool MoveLeft();
- bool MoveRight();
-
- int GetCondition() const { return m_condition; };
-#ifdef _DEBUG
- virtual void DumpTextureUse();
-#endif
-protected:
- void LoadControl(TiXmlElement *child, CGUIControlGroup *group);
- void Update(CFileItem *item);
-
- CGUIListGroup m_group;
-
- float m_width;
- float m_height;
- bool m_focused;
- bool m_invalidated;
-
- int m_condition;
- bool m_isPlaying;
-};
-
diff --git a/guilib/GUIListLabel.cpp b/guilib/GUIListLabel.cpp
deleted file mode 100644
index 28439cf58e..0000000000
--- a/guilib/GUIListLabel.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIListLabel.h"
-#include "utils/CharsetConverter.h"
-#include <limits>
-
-CGUIListLabel::CGUIListLabel(int parentID, int controlID, float posX, float posY, float width, float height, const CLabelInfo& labelInfo, const CGUIInfoLabel &info, bool alwaysScroll)
- : CGUIControl(parentID, controlID, posX, posY, width, height)
- , m_label(posX, posY, width, height, labelInfo, alwaysScroll ? CGUILabel::OVER_FLOW_SCROLL : CGUILabel::OVER_FLOW_TRUNCATE)
-{
- m_info = info;
- m_alwaysScroll = alwaysScroll;
- // TODO: Remove this "correction"
- if (labelInfo.align & XBFONT_RIGHT)
- m_label.SetMaxRect(m_posX - m_width, m_posY, m_width, m_height);
- else if (labelInfo.align & XBFONT_CENTER_X)
- m_label.SetMaxRect(m_posX - m_width*0.5f, m_posY, m_width, m_height);
- if (m_info.IsConstant())
- SetLabel(m_info.GetLabel(m_parentID, true));
- ControlType = GUICONTROL_LISTLABEL;
-}
-
-CGUIListLabel::~CGUIListLabel(void)
-{
-}
-
-void CGUIListLabel::SetScrolling(bool scrolling)
-{
- m_label.SetScrolling(scrolling || m_alwaysScroll);
-}
-
-void CGUIListLabel::SetSelected(bool selected)
-{
- m_label.SetColor(selected ? CGUILabel::COLOR_SELECTED : CGUILabel::COLOR_TEXT);
-}
-
-void CGUIListLabel::SetFocus(bool focus)
-{
- CGUIControl::SetFocus(focus);
- if (!focus)
- SetScrolling(false);
-}
-
-void CGUIListLabel::UpdateColors()
-{
- m_label.UpdateColors();
- CGUIControl::UpdateColors();
-}
-
-void CGUIListLabel::Render()
-{
- m_label.Render();
- CGUIControl::Render();
-}
-
-void CGUIListLabel::UpdateInfo(const CGUIListItem *item)
-{
- if (m_info.IsConstant() && !m_bInvalidated)
- return; // nothing to do
-
- if (item)
- SetLabel(m_info.GetItemLabel(item));
- else
- SetLabel(m_info.GetLabel(m_parentID, true));
-}
-
-void CGUIListLabel::SetInvalid()
-{
- m_label.SetInvalid();
- CGUIControl::SetInvalid();
-}
-
-void CGUIListLabel::SetLabel(const CStdString &label)
-{
- m_label.SetText(label);
-}
diff --git a/guilib/GUIListLabel.h b/guilib/GUIListLabel.h
deleted file mode 100644
index 5c82fe196e..0000000000
--- a/guilib/GUIListLabel.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*!
-\file GUIListLabel.h
-\brief
-*/
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIControl.h"
-#include "GUILabel.h"
-
-/*!
- \ingroup controls
- \brief
- */
-class CGUIListLabel :
- public CGUIControl
-{
-public:
- CGUIListLabel(int parentID, int controlID, float posX, float posY, float width, float height, const CLabelInfo& labelInfo, const CGUIInfoLabel &label, bool alwaysScroll);
- virtual ~CGUIListLabel(void);
- virtual CGUIListLabel *Clone() const { return new CGUIListLabel(*this); };
-
- virtual void Render();
- virtual bool CanFocus() const { return false; };
- virtual void UpdateInfo(const CGUIListItem *item = NULL);
- virtual void SetFocus(bool focus);
- virtual void SetInvalid();
-
- void SetLabel(const CStdString &label);
- void SetSelected(bool selected);
- void SetScrolling(bool scrolling);
-
- static void CheckAndCorrectOverlap(CGUIListLabel &label1, CGUIListLabel &label2)
- {
- CGUILabel::CheckAndCorrectOverlap(label1.m_label, label2.m_label);
- }
-
-protected:
- virtual void UpdateColors();
-
- CGUILabel m_label;
- CGUIInfoLabel m_info;
- bool m_alwaysScroll;
-};
diff --git a/guilib/GUIMessage.cpp b/guilib/GUIMessage.cpp
deleted file mode 100644
index 437aa9ff4f..0000000000
--- a/guilib/GUIMessage.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIMessage.h"
-#include "LocalizeStrings.h"
-
-using namespace std;
-
-CStdString CGUIMessage::empty_string;
-
-CGUIMessage::CGUIMessage(int msg, int senderID, int controlID, int param1, int param2)
-{
- m_message = msg;
- m_senderID = senderID;
- m_controlID = controlID;
- m_param1 = param1;
- m_param2 = param2;
- m_pointer = NULL;
-}
-
-CGUIMessage::CGUIMessage(int msg, int senderID, int controlID, int param1, int param2, CFileItemList *item)
-{
- m_message = msg;
- m_senderID = senderID;
- m_controlID = controlID;
- m_param1 = param1;
- m_param2 = param2;
- m_pointer = item;
-}
-
-CGUIMessage::CGUIMessage(int msg, int senderID, int controlID, int param1, int param2, const CGUIListItemPtr &item)
-{
- m_message = msg;
- m_senderID = senderID;
- m_controlID = controlID;
- m_param1 = param1;
- m_param2 = param2;
- m_pointer = NULL;
- m_item = item;
-}
-
-CGUIMessage::CGUIMessage(const CGUIMessage& msg)
-{
- *this = msg;
-}
-
-CGUIMessage::~CGUIMessage(void)
-{}
-
-
-int CGUIMessage::GetControlId() const
-{
- return m_controlID;
-}
-
-int CGUIMessage::GetMessage() const
-{
- return m_message;
-}
-
-void* CGUIMessage::GetPointer() const
-{
- return m_pointer;
-}
-
-CGUIListItemPtr CGUIMessage::GetItem() const
-{
- return m_item;
-}
-
-int CGUIMessage::GetParam1() const
-{
- return m_param1;
-}
-
-int CGUIMessage::GetParam2() const
-{
- return m_param2;
-}
-
-int CGUIMessage::GetSenderId() const
-{
- return m_senderID;
-}
-
-
-const CGUIMessage& CGUIMessage::operator = (const CGUIMessage& msg)
-{
- if (this == &msg) return * this;
-
- m_message = msg.m_message;
- m_controlID = msg.m_controlID;
- m_param1 = msg.m_param1;
- m_param2 = msg.m_param2;
- m_pointer = msg.m_pointer;
- m_strLabel = msg.m_strLabel;
- m_senderID = msg.m_senderID;
- m_params = msg.m_params;
- m_item = msg.m_item;
- m_action = msg.m_action;
- return *this;
-}
-
-
-void CGUIMessage::SetParam1(int param1)
-{
- m_param1 = param1;
-}
-
-void CGUIMessage::SetParam2(int param2)
-{
- m_param2 = param2;
-}
-
-void CGUIMessage::SetPointer(void* lpVoid)
-{
- m_pointer = lpVoid;
-}
-
-void CGUIMessage::SetLabel(const string& strLabel)
-{
- m_strLabel = strLabel;
-}
-
-const string& CGUIMessage::GetLabel() const
-{
- return m_strLabel;
-}
-
-void CGUIMessage::SetLabel(int iString)
-{
- m_strLabel = g_localizeStrings.Get(iString);
-}
-
-void CGUIMessage::SetStringParam(const CStdString& strParam)
-{
- m_params.clear();
- if (strParam.size())
- m_params.push_back(strParam);
-}
-
-void CGUIMessage::SetStringParams(const vector<CStdString> &params)
-{
- m_params = params;
-}
-
-const CStdString& CGUIMessage::GetStringParam(size_t param) const
-{
- if (param >= m_params.size())
- return empty_string;
- return m_params[param];
-}
-
-size_t CGUIMessage::GetNumStringParams() const
-{
- return m_params.size();
-}
-
-void CGUIMessage::SetAction(const CGUIActionDescriptor& action)
-{
- m_action = action;
-}
-
-const CGUIActionDescriptor& CGUIMessage::GetAction() const
-{
- return m_action;
-}
diff --git a/guilib/GUIMessage.h b/guilib/GUIMessage.h
deleted file mode 100644
index 0a76f33a58..0000000000
--- a/guilib/GUIMessage.h
+++ /dev/null
@@ -1,314 +0,0 @@
-/*!
-\file GUIMessage.h
-\brief
-*/
-
-#ifndef GUILIB_MESSAGE_H
-#define GUILIB_MESSAGE_H
-
-#include "GUIActionDescriptor.h"
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#define GUI_MSG_WINDOW_INIT 1 // initialize window
-#define GUI_MSG_WINDOW_DEINIT 2 // deinit window
-#define GUI_MSG_WINDOW_RESET 27 // reset window to initial state
-
-#define GUI_MSG_SETFOCUS 3 // set focus to control param1=up/down/left/right
-#define GUI_MSG_LOSTFOCUS 4 // control lost focus
-
-#define GUI_MSG_CLICKED 5 // control has been clicked
-
-#define GUI_MSG_VISIBLE 6 // set control visible
-#define GUI_MSG_HIDDEN 7 // set control hidden
-
-#define GUI_MSG_ENABLED 8 // enable control
-#define GUI_MSG_DISABLED 9 // disable control
-
-#define GUI_MSG_SELECTED 10 // control = selected
-#define GUI_MSG_DESELECTED 11 // control = not selected
-
-#define GUI_MSG_LABEL_ADD 12 // add label control (for controls supporting more then 1 label)
-
-#define GUI_MSG_LABEL_SET 13 // set the label of a control
-
-#define GUI_MSG_LABEL_RESET 14 // clear all labels of a control // add label control (for controls supporting more then 1 label)
-
-#define GUI_MSG_ITEM_SELECTED 15 // ask control 2 return the selected item
-#define GUI_MSG_ITEM_SELECT 16 // ask control 2 select a specific item
-#define GUI_MSG_LABEL2_SET 17
-#define GUI_MSG_SHOWRANGE 18
-
-#define GUI_MSG_FULLSCREEN 19 // should go to fullscreen window (vis or video)
-#define GUI_MSG_EXECUTE 20 // user has clicked on a button with <execute> tag
-
-#define GUI_MSG_NOTIFY_ALL 21 // message will be send to all active and inactive(!) windows, all active modal and modeless dialogs
- // dwParam1 must contain an additional message the windows should react on
-
-#define GUI_MSG_REFRESH_THUMBS 22 // message is sent to all windows to refresh all thumbs
-
-#define GUI_MSG_MOVE 23 // message is sent to the window from the base control class when it's
- // been asked to move. dwParam1 contains direction.
-
-#define GUI_MSG_LABEL_BIND 24 // bind label control (for controls supporting more then 1 label)
-
-#define GUI_MSG_SELCHANGED 25 // selection within the control has changed
-
-#define GUI_MSG_FOCUSED 26 // a control has become focused
-
-#define GUI_MSG_PAGE_CHANGE 28 // a page control has changed the page number
-
-#define GUI_MSG_REFRESH_LIST 29 // message sent to all listing controls telling them to refresh their item layouts
-
-#define GUI_MSG_PAGE_UP 30 // page up
-#define GUI_MSG_PAGE_DOWN 31 // page down
-#define GUI_MSG_MOVE_OFFSET 32 // Instruct the contorl to MoveUp or MoveDown by offset amount
-
-#define GUI_MSG_SET_TYPE 33 ///< Instruct a control to set it's type appropriately
-
-/*!
- \brief Message indicating the window has been resized
- Any controls that keep stored sizing information based on aspect ratio or window size should
- recalculate sizing information
- */
-#define GUI_MSG_WINDOW_RESIZE 34
-
-/*!
- \brief Message indicating loss of renderer, prior to reset
- Any controls that keep shared resources should free them on receipt of this message, as the renderer
- is about to be reset.
- */
-#define GUI_MSG_RENDERER_LOST 35
-
-/*!
- \brief Message indicating regain of renderer, after reset
- Any controls that keep shared resources may reallocate them now that the renderer is back
- */
-#define GUI_MSG_RENDERER_RESET 36
-
-/*!
- \brief A control wishes to have (or release) exclusive access to mouse actions
- */
-#define GUI_MSG_EXCLUSIVE_MOUSE 37
-
-/*!
- \brief A request for supported gestures is made
- */
-#define GUI_MSG_GESTURE_NOTIFY 38
-
-#define GUI_MSG_USER 1000
-
-/*!
- \ingroup winmsg
- \brief
- */
-#define CONTROL_SELECT(controlID) \
-do { \
- CGUIMessage msg(GUI_MSG_SELECTED, GetID(), controlID); \
- OnMessage(msg); \
-} while(0)
-
-/*!
- \ingroup winmsg
- \brief
- */
-#define CONTROL_DESELECT(controlID) \
-do { \
- CGUIMessage msg(GUI_MSG_DESELECTED, GetID(), controlID); \
- OnMessage(msg); \
-} while(0)
-
-
-/*!
- \ingroup winmsg
- \brief
- */
-#define CONTROL_ENABLE(controlID) \
-do { \
- CGUIMessage msg(GUI_MSG_ENABLED, GetID(), controlID); \
- OnMessage(msg); \
-} while(0)
-
-/*!
- \ingroup winmsg
- \brief
- */
-#define CONTROL_DISABLE(controlID) \
-do { \
- CGUIMessage msg(GUI_MSG_DISABLED, GetID(), controlID); \
- OnMessage(msg); \
-} while(0)
-
-
-/*!
- \ingroup winmsg
- \brief
- */
-#define CONTROL_ENABLE_ON_CONDITION(controlID, bCondition) \
-do { \
- CGUIMessage msg(bCondition ? GUI_MSG_ENABLED:GUI_MSG_DISABLED, GetID(), controlID); \
- OnMessage(msg); \
-} while(0)
-
-
-/*!
- \ingroup winmsg
- \brief
- */
-#define CONTROL_SELECT_ITEM(controlID,iItem) \
-do { \
- CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), controlID,iItem); \
- OnMessage(msg); \
-} while(0)
-
-/*!
- \ingroup winmsg
- \brief Set the label of the current control
- */
-#define SET_CONTROL_LABEL(controlID,label) \
-do { \
- CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), controlID); \
- msg.SetLabel(label); \
- OnMessage(msg); \
-} while(0)
-
-/*!
- \ingroup winmsg
- \brief Set the second label of the current control
- */
-#define SET_CONTROL_LABEL2(controlID,label) \
-do { \
- CGUIMessage msg(GUI_MSG_LABEL2_SET, GetID(), controlID); \
- msg.SetLabel(label); \
- OnMessage(msg); \
-} while(0)
-
-/*!
- \ingroup winmsg
- \brief
- */
-#define SET_CONTROL_HIDDEN(controlID) \
-do { \
- CGUIMessage msg(GUI_MSG_HIDDEN, GetID(), controlID); \
- OnMessage(msg); \
-} while(0)
-
-/*!
- \ingroup winmsg
- \brief
- */
-#define SET_CONTROL_FOCUS(controlID, dwParam) \
-do { \
- CGUIMessage msg(GUI_MSG_SETFOCUS, GetID(), controlID, dwParam); \
- OnMessage(msg); \
-} while(0)
-
-/*!
- \ingroup winmsg
- \brief
- */
-#define SET_CONTROL_VISIBLE(controlID) \
-do { \
- CGUIMessage msg(GUI_MSG_VISIBLE, GetID(), controlID); \
- OnMessage(msg); \
-} while(0)
-
-#define SET_CONTROL_SELECTED(dwSenderId, controlID, bSelect) \
-do { \
- CGUIMessage msg(bSelect?GUI_MSG_SELECTED:GUI_MSG_DESELECTED, dwSenderId, controlID); \
- OnMessage(msg); \
-} while(0)
-
-#define BIND_CONTROL(i,c,pv) \
-do { \
- pv = ((c*)GetControl(i));\
-} while(0)
-
-/*!
-\ingroup winmsg
-\brief Click message sent from controls to windows.
- */
-#define SEND_CLICK_MESSAGE(id, parentID, action) \
-do { \
- CGUIMessage msg(GUI_MSG_CLICKED, id, parentID, action); \
- SendWindowMessage(msg); \
-} while(0)
-
-#include <vector>
-#include "boost/shared_ptr.hpp"
-#include "StdString.h"
-
-// forwards
-class CGUIListItem; typedef boost::shared_ptr<CGUIListItem> CGUIListItemPtr;
-class CFileItemList;
-
-/*!
- \ingroup winmsg
- \brief
- */
-class CGUIMessage
-{
-public:
- CGUIMessage(int dwMsg, int senderID, int controlID, int param1 = 0, int param2 = 0);
- CGUIMessage(int msg, int senderID, int controlID, int param1, int param2, CFileItemList* item);
- CGUIMessage(int msg, int senderID, int controlID, int param1, int param2, const CGUIListItemPtr &item);
- CGUIMessage(const CGUIMessage& msg);
- virtual ~CGUIMessage(void);
- const CGUIMessage& operator = (const CGUIMessage& msg);
-
- int GetControlId() const ;
- int GetMessage() const;
- void* GetPointer() const;
- CGUIListItemPtr GetItem() const;
- int GetParam1() const;
- int GetParam2() const;
- int GetSenderId() const;
- void SetParam1(int param1);
- void SetParam2(int param2);
- void SetPointer(void* pointer);
- void SetLabel(const std::string& strLabel);
- void SetLabel(int iString); // for convience - looks up in strings.xml
- const std::string& GetLabel() const;
- void SetStringParam(const CStdString &strParam);
- void SetStringParams(const std::vector<CStdString> &params);
- const CStdString& GetStringParam(size_t param = 0) const;
- size_t GetNumStringParams() const;
- void SetAction(const CGUIActionDescriptor& action);
- const CGUIActionDescriptor& GetAction() const;
-
-private:
- std::string m_strLabel;
- std::vector<CStdString> m_params;
- CGUIActionDescriptor m_action;
- int m_senderID;
- int m_controlID;
- int m_message;
- void* m_pointer;
- int m_param1;
- int m_param2;
- CGUIListItemPtr m_item;
-
- static CStdString empty_string;
-};
-#endif
diff --git a/guilib/GUIMoverControl.cpp b/guilib/GUIMoverControl.cpp
deleted file mode 100644
index d9f2465575..0000000000
--- a/guilib/GUIMoverControl.cpp
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIMoverControl.h"
-#include "GUIWindowManager.h"
-#include "Key.h"
-#include "utils/TimeUtils.h"
-
-// time to reset accelerated cursors (digital movement)
-#define MOVE_TIME_OUT 500L
-
-CGUIMoverControl::CGUIMoverControl(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& textureFocus, const CTextureInfo& textureNoFocus)
- : CGUIControl(parentID, controlID, posX, posY, width, height)
- , m_imgFocus(posX, posY, width, height, textureFocus)
- , m_imgNoFocus(posX, posY, width, height, textureNoFocus)
-{
- m_frameCounter = 0;
- m_lastMoveTime = 0;
- m_fSpeed = 1.0;
- m_fAnalogSpeed = 2.0f; // TODO: implement correct analog speed
- m_fAcceleration = 0.2f; // TODO: implement correct computation of acceleration
- m_fMaxSpeed = 10.0; // TODO: implement correct computation of maxspeed
- ControlType = GUICONTROL_MOVER;
- SetLimits(0, 0, 720, 576); // defaults
- SetLocation(0, 0, false); // defaults
-}
-
-CGUIMoverControl::~CGUIMoverControl(void)
-{}
-
-void CGUIMoverControl::Render()
-{
- if (m_bInvalidated)
- {
- m_imgFocus.SetWidth(m_width);
- m_imgFocus.SetHeight(m_height);
-
- m_imgNoFocus.SetWidth(m_width);
- m_imgNoFocus.SetHeight(m_height);
- }
- if (HasFocus())
- {
- unsigned int alphaCounter = m_frameCounter + 2;
- unsigned int alphaChannel;
- if ((alphaCounter % 128) >= 64)
- alphaChannel = alphaCounter % 64;
- else
- alphaChannel = 63 - (alphaCounter % 64);
-
- alphaChannel += 192;
- SetAlpha( (unsigned char)alphaChannel );
- m_imgFocus.SetVisible(true);
- m_imgNoFocus.SetVisible(false);
- m_frameCounter++;
- }
- else
- {
- SetAlpha(0xff);
- m_imgFocus.SetVisible(false);
- m_imgNoFocus.SetVisible(true);
- }
- // render both so the visibility settings cause the frame counter to resetcorrectly
- m_imgFocus.Render();
- m_imgNoFocus.Render();
- CGUIControl::Render();
-}
-
-bool CGUIMoverControl::OnAction(const CAction &action)
-{
- if (action.GetID() == ACTION_SELECT_ITEM)
- {
- // button selected - send message to parent
- CGUIMessage message(GUI_MSG_CLICKED, GetID(), GetParentID());
- SendWindowMessage(message);
- return true;
- }
- if (action.GetID() == ACTION_ANALOG_MOVE)
- {
- // if (m_dwAllowedDirections == ALLOWED_DIRECTIONS_UPDOWN)
- // Move(0, (int)(-m_fAnalogSpeed*action.GetAmount(1)));
- // else if (m_dwAllowedDirections == ALLOWED_DIRECTIONS_LEFTRIGHT)
- // Move((int)(m_fAnalogSpeed*action.GetAmount()), 0);
- // else // ALLOWED_DIRECTIONS_ALL
- Move((int)(m_fAnalogSpeed*action.GetAmount()), (int)( -m_fAnalogSpeed*action.GetAmount(1)));
- return true;
- }
- // base class
- return CGUIControl::OnAction(action);
-}
-
-void CGUIMoverControl::OnUp()
-{
- // if (m_dwAllowedDirections == ALLOWED_DIRECTIONS_LEFTRIGHT) return;
- UpdateSpeed(DIRECTION_UP);
- Move(0, (int) - m_fSpeed);
-}
-
-void CGUIMoverControl::OnDown()
-{
- // if (m_dwAllowedDirections == ALLOWED_DIRECTIONS_LEFTRIGHT) return;
- UpdateSpeed(DIRECTION_DOWN);
- Move(0, (int)m_fSpeed);
-}
-
-void CGUIMoverControl::OnLeft()
-{
- // if (m_dwAllowedDirections == ALLOWED_DIRECTIONS_UPDOWN) return;
- UpdateSpeed(DIRECTION_LEFT);
- Move((int) - m_fSpeed, 0);
-}
-
-void CGUIMoverControl::OnRight()
-{
- // if (m_dwAllowedDirections == ALLOWED_DIRECTIONS_UPDOWN) return;
- UpdateSpeed(DIRECTION_RIGHT);
- Move((int)m_fSpeed, 0);
-}
-
-EVENT_RESULT CGUIMoverControl::OnMouseEvent(const CPoint &point, const CMouseEvent &event)
-{
- if (event.m_id == ACTION_MOUSE_DRAG)
- {
- if (event.m_state == 1)
- { // grab exclusive access
- CGUIMessage msg(GUI_MSG_EXCLUSIVE_MOUSE, GetID(), GetParentID());
- SendWindowMessage(msg);
- }
- else if (event.m_state == 3)
- { // release exclusive access
- CGUIMessage msg(GUI_MSG_EXCLUSIVE_MOUSE, 0, GetParentID());
- SendWindowMessage(msg);
- }
- Move((int)event.m_offsetX, (int)event.m_offsetY);
- return EVENT_RESULT_HANDLED;
- }
- return EVENT_RESULT_UNHANDLED;
-}
-
-void CGUIMoverControl::UpdateSpeed(int nDirection)
-{
- if (CTimeUtils::GetFrameTime() - m_lastMoveTime > MOVE_TIME_OUT)
- {
- m_fSpeed = 1;
- m_nDirection = DIRECTION_NONE;
- }
- m_lastMoveTime = CTimeUtils::GetFrameTime();
- if (nDirection == m_nDirection)
- { // accelerate
- m_fSpeed += m_fAcceleration;
- if (m_fSpeed > m_fMaxSpeed) m_fSpeed = m_fMaxSpeed;
- }
- else
- { // reset direction and speed
- m_fSpeed = 1;
- m_nDirection = nDirection;
- }
-}
-
-void CGUIMoverControl::AllocResources()
-{
- CGUIControl::AllocResources();
- m_frameCounter = 0;
- m_imgFocus.AllocResources();
- m_imgNoFocus.AllocResources();
- float width = m_width ? m_width : m_imgFocus.GetWidth();
- float height = m_height ? m_height : m_imgFocus.GetHeight();
- SetWidth(width);
- SetHeight(height);
-}
-
-void CGUIMoverControl::FreeResources(bool immediately)
-{
- CGUIControl::FreeResources(immediately);
- m_imgFocus.FreeResources(immediately);
- m_imgNoFocus.FreeResources(immediately);
-}
-
-void CGUIMoverControl::DynamicResourceAlloc(bool bOnOff)
-{
- CGUIControl::DynamicResourceAlloc(bOnOff);
- m_imgFocus.DynamicResourceAlloc(bOnOff);
- m_imgNoFocus.DynamicResourceAlloc(bOnOff);
-}
-
-void CGUIMoverControl::SetInvalid()
-{
- CGUIControl::SetInvalid();
- m_imgFocus.SetInvalid();
- m_imgNoFocus.SetInvalid();
-}
-
-void CGUIMoverControl::Move(int iX, int iY)
-{
- int iLocX = m_iLocationX + iX;
- int iLocY = m_iLocationY + iY;
- // check if we are within the bounds
- if (iLocX < m_iX1) iLocX = m_iX1;
- if (iLocY < m_iY1) iLocY = m_iY1;
- if (iLocX > m_iX2) iLocX = m_iX2;
- if (iLocY > m_iY2) iLocY = m_iY2;
- // ok, now set the location of the mover
- SetLocation(iLocX, iLocY);
-}
-
-void CGUIMoverControl::SetLocation(int iLocX, int iLocY, bool bSetPosition)
-{
- if (bSetPosition) SetPosition(GetXPosition() + iLocX - m_iLocationX, GetYPosition() + iLocY - m_iLocationY);
- m_iLocationX = iLocX;
- m_iLocationY = iLocY;
-}
-
-void CGUIMoverControl::SetPosition(float posX, float posY)
-{
- CGUIControl::SetPosition(posX, posY);
- m_imgFocus.SetPosition(posX, posY);
- m_imgNoFocus.SetPosition(posX, posY);
-}
-
-void CGUIMoverControl::SetAlpha(unsigned char alpha)
-{
- m_imgFocus.SetAlpha(alpha);
- m_imgNoFocus.SetAlpha(alpha);
-}
-
-void CGUIMoverControl::UpdateColors()
-{
- CGUIControl::UpdateColors();
- m_imgFocus.SetDiffuseColor(m_diffuseColor);
- m_imgNoFocus.SetDiffuseColor(m_diffuseColor);
-}
-
-void CGUIMoverControl::SetLimits(int iX1, int iY1, int iX2, int iY2)
-{
- m_iX1 = iX1;
- m_iY1 = iY1;
- m_iX2 = iX2;
- m_iY2 = iY2;
-}
diff --git a/guilib/GUIMoverControl.h b/guilib/GUIMoverControl.h
deleted file mode 100644
index 49050bbce8..0000000000
--- a/guilib/GUIMoverControl.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*!
-\file GUIMoverControl.h
-\brief
-*/
-
-#ifndef GUILIB_GUIMoverCONTROL_H
-#define GUILIB_GUIMoverCONTROL_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUITexture.h"
-#include "GUIControl.h"
-
-#define ALLOWED_DIRECTIONS_ALL 0
-#define ALLOWED_DIRECTIONS_UPDOWN 1
-#define ALLOWED_DIRECTIONS_LEFTRIGHT 2
-
-#define DIRECTION_NONE 0
-#define DIRECTION_UP 1
-#define DIRECTION_DOWN 2
-#define DIRECTION_LEFT 3
-#define DIRECTION_RIGHT 4
-
-// normal alignment is TOP LEFT 0 = topleft, 1 = topright
-#define ALIGN_RIGHT 1
-#define ALIGN_BOTTOM 2
-
-/*!
- \ingroup controls
- \brief
- */
-class CGUIMoverControl : public CGUIControl
-{
-public:
- CGUIMoverControl(int parentID, int controlID,
- float posX, float posY, float width, float height,
- const CTextureInfo& textureFocus, const CTextureInfo& textureNoFocus);
-
- virtual ~CGUIMoverControl(void);
- virtual CGUIMoverControl *Clone() const { return new CGUIMoverControl(*this); };
-
- virtual void Render();
- virtual bool OnAction(const CAction &action);
- virtual void OnUp();
- virtual void OnDown();
- virtual void OnLeft();
- virtual void OnRight();
- virtual void AllocResources();
- virtual void FreeResources(bool immediately = false);
- virtual void DynamicResourceAlloc(bool bOnOff);
- virtual void SetInvalid();
- virtual void SetPosition(float posX, float posY);
- void SetLimits(int iX1, int iY1, int iX2, int iY2);
- void SetLocation(int iLocX, int iLocY, bool bSetPosition = true);
- int GetXLocation() const { return m_iLocationX;};
- int GetYLocation() const { return m_iLocationY;};
-
-protected:
- virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event);
- virtual void UpdateColors();
- void SetAlpha(unsigned char alpha);
- void UpdateSpeed(int nDirection);
- void Move(int iX, int iY);
- CGUITexture m_imgFocus;
- CGUITexture m_imgNoFocus;
- unsigned int m_frameCounter;
- unsigned int m_lastMoveTime;
- int m_nDirection;
- float m_fSpeed;
- float m_fAnalogSpeed;
- float m_fMaxSpeed;
- float m_fAcceleration;
- int m_iX1, m_iX2, m_iY1, m_iY2;
- int m_iLocationX, m_iLocationY;
-};
-#endif
diff --git a/guilib/GUIMultiImage.cpp b/guilib/GUIMultiImage.cpp
deleted file mode 100644
index 31aeb41f0b..0000000000
--- a/guilib/GUIMultiImage.cpp
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIMultiImage.h"
-#include "TextureManager.h"
-#include "FileSystem/Directory.h"
-#include "Util.h"
-#include "FileItem.h"
-#include "Key.h"
-
-using namespace std;
-using namespace XFILE;
-
-CGUIMultiImage::CGUIMultiImage(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& texture, unsigned int timePerImage, unsigned int fadeTime, bool randomized, bool loop, unsigned int timeToPauseAtEnd)
- : CGUIControl(parentID, controlID, posX, posY, width, height),
- m_image(0, 0, posX, posY, width, height, texture)
-{
- m_currentImage = 0;
- m_timePerImage = timePerImage + fadeTime;
- m_timeToPauseAtEnd = timeToPauseAtEnd;
- m_image.SetCrossFade(fadeTime);
- m_randomized = randomized;
- m_loop = loop;
- ControlType = GUICONTROL_MULTI_IMAGE;
- m_bDynamicResourceAlloc=false;
- m_directoryLoaded = false;
-}
-
-CGUIMultiImage::CGUIMultiImage(const CGUIMultiImage &from)
-: CGUIControl(from), m_image(from.m_image)
-{
- m_texturePath = from.m_texturePath;
- m_timePerImage = from.m_timePerImage;
- m_timeToPauseAtEnd = from.m_timeToPauseAtEnd;
- m_randomized = from.m_randomized;
- m_loop = from.m_loop;
- m_bDynamicResourceAlloc=false;
- m_directoryLoaded = false;
- if (m_texturePath.IsConstant())
- m_currentPath = m_texturePath.GetLabel(WINDOW_INVALID);
- m_currentImage = 0;
- ControlType = GUICONTROL_MULTI_IMAGE;
-}
-
-CGUIMultiImage::~CGUIMultiImage(void)
-{
-}
-
-void CGUIMultiImage::UpdateVisibility(const CGUIListItem *item)
-{
- CGUIControl::UpdateVisibility(item);
-
- // check if we're hidden, and deallocate if so
- if (!IsVisible() && m_visible != DELAYED)
- {
- if (m_bDynamicResourceAlloc && m_bAllocated)
- FreeResources();
- return;
- }
-
- // we are either delayed or visible, so we can allocate our resources
- if (!m_directoryLoaded)
- {
- LoadDirectory();
- m_image.SetFileName(m_files.size() ? m_files[0] : "");
- }
- if (!m_bAllocated)
- AllocResources();
-}
-
-void CGUIMultiImage::UpdateInfo(const CGUIListItem *item)
-{
- // check for conditional information before we
- // alloc as this can free our resources
- if (!m_texturePath.IsConstant())
- {
- CStdString texturePath;
- if (item)
- texturePath = m_texturePath.GetItemLabel(item, true);
- else
- texturePath = m_texturePath.GetLabel(m_parentID);
- if (texturePath != m_currentPath && !texturePath.IsEmpty())
- {
- // a new path - set our current path and tell ourselves to load our directory
- m_currentPath = texturePath;
- m_directoryLoaded = false;
- }
- }
-}
-
-void CGUIMultiImage::Render()
-{
- // Set a viewport so that we don't render outside the defined area
- if (!m_files.empty() && g_graphicsContext.SetClipRegion(m_posX, m_posY, m_width, m_height))
- {
- unsigned int nextImage = m_currentImage + 1;
- if (nextImage >= m_files.size())
- nextImage = m_loop ? 0 : m_currentImage; // stay on the last image if <loop>no</loop>
-
- if (nextImage != m_currentImage)
- {
- // check if we should be loading a new image yet
- unsigned int timeToShow = m_timePerImage;
- if (0 == nextImage) // last image should be paused for a bit longer if that's what the skinner wishes.
- timeToShow += m_timeToPauseAtEnd;
- if (m_imageTimer.IsRunning() && m_imageTimer.GetElapsedMilliseconds() > timeToShow)
- {
- // grab a new image
- m_currentImage = nextImage;
- m_image.SetFileName(m_files[m_currentImage]);
- m_imageTimer.StartZero();
- }
- }
- m_image.SetColorDiffuse(m_diffuseColor);
- m_image.Render();
- g_graphicsContext.RestoreClipRegion();
- }
- CGUIControl::Render();
-}
-
-bool CGUIMultiImage::OnAction(const CAction &action)
-{
- return false;
-}
-
-bool CGUIMultiImage::OnMessage(CGUIMessage &message)
-{
- if (message.GetMessage() == GUI_MSG_REFRESH_THUMBS)
- {
- if (!m_texturePath.IsConstant())
- FreeResources();
- return true;
- }
- return CGUIControl::OnMessage(message);
-}
-
-void CGUIMultiImage::AllocResources()
-{
- FreeResources();
- CGUIControl::AllocResources();
-
- if (!m_directoryLoaded)
- LoadDirectory();
-
- // Load in the current image, and reset our timer
- m_currentImage = 0;
- m_imageTimer.StartZero();
-
- // and re-randomize if our control has been reallocated
- if (m_randomized)
- random_shuffle(m_files.begin(), m_files.end());
-
- m_image.SetFileName(m_files.size() ? m_files[0] : "");
-}
-
-void CGUIMultiImage::FreeResources(bool immediately)
-{
- m_image.FreeResources(immediately);
- m_currentImage = 0;
- CGUIControl::FreeResources(immediately);
-}
-
-void CGUIMultiImage::DynamicResourceAlloc(bool bOnOff)
-{
- CGUIControl::DynamicResourceAlloc(bOnOff);
- m_bDynamicResourceAlloc=bOnOff;
-}
-
-void CGUIMultiImage::SetInvalid()
-{
- m_image.SetInvalid();
- CGUIControl::SetInvalid();
-}
-
-bool CGUIMultiImage::CanFocus() const
-{
- return false;
-}
-
-void CGUIMultiImage::SetAspectRatio(const CAspectRatio &ratio)
-{
- m_image.SetAspectRatio(ratio);
-}
-
-void CGUIMultiImage::LoadDirectory()
-{
- // Load any images from our texture bundle first
- m_files.clear();
-
- // don't load any images if our path is empty
- if (m_currentPath.IsEmpty()) return;
-
- // check to see if we have a single image or a folder of images
- CFileItem item(m_currentPath, false);
- if (item.IsPicture())
- {
- m_files.push_back(m_currentPath);
- }
- else
- { // folder of images
- g_TextureManager.GetBundledTexturesFromPath(m_currentPath, m_files);
-
- // Load in our images from the directory specified
- // m_currentPath is relative (as are all skin paths)
- CStdString realPath = g_TextureManager.GetTexturePath(m_currentPath, true);
- if (realPath.IsEmpty() && m_files.empty())
- return;
-
- CUtil::AddSlashAtEnd(realPath);
- CFileItemList items;
- CDirectory::GetDirectory(realPath, items);
- for (int i=0; i < items.Size(); i++)
- {
- CFileItemPtr pItem = items[i];
- if (pItem->IsPicture())
- m_files.push_back(pItem->m_strPath);
- }
- }
-
- // Randomize or sort our images if necessary
- if (m_randomized)
- random_shuffle(m_files.begin(), m_files.end());
- else
- sort(m_files.begin(), m_files.end());
-
- // flag as loaded - no point in constantly reloading them
- m_directoryLoaded = true;
- m_imageTimer.StartZero();
-}
-
-void CGUIMultiImage::SetInfo(const CGUIInfoLabel &info)
-{
- m_texturePath = info;
- if (m_texturePath.IsConstant())
- m_currentPath = m_texturePath.GetLabel(WINDOW_INVALID);
-}
diff --git a/guilib/GUIMultiImage.h b/guilib/GUIMultiImage.h
deleted file mode 100644
index b947b6c034..0000000000
--- a/guilib/GUIMultiImage.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*!
-\file GUIMultiImage.h
-\brief
-*/
-
-#ifndef GUILIB_GUIMULTIIMAGECONTROL_H
-#define GUILIB_GUIMULTIIMAGECONTROL_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIImage.h"
-#include "utils/Stopwatch.h"
-
-/*!
- \ingroup controls
- \brief
- */
-class CGUIMultiImage : public CGUIControl
-{
-public:
- CGUIMultiImage(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& texture, unsigned int timePerImage, unsigned int fadeTime, bool randomized, bool loop, unsigned int timeToPauseAtEnd);
- CGUIMultiImage(const CGUIMultiImage &from);
- virtual ~CGUIMultiImage(void);
- virtual CGUIMultiImage *Clone() const { return new CGUIMultiImage(*this); };
-
- virtual void Render();
- virtual void UpdateVisibility(const CGUIListItem *item = NULL);
- virtual void UpdateInfo(const CGUIListItem *item = NULL);
- virtual bool OnAction(const CAction &action);
- virtual bool OnMessage(CGUIMessage &message);
- virtual void AllocResources();
- virtual void FreeResources(bool immediately = false);
- virtual void DynamicResourceAlloc(bool bOnOff);
- virtual bool IsDynamicallyAllocated() { return m_bDynamicResourceAlloc; };
- virtual void SetInvalid();
- virtual bool CanFocus() const;
-
- void SetInfo(const CGUIInfoLabel &info);
- void SetAspectRatio(const CAspectRatio &ratio);
-
-protected:
- void LoadDirectory();
-
- CGUIInfoLabel m_texturePath;
- CStdString m_currentPath;
- unsigned int m_currentImage;
- CStopWatch m_imageTimer;
- unsigned int m_timePerImage;
- unsigned int m_timeToPauseAtEnd;
- bool m_randomized;
- bool m_loop;
-
- bool m_bDynamicResourceAlloc;
- bool m_directoryLoaded;
- std::vector<CStdString> m_files;
-
- CGUIImage m_image;
-};
-#endif
diff --git a/guilib/GUIMultiSelectText.cpp b/guilib/GUIMultiSelectText.cpp
deleted file mode 100644
index 8c9592b480..0000000000
--- a/guilib/GUIMultiSelectText.cpp
+++ /dev/null
@@ -1,436 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIMultiSelectText.h"
-#include "GUIWindowManager.h"
-#include "Key.h"
-#include "utils/log.h"
-
-using namespace std;
-
-CGUIMultiSelectTextControl::CSelectableString::CSelectableString(CGUIFont *font, const CStdString &text, bool selectable, const CStdString &clickAction)
- : m_text(font, false)
-{
- m_selectable = selectable;
- m_clickAction = clickAction;
- m_clickAction.TrimLeft(" =");
- m_clickAction.TrimRight(" ");
- m_text.Update(text);
- float height;
- m_text.GetTextExtent(m_length, height);
-}
-
-CGUIMultiSelectTextControl::CGUIMultiSelectTextControl(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& textureFocus, const CTextureInfo& textureNoFocus, const CLabelInfo& labelInfo, const CGUIInfoLabel &content)
- : CGUIControl(parentID, controlID, posX, posY, width, height)
- , m_button(parentID, controlID, posX, posY, width, height, textureFocus, textureNoFocus, labelInfo)
-{
- m_info = content;
- m_label = labelInfo;
- m_selectedItem = 0;
- m_offset = 0;
- m_totalWidth = 0;
- m_scrollOffset = 0;
- m_scrollSpeed = 0;
- m_scrollLastTime = 0;
- m_renderTime = 0;
- m_label.align &= ~3; // we currently ignore all x alignment
-}
-
-CGUIMultiSelectTextControl::~CGUIMultiSelectTextControl(void)
-{
-}
-
-void CGUIMultiSelectTextControl::DoRender(unsigned int currentTime)
-{
- m_renderTime = currentTime;
- CGUIControl::DoRender(currentTime);
-}
-
-void CGUIMultiSelectTextControl::UpdateColors()
-{
- m_label.UpdateColors();
- CGUIControl::UpdateColors();
-}
-
-void CGUIMultiSelectTextControl::Render()
-{
- // check our selected item is in range
- unsigned int numSelectable = GetNumSelectable();
- if (!numSelectable)
- SetFocus(false);
- else if (m_selectedItem >= numSelectable)
- m_selectedItem = numSelectable - 1;
-
- // and validate our offset
- if (m_offset + m_width > m_totalWidth)
- m_offset = m_totalWidth - m_width;
- if (m_offset < 0) m_offset = 0;
-
- // handle scrolling
- m_scrollOffset += m_scrollSpeed * (m_renderTime - m_scrollLastTime);
- if ((m_scrollSpeed < 0 && m_scrollOffset < m_offset) ||
- (m_scrollSpeed > 0 && m_scrollOffset > m_offset))
- {
- m_scrollOffset = m_offset;
- m_scrollSpeed = 0;
- }
- m_scrollLastTime = m_renderTime;
-
- // clip and set our scrolling origin
- bool clip(m_width < m_totalWidth);
- if (clip)
- { // need to crop
- if (!g_graphicsContext.SetClipRegion(m_posX, m_posY, m_width, m_height))
- return; // nothing to render??
- }
- g_graphicsContext.SetOrigin(-m_scrollOffset, 0);
-
- // render the buttons
- for (unsigned int i = 0; i < m_buttons.size(); i++)
- {
- m_buttons[i].SetFocus(HasFocus() && i == m_selectedItem);
- m_buttons[i].DoRender(m_renderTime);
- }
-
- // position the text - we center vertically if applicable, and use the offsets.
- // all x-alignment is ignored for now (see constructor)
- float posX = m_posX;
- float posY = m_posY + m_label.offsetY;
- if (m_label.align & XBFONT_CENTER_Y)
- posY = m_posY + m_height * 0.5f;
-
- if (m_items.size() && m_items[0].m_selectable)
- posX += m_label.offsetX;
-
- // render the text
- unsigned int num_selectable = 0;
- for (unsigned int i = 0; i < m_items.size(); i++)
- {
- CSelectableString &string = m_items[i];
- if (IsDisabled()) // all text is rendered with disabled color
- string.m_text.Render(posX, posY, 0, m_label.disabledColor, m_label.shadowColor, m_label.align, 0, true);
- else if (HasFocus() && string.m_selectable && num_selectable == m_selectedItem) // text is rendered with focusedcolor
- string.m_text.Render(posX, posY, 0, m_label.focusedColor, m_label.shadowColor, m_label.align, 0);
- else // text is rendered with textcolor
- string.m_text.Render(posX, posY, 0, m_label.textColor, m_label.shadowColor, m_label.align, 0);
- posX += string.m_length;
- if (string.m_selectable)
- num_selectable++;
- }
-
- g_graphicsContext.RestoreOrigin();
- if (clip)
- g_graphicsContext.RestoreClipRegion();
-
- CGUIControl::Render();
-}
-
-void CGUIMultiSelectTextControl::UpdateInfo(const CGUIListItem *item)
-{
- if (m_info.IsEmpty())
- return; // nothing to do
-
- if (item)
- UpdateText(m_info.GetItemLabel(item));
- else
- UpdateText(m_info.GetLabel(m_parentID));
-}
-
-bool CGUIMultiSelectTextControl::OnAction(const CAction &action)
-{
- if (action.GetID() == ACTION_SELECT_ITEM)
- {
- // item is clicked - see if we have a clickaction
- CStdString clickAction;
- unsigned int selected = 0;
- for (unsigned int i = 0; i < m_items.size(); i++)
- {
- if (m_items[i].m_selectable)
- {
- if (m_selectedItem == selected)
- clickAction = m_items[i].m_clickAction;
- selected++;
- }
- }
- if (!clickAction.IsEmpty())
- { // have a click action -> perform it
- CGUIMessage message(GUI_MSG_EXECUTE, m_controlID, m_parentID);
- message.SetStringParam(clickAction);
- g_windowManager.SendMessage(message);
- }
- else
- { // no click action, just send a message to the window
- CGUIMessage msg(GUI_MSG_CLICKED, m_controlID, m_parentID, m_selectedItem);
- SendWindowMessage(msg);
- }
- return true;
- }
- return CGUIControl::OnAction(action);
-}
-
-void CGUIMultiSelectTextControl::OnLeft()
-{
- if (MoveLeft())
- return;
- CGUIControl::OnLeft();
-}
-
-void CGUIMultiSelectTextControl::OnRight()
-{
- if (MoveRight())
- return;
- CGUIControl::OnRight();
-}
-
-// movement functions (callable from lists)
-bool CGUIMultiSelectTextControl::MoveLeft()
-{
- if (m_selectedItem > 0)
- ScrollToItem(m_selectedItem - 1);
- else if (GetNumSelectable() && m_controlLeft && m_controlLeft == m_controlID)
- ScrollToItem(GetNumSelectable() - 1);
- else
- return false;
- return true;
-}
-
-bool CGUIMultiSelectTextControl::MoveRight()
-{
- if (GetNumSelectable() && m_selectedItem < GetNumSelectable() - 1)
- ScrollToItem(m_selectedItem + 1);
- else if (m_controlRight && m_controlRight == m_controlID)
- ScrollToItem(0);
- else
- return false;
- return true;
-}
-
-void CGUIMultiSelectTextControl::SelectItemFromPoint(const CPoint &point)
-{
- int item = GetItemFromPoint(point);
- if (item != -1)
- {
- ScrollToItem(item);
- SetFocus(true);
- }
- else
- SetFocus(false);
-}
-
-bool CGUIMultiSelectTextControl::HitTest(const CPoint &point) const
-{
- return (GetItemFromPoint(point) != -1);
-}
-
-bool CGUIMultiSelectTextControl::OnMouseOver(const CPoint &point)
-{
- ScrollToItem(GetItemFromPoint(point));
- return CGUIControl::OnMouseOver(point);
-}
-
-EVENT_RESULT CGUIMultiSelectTextControl::OnMouseEvent(const CPoint &point, const CMouseEvent &event)
-{
- if (event.m_id == ACTION_MOUSE_LEFT_CLICK)
- {
- m_selectedItem = GetItemFromPoint(point);
- OnAction(CAction(ACTION_SELECT_ITEM));
- return EVENT_RESULT_HANDLED;
- }
- return EVENT_RESULT_UNHANDLED;
-}
-
-int CGUIMultiSelectTextControl::GetItemFromPoint(const CPoint &point) const
-{
- if (!m_label.font) return -1;
- float posX = m_posX;
- unsigned int selectable = 0;
- for (unsigned int i = 0; i < m_items.size(); i++)
- {
- const CSelectableString &string = m_items[i];
- if (string.m_selectable)
- {
- CRect rect(posX, m_posY, posX + string.m_length, m_posY + m_height);
- if (rect.PtInRect(point))
- return selectable;
- selectable++;
- }
- posX += string.m_length;
- }
- return -1;
-}
-
-void CGUIMultiSelectTextControl::UpdateText(const CStdString &text)
-{
- if (text == m_oldText)
- return;
-
- m_items.clear();
-
- // parse our text into clickable blocks
- // format is [ONCLICK <action>] [/ONCLICK]
- size_t startClickable = text.Find("[ONCLICK");
- size_t startUnclickable = 0;
-
- // add the first unclickable block
- if (startClickable != CStdString::npos)
- AddString(text.Mid(startUnclickable, startClickable - startUnclickable), false);
- else
- AddString(text.Mid(startUnclickable), false);
- while (startClickable != CStdString::npos)
- {
- // grep out the action and the end of the string
- size_t endAction = text.Find(']', startClickable + 8);
- size_t endClickable = text.Find("[/ONCLICK]", startClickable + 8);
- if (endAction != CStdString::npos && endClickable != CStdString::npos)
- { // success - add the string, and move the start of our next unclickable portion along
- AddString(text.Mid(endAction + 1, endClickable - endAction - 1), true, text.Mid(startClickable + 8, endAction - startClickable - 8));
- startUnclickable = endClickable + 10;
- }
- else
- {
- CLog::Log(LOGERROR, "Invalid multiselect string %s", text.c_str());
- break;
- }
- startClickable = text.Find("[ONCLICK", startUnclickable);
- // add the unclickable portion
- if (startClickable != CStdString::npos)
- AddString(text.Mid(startUnclickable, startClickable - startUnclickable), false);
- else
- AddString(text.Mid(startUnclickable), false);
- }
-
- m_oldText = text;
-
- // finally, position our buttons
- PositionButtons();
-}
-
-void CGUIMultiSelectTextControl::AddString(const CStdString &text, bool selectable, const CStdString &clickAction)
-{
- if (!text.IsEmpty())
- m_items.push_back(CSelectableString(m_label.font, text, selectable, clickAction));
-}
-
-void CGUIMultiSelectTextControl::PositionButtons()
-{
- m_buttons.clear();
-
- // add new buttons
- m_totalWidth = 0;
- if (m_items.size() && m_items.front().m_selectable)
- m_totalWidth += m_label.offsetX;
-
- for (unsigned int i = 0; i < m_items.size(); i++)
- {
- const CSelectableString &text = m_items[i];
- if (text.m_selectable)
- {
- CGUIButtonControl button(m_button);
- button.SetPosition(m_posX + m_totalWidth - m_label.offsetX, m_posY);
- button.SetWidth(text.m_length + 2 * m_label.offsetX);
- m_buttons.push_back(button);
- }
- m_totalWidth += text.m_length;
- }
-
- if (m_items.size() && m_items.back().m_selectable)
- m_totalWidth += m_label.offsetX;
-}
-
-CStdString CGUIMultiSelectTextControl::GetDescription() const
-{
- // We currently just return the entire string - should we bother returning the
- // particular subitems of this?
- CStdString strLabel(m_info.GetLabel(m_parentID));
- return strLabel;
-}
-
-unsigned int CGUIMultiSelectTextControl::GetNumSelectable() const
-{
- unsigned int selectable = 0;
- for (unsigned int i = 0; i < m_items.size(); i++)
- if (m_items[i].m_selectable)
- selectable++;
- return selectable;
-}
-
-unsigned int CGUIMultiSelectTextControl::GetFocusedItem() const
-{
- if (GetNumSelectable())
- return m_selectedItem + 1;
- return 0;
-}
-
-void CGUIMultiSelectTextControl::SetFocusedItem(unsigned int item)
-{
- SetFocus(item > 0);
- if (item > 0)
- ScrollToItem(item - 1);
-}
-
-bool CGUIMultiSelectTextControl::CanFocus() const
-{
- if (!GetNumSelectable()) return false;
- return CGUIControl::CanFocus();
-}
-
-void CGUIMultiSelectTextControl::SetFocus(bool focus)
-{
- for (unsigned int i = 0; i < m_buttons.size(); i++)
- m_buttons[i].SetFocus(focus);
- CGUIControl::SetFocus(focus);
-}
-
-// overrides to allow anims to translate down to the focus image
-void CGUIMultiSelectTextControl::SetAnimations(const vector<CAnimation> &animations)
-{
- // send any focus animations down to the focus image only
- m_animations.clear();
- vector<CAnimation> focusAnims;
- for (unsigned int i = 0; i < animations.size(); i++)
- {
- const CAnimation &anim = animations[i];
- if (anim.GetType() == ANIM_TYPE_FOCUS)
- focusAnims.push_back(anim);
- else
- m_animations.push_back(anim);
- }
- m_button.SetAnimations(focusAnims);
-}
-
-void CGUIMultiSelectTextControl::ScrollToItem(unsigned int item)
-{
- static const unsigned int time_to_scroll = 200;
- if (item >= m_buttons.size()) return;
- // grab our button
- const CGUIButtonControl &button = m_buttons[item];
- float left = button.GetXPosition();
- float right = left + button.GetWidth();
- // make sure that we scroll so that this item is on screen
- m_scrollOffset = m_offset;
- if (left < m_posX + m_offset)
- m_offset = left - m_posX;
- else if (right > m_posX + m_offset + m_width)
- m_offset = right - m_width - m_posX;
- m_scrollSpeed = (m_offset - m_scrollOffset) / time_to_scroll;
- m_selectedItem = item;
-}
-
diff --git a/guilib/GUIMultiSelectText.h b/guilib/GUIMultiSelectText.h
deleted file mode 100644
index 18f5706436..0000000000
--- a/guilib/GUIMultiSelectText.h
+++ /dev/null
@@ -1,101 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIButtonControl.h"
-
-/*!
- \ingroup controls
- \brief
- */
-class CGUIMultiSelectTextControl : public CGUIControl
-{
-public:
- CGUIMultiSelectTextControl(int parentID, int controlID,
- float posX, float posY, float width, float height,
- const CTextureInfo& textureFocus, const CTextureInfo& textureNoFocus, const CLabelInfo &label, const CGUIInfoLabel &content);
-
- virtual ~CGUIMultiSelectTextControl(void);
- virtual CGUIMultiSelectTextControl *Clone() const { return new CGUIMultiSelectTextControl(*this); };
-
- virtual void DoRender(unsigned int currentTime);
- virtual void Render();
-
- virtual bool OnAction(const CAction &action);
- virtual void OnLeft();
- virtual void OnRight();
- virtual bool HitTest(const CPoint &point) const;
- virtual bool OnMouseOver(const CPoint &point);
- virtual void UpdateInfo(const CGUIListItem *item = NULL);
-
- virtual CStdString GetDescription() const;
- virtual bool CanFocus() const;
-
- void UpdateText(const CStdString &text);
- bool MoveLeft();
- bool MoveRight();
- void SelectItemFromPoint(const CPoint &point);
- unsigned int GetFocusedItem() const;
- void SetFocusedItem(unsigned int item);
-
- // overrides to allow all focus anims to translate down to the focus image
- virtual void SetAnimations(const std::vector<CAnimation> &animations);
- virtual void SetFocus(bool focus);
-protected:
- virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event);
- virtual void UpdateColors();
- void AddString(const CStdString &text, bool selectable, const CStdString &clickAction = "");
- void PositionButtons();
- unsigned int GetNumSelectable() const;
- int GetItemFromPoint(const CPoint &point) const;
- void ScrollToItem(unsigned int item);
-
- // the static strings and buttons strings
- class CSelectableString
- {
- public:
- CSelectableString(CGUIFont *font, const CStdString &text, bool selectable, const CStdString &clickAction);
- CGUITextLayout m_text;
- float m_length;
- bool m_selectable;
- CStdString m_clickAction;
- };
- std::vector<CSelectableString> m_items;
-
- CLabelInfo m_label;
- CGUIInfoLabel m_info;
- CStdString m_oldText;
- unsigned int m_renderTime;
-
- // scrolling
- float m_totalWidth;
- float m_offset;
- float m_scrollOffset;
- float m_scrollSpeed;
- unsigned int m_scrollLastTime;
-
- // buttons
- CGUIButtonControl m_button;
- unsigned int m_selectedItem;
- std::vector<CGUIButtonControl> m_buttons;
-};
-
diff --git a/guilib/GUIPanelContainer.cpp b/guilib/GUIPanelContainer.cpp
deleted file mode 100644
index 3031c571b9..0000000000
--- a/guilib/GUIPanelContainer.cpp
+++ /dev/null
@@ -1,492 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIPanelContainer.h"
-#include "GUIListItem.h"
-#include "utils/GUIInfoManager.h"
-#include "Key.h"
-
-using namespace std;
-
-CGUIPanelContainer::CGUIPanelContainer(int parentID, int controlID, float posX, float posY, float width, float height, ORIENTATION orientation, int scrollTime, int preloadItems)
- : CGUIBaseContainer(parentID, controlID, posX, posY, width, height, orientation, scrollTime, preloadItems)
-{
- ControlType = GUICONTAINER_PANEL;
- m_type = VIEW_TYPE_ICON;
- m_itemsPerRow = 1;
-}
-
-CGUIPanelContainer::~CGUIPanelContainer(void)
-{
-}
-
-void CGUIPanelContainer::Render()
-{
- ValidateOffset();
-
- if (m_bInvalidated)
- UpdateLayout();
-
- if (!m_layout || !m_focusedLayout) return;
-
- UpdateScrollOffset();
-
- int offset = (int)(m_scrollOffset / m_layout->Size(m_orientation));
-
- int cacheBefore, cacheAfter;
- GetCacheOffsets(cacheBefore, cacheAfter);
-
- // Free memory not used on screen at the moment, do this first so there's more memory for the new items.
- FreeMemory(CorrectOffset(offset - cacheBefore, 0), CorrectOffset(offset + cacheAfter + m_itemsPerPage + 1, 0));
-
- g_graphicsContext.SetClipRegion(m_posX, m_posY, m_width, m_height);
- CPoint origin = CPoint(m_posX, m_posY) + m_renderOffset;
- float pos = (m_orientation == VERTICAL) ? origin.y : origin.x;
- float end = (m_orientation == VERTICAL) ? m_posY + m_height : m_posX + m_width;
- pos += (offset - cacheBefore) * m_layout->Size(m_orientation) - m_scrollOffset;
- end += cacheAfter * m_layout->Size(m_orientation);
-
- float focusedPos = 0;
- int focusedCol = 0;
- CGUIListItemPtr focusedItem;
- int current = (offset - cacheBefore) * m_itemsPerRow;
- int col = 0;
- while (pos < end && m_items.size())
- {
- if (current >= (int)m_items.size())
- break;
- if (current >= 0)
- {
- CGUIListItemPtr item = m_items[current];
- bool focused = (current == m_offset * m_itemsPerRow + m_cursor) && m_bHasFocus;
- // render our item
- if (focused)
- {
- focusedPos = pos;
- focusedCol = col;
- focusedItem = item;
- }
- else
- {
- if (m_orientation == VERTICAL)
- RenderItem(origin.x + col * m_layout->Size(HORIZONTAL), pos, item.get(), false);
- else
- RenderItem(pos, origin.y + col * m_layout->Size(VERTICAL), item.get(), false);
- }
- }
- // increment our position
- if (col < m_itemsPerRow - 1)
- col++;
- else
- {
- pos += m_layout->Size(m_orientation);
- col = 0;
- }
- current++;
- }
- // and render the focused item last (for overlapping purposes)
- if (focusedItem)
- {
- if (m_orientation == VERTICAL)
- RenderItem(origin.x + focusedCol * m_layout->Size(HORIZONTAL), focusedPos, focusedItem.get(), true);
- else
- RenderItem(focusedPos, origin.y + focusedCol * m_layout->Size(VERTICAL), focusedItem.get(), true);
- }
-
- g_graphicsContext.RestoreClipRegion();
-
- UpdatePageControl(offset);
-
- CGUIControl::Render();
-}
-
-bool CGUIPanelContainer::OnAction(const CAction &action)
-{
- switch (action.GetID())
- {
- case ACTION_PAGE_UP:
- {
- if (m_offset == 0)
- { // already on the first page, so move to the first item
- SetCursor(0);
- }
- else
- { // scroll up to the previous page
- Scroll( -m_itemsPerPage);
- }
- return true;
- }
- break;
- case ACTION_PAGE_DOWN:
- {
- if ((m_offset + m_itemsPerPage) * m_itemsPerRow >= (int)m_items.size() || (int)m_items.size() < m_itemsPerPage)
- { // already at the last page, so move to the last item.
- SetCursor(m_items.size() - m_offset * m_itemsPerRow - 1);
- }
- else
- { // scroll down to the next page
- Scroll(m_itemsPerPage);
- }
- return true;
- }
- break;
- // smooth scrolling (for analog controls)
- case ACTION_SCROLL_UP:
- {
- m_analogScrollCount += action.GetAmount() * action.GetAmount();
- bool handled = false;
- while (m_analogScrollCount > AnalogScrollSpeed())
- {
- handled = true;
- m_analogScrollCount -= AnalogScrollSpeed();
- if (m_offset > 0)// && m_cursor <= m_itemsPerPage * m_itemsPerRow / 2)
- {
- Scroll(-1);
- }
- else if (m_cursor > 0)
- {
- SetCursor(m_cursor - 1);
- }
- }
- return handled;
- }
- break;
- case ACTION_SCROLL_DOWN:
- {
- m_analogScrollCount += action.GetAmount() * action.GetAmount();
- bool handled = false;
- while (m_analogScrollCount > AnalogScrollSpeed())
- {
- handled = true;
- m_analogScrollCount -= AnalogScrollSpeed();
- if ((m_offset + m_itemsPerPage) * m_itemsPerRow < (int)m_items.size())// && m_cursor >= m_itemsPerPage * m_itemsPerRow / 2)
- {
- Scroll(1);
- }
- else if (m_cursor < m_itemsPerPage * m_itemsPerRow - 1 && m_offset * m_itemsPerRow + m_cursor < (int)m_items.size() - 1)
- {
- SetCursor(m_cursor + 1);
- }
- }
- return handled;
- }
- break;
- }
- return CGUIBaseContainer::OnAction(action);
-}
-
-bool CGUIPanelContainer::OnMessage(CGUIMessage& message)
-{
- if (message.GetControlId() == GetID() )
- {
- if (message.GetMessage() == GUI_MSG_LABEL_RESET)
- {
- SetCursor(0);
- // fall through to base class
- }
- else if (message.GetMessage() == GUI_MSG_ITEM_SELECT)
- {
- SelectItem(message.GetParam1());
- return true;
- }
- }
- return CGUIBaseContainer::OnMessage(message);
-}
-
-void CGUIPanelContainer::OnLeft()
-{
- bool wrapAround = m_controlLeft == GetID() || !(m_controlLeft || m_leftActions.size());
- if (m_orientation == VERTICAL && MoveLeft(wrapAround))
- return;
- if (m_orientation == HORIZONTAL && MoveUp(wrapAround))
- return;
- CGUIControl::OnLeft();
-}
-
-void CGUIPanelContainer::OnRight()
-{
- bool wrapAround = m_controlRight == GetID() || !(m_controlRight || m_rightActions.size());
- if (m_orientation == VERTICAL && MoveRight(wrapAround))
- return;
- if (m_orientation == HORIZONTAL && MoveDown(wrapAround))
- return;
- return CGUIControl::OnRight();
-}
-
-void CGUIPanelContainer::OnUp()
-{
- bool wrapAround = m_controlUp == GetID() || !(m_controlUp || m_upActions.size());
- if (m_orientation == VERTICAL && MoveUp(wrapAround))
- return;
- if (m_orientation == HORIZONTAL && MoveLeft(wrapAround))
- return;
- CGUIControl::OnUp();
-}
-
-void CGUIPanelContainer::OnDown()
-{
- bool wrapAround = m_controlDown == GetID() || !(m_controlDown || m_downActions.size());
- if (m_orientation == VERTICAL && MoveDown(wrapAround))
- return;
- if (m_orientation == HORIZONTAL && MoveRight(wrapAround))
- return;
- return CGUIControl::OnDown();
-}
-
-bool CGUIPanelContainer::MoveDown(bool wrapAround)
-{
- if (m_cursor + m_itemsPerRow < m_itemsPerPage * m_itemsPerRow && (m_offset + 1 + m_cursor / m_itemsPerRow) * m_itemsPerRow < (int)m_items.size())
- { // move to last item if necessary
- if ((m_offset + 1)*m_itemsPerRow + m_cursor >= (int)m_items.size())
- SetCursor((int)m_items.size() - 1 - m_offset*m_itemsPerRow);
- else
- SetCursor(m_cursor + m_itemsPerRow);
- }
- else if ((m_offset + 1 + m_cursor / m_itemsPerRow) * m_itemsPerRow < (int)m_items.size())
- { // we scroll to the next row, and move to last item if necessary
- if ((m_offset + 1)*m_itemsPerRow + m_cursor >= (int)m_items.size())
- SetCursor((int)m_items.size() - 1 - (m_offset + 1)*m_itemsPerRow);
- ScrollToOffset(m_offset + 1);
- }
- else if (wrapAround)
- { // move first item in list
- SetCursor(m_cursor % m_itemsPerRow);
- ScrollToOffset(0);
- SetContainerMoving(1);
- }
- else
- return false;
- return true;
-}
-
-bool CGUIPanelContainer::MoveUp(bool wrapAround)
-{
- if (m_cursor >= m_itemsPerRow)
- SetCursor(m_cursor - m_itemsPerRow);
- else if (m_offset > 0)
- ScrollToOffset(m_offset - 1);
- else if (wrapAround)
- { // move last item in list in this column
- SetCursor((m_cursor % m_itemsPerRow) + (m_itemsPerPage - 1) * m_itemsPerRow);
- int offset = max((int)GetRows() - m_itemsPerPage, 0);
- // should check here whether cursor is actually allowed here, and reduce accordingly
- if (offset * m_itemsPerRow + m_cursor >= (int)m_items.size())
- SetCursor((int)m_items.size() - offset * m_itemsPerRow - 1);
- ScrollToOffset(offset);
- SetContainerMoving(-1);
- }
- else
- return false;
- return true;
-}
-
-bool CGUIPanelContainer::MoveLeft(bool wrapAround)
-{
- int col = m_cursor % m_itemsPerRow;
- if (col > 0)
- SetCursor(m_cursor - 1);
- else if (wrapAround)
- { // wrap around
- SetCursor(m_cursor + m_itemsPerRow - 1);
- if (m_offset * m_itemsPerRow + m_cursor >= (int)m_items.size())
- SetCursor((int)m_items.size() - m_offset * m_itemsPerRow);
- }
- else
- return false;
- return true;
-}
-
-bool CGUIPanelContainer::MoveRight(bool wrapAround)
-{
- int col = m_cursor % m_itemsPerRow;
- if (col + 1 < m_itemsPerRow && m_offset * m_itemsPerRow + m_cursor + 1 < (int)m_items.size())
- SetCursor(m_cursor + 1);
- else if (wrapAround) // move first item in row
- SetCursor(m_cursor - col);
- else
- return false;
- return true;
-}
-
-// scrolls the said amount
-void CGUIPanelContainer::Scroll(int amount)
-{
- // increase or decrease the offset
- int offset = m_offset + amount;
- if (offset > ((int)GetRows() - m_itemsPerPage) * m_itemsPerRow)
- {
- offset = ((int)GetRows() - m_itemsPerPage) * m_itemsPerRow;
- }
- if (offset < 0) offset = 0;
- ScrollToOffset(offset);
-}
-
-void CGUIPanelContainer::ValidateOffset()
-{ // first thing is we check the range of m_offset
- if (!m_layout) return;
- if (m_offset > (int)GetRows() - m_itemsPerPage || m_scrollOffset > ((int)GetRows() - m_itemsPerPage) * m_layout->Size(m_orientation))
- {
- m_offset = (int)GetRows() - m_itemsPerPage;
- m_scrollOffset = m_offset * m_layout->Size(m_orientation);
- }
- if (m_offset < 0 || m_scrollOffset < 0)
- {
- m_offset = 0;
- m_scrollOffset = 0;
- }
-}
-
-void CGUIPanelContainer::SetCursor(int cursor)
-{
- // +1 to ensure we're OK if we have a half item
- if (cursor > (m_itemsPerPage + 1)*m_itemsPerRow - 1) cursor = (m_itemsPerPage + 1)*m_itemsPerRow - 1;
- if (cursor < 0) cursor = 0;
- if (!m_wasReset)
- SetContainerMoving(cursor - m_cursor);
- m_cursor = cursor;
-}
-
-void CGUIPanelContainer::CalculateLayout()
-{
- GetCurrentLayouts();
-
- if (!m_layout || !m_focusedLayout) return;
- // calculate the number of items to display
- if (m_orientation == HORIZONTAL)
- {
- m_itemsPerRow = (int)(m_height / m_layout->Size(VERTICAL));
- m_itemsPerPage = (int)(m_width / m_layout->Size(HORIZONTAL));
- }
- else
- {
- m_itemsPerRow = (int)(m_width / m_layout->Size(HORIZONTAL));
- m_itemsPerPage = (int)(m_height / m_layout->Size(VERTICAL));
- }
- if (m_itemsPerRow < 1) m_itemsPerRow = 1;
- if (m_itemsPerPage < 1) m_itemsPerPage = 1;
-
- // ensure that the scroll offset is a multiple of our size
- m_scrollOffset = m_offset * m_layout->Size(m_orientation);
-}
-
-unsigned int CGUIPanelContainer::GetRows() const
-{
- assert(m_itemsPerRow > 0);
- return (m_items.size() + m_itemsPerRow - 1) / m_itemsPerRow;
-}
-
-float CGUIPanelContainer::AnalogScrollSpeed() const
-{
- return 10.0f / m_itemsPerPage;
-}
-
-int CGUIPanelContainer::CorrectOffset(int offset, int cursor) const
-{
- return offset * m_itemsPerRow + cursor;
-}
-
-int CGUIPanelContainer::GetCursorFromPoint(const CPoint &point, CPoint *itemPoint) const
-{
- if (!m_layout)
- return -1;
-
- float sizeX = m_orientation == VERTICAL ? m_layout->Size(HORIZONTAL) : m_layout->Size(VERTICAL);
- float sizeY = m_orientation == VERTICAL ? m_layout->Size(VERTICAL) : m_layout->Size(HORIZONTAL);
-
- float posY = m_orientation == VERTICAL ? point.y : point.x;
- for (int y = 0; y < m_itemsPerPage + 1; y++) // +1 to ensure if we have a half item we can select it
- {
- float posX = m_orientation == VERTICAL ? point.x : point.y;
- for (int x = 0; x < m_itemsPerRow; x++)
- {
- int item = x + y * m_itemsPerRow;
- if (posX < sizeX && posY < sizeY && item + m_offset < (int)m_items.size())
- { // found
- return item;
- }
- posX -= sizeX;
- }
- posY -= sizeY;
- }
- return false;
-}
-
-bool CGUIPanelContainer::SelectItemFromPoint(const CPoint &point)
-{
- int cursor = GetCursorFromPoint(point);
- if (cursor < 0)
- return false;
- SetCursor(cursor);
- return true;
-}
-
-bool CGUIPanelContainer::GetCondition(int condition, int data) const
-{ // probably only works vertically atm...
- int row = m_cursor / m_itemsPerRow;
- int col = m_cursor % m_itemsPerRow;
- if (m_orientation == HORIZONTAL)
- swap(row, col);
- switch (condition)
- {
- case CONTAINER_ROW:
- return (row == data);
- case CONTAINER_COLUMN:
- return (col == data);
- default:
- return CGUIBaseContainer::GetCondition(condition, data);
- }
-}
-
-void CGUIPanelContainer::SelectItem(int item)
-{
- // Check that m_offset is valid
- ValidateOffset();
- // only select an item if it's in a valid range
- if (item >= 0 && item < (int)m_items.size())
- {
- // Select the item requested
- if (item >= m_offset * m_itemsPerRow && item < (m_offset + m_itemsPerPage) * m_itemsPerRow)
- { // the item is on the current page, so don't change it.
- SetCursor(item - m_offset * m_itemsPerRow);
- }
- else if (item < m_offset * m_itemsPerRow)
- { // item is on a previous page - make it the first item on the page
- SetCursor(item % m_itemsPerRow);
- ScrollToOffset((item - m_cursor) / m_itemsPerRow);
- }
- else // (item >= m_offset+m_itemsPerPage)
- { // item is on a later page - make it the last row on the page
- SetCursor(item % m_itemsPerRow + m_itemsPerRow * (m_itemsPerPage - 1));
- ScrollToOffset((item - m_cursor) / m_itemsPerRow);
- }
- }
-}
-
-bool CGUIPanelContainer::HasPreviousPage() const
-{
- return (m_offset > 0);
-}
-
-bool CGUIPanelContainer::HasNextPage() const
-{
- return (m_offset != (int)GetRows() - m_itemsPerPage && (int)GetRows() > m_itemsPerPage);
-}
-
diff --git a/guilib/GUIPanelContainer.h b/guilib/GUIPanelContainer.h
deleted file mode 100644
index f6f7b2a43f..0000000000
--- a/guilib/GUIPanelContainer.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*!
-\file GUIPanelContainer.h
-\brief
-*/
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIBaseContainer.h"
-
-/*!
- \ingroup controls
- \brief
- */
-class CGUIPanelContainer : public CGUIBaseContainer
-{
-public:
- CGUIPanelContainer(int parentID, int controlID, float posX, float posY, float width, float height, ORIENTATION orientation, int scrollTime, int preloadItems);
- virtual ~CGUIPanelContainer(void);
- virtual CGUIPanelContainer *Clone() const { return new CGUIPanelContainer(*this); };
-
- virtual void Render();
- virtual bool OnAction(const CAction &action);
- virtual bool OnMessage(CGUIMessage& message);
- virtual void OnLeft();
- virtual void OnRight();
- virtual void OnUp();
- virtual void OnDown();
- virtual bool GetCondition(int condition, int data) const;
-protected:
- virtual bool MoveUp(bool wrapAround);
- virtual bool MoveDown(bool wrapAround);
- virtual bool MoveLeft(bool wrapAround);
- virtual bool MoveRight(bool wrapAround);
- virtual void Scroll(int amount);
- float AnalogScrollSpeed() const;
- virtual void ValidateOffset();
- virtual void CalculateLayout();
- unsigned int GetRows() const;
- virtual int CorrectOffset(int offset, int cursor) const;
- virtual bool SelectItemFromPoint(const CPoint &point);
- virtual int GetCursorFromPoint(const CPoint &point, CPoint *itemPoint = NULL) const;
- void SetCursor(int cursor);
- virtual void SelectItem(int item);
- virtual bool HasPreviousPage() const;
- virtual bool HasNextPage() const;
-
- int m_itemsPerRow;
-};
-
diff --git a/guilib/GUIProgressControl.cpp b/guilib/GUIProgressControl.cpp
deleted file mode 100644
index f322040780..0000000000
--- a/guilib/GUIProgressControl.cpp
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIProgressControl.h"
-#include "utils/GUIInfoManager.h"
-
-CGUIProgressControl::CGUIProgressControl(int parentID, int controlID,
- float posX, float posY, float width,
- float height, const CTextureInfo& backGroundTexture,
- const CTextureInfo& leftTexture,
- const CTextureInfo& midTexture,
- const CTextureInfo& rightTexture,
- const CTextureInfo& overlayTexture,
- bool reveal)
- : CGUIControl(parentID, controlID, posX, posY, width, height)
- , m_guiBackground(posX, posY, width, height, backGroundTexture)
- , m_guiLeft(posX, posY, width, height, leftTexture)
- , m_guiMid(posX, posY, width, height, midTexture)
- , m_guiRight(posX, posY, width, height, rightTexture)
- , m_guiOverlay(posX, posY, width, height, overlayTexture)
-{
- m_fPercent = 0;
- m_iInfoCode = 0;
- ControlType = GUICONTROL_PROGRESS;
- m_bReveal = reveal;
-}
-
-CGUIProgressControl::~CGUIProgressControl(void)
-{
-}
-
-void CGUIProgressControl::SetPosition(float posX, float posY)
-{
- // everything is positioned based on the background image position
- CGUIControl::SetPosition(posX, posY);
- m_guiBackground.SetPosition(posX, posY);
-}
-
-void CGUIProgressControl::Render()
-{
- if (!IsDisabled())
- {
- if (m_iInfoCode)
- m_fPercent = (float)g_infoManager.GetInt(m_iInfoCode);
- if (m_fPercent < 0.0f) m_fPercent = 0.0f;
- if (m_fPercent > 100.0f) m_fPercent = 100.0f;
-
- if (m_width == 0)
- m_width = m_guiBackground.GetTextureWidth();
- if (m_height == 0)
- m_height = m_guiBackground.GetTextureHeight();
-
- m_guiBackground.SetHeight(m_height);
- m_guiBackground.SetWidth(m_width);
- m_guiBackground.Render();
-
- float fScaleX, fScaleY;
- fScaleY = m_guiBackground.GetTextureHeight() ? m_height / m_guiBackground.GetTextureHeight() : 1.0f;
- fScaleX = m_guiBackground.GetTextureWidth() ? m_width / m_guiBackground.GetTextureWidth() : 1.0f;
-
- float posX = m_guiBackground.GetXPosition();
- float posY = m_guiBackground.GetYPosition();
-
- if (m_guiLeft.GetFileName().IsEmpty() && m_guiRight.GetFileName().IsEmpty())
- { // rendering without left and right image - fill the mid image completely
- float width = m_fPercent * m_width * 0.01f;
- if (m_fPercent && width > 1)
- {
- float offset = fabs(fScaleY * 0.5f * (m_guiMid.GetTextureHeight() - m_guiBackground.GetTextureHeight()));
- if (offset > 0) // Center texture to the background if necessary
- m_guiMid.SetPosition(posX, posY + offset);
- else
- m_guiMid.SetPosition(posX, posY);
- m_guiMid.SetHeight(fScaleY * m_guiMid.GetTextureHeight());
- if (m_bReveal)
- {
- m_guiMid.SetWidth(m_width);
- g_graphicsContext.SetClipRegion(posX, posY+offset, width, fScaleY * m_guiMid.GetTextureHeight());
- m_guiMid.Render();
- g_graphicsContext.RestoreClipRegion();
- }
- else
- {
- m_guiMid.SetWidth(width);
- m_guiMid.Render();
- }
- }
- }
- else
- {
-
- float fWidth = m_fPercent;
- float fFullWidth = m_guiBackground.GetTextureWidth() - m_guiLeft.GetTextureWidth() - m_guiRight.GetTextureWidth();
- fWidth /= 100.0f;
- fWidth *= fFullWidth;
-
- float offset = fabs(fScaleY * 0.5f * (m_guiLeft.GetTextureHeight() - m_guiBackground.GetTextureHeight()));
- if (offset > 0) // Center texture to the background if necessary
- m_guiLeft.SetPosition(posX, posY + offset);
- else
- m_guiLeft.SetPosition(posX, posY);
- m_guiLeft.SetHeight(fScaleY * m_guiLeft.GetTextureHeight());
- m_guiLeft.SetWidth(fScaleX * m_guiLeft.GetTextureWidth());
- m_guiLeft.Render();
-
- posX += fScaleX * m_guiLeft.GetTextureWidth();
- if (m_fPercent && (int)(fScaleX * fWidth) > 1)
- {
- float offset = fabs(fScaleY * 0.5f * (m_guiMid.GetTextureHeight() - m_guiBackground.GetTextureHeight()));
- if (offset > 0) // Center texture to the background if necessary
- m_guiMid.SetPosition(posX, posY + offset);
- else
- m_guiMid.SetPosition(posX, posY);
- m_guiMid.SetHeight(fScaleY * m_guiMid.GetTextureHeight());
- if (m_bReveal)
- {
- m_guiMid.SetWidth(fScaleX * fFullWidth);
- g_graphicsContext.SetClipRegion(posX, posY+offset, fScaleX * fWidth, fScaleY * m_guiMid.GetTextureHeight());
- m_guiMid.Render();
- g_graphicsContext.RestoreClipRegion();
- }
- else
- {
- m_guiMid.SetWidth(fScaleX * fWidth);
- m_guiMid.Render();
- }
- posX += fWidth * fScaleX;
- }
-
- offset = fabs(fScaleY * 0.5f * (m_guiRight.GetTextureHeight() - m_guiBackground.GetTextureHeight()));
- if (offset > 0) // Center texture to the background if necessary
- m_guiRight.SetPosition(posX, posY + offset);
- else
- m_guiRight.SetPosition(posX, posY);
- m_guiRight.SetHeight(fScaleY * m_guiRight.GetTextureHeight());
- m_guiRight.SetWidth(fScaleX * m_guiRight.GetTextureWidth());
- m_guiRight.Render();
- }
- float offset = fabs(fScaleY * 0.5f * (m_guiOverlay.GetTextureHeight() - m_guiBackground.GetTextureHeight()));
- if (offset > 0) // Center texture to the background if necessary
- m_guiOverlay.SetPosition(m_guiBackground.GetXPosition(), m_guiBackground.GetYPosition() + offset);
- else
- m_guiOverlay.SetPosition(m_guiBackground.GetXPosition(), m_guiBackground.GetYPosition());
- m_guiOverlay.SetHeight(fScaleY * m_guiOverlay.GetTextureHeight());
- m_guiOverlay.SetWidth(fScaleX * m_guiOverlay.GetTextureWidth());
- m_guiOverlay.Render();
- }
- CGUIControl::Render();
-}
-
-
-bool CGUIProgressControl::CanFocus() const
-{
- return false;
-}
-
-
-bool CGUIProgressControl::OnMessage(CGUIMessage& message)
-{
- return CGUIControl::OnMessage(message);
-}
-
-void CGUIProgressControl::SetPercentage(float fPercent)
-{
- m_fPercent = fPercent;
-}
-
-float CGUIProgressControl::GetPercentage() const
-{
- return m_fPercent;
-}
-void CGUIProgressControl::FreeResources(bool immediately)
-{
- CGUIControl::FreeResources(immediately);
- m_guiBackground.FreeResources(immediately);
- m_guiMid.FreeResources(immediately);
- m_guiRight.FreeResources(immediately);
- m_guiLeft.FreeResources(immediately);
- m_guiOverlay.FreeResources(immediately);
-}
-
-void CGUIProgressControl::DynamicResourceAlloc(bool bOnOff)
-{
- CGUIControl::DynamicResourceAlloc(bOnOff);
- m_guiBackground.DynamicResourceAlloc(bOnOff);
- m_guiMid.DynamicResourceAlloc(bOnOff);
- m_guiRight.DynamicResourceAlloc(bOnOff);
- m_guiLeft.DynamicResourceAlloc(bOnOff);
- m_guiOverlay.DynamicResourceAlloc(bOnOff);
-}
-
-void CGUIProgressControl::AllocResources()
-{
- CGUIControl::AllocResources();
- m_guiBackground.AllocResources();
- m_guiMid.AllocResources();
- m_guiRight.AllocResources();
- m_guiLeft.AllocResources();
- m_guiOverlay.AllocResources();
-
- m_guiBackground.SetHeight(25);
- m_guiRight.SetHeight(20);
- m_guiLeft.SetHeight(20);
- m_guiMid.SetHeight(20);
- m_guiOverlay.SetHeight(20);
-}
-
-void CGUIProgressControl::SetInvalid()
-{
- CGUIControl::SetInvalid();
- m_guiBackground.SetInvalid();
- m_guiMid.SetInvalid();
- m_guiRight.SetInvalid();
- m_guiLeft.SetInvalid();
- m_guiOverlay.SetInvalid();
-}
-
-void CGUIProgressControl::SetInfo(int iInfo)
-{
- m_iInfoCode = iInfo;
-}
-
-void CGUIProgressControl::UpdateColors()
-{
- CGUIControl::UpdateColors();
- m_guiBackground.SetDiffuseColor(m_diffuseColor);
- m_guiRight.SetDiffuseColor(m_diffuseColor);
- m_guiLeft.SetDiffuseColor(m_diffuseColor);
- m_guiMid.SetDiffuseColor(m_diffuseColor);
- m_guiOverlay.SetDiffuseColor(m_diffuseColor);
-}
-
-CStdString CGUIProgressControl::GetDescription() const
-{
- CStdString percent;
- percent.Format("%2.f", m_fPercent);
- return percent;
-}
diff --git a/guilib/GUIProgressControl.h b/guilib/GUIProgressControl.h
deleted file mode 100644
index 86ea5c8cc7..0000000000
--- a/guilib/GUIProgressControl.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*!
-\file GUIProgressControl.h
-\brief
-*/
-
-#ifndef GUILIB_GUIPROGRESSCONTROL_H
-#define GUILIB_GUIPROGRESSCONTROL_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUITexture.h"
-#include "GUIControl.h"
-
-/*!
- \ingroup controls
- \brief
- */
-class CGUIProgressControl :
- public CGUIControl
-{
-public:
- CGUIProgressControl(int parentID, int controlID, float posX, float posY,
- float width, float height, const CTextureInfo& backGroundTexture,
- const CTextureInfo& leftTexture, const CTextureInfo& midTexture,
- const CTextureInfo& rightTexture, const CTextureInfo& overlayTexture,
- bool reveal=false);
- virtual ~CGUIProgressControl(void);
- virtual CGUIProgressControl *Clone() const { return new CGUIProgressControl(*this); };
-
- virtual void Render();
- virtual bool CanFocus() const;
- virtual void AllocResources();
- virtual void FreeResources(bool immediately = false);
- virtual void DynamicResourceAlloc(bool bOnOff);
- virtual void SetInvalid();
- virtual bool OnMessage(CGUIMessage& message);
- virtual void SetPosition(float posX, float posY);
- void SetPercentage(float fPercent);
- void SetInfo(int iInfo);
- int GetInfo() const {return m_iInfoCode;};
-
- float GetPercentage() const;
- CStdString GetDescription() const;
-protected:
- virtual void UpdateColors();
- CGUITexture m_guiBackground;
- CGUITexture m_guiLeft;
- CGUITexture m_guiMid;
- CGUITexture m_guiRight;
- CGUITexture m_guiOverlay;
- int m_iInfoCode;
- float m_fPercent;
- bool m_bReveal;
-};
-#endif
diff --git a/guilib/GUIRSSControl.cpp b/guilib/GUIRSSControl.cpp
deleted file mode 100644
index 0f841e585c..0000000000
--- a/guilib/GUIRSSControl.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIRSSControl.h"
-#include "GUIWindowManager.h"
-#include "GUISettings.h"
-#include "utils/CriticalSection.h"
-#include "utils/SingleLock.h"
-#include "utils/RssReader.h"
-#include "StringUtils.h"
-
-using namespace std;
-
-CGUIRSSControl::CGUIRSSControl(int parentID, int controlID, float posX, float posY, float width, float height, const CLabelInfo& labelInfo, const CGUIInfoColor &channelColor, const CGUIInfoColor &headlineColor, CStdString& strRSSTags)
-: CGUIControl(parentID, controlID, posX, posY, width, height),
- m_scrollInfo(0,0,labelInfo.scrollSpeed,"")
-{
- m_label = labelInfo;
- m_headlineColor = headlineColor;
- m_channelColor = channelColor;
-
- m_strRSSTags = strRSSTags;
-
- m_pReader = NULL;
- m_rtl = false;
- ControlType = GUICONTROL_RSS;
-}
-
-CGUIRSSControl::CGUIRSSControl(const CGUIRSSControl &from)
-: CGUIControl(from),m_scrollInfo(from.m_scrollInfo)
-{
- m_label = from.m_label;
- m_headlineColor = from.m_headlineColor;
- m_channelColor = from.m_channelColor;
- m_strRSSTags = from.m_strRSSTags;
- m_pReader = NULL;
- ControlType = GUICONTROL_RSS;
-}
-
-CGUIRSSControl::~CGUIRSSControl(void)
-{
- CSingleLock lock(m_criticalSection);
- if (m_pReader)
- m_pReader->SetObserver(NULL);
- m_pReader = NULL;
-}
-
-void CGUIRSSControl::SetUrls(const vector<string> &vecUrl, bool rtl)
-{
- m_vecUrls = vecUrl;
- m_rtl = rtl;
- if (m_scrollInfo.pixelSpeed > 0 && rtl)
- m_scrollInfo.pixelSpeed *= -1;
- else if (m_scrollInfo.pixelSpeed < 0 && !rtl)
- m_scrollInfo.pixelSpeed *= -1;
-}
-
-void CGUIRSSControl::SetIntervals(const vector<int>& vecIntervals)
-{
- m_vecIntervals = vecIntervals;
-}
-
-void CGUIRSSControl::UpdateColors()
-{
- m_label.UpdateColors();
- m_headlineColor.Update();
- m_channelColor.Update();
- CGUIControl::UpdateColors();
-}
-
-void CGUIRSSControl::Render()
-{
- // only render the control if they are enabled
- if (g_guiSettings.GetBool("lookandfeel.enablerssfeeds") && g_rssManager.IsActive())
- {
- CSingleLock lock(m_criticalSection);
- // Create RSS background/worker thread if needed
- if (m_pReader == NULL)
- {
- if (g_rssManager.GetReader(GetID(), GetParentID(), this, m_pReader))
- m_scrollInfo.characterPos = m_pReader->m_SavedScrollPos;
- else
- {
- if (m_strRSSTags != "")
- {
- CStdStringArray vecSplitTags;
-
- StringUtils::SplitString(m_strRSSTags, ",", vecSplitTags);
-
- for (unsigned int i = 0;i < vecSplitTags.size();i++)
- m_pReader->AddTag(vecSplitTags[i]);
- }
- // use half the width of the control as spacing between feeds, and double this between feed sets
- float spaceWidth = (m_label.font) ? m_label.font->GetCharWidth(L' ') : 15;
- m_pReader->Create(this, m_vecUrls, m_vecIntervals, (int)(0.5f*GetWidth() / spaceWidth) + 1, m_rtl);
- }
- }
-
- if (m_label.font)
- {
- vecColors colors;
- colors.push_back(m_label.textColor);
- colors.push_back(m_headlineColor);
- colors.push_back(m_channelColor);
- m_label.font->DrawScrollingText(m_posX, m_posY, colors, m_label.shadowColor, m_feed, 0, m_width, m_scrollInfo);
- }
-
- if (m_pReader)
- {
- m_pReader->CheckForUpdates();
- m_pReader->m_SavedScrollPos = m_scrollInfo.characterPos;
- }
- }
- CGUIControl::Render();
-}
-
-void CGUIRSSControl::OnFeedUpdate(const vecText &feed)
-{
- CSingleLock lock(m_criticalSection);
- m_feed = feed;
-}
-
-void CGUIRSSControl::OnFeedRelease()
-{
- m_pReader = NULL;
-}
-
-
diff --git a/guilib/GUIRSSControl.h b/guilib/GUIRSSControl.h
deleted file mode 100644
index c8ea850239..0000000000
--- a/guilib/GUIRSSControl.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*!
-\file GUIRSSControl.h
-\brief
-*/
-
-#ifndef GUILIB_GUIRSSControl_H
-#define GUILIB_GUIRSSControl_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIControl.h"
-#include "GUILabel.h"
-
-typedef uint32_t character_t;
-typedef uint32_t color_t;
-typedef std::vector<character_t> vecText;
-typedef std::vector<color_t> vecColors;
-
-class CRssReader;
-
-class IRssObserver
-{
-public:
- virtual void OnFeedUpdate(const vecText &feed) = 0;
- virtual void OnFeedRelease() = 0;
- virtual ~IRssObserver() {}
-};
-
-/*!
-\ingroup controls
-\brief
-*/
-class CGUIRSSControl : public CGUIControl, public IRssObserver
-{
-public:
- CGUIRSSControl(int parentID, int controlID, float posX, float posY, float width, float height, const CLabelInfo& labelInfo, const CGUIInfoColor &channelColor, const CGUIInfoColor &headlineColor, CStdString& strRSSTags);
- CGUIRSSControl(const CGUIRSSControl &from);
- virtual ~CGUIRSSControl(void);
- virtual CGUIRSSControl *Clone() const { return new CGUIRSSControl(*this); };
-
- virtual void Render();
- virtual void OnFeedUpdate(const vecText &feed);
- virtual void OnFeedRelease();
- virtual bool CanFocus() const { return false; };
-
- void SetIntervals(const std::vector<int>& vecIntervals);
- void SetUrls(const std::vector<std::string>& vecUrl, bool rtl);
-
-protected:
- virtual void UpdateColors();
-
- CCriticalSection m_criticalSection;
-
- CRssReader* m_pReader;
- vecText m_feed;
-
- CStdString m_strRSSTags;
-
- CLabelInfo m_label;
- CGUIInfoColor m_channelColor;
- CGUIInfoColor m_headlineColor;
-
- std::vector<std::string> m_vecUrls;
- std::vector<int> m_vecIntervals;
- bool m_rtl;
- CScrollInfo m_scrollInfo;
-};
-#endif
diff --git a/guilib/GUIRadioButtonControl.cpp b/guilib/GUIRadioButtonControl.cpp
deleted file mode 100644
index f8bccea3f6..0000000000
--- a/guilib/GUIRadioButtonControl.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIRadioButtonControl.h"
-#include "utils/GUIInfoManager.h"
-#include "GUIFontManager.h"
-#include "Key.h"
-
-CGUIRadioButtonControl::CGUIRadioButtonControl(int parentID, int controlID, float posX, float posY, float width, float height,
- const CTextureInfo& textureFocus, const CTextureInfo& textureNoFocus,
- const CLabelInfo& labelInfo,
- const CTextureInfo& radioOn, const CTextureInfo& radioOff)
- : CGUIButtonControl(parentID, controlID, posX, posY, width, height, textureFocus, textureNoFocus, labelInfo)
- , m_imgRadioOn(posX, posY, 16, 16, radioOn)
- , m_imgRadioOff(posX, posY, 16, 16, radioOff)
-{
- m_radioPosX = 0;
- m_radioPosY = 0;
- m_toggleSelect = 0;
- m_imgRadioOn.SetAspectRatio(CAspectRatio::AR_KEEP);\
- m_imgRadioOff.SetAspectRatio(CAspectRatio::AR_KEEP);
- ControlType = GUICONTROL_RADIO;
-}
-
-CGUIRadioButtonControl::~CGUIRadioButtonControl(void)
-{}
-
-
-void CGUIRadioButtonControl::Render()
-{
- CGUIButtonControl::Render();
-
- // ask our infoManager whether we are selected or not...
- if (m_toggleSelect)
- m_bSelected = g_infoManager.GetBool(m_toggleSelect, m_parentID);
-
- if ( IsSelected() && !IsDisabled() )
- m_imgRadioOn.Render();
- else
- m_imgRadioOff.Render();
-}
-
-bool CGUIRadioButtonControl::OnAction(const CAction &action)
-{
- if (action.GetID() == ACTION_SELECT_ITEM)
- {
- m_bSelected = !m_bSelected;
- }
- return CGUIButtonControl::OnAction(action);
-}
-
-bool CGUIRadioButtonControl::OnMessage(CGUIMessage& message)
-{
- return CGUIButtonControl::OnMessage(message);
-}
-
-void CGUIRadioButtonControl::AllocResources()
-{
- CGUIButtonControl::AllocResources();
- m_imgRadioOn.AllocResources();
- m_imgRadioOff.AllocResources();
-
- SetPosition(m_posX, m_posY);
-}
-
-void CGUIRadioButtonControl::FreeResources(bool immediately)
-{
- CGUIButtonControl::FreeResources(immediately);
- m_imgRadioOn.FreeResources(immediately);
- m_imgRadioOff.FreeResources(immediately);
-}
-
-void CGUIRadioButtonControl::DynamicResourceAlloc(bool bOnOff)
-{
- CGUIControl::DynamicResourceAlloc(bOnOff);
- m_imgRadioOn.DynamicResourceAlloc(bOnOff);
- m_imgRadioOff.DynamicResourceAlloc(bOnOff);
-}
-
-void CGUIRadioButtonControl::SetInvalid()
-{
- CGUIButtonControl::SetInvalid();
- m_imgRadioOn.SetInvalid();
- m_imgRadioOff.SetInvalid();
-}
-
-void CGUIRadioButtonControl::SetPosition(float posX, float posY)
-{
- CGUIButtonControl::SetPosition(posX, posY);
- float radioPosX = m_radioPosX ? m_posX + m_radioPosX : (m_posX + m_width - 8) - m_imgRadioOn.GetWidth();
- float radioPosY = m_radioPosY ? m_posY + m_radioPosY : m_posY + (m_height - m_imgRadioOn.GetHeight()) / 2;
- m_imgRadioOn.SetPosition(radioPosX, radioPosY);
- m_imgRadioOff.SetPosition(radioPosX, radioPosY);
-}
-
-void CGUIRadioButtonControl::SetRadioDimensions(float posX, float posY, float width, float height)
-{
- m_radioPosX = posX;
- m_radioPosY = posY;
- if (width)
- {
- m_imgRadioOn.SetWidth(width);
- m_imgRadioOff.SetWidth(width);
- }
- if (height)
- {
- m_imgRadioOn.SetHeight(height);
- m_imgRadioOff.SetHeight(height);
- }
- SetPosition(GetXPosition(), GetYPosition());
-}
-
-void CGUIRadioButtonControl::SetWidth(float width)
-{
- CGUIButtonControl::SetWidth(width);
- SetPosition(GetXPosition(), GetYPosition());
-}
-
-void CGUIRadioButtonControl::SetHeight(float height)
-{
- CGUIButtonControl::SetHeight(height);
- SetPosition(GetXPosition(), GetYPosition());
-}
-
-CStdString CGUIRadioButtonControl::GetDescription() const
-{
- CStdString strLabel = CGUIButtonControl::GetDescription();
- if (m_bSelected)
- strLabel += " (*)";
- else
- strLabel += " ( )";
- return strLabel;
-}
-
-void CGUIRadioButtonControl::UpdateColors()
-{
- CGUIButtonControl::UpdateColors();
- m_imgRadioOn.SetDiffuseColor(m_diffuseColor);
- m_imgRadioOff.SetDiffuseColor(m_diffuseColor);
-}
-
diff --git a/guilib/GUIRadioButtonControl.h b/guilib/GUIRadioButtonControl.h
deleted file mode 100644
index 2c66febfb2..0000000000
--- a/guilib/GUIRadioButtonControl.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*!
-\file GUIRadioButtonControl.h
-\brief
-*/
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIButtonControl.h"
-
-/*!
- \ingroup controls
- \brief
- */
-class CGUIRadioButtonControl :
- public CGUIButtonControl
-{
-public:
- CGUIRadioButtonControl(int parentID, int controlID,
- float posX, float posY, float width, float height,
- const CTextureInfo& textureFocus, const CTextureInfo& textureNoFocus,
- const CLabelInfo& labelInfo,
- const CTextureInfo& radioOn, const CTextureInfo& radioOff);
-
- virtual ~CGUIRadioButtonControl(void);
- virtual CGUIRadioButtonControl *Clone() const { return new CGUIRadioButtonControl(*this); };
-
- virtual void Render();
- virtual bool OnAction(const CAction &action) ;
- virtual bool OnMessage(CGUIMessage& message);
- virtual void AllocResources();
- virtual void FreeResources(bool immediately = false);
- virtual void DynamicResourceAlloc(bool bOnOff);
- virtual void SetInvalid();
- virtual void SetPosition(float posX, float posY);
- virtual void SetWidth(float width);
- virtual void SetHeight(float height);
- virtual CStdString GetDescription() const;
- void SetRadioDimensions(float posX, float posY, float width, float height);
- void SetToggleSelect(int toggleSelect) { m_toggleSelect = toggleSelect; };
- bool IsSelected() const { return m_bSelected; };
-protected:
- virtual void UpdateColors();
- CGUITexture m_imgRadioOn;
- CGUITexture m_imgRadioOff;
- float m_radioPosX;
- float m_radioPosY;
- int m_toggleSelect;
-};
diff --git a/guilib/GUIRenderingControl.cpp b/guilib/GUIRenderingControl.cpp
deleted file mode 100644
index b5cacef5d8..0000000000
--- a/guilib/GUIRenderingControl.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2005-2010 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIRenderingControl.h"
-#include "GUIUserMessages.h"
-#include "addons/Visualisation.h"
-#include "utils/SingleLock.h"
-
-using namespace std;
-using namespace ADDON;
-
-#define LABEL_ROW1 10
-#define LABEL_ROW2 11
-#define LABEL_ROW3 12
-
-CGUIRenderingControl::CGUIRenderingControl(int parentID, int controlID, float posX, float posY, float width, float height)
- : CGUIControl(parentID, controlID, posX, posY, width, height)
-{
- ControlType = GUICONTROL_RENDERADDON;
-}
-
-CGUIRenderingControl::CGUIRenderingControl(const CGUIRenderingControl &from)
-: CGUIControl(from)
-{
- ControlType = GUICONTROL_RENDERADDON;
-}
-
-void CGUIRenderingControl::LoadAddon(const AddonPtr &addon)
-{
- if (!addon)
- return;
-
- CSingleLock lock(m_rendering);
- g_graphicsContext.CaptureStateBlock();
- float x = g_graphicsContext.ScaleFinalXCoord(GetXPosition(), GetYPosition());
- float y = g_graphicsContext.ScaleFinalYCoord(GetXPosition(), GetYPosition());
- float w = g_graphicsContext.ScaleFinalXCoord(GetXPosition() + GetWidth(), GetYPosition() + GetHeight()) - x;
- float h = g_graphicsContext.ScaleFinalYCoord(GetXPosition() + GetWidth(), GetYPosition() + GetHeight()) - y;
- if (x < 0) x = 0;
- if (y < 0) y = 0;
- if (x + w > g_graphicsContext.GetWidth()) w = g_graphicsContext.GetWidth() - x;
- if (y + h > g_graphicsContext.GetHeight()) h = g_graphicsContext.GetHeight() - y;
-
- VizPtr viz = boost::dynamic_pointer_cast<CVisualisation>(addon);
- if (viz && viz->Create((int)(x+0.5f), (int)(y+0.5f), (int)(w+0.5f), (int)(h+0.5f)))
- {
- m_addon = viz;
- }
-
- g_graphicsContext.ApplyStateBlock();
- VerifyGLState();
-}
-
-void CGUIRenderingControl::UpdateVisibility(const CGUIListItem *item)
-{
- // if made invisible, start timer, only free addonptr after
- // some period, configurable by window class
- CGUIControl::UpdateVisibility(item);
- if (!IsVisible() && m_addon)
- FreeResources();
-}
-
-void CGUIRenderingControl::Render()
-{
- CSingleLock lock(m_rendering);
- if (m_addon)
- {
- // set the viewport - note: We currently don't have any control over how
- // the addon renders, so the best we can do is attempt to define
- // a viewport??
- g_graphicsContext.SetViewPort(m_posX, m_posY, m_width, m_height);
- g_graphicsContext.CaptureStateBlock();
- m_addon->Render();
- g_graphicsContext.ApplyStateBlock();
- g_graphicsContext.RestoreViewPort();
- }
-
- CGUIControl::Render();
-}
-
-void CGUIRenderingControl::FreeResources(bool immediately)
-{
- if (!m_addon) return;
-
- CSingleLock lock(m_rendering);
- g_graphicsContext.CaptureStateBlock(); //TODO locking
- m_addon->Stop();
- g_graphicsContext.ApplyStateBlock();
- m_addon.reset();
-}
-
-bool CGUIRenderingControl::CanFocusFromPoint(const CPoint &point) const
-{ // mouse is allowed to focus this control, but it doesn't actually receive focus
- return IsVisible() && HitTest(point);
-}
diff --git a/guilib/GUIRenderingControl.h b/guilib/GUIRenderingControl.h
deleted file mode 100644
index 8858c7dff3..0000000000
--- a/guilib/GUIRenderingControl.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#pragma once
-/*
- * Copyright (C) 2005-2010 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIControl.h"
-#include "addons/IAddon.h"
-
-class CGUIRenderingControl : public CGUIControl
-{
-public:
- CGUIRenderingControl(int parentID, int controlID, float posX, float posY, float width, float height);
- CGUIRenderingControl(const CGUIRenderingControl &from);
- virtual CGUIRenderingControl *Clone() const { return new CGUIRenderingControl(*this); }; //TODO check for naughties
-
- virtual void Render();
- virtual void UpdateVisibility(const CGUIListItem *item = NULL);
- virtual void FreeResources(bool immediately = false);
- virtual bool CanFocus() const { return false; }
- virtual bool CanFocusFromPoint(const CPoint &point) const;
- void LoadAddon(const ADDON::AddonPtr &addon);
-
-protected:
- CCriticalSection m_rendering;
- ADDON::VizPtr m_addon;
-};
diff --git a/guilib/GUIResizeControl.cpp b/guilib/GUIResizeControl.cpp
deleted file mode 100644
index ca92594614..0000000000
--- a/guilib/GUIResizeControl.cpp
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIResizeControl.h"
-#include "GUIWindowManager.h"
-#include "Key.h"
-#include "utils/TimeUtils.h"
-
-// time to reset accelerated cursors (digital movement)
-#define MOVE_TIME_OUT 500L
-
-CGUIResizeControl::CGUIResizeControl(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& textureFocus, const CTextureInfo& textureNoFocus)
- : CGUIControl(parentID, controlID, posX, posY, width, height)
- , m_imgFocus(posX, posY, width, height, textureFocus)
- , m_imgNoFocus(posX, posY, width, height, textureNoFocus)
-{
- m_frameCounter = 0;
- m_lastMoveTime = 0;
- m_fSpeed = 1.0;
- m_fAnalogSpeed = 2.0f; // TODO: implement correct analog speed
- m_fAcceleration = 0.2f; // TODO: implement correct computation of acceleration
- m_fMaxSpeed = 10.0; // TODO: implement correct computation of maxspeed
- ControlType = GUICONTROL_RESIZE;
- SetLimits(0, 0, 720, 576); // defaults
-}
-
-CGUIResizeControl::~CGUIResizeControl(void)
-{}
-
-void CGUIResizeControl::Render()
-{
- if (m_bInvalidated)
- {
- m_imgFocus.SetWidth(m_width);
- m_imgFocus.SetHeight(m_height);
-
- m_imgNoFocus.SetWidth(m_width);
- m_imgNoFocus.SetHeight(m_height);
- }
- if (HasFocus())
- {
- unsigned int alphaCounter = m_frameCounter + 2;
- unsigned int alphaChannel;
- if ((alphaCounter % 128) >= 64)
- alphaChannel = alphaCounter % 64;
- else
- alphaChannel = 63 - (alphaCounter % 64);
-
- alphaChannel += 192;
- SetAlpha( (unsigned char)alphaChannel );
- m_imgFocus.SetVisible(true);
- m_imgNoFocus.SetVisible(false);
- m_frameCounter++;
- }
- else
- {
- SetAlpha(0xff);
- m_imgFocus.SetVisible(false);
- m_imgNoFocus.SetVisible(true);
- }
- // render both so the visibility settings cause the frame counter to resetcorrectly
- m_imgFocus.Render();
- m_imgNoFocus.Render();
- CGUIControl::Render();
-}
-
-bool CGUIResizeControl::OnAction(const CAction &action)
-{
- if (action.GetID() == ACTION_SELECT_ITEM)
- {
- // button selected - send message to parent
- CGUIMessage message(GUI_MSG_CLICKED, GetID(), GetParentID());
- SendWindowMessage(message);
- return true;
- }
- if (action.GetID() == ACTION_ANALOG_MOVE)
- {
- Resize(m_fAnalogSpeed*action.GetAmount(), -m_fAnalogSpeed*action.GetAmount(1));
- return true;
- }
- return CGUIControl::OnAction(action);
-}
-
-void CGUIResizeControl::OnUp()
-{
- UpdateSpeed(DIRECTION_UP);
- Resize(0, -m_fSpeed);
-}
-
-void CGUIResizeControl::OnDown()
-{
- UpdateSpeed(DIRECTION_DOWN);
- Resize(0, m_fSpeed);
-}
-
-void CGUIResizeControl::OnLeft()
-{
- UpdateSpeed(DIRECTION_LEFT);
- Resize(-m_fSpeed, 0);
-}
-
-void CGUIResizeControl::OnRight()
-{
- UpdateSpeed(DIRECTION_RIGHT);
- Resize(m_fSpeed, 0);
-}
-
-EVENT_RESULT CGUIResizeControl::OnMouseEvent(const CPoint &point, const CMouseEvent &event)
-{
- if (event.m_id == ACTION_MOUSE_DRAG)
- {
- if (event.m_state == 1)
- { // grab exclusive access
- CGUIMessage msg(GUI_MSG_EXCLUSIVE_MOUSE, GetID(), GetParentID());
- SendWindowMessage(msg);
- }
- else if (event.m_state == 3)
- { // release exclusive access
- CGUIMessage msg(GUI_MSG_EXCLUSIVE_MOUSE, 0, GetParentID());
- SendWindowMessage(msg);
- }
- Resize(event.m_offsetX, event.m_offsetY);
- return EVENT_RESULT_HANDLED;
- }
- return EVENT_RESULT_UNHANDLED;
-}
-
-void CGUIResizeControl::UpdateSpeed(int nDirection)
-{
- if (CTimeUtils::GetFrameTime() - m_lastMoveTime > MOVE_TIME_OUT)
- {
- m_fSpeed = 1;
- m_nDirection = DIRECTION_NONE;
- }
- m_lastMoveTime = CTimeUtils::GetFrameTime();
- if (nDirection == m_nDirection)
- { // accelerate
- m_fSpeed += m_fAcceleration;
- if (m_fSpeed > m_fMaxSpeed) m_fSpeed = m_fMaxSpeed;
- }
- else
- { // reset direction and speed
- m_fSpeed = 1;
- m_nDirection = nDirection;
- }
-}
-
-void CGUIResizeControl::AllocResources()
-{
- CGUIControl::AllocResources();
- m_frameCounter = 0;
- m_imgFocus.AllocResources();
- m_imgNoFocus.AllocResources();
- m_width = m_imgFocus.GetWidth();
- m_height = m_imgFocus.GetHeight();
-}
-
-void CGUIResizeControl::FreeResources(bool immediately)
-{
- CGUIControl::FreeResources(immediately);
- m_imgFocus.FreeResources(immediately);
- m_imgNoFocus.FreeResources(immediately);
-}
-
-void CGUIResizeControl::DynamicResourceAlloc(bool bOnOff)
-{
- CGUIControl::DynamicResourceAlloc(bOnOff);
- m_imgFocus.DynamicResourceAlloc(bOnOff);
- m_imgNoFocus.DynamicResourceAlloc(bOnOff);
-}
-
-void CGUIResizeControl::SetInvalid()
-{
- CGUIControl::SetInvalid();
- m_imgFocus.SetInvalid();
- m_imgNoFocus.SetInvalid();
-}
-
-void CGUIResizeControl::Resize(float x, float y)
-{
- float width = m_width + x;
- float height = m_height + y;
- // check if we are within the bounds
- if (width < m_x1) width = m_x1;
- if (height < m_y1) height = m_y1;
- if (width > m_x2) width = m_x2;
- if (height > m_y2) height = m_y2;
- // ok, now set the default size of the resize control
- SetWidth(width);
- SetHeight(height);
-}
-
-void CGUIResizeControl::SetPosition(float posX, float posY)
-{
- CGUIControl::SetPosition(posX, posY);
- m_imgFocus.SetPosition(posX, posY);
- m_imgNoFocus.SetPosition(posX, posY);
-}
-
-void CGUIResizeControl::SetAlpha(unsigned char alpha)
-{
- m_imgFocus.SetAlpha(alpha);
- m_imgNoFocus.SetAlpha(alpha);
-}
-
-void CGUIResizeControl::UpdateColors()
-{
- CGUIControl::UpdateColors();
- m_imgFocus.SetDiffuseColor(m_diffuseColor);
- m_imgNoFocus.SetDiffuseColor(m_diffuseColor);
-}
-
-void CGUIResizeControl::SetLimits(float x1, float y1, float x2, float y2)
-{
- m_x1 = x1;
- m_y1 = y1;
- m_x2 = x2;
- m_y2 = y2;
-}
diff --git a/guilib/GUIResizeControl.h b/guilib/GUIResizeControl.h
deleted file mode 100644
index b28a12f02b..0000000000
--- a/guilib/GUIResizeControl.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*!
-\file GUIRESIZEControl.h
-\brief
-*/
-
-#ifndef GUILIB_GUIRESIZECONTROL_H
-#define GUILIB_GUIRESIZECONTROL_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUITexture.h"
-#include "GUIControl.h"
-
-#define DIRECTION_NONE 0
-#define DIRECTION_UP 1
-#define DIRECTION_DOWN 2
-#define DIRECTION_LEFT 3
-#define DIRECTION_RIGHT 4
-
-/*!
- \ingroup controls
- \brief
- */
-class CGUIResizeControl : public CGUIControl
-{
-public:
- CGUIResizeControl(int parentID, int controlID,
- float posX, float posY, float width, float height,
- const CTextureInfo& textureFocus, const CTextureInfo& textureNoFocus);
-
- virtual ~CGUIResizeControl(void);
- virtual CGUIResizeControl *Clone() const { return new CGUIResizeControl(*this); };
-
- virtual void Render();
- virtual bool OnAction(const CAction &action);
- virtual void OnUp();
- virtual void OnDown();
- virtual void OnLeft();
- virtual void OnRight();
- virtual void AllocResources();
- virtual void FreeResources(bool immediately = false);
- virtual void DynamicResourceAlloc(bool bOnOff);
- virtual void SetInvalid();
- virtual void SetPosition(float posX, float posY);
- void SetLimits(float x1, float y1, float x2, float y2);
-
-protected:
- virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event);
- virtual void UpdateColors();
- void SetAlpha(unsigned char alpha);
- void UpdateSpeed(int nDirection);
- void Resize(float x, float y);
- CGUITexture m_imgFocus;
- CGUITexture m_imgNoFocus;
- unsigned int m_frameCounter;
- unsigned int m_lastMoveTime;
- int m_nDirection;
- float m_fSpeed;
- float m_fAnalogSpeed;
- float m_fMaxSpeed;
- float m_fAcceleration;
- float m_x1, m_x2, m_y1, m_y2;
-};
-#endif
diff --git a/guilib/GUIScrollBarControl.cpp b/guilib/GUIScrollBarControl.cpp
deleted file mode 100644
index a74dfc72fb..0000000000
--- a/guilib/GUIScrollBarControl.cpp
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIScrollBarControl.h"
-#include "Key.h"
-
-#define MIN_NIB_SIZE 4.0f
-
-CGUIScrollBar::CGUIScrollBar(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& backGroundTexture, const CTextureInfo& barTexture, const CTextureInfo& barTextureFocus, const CTextureInfo& nibTexture, const CTextureInfo& nibTextureFocus, ORIENTATION orientation, bool showOnePage)
- : CGUIControl(parentID, controlID, posX, posY, width, height)
- , m_guiBackground(posX, posY, width, height, backGroundTexture)
- , m_guiBarNoFocus(posX, posY, width, height, barTexture)
- , m_guiBarFocus(posX, posY, width, height, barTextureFocus)
- , m_guiNibNoFocus(posX, posY, width, height, nibTexture)
- , m_guiNibFocus(posX, posY, width, height, nibTextureFocus)
-{
- m_guiNibNoFocus.SetAspectRatio(CAspectRatio::AR_CENTER);
- m_guiNibFocus.SetAspectRatio(CAspectRatio::AR_CENTER);
- m_numItems = 100;
- m_offset = 0;
- m_pageSize = 10;
- ControlType = GUICONTROL_SCROLLBAR;
- m_orientation = orientation;
- m_showOnePage = showOnePage;
-}
-
-CGUIScrollBar::~CGUIScrollBar(void)
-{
-}
-
-
-void CGUIScrollBar::Render()
-{
- if (m_bInvalidated)
- UpdateBarSize();
-
- m_guiBackground.Render();
- if (m_bHasFocus)
- {
- m_guiBarFocus.Render();
- m_guiNibFocus.Render();
- }
- else
- {
- m_guiBarNoFocus.Render();
- m_guiNibNoFocus.Render();
- }
-
- CGUIControl::Render();
-}
-
-bool CGUIScrollBar::OnMessage(CGUIMessage& message)
-{
- switch (message.GetMessage())
- {
- case GUI_MSG_ITEM_SELECT:
- SetValue(message.GetParam1());
- return true;
- case GUI_MSG_LABEL_RESET:
- SetRange(message.GetParam1(), message.GetParam2());
- return true;
- case GUI_MSG_PAGE_UP:
- Move(-1);
- return true;
- case GUI_MSG_PAGE_DOWN:
- Move(1);
- return true;
- }
- return CGUIControl::OnMessage(message);
-}
-
-bool CGUIScrollBar::OnAction(const CAction &action)
-{
- switch ( action.GetID() )
- {
- case ACTION_MOVE_LEFT:
- if (m_orientation == HORIZONTAL)
- {
- Move( -1);
- return true;
- }
- break;
-
- case ACTION_MOVE_RIGHT:
- if (m_orientation == HORIZONTAL)
- {
- Move(1);
- return true;
- }
- break;
- case ACTION_MOVE_UP:
- if (m_orientation == VERTICAL)
- {
- Move(-1);
- return true;
- }
- break;
-
- case ACTION_MOVE_DOWN:
- if (m_orientation == VERTICAL)
- {
- Move(1);
- return true;
- }
- break;
- }
- return CGUIControl::OnAction(action);
-}
-
-void CGUIScrollBar::Move(int numSteps)
-{
- m_offset += numSteps * m_pageSize;
- if (m_offset > m_numItems - m_pageSize) m_offset = m_numItems - m_pageSize;
- if (m_offset < 0) m_offset = 0;
- CGUIMessage message(GUI_MSG_NOTIFY_ALL, GetParentID(), GetID(), GUI_MSG_PAGE_CHANGE, m_offset);
- SendWindowMessage(message);
- SetInvalid();
-}
-
-void CGUIScrollBar::SetRange(int pageSize, int numItems)
-{
- m_pageSize = pageSize;
- m_numItems = numItems;
- m_offset = 0;
- SetInvalid();
-}
-
-void CGUIScrollBar::SetValue(int value)
-{
- m_offset = value;
- SetInvalid();
-}
-
-void CGUIScrollBar::FreeResources(bool immediately)
-{
- CGUIControl::FreeResources(immediately);
- m_guiBackground.FreeResources(immediately);
- m_guiBarNoFocus.FreeResources(immediately);
- m_guiBarFocus.FreeResources(immediately);
- m_guiNibNoFocus.FreeResources(immediately);
- m_guiNibFocus.FreeResources(immediately);
-}
-
-void CGUIScrollBar::DynamicResourceAlloc(bool bOnOff)
-{
- CGUIControl::DynamicResourceAlloc(bOnOff);
- m_guiBackground.DynamicResourceAlloc(bOnOff);
- m_guiBarNoFocus.DynamicResourceAlloc(bOnOff);
- m_guiBarFocus.DynamicResourceAlloc(bOnOff);
- m_guiNibNoFocus.DynamicResourceAlloc(bOnOff);
- m_guiNibFocus.DynamicResourceAlloc(bOnOff);
-}
-
-void CGUIScrollBar::AllocResources()
-{
- CGUIControl::AllocResources();
- m_guiBackground.AllocResources();
- m_guiBarNoFocus.AllocResources();
- m_guiBarFocus.AllocResources();
- m_guiNibNoFocus.AllocResources();
- m_guiNibFocus.AllocResources();
-}
-
-void CGUIScrollBar::SetInvalid()
-{
- CGUIControl::SetInvalid();
- m_guiBackground.SetInvalid();
- m_guiBarFocus.SetInvalid();
- m_guiBarFocus.SetInvalid();
- m_guiNibNoFocus.SetInvalid();
- m_guiNibFocus.SetInvalid();
-}
-
-void CGUIScrollBar::UpdateBarSize()
-{
- // scale our textures to suit
- if (m_orientation == VERTICAL)
- {
- // calculate the height to display the nib at
- float percent = (m_numItems == 0) ? 0 : (float)m_pageSize / m_numItems;
- float nibSize = GetHeight() * percent;
- if (nibSize < m_guiNibFocus.GetTextureHeight() + 2 * MIN_NIB_SIZE) nibSize = m_guiNibFocus.GetTextureHeight() + 2 * MIN_NIB_SIZE;
- if (nibSize > GetHeight()) nibSize = GetHeight();
-
- m_guiBarNoFocus.SetHeight(nibSize);
- m_guiBarFocus.SetHeight(nibSize);
- m_guiNibNoFocus.SetHeight(nibSize);
- m_guiNibFocus.SetHeight(nibSize);
- // nibSize may be altered by the border size of the nib (and bar).
- nibSize = std::max(m_guiBarFocus.GetHeight(), m_guiNibFocus.GetHeight());
-
- // and the position
- percent = (m_numItems == m_pageSize) ? 0 : (float)m_offset / (m_numItems - m_pageSize);
- float nibPos = (GetHeight() - nibSize) * percent;
- if (nibPos < 0) nibPos = 0;
- if (nibPos > GetHeight() - nibSize) nibPos = GetHeight() - nibSize;
- m_guiBarNoFocus.SetPosition(GetXPosition(), GetYPosition() + nibPos);
- m_guiBarFocus.SetPosition(GetXPosition(), GetYPosition() + nibPos);
- m_guiNibNoFocus.SetPosition(GetXPosition(), GetYPosition() + nibPos);
- m_guiNibFocus.SetPosition(GetXPosition(), GetYPosition() + nibPos);
- }
- else
- {
- // calculate the height to display the nib at
- float percent = (m_numItems == 0) ? 0 : (float)m_pageSize / m_numItems;
- float nibSize = GetWidth() * percent + 0.5f;
- if (nibSize < m_guiNibFocus.GetTextureWidth() + 2 * MIN_NIB_SIZE) nibSize = m_guiNibFocus.GetTextureWidth() + 2 * MIN_NIB_SIZE;
- if (nibSize > GetWidth()) nibSize = GetWidth();
-
- m_guiBarNoFocus.SetWidth(nibSize);
- m_guiBarFocus.SetWidth(nibSize);
- m_guiNibNoFocus.SetWidth(nibSize);
- m_guiNibFocus.SetWidth(nibSize);
-
- // and the position
- percent = (m_numItems == m_pageSize) ? 0 : (float)m_offset / (m_numItems - m_pageSize);
- float nibPos = (GetWidth() - nibSize) * percent;
- if (nibPos < 0) nibPos = 0;
- if (nibPos > GetWidth() - nibSize) nibPos = GetWidth() - nibSize;
- m_guiBarNoFocus.SetPosition(GetXPosition() + nibPos, GetYPosition());
- m_guiBarFocus.SetPosition(GetXPosition() + nibPos, GetYPosition());
- m_guiNibNoFocus.SetPosition(GetXPosition() + nibPos, GetYPosition());
- m_guiNibFocus.SetPosition(GetXPosition() + nibPos, GetYPosition());
- }
-}
-
-bool CGUIScrollBar::HitTest(const CPoint &point) const
-{
- if (m_guiBackground.HitTest(point)) return true;
- if (m_guiBarNoFocus.HitTest(point)) return true;
- return false;
-}
-
-void CGUIScrollBar::SetFromPosition(const CPoint &point)
-{
- float fPercent;
- if (m_orientation == VERTICAL)
- fPercent = (point.y - m_guiBackground.GetYPosition() - 0.5f*m_guiBarFocus.GetHeight()) / m_guiBackground.GetHeight();
- else
- fPercent = (point.x - m_guiBackground.GetXPosition() - 0.5f*m_guiBarFocus.GetWidth()) / m_guiBackground.GetWidth();
- if (fPercent < 0) fPercent = 0;
- if (fPercent > 1) fPercent = 1;
- m_offset = (int)(floor(fPercent * m_numItems + 0.5f));
- CGUIMessage message(GUI_MSG_NOTIFY_ALL, GetParentID(), GetID(), GUI_MSG_PAGE_CHANGE, m_offset);
- SendWindowMessage(message);
- SetInvalid();
-}
-
-EVENT_RESULT CGUIScrollBar::OnMouseEvent(const CPoint &point, const CMouseEvent &event)
-{
- if (event.m_id == ACTION_MOUSE_DRAG)
- {
- if (event.m_state == 1)
- { // we want exclusive access
- CGUIMessage msg(GUI_MSG_EXCLUSIVE_MOUSE, GetID(), GetParentID());
- SendWindowMessage(msg);
- }
- else if (event.m_state == 3)
- { // we're done with exclusive access
- CGUIMessage msg(GUI_MSG_EXCLUSIVE_MOUSE, 0, GetParentID());
- SendWindowMessage(msg);
- }
- SetFromPosition(point);
- return EVENT_RESULT_HANDLED;
- }
- else if (event.m_id == ACTION_MOUSE_LEFT_CLICK && m_guiBackground.HitTest(point))
- {
- SetFromPosition(point);
- return EVENT_RESULT_HANDLED;
- }
- else if (event.m_id == ACTION_MOUSE_WHEEL_UP)
- {
- Move(-1);
- return EVENT_RESULT_HANDLED;
- }
- else if (event.m_id == ACTION_MOUSE_WHEEL_DOWN)
- {
- Move(1);
- return EVENT_RESULT_HANDLED;
- }
- return EVENT_RESULT_UNHANDLED;
-}
-
-CStdString CGUIScrollBar::GetDescription() const
-{
- CStdString description;
- description.Format("%i/%i", m_offset, m_numItems);
- return description;
-}
-
-void CGUIScrollBar::UpdateColors()
-{
- CGUIControl::UpdateColors();
- m_guiBackground.SetDiffuseColor(m_diffuseColor);
- m_guiBarNoFocus.SetDiffuseColor(m_diffuseColor);
- m_guiBarFocus.SetDiffuseColor(m_diffuseColor);
- m_guiNibNoFocus.SetDiffuseColor(m_diffuseColor);
- m_guiNibFocus.SetDiffuseColor(m_diffuseColor);
-}
-
-bool CGUIScrollBar::IsVisible() const
-{
- // page controls can be optionally disabled if the number of pages is 1
- if (m_numItems <= m_pageSize && !m_showOnePage)
- return false;
- return CGUIControl::IsVisible();
-}
diff --git a/guilib/GUIScrollBarControl.h b/guilib/GUIScrollBarControl.h
deleted file mode 100644
index c26db1567d..0000000000
--- a/guilib/GUIScrollBarControl.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*!
-\file GUIScrollBar.h
-\brief
-*/
-
-#ifndef GUILIB_GUISCROLLBAR_H
-#define GUILIB_GUISCROLLBAR_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUITexture.h"
-#include "GUIControl.h"
-
-/*!
- \ingroup controls
- \brief
- */
-class CGUIScrollBar :
- public CGUIControl
-{
-public:
- CGUIScrollBar(int parentID, int controlID, float posX, float posY,
- float width, float height,
- const CTextureInfo& backGroundTexture,
- const CTextureInfo& barTexture, const CTextureInfo& barTextureFocus,
- const CTextureInfo& nibTexture, const CTextureInfo& nibTextureFocus,
- ORIENTATION orientation, bool showOnePage);
- virtual ~CGUIScrollBar(void);
- virtual CGUIScrollBar *Clone() const { return new CGUIScrollBar(*this); };
-
- virtual void Render();
- virtual bool OnAction(const CAction &action);
- virtual void AllocResources();
- virtual void FreeResources(bool immediately = false);
- virtual void DynamicResourceAlloc(bool bOnOff);
- virtual void SetInvalid();
- virtual void SetRange(int pageSize, int numItems);
- virtual bool OnMessage(CGUIMessage& message);
- void SetValue(int value);
- int GetValue() const;
- virtual CStdString GetDescription() const;
- virtual bool IsVisible() const;
-protected:
- virtual bool HitTest(const CPoint &point) const;
- virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event);
- virtual void UpdateColors();
- void UpdateBarSize();
- virtual void Move(int iNumSteps);
- virtual void SetFromPosition(const CPoint &point);
-
- CGUITexture m_guiBackground;
- CGUITexture m_guiBarNoFocus;
- CGUITexture m_guiBarFocus;
- CGUITexture m_guiNibNoFocus;
- CGUITexture m_guiNibFocus;
-
- int m_numItems;
- int m_pageSize;
- int m_offset;
-
- bool m_showOnePage;
- ORIENTATION m_orientation;
-};
-#endif
diff --git a/guilib/GUISelectButtonControl.cpp b/guilib/GUISelectButtonControl.cpp
deleted file mode 100644
index 7dd9597aaa..0000000000
--- a/guilib/GUISelectButtonControl.cpp
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUISelectButtonControl.h"
-#include "GUIWindowManager.h"
-#include "utils/CharsetConverter.h"
-#include "utils/TimeUtils.h"
-#include "Key.h"
-
-CGUISelectButtonControl::CGUISelectButtonControl(int parentID, int controlID,
- float posX, float posY,
- float width, float height,
- const CTextureInfo& buttonFocus,
- const CTextureInfo& button,
- const CLabelInfo& labelInfo,
- const CTextureInfo& selectBackground,
- const CTextureInfo& selectArrowLeft,
- const CTextureInfo& selectArrowLeftFocus,
- const CTextureInfo& selectArrowRight,
- const CTextureInfo& selectArrowRightFocus
- )
- : CGUIButtonControl(parentID, controlID, posX, posY, width, height, buttonFocus, button, labelInfo)
- , m_imgBackground(posX, posY, width, height, selectBackground)
- , m_imgLeft(posX, posY, 16, 16, selectArrowLeft)
- , m_imgLeftFocus(posX, posY, 16, 16, selectArrowLeftFocus)
- , m_imgRight(posX, posY, 16, 16, selectArrowRight)
- , m_imgRightFocus(posX, posY, 16, 16, selectArrowRightFocus)
-{
- m_bShowSelect = false;
- m_iCurrentItem = -1;
- m_iDefaultItem = -1;
- m_iStartFrame = 0;
- m_bLeftSelected = false;
- m_bRightSelected = false;
- m_bMovedLeft = false;
- m_bMovedRight = false;
- m_ticks = 0;
- m_label.SetAlign(m_label.GetLabelInfo().align | XBFONT_CENTER_X);
- ControlType = GUICONTROL_SELECTBUTTON;
-}
-
-CGUISelectButtonControl::~CGUISelectButtonControl(void)
-{}
-
-void CGUISelectButtonControl::Render()
-{
- if (m_bInvalidated)
- {
- m_imgBackground.SetWidth(m_width);
- m_imgBackground.SetHeight(m_height);
- }
- // Are we in selection mode
- if (m_bShowSelect)
- {
- // render background, left and right arrow
- m_imgBackground.Render();
-
- CGUILabel::COLOR color = CGUILabel::COLOR_TEXT;
-
- // User has moved left...
- if (m_bMovedLeft)
- {
- m_iStartFrame++;
- if (m_iStartFrame >= 10)
- {
- m_iStartFrame = 0;
- m_bMovedLeft = false;
- }
- // If we are moving left
- // render item text as disabled
- color = CGUILabel::COLOR_DISABLED;
- }
-
- // Render arrow
- if (m_bLeftSelected || m_bMovedLeft)
- m_imgLeftFocus.Render();
- else
- m_imgLeft.Render();
-
- // User has moved right...
- if (m_bMovedRight)
- {
- m_iStartFrame++;
- if (m_iStartFrame >= 10)
- {
- m_iStartFrame = 0;
- m_bMovedRight = false;
- }
- // If we are moving right
- // render item text as disabled
- color = CGUILabel::COLOR_DISABLED;
- }
-
- // Render arrow
- if (m_bRightSelected || m_bMovedRight)
- m_imgRightFocus.Render();
- else
- m_imgRight.Render();
-
- // Render text if a current item is available
- if (m_iCurrentItem >= 0 && (unsigned)m_iCurrentItem < m_vecItems.size())
- {
- m_label.SetMaxRect(m_posX, m_posY, m_width, m_height);
- m_label.SetText(m_vecItems[m_iCurrentItem]);
- m_label.SetColor(color);
- m_label.Render();
- }
-
- // Select current item, if user doesn't
- // move left or right for 1.5 sec.
- unsigned int ticksSpan = CTimeUtils::GetFrameTime() - m_ticks;
- if (ticksSpan > 1500)
- {
- // User hasn't moved disable selection mode...
- m_bShowSelect = false;
-
- // ...and send a thread message.
- // (Sending a message with SendMessage
- // can result in a GPF.)
- CGUIMessage message(GUI_MSG_CLICKED, GetID(), GetParentID() );
- g_windowManager.SendThreadMessage(message);
- }
- } // if (m_bShowSelect)
- else
- {
- // No, render a normal button
- CGUIButtonControl::Render();
- }
- CGUIControl::Render();
-}
-
-bool CGUISelectButtonControl::OnMessage(CGUIMessage& message)
-{
- if ( message.GetControlId() == GetID() )
- {
- if (message.GetMessage() == GUI_MSG_LABEL_ADD)
- {
- if (m_vecItems.size() <= 0)
- {
- m_iCurrentItem = 0;
- m_iDefaultItem = 0;
- }
- m_vecItems.push_back(message.GetLabel());
- return true;
- }
- else if (message.GetMessage() == GUI_MSG_LABEL_RESET)
- {
- m_vecItems.erase(m_vecItems.begin(), m_vecItems.end());
- m_iCurrentItem = -1;
- m_iDefaultItem = -1;
- return true;
- }
- else if (message.GetMessage() == GUI_MSG_ITEM_SELECTED)
- {
- message.SetParam1(m_iCurrentItem);
- if (m_iCurrentItem >= 0 && m_iCurrentItem < (int)m_vecItems.size())
- message.SetLabel(m_vecItems[m_iCurrentItem]);
- return true;
- }
- else if (message.GetMessage() == GUI_MSG_ITEM_SELECT)
- {
- m_iDefaultItem = m_iCurrentItem = message.GetParam1();
- return true;
- }
- }
-
- return CGUIButtonControl::OnMessage(message);
-}
-
-bool CGUISelectButtonControl::OnAction(const CAction &action)
-{
- if (!m_bShowSelect)
- {
- if (action.GetID() == ACTION_SELECT_ITEM)
- {
- // Enter selection mode
- m_bShowSelect = true;
-
- // Start timer, if user doesn't select an item
- // or moves left/right. The control will
- // automatically select the current item.
- m_ticks = CTimeUtils::GetFrameTime();
- return true;
- }
- else
- return CGUIButtonControl::OnAction(action);
- }
- else
- {
- if (action.GetID() == ACTION_SELECT_ITEM)
- {
- // User has selected an item, disable selection mode...
- m_bShowSelect = false;
-
- // ...and send a message.
- CGUIMessage message(GUI_MSG_CLICKED, GetID(), GetParentID() );
- SendWindowMessage(message);
- return true;
- }
- if (action.GetID() == ACTION_MOVE_UP || action.GetID() == ACTION_MOVE_DOWN )
- {
- // Disable selection mode when moving up or down
- m_bShowSelect = false;
- m_iCurrentItem = m_iDefaultItem;
- }
- // call the base class
- return CGUIButtonControl::OnAction(action);
- }
-}
-
-void CGUISelectButtonControl::FreeResources(bool immediately)
-{
- CGUIButtonControl::FreeResources(immediately);
-
- m_imgBackground.FreeResources(immediately);
-
- m_imgLeft.FreeResources(immediately);
- m_imgLeftFocus.FreeResources(immediately);
-
- m_imgRight.FreeResources(immediately);
- m_imgRightFocus.FreeResources(immediately);
-
- m_bShowSelect = false;
-}
-
-void CGUISelectButtonControl::DynamicResourceAlloc(bool bOnOff)
-{
- CGUIControl::DynamicResourceAlloc(bOnOff);
-
- m_imgBackground.DynamicResourceAlloc(bOnOff);
-
- m_imgLeft.DynamicResourceAlloc(bOnOff);
- m_imgLeftFocus.DynamicResourceAlloc(bOnOff);
-
- m_imgRight.DynamicResourceAlloc(bOnOff);
- m_imgRightFocus.DynamicResourceAlloc(bOnOff);
-}
-
-void CGUISelectButtonControl::AllocResources()
-{
- CGUIButtonControl::AllocResources();
-
- m_imgBackground.AllocResources();
-
- m_imgLeft.AllocResources();
- m_imgLeftFocus.AllocResources();
-
- m_imgRight.AllocResources();
- m_imgRightFocus.AllocResources();
-
- // Position right arrow
- float posX = (m_posX + m_width - 8) - 16;
- float posY = m_posY + (m_height - 16) / 2;
- m_imgRight.SetPosition(posX, posY);
- m_imgRightFocus.SetPosition(posX, posY);
-
- // Position left arrow
- posX = m_posX + 8;
- m_imgLeft.SetPosition(posX, posY);
- m_imgLeftFocus.SetPosition(posX, posY);
-}
-
-void CGUISelectButtonControl::SetInvalid()
-{
- CGUIButtonControl::SetInvalid();
- m_imgBackground.SetInvalid();
- m_imgLeft.SetInvalid();
- m_imgLeftFocus.SetInvalid();
- m_imgRight.SetInvalid();
- m_imgRightFocus.SetInvalid();
-}
-
-void CGUISelectButtonControl::OnLeft()
-{
- if (m_bShowSelect)
- {
- // Set for visual feedback
- m_bMovedLeft = true;
- m_iStartFrame = 0;
-
- // Reset timer for automatically selecting
- // the current item.
- m_ticks = CTimeUtils::GetFrameTime();
-
- // Switch to previous item
- if (m_vecItems.size() > 0)
- {
- m_iCurrentItem--;
- if (m_iCurrentItem < 0)
- m_iCurrentItem = (int)m_vecItems.size() - 1;
- }
- }
- else
- { // use the base class
- CGUIButtonControl::OnLeft();
- }
-}
-
-void CGUISelectButtonControl::OnRight()
-{
- if (m_bShowSelect)
- {
- // Set for visual feedback
- m_bMovedRight = true;
- m_iStartFrame = 0;
-
- // Reset timer for automatically selecting
- // the current item.
- m_ticks = CTimeUtils::GetFrameTime();
-
- // Switch to next item
- if (m_vecItems.size() > 0)
- {
- m_iCurrentItem++;
- if (m_iCurrentItem >= (int)m_vecItems.size())
- m_iCurrentItem = 0;
- }
- }
- else
- { // use the base class
- CGUIButtonControl::OnRight();
- }
-}
-
-bool CGUISelectButtonControl::OnMouseOver(const CPoint &point)
-{
- bool ret = CGUIControl::OnMouseOver(point);
- m_bLeftSelected = false;
- m_bRightSelected = false;
- if (m_imgLeft.HitTest(point))
- { // highlight the left control, but don't start moving until we have clicked
- m_bLeftSelected = true;
- }
- if (m_imgRight.HitTest(point))
- { // highlight the right control, but don't start moving until we have clicked
- m_bRightSelected = true;
- }
- // reset ticks
- m_ticks = CTimeUtils::GetFrameTime();
- return ret;
-}
-
-EVENT_RESULT CGUISelectButtonControl::OnMouseEvent(const CPoint &point, const CMouseEvent &event)
-{
- if (event.m_id == ACTION_MOUSE_LEFT_CLICK)
- {
- if (m_bShowSelect && m_imgLeft.HitTest(point))
- OnLeft();
- else if (m_bShowSelect && m_imgRight.HitTest(point))
- OnRight();
- else // normal select
- CGUIButtonControl::OnMouseEvent(point, event);
- return EVENT_RESULT_HANDLED;
- }
- else if (event.m_id == ACTION_MOUSE_WHEEL_UP)
- {
- OnLeft();
- return EVENT_RESULT_HANDLED;
- }
- else if (event.m_id == ACTION_MOUSE_WHEEL_DOWN)
- {
- OnRight();
- return EVENT_RESULT_HANDLED;
- }
- return EVENT_RESULT_UNHANDLED;
-}
-
-void CGUISelectButtonControl::SetPosition(float posX, float posY)
-{
- float leftOffX = m_imgLeft.GetXPosition() - m_posX;
- float leftOffY = m_imgLeft.GetYPosition() - m_posY;
- float rightOffX = m_imgRight.GetXPosition() - m_posX;
- float rightOffY = m_imgRight.GetYPosition() - m_posY;
- float backOffX = m_imgBackground.GetXPosition() - m_posX;
- float backOffY = m_imgBackground.GetYPosition() - m_posY;
- CGUIButtonControl::SetPosition(posX, posY);
- m_imgLeft.SetPosition(posX + leftOffX, posY + leftOffY);
- m_imgLeftFocus.SetPosition(posX + leftOffX, posY + leftOffY);
- m_imgRight.SetPosition(posX + rightOffX, posY + rightOffY);
- m_imgRightFocus.SetPosition(posX + rightOffX, posY + rightOffY);
- m_imgBackground.SetPosition(posX + backOffX, posY + backOffY);
-}
-
-void CGUISelectButtonControl::UpdateColors()
-{
- CGUIButtonControl::UpdateColors();
- m_imgLeft.SetDiffuseColor(m_diffuseColor);
- m_imgLeftFocus.SetDiffuseColor(m_diffuseColor);
- m_imgRight.SetDiffuseColor(m_diffuseColor);
- m_imgRightFocus.SetDiffuseColor(m_diffuseColor);
- m_imgBackground.SetDiffuseColor(m_diffuseColor);
-}
-
diff --git a/guilib/GUISelectButtonControl.h b/guilib/GUISelectButtonControl.h
deleted file mode 100644
index 519b0af265..0000000000
--- a/guilib/GUISelectButtonControl.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/*!
-\file GUISelectButtonControl.h
-\brief
-*/
-
-#ifndef GUILIB_GUIWINDOWSELECTCONTROL_H
-#define GUILIB_GUIWINDOWSELECTCONTROL_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIButtonControl.h"
-
-/*!
- \ingroup controls
- \brief Button with multi selection choice.
-
- Behaves like a normal button control, but when pressing,
- it can show multiple strings. The user can choose one by
- moving left or right. \n
- \n
- Messages the button reactes on: \n
-
- - GUI_MSG_LABEL_ADD \n
- Add a label to the control. Use CGUIMessage::SetLabel
- to set the label text.
- - GUI_MSG_LABEL_RESET \n
- Remove all labels from the control.
- - GUI_MSG_ITEM_SELECTED \n
- After sending this message the CGUIMessage::GetParam1
- contains the selected label as an integer.
- \note The order of the items depends on the order they have been added to
- the control using GUI_MSG_LABEL_ADD.
- - GUI_MSG_ITEM_SELECT \n
- Send this message with CGUIMessage::SetParam1() set to the label
- to be selected. \n
- \n
- Example entry to define a select button in a window or as reference control: \n
- \verbatim
- <control>
- <description>default select button</description
- <type>selectbutton</type>
- <id>6</id>
- <posX>60</posX>
- <posY>192</posY>
- <width>130</width>
- <height>32</height>
- <label>132</label>
- <font>font13</font>
- <textureFocus>button-focus.png</textureFocus>
- <textureNoFocus>button-nofocus.jpg</textureNoFocus>
- <texturebg>button-focus.png</texturebg>
- <textureLeft>scroll-left.png</textureLeft>
- <textureRight>scroll-right.png</textureRight>
- <font>font13</font>
- <textcolor>ffffffff</textcolor>
- <colordiffuse>ffffffff</colordiffuse>
- <disabledcolor>60ffffff</disabledcolor>
- <onleft>50</onleft>
- <onright>50</onright>
- <onup>3</onup>
- <ondown>7</ondown>
- </control>
- \endverbatim
-
- \sa CGUIMessage
- */
-class CGUISelectButtonControl : public CGUIButtonControl
-{
-public:
- CGUISelectButtonControl(int parentID, int controlID,
- float posX, float posY,
- float width, float height,
- const CTextureInfo& buttonFocus, const CTextureInfo& button,
- const CLabelInfo& labelInfo,
- const CTextureInfo& selectBackground,
- const CTextureInfo& selectArrowLeft, const CTextureInfo& selectArrowLeftFocus,
- const CTextureInfo& selectArrowRight, const CTextureInfo& selectArrowRightFocus);
- virtual ~CGUISelectButtonControl(void);
- virtual CGUISelectButtonControl *Clone() const { return new CGUISelectButtonControl(*this); };
-
- virtual void Render();
- virtual bool OnAction(const CAction &action) ;
- virtual void OnLeft();
- virtual void OnRight();
- virtual bool OnMessage(CGUIMessage& message);
- virtual bool OnMouseOver(const CPoint &point);
-
- virtual void AllocResources();
- virtual void FreeResources(bool immediately = false);
- virtual void DynamicResourceAlloc(bool bOnOff);
- virtual void SetInvalid();
- virtual void SetPosition(float posX, float posY);
-
-protected:
- virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event);
- virtual void UpdateColors();
- bool m_bShowSelect;
- CGUITexture m_imgBackground;
- CGUITexture m_imgLeft;
- CGUITexture m_imgLeftFocus;
- CGUITexture m_imgRight;
- CGUITexture m_imgRightFocus;
- std::vector<std::string> m_vecItems;
- int m_iCurrentItem;
- int m_iDefaultItem;
- int m_iStartFrame;
- bool m_bLeftSelected;
- bool m_bRightSelected;
- bool m_bMovedLeft;
- bool m_bMovedRight;
- unsigned int m_ticks;
-};
-#endif
diff --git a/guilib/GUISettingsSliderControl.cpp b/guilib/GUISettingsSliderControl.cpp
deleted file mode 100644
index 4edc3ba1e3..0000000000
--- a/guilib/GUISettingsSliderControl.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUISettingsSliderControl.h"
-
-CGUISettingsSliderControl::CGUISettingsSliderControl(int parentID, int controlID, float posX, float posY, float width, float height, float sliderWidth, float sliderHeight, const CTextureInfo &textureFocus, const CTextureInfo &textureNoFocus, const CTextureInfo& backGroundTexture, const CTextureInfo& nibTexture, const CTextureInfo& nibTextureFocus, const CLabelInfo &labelInfo, int iType)
- : CGUISliderControl(parentID, controlID, posX, posY, sliderWidth, sliderHeight, backGroundTexture, nibTexture,nibTextureFocus, iType)
- , m_buttonControl(parentID, controlID, posX, posY, width, height, textureFocus, textureNoFocus, labelInfo)
- , m_label(posX, posY, width, height, labelInfo)
-{
- m_label.SetAlign(XBFONT_CENTER_Y | XBFONT_RIGHT);
- ControlType = GUICONTROL_SETTINGS_SLIDER;
-}
-
-CGUISettingsSliderControl::~CGUISettingsSliderControl(void)
-{
-}
-
-
-void CGUISettingsSliderControl::Render()
-{
- // make sure the button has focus if it should have...
- m_buttonControl.SetFocus(HasFocus());
- m_buttonControl.SetPulseOnSelect(m_pulseOnSelect);
- m_buttonControl.SetEnabled(m_enabled);
- m_buttonControl.Render();
- CGUISliderControl::Render();
-
- // now render our text
- m_label.SetMaxRect(m_buttonControl.GetXPosition(), m_posY, m_posX - m_buttonControl.GetXPosition(), m_height);
- m_label.SetText(CGUISliderControl::GetDescription());
- if (IsDisabled())
- m_label.SetColor(CGUILabel::COLOR_DISABLED);
- else if (HasFocus())
- m_label.SetColor(CGUILabel::COLOR_FOCUSED);
- else
- m_label.SetColor(CGUILabel::COLOR_TEXT);
- m_label.Render();
-}
-
-bool CGUISettingsSliderControl::OnAction(const CAction &action)
-{
- return CGUISliderControl::OnAction(action);
-}
-
-void CGUISettingsSliderControl::FreeResources(bool immediately)
-{
- CGUISliderControl::FreeResources(immediately);
- m_buttonControl.FreeResources(immediately);
-}
-
-void CGUISettingsSliderControl::DynamicResourceAlloc(bool bOnOff)
-{
- CGUISliderControl::DynamicResourceAlloc(bOnOff);
- m_buttonControl.DynamicResourceAlloc(bOnOff);
-}
-
-void CGUISettingsSliderControl::AllocResources()
-{
- CGUISliderControl::AllocResources();
- m_buttonControl.AllocResources();
-}
-
-void CGUISettingsSliderControl::SetInvalid()
-{
- CGUISliderControl::SetInvalid();
- m_buttonControl.SetInvalid();
-}
-
-void CGUISettingsSliderControl::SetPosition(float posX, float posY)
-{
- m_buttonControl.SetPosition(posX, posY);
- float sliderPosX = posX + m_buttonControl.GetWidth() - m_width - m_buttonControl.GetLabelInfo().offsetX;
- float sliderPosY = posY + (m_buttonControl.GetHeight() - m_height) * 0.5f;
- CGUISliderControl::SetPosition(sliderPosX, sliderPosY);
-}
-
-void CGUISettingsSliderControl::SetWidth(float width)
-{
- m_buttonControl.SetWidth(width);
- SetPosition(GetXPosition(), GetYPosition());
-}
-
-void CGUISettingsSliderControl::SetHeight(float height)
-{
- m_buttonControl.SetHeight(height);
- SetPosition(GetXPosition(), GetYPosition());
-}
-
-void CGUISettingsSliderControl::SetEnabled(bool bEnable)
-{
- CGUISliderControl::SetEnabled(bEnable);
- m_buttonControl.SetEnabled(bEnable);
-}
-
-CStdString CGUISettingsSliderControl::GetDescription() const
-{
- return m_buttonControl.GetDescription() + " " + CGUISliderControl::GetDescription();
-}
-
-void CGUISettingsSliderControl::UpdateColors()
-{
- m_buttonControl.UpdateColors();
- CGUISliderControl::UpdateColors();
-}
diff --git a/guilib/GUISettingsSliderControl.h b/guilib/GUISettingsSliderControl.h
deleted file mode 100644
index 42ee3605c6..0000000000
--- a/guilib/GUISettingsSliderControl.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*!
-\file GUISliderControl.h
-\brief
-*/
-
-#ifndef GUILIB_GUISettingsSliderCONTROL_H
-#define GUILIB_GUISettingsSliderCONTROL_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUISliderControl.h"
-#include "GUIButtonControl.h"
-
-#define SPIN_CONTROL_TYPE_INT 1
-#define SPIN_CONTROL_TYPE_FLOAT 2
-#define SPIN_CONTROL_TYPE_TEXT 3
-
-/*!
- \ingroup controls
- \brief
- */
-class CGUISettingsSliderControl :
- public CGUISliderControl
-{
-public:
- CGUISettingsSliderControl(int parentID, int controlID, float posX, float posY, float width, float height, float sliderWidth, float sliderHeight, const CTextureInfo &textureFocus, const CTextureInfo &textureNoFocus, const CTextureInfo& backGroundTexture, const CTextureInfo& nibTexture, const CTextureInfo& nibTextureFocus, const CLabelInfo &labelInfo, int iType);
- virtual ~CGUISettingsSliderControl(void);
- virtual CGUISettingsSliderControl *Clone() const { return new CGUISettingsSliderControl(*this); };
-
- virtual void Render();
- virtual bool OnAction(const CAction &action);
- virtual void AllocResources();
- virtual void FreeResources(bool immediately = false);
- virtual void DynamicResourceAlloc(bool bOnOff);
- virtual void SetInvalid();
- virtual void SetPosition(float posX, float posY);
- virtual float GetWidth() const { return m_buttonControl.GetWidth();};
- virtual void SetWidth(float width);
- virtual float GetHeight() const { return m_buttonControl.GetHeight();};
- virtual void SetHeight(float height);
- virtual void SetEnabled(bool bEnable);
-
- void SetText(const std::string &label) {m_buttonControl.SetLabel(label);};
- virtual float GetXPosition() const { return m_buttonControl.GetXPosition();};
- virtual float GetYPosition() const { return m_buttonControl.GetYPosition();};
- virtual CStdString GetDescription() const;
- virtual bool HitTest(const CPoint &point) const { return m_buttonControl.HitTest(point); };
-
-protected:
- virtual void UpdateColors();
-
-private:
- CGUIButtonControl m_buttonControl;
- CGUILabel m_label;
-};
-#endif
diff --git a/guilib/GUIShader.cpp b/guilib/GUIShader.cpp
deleted file mode 100644
index eb69d8c0be..0000000000
--- a/guilib/GUIShader.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
-* Copyright (C) 2005-2008 Team XBMC
-* http://www.xbmc.org
-*
-* This Program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, 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 General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with XBMC; see the file COPYING. If not, write to
-* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-* http://www.gnu.org/copyleft/gpl.html
-*
-*/
-
-
-#include "system.h"
-
-#if HAS_GLES == 2
-
-#include "GUIShader.h"
-#include "MatrixGLES.h"
-#include "utils/log.h"
-
-CGUIShader::CGUIShader( const char *shader ) : CGLSLShaderProgram("guishader_vert.glsl", shader)
-{
- // Initialise values
- m_hTex0 = 0;
- m_hTex1 = 0;
- m_hProj = 0;
- m_hModel = 0;
- m_hPos = 0;
- m_hCol = 0;
- m_hCord0 = 0;
- m_hCord1 = 0;
-
- m_proj = NULL;
- m_model = NULL;
-}
-
-void CGUIShader::OnCompiledAndLinked()
-{
- // This is called after CompileAndLink()
-
- // Variables passed directly to the Fragment shader
- m_hTex0 = glGetUniformLocation(ProgramHandle(), "m_samp0");
- m_hTex1 = glGetUniformLocation(ProgramHandle(), "m_samp1");
- // Variables passed directly to the Vertex shader
- m_hProj = glGetUniformLocation(ProgramHandle(), "m_proj");
- m_hModel = glGetUniformLocation(ProgramHandle(), "m_model");
- m_hPos = glGetAttribLocation(ProgramHandle(), "m_attrpos");
- m_hCol = glGetAttribLocation(ProgramHandle(), "m_attrcol");
- m_hCord0 = glGetAttribLocation(ProgramHandle(), "m_attrcord0");
- m_hCord1 = glGetAttribLocation(ProgramHandle(), "m_attrcord1");
-
- // it's okay to do this only one time. Textures units never change
- glUniform1i(m_hTex0, 0);
- glUniform1i(m_hTex1, 1);
-}
-
-bool CGUIShader::OnEnabled()
-{
- // This is called after glUseProgram()
-
- glUniformMatrix4fv(m_hProj, 1, GL_FALSE, g_matrices.GetMatrix(MM_PROJECTION));
- glUniformMatrix4fv(m_hModel, 1, GL_FALSE, g_matrices.GetMatrix(MM_MODELVIEW));
-
- return true;
-}
-
-void CGUIShader::Free()
-{
- // Do Cleanup here
- CGLSLShaderProgram::Free();
-}
-
-#endif
diff --git a/guilib/GUIShader.h b/guilib/GUIShader.h
deleted file mode 100644
index 8307f876b2..0000000000
--- a/guilib/GUIShader.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-* Copyright (C) 2005-2008 Team XBMC
-* http://www.xbmc.org
-*
-* This Program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, 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 General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with XBMC; see the file COPYING. If not, write to
-* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-* http://www.gnu.org/copyleft/gpl.html
-*
-*/
-
-#ifndef GUI_SHADER_H
-#define GUI_SHADER_H
-
-#pragma once
-
-#include "Shader.h"
-
-using namespace Shaders;
-
-class CGUIShader : public CGLSLShaderProgram
-{
-public:
- CGUIShader( const char *shader = 0 );
- void OnCompiledAndLinked();
- bool OnEnabled();
- void Free();
-
- GLint GetPosLoc() { return m_hPos; }
- GLint GetColLoc() { return m_hCol; }
- GLint GetCord0Loc() { return m_hCord0; }
- GLint GetCord1Loc() { return m_hCord1; }
-
-protected:
- GLint m_hTex0;
- GLint m_hTex1;
- GLint m_hProj;
- GLint m_hModel;
- GLint m_hPos;
- GLint m_hCol;
- GLint m_hCord0;
- GLint m_hCord1;
-
- GLfloat *m_proj;
- GLfloat *m_model;
-};
-
-#endif // GUI_SHADER_H
diff --git a/guilib/GUISliderControl.cpp b/guilib/GUISliderControl.cpp
deleted file mode 100644
index baf6f48518..0000000000
--- a/guilib/GUISliderControl.cpp
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUISliderControl.h"
-#include "utils/GUIInfoManager.h"
-#include "Key.h"
-#include "MathUtils.h"
-
-CGUISliderControl::CGUISliderControl(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& backGroundTexture, const CTextureInfo& nibTexture, const CTextureInfo& nibTextureFocus, int iType)
- : CGUIControl(parentID, controlID, posX, posY, width, height)
- , m_guiBackground(posX, posY, width, height, backGroundTexture)
- , m_guiMid(posX, posY, width, height, nibTexture)
- , m_guiMidFocus(posX, posY, width, height, nibTextureFocus)
-{
- m_iType = iType;
- m_iPercent = 0;
- m_iStart = 0;
- m_iEnd = 100;
- m_iInterval = 1;
- m_fStart = 0.0f;
- m_fEnd = 1.0f;
- m_fInterval = 0.1f;
- m_iValue = 0;
- m_fValue = 0.0;
- ControlType = GUICONTROL_SLIDER;
- m_iInfoCode = 0;
-}
-
-CGUISliderControl::~CGUISliderControl(void)
-{
-}
-
-void CGUISliderControl::Render()
-{
- m_guiBackground.SetPosition( m_posX, m_posY );
- if (m_iInfoCode)
- SetIntValue(g_infoManager.GetInt(m_iInfoCode));
-
- float fScaleX = m_width == 0 ? 1.0f : m_width / m_guiBackground.GetTextureWidth();
- float fScaleY = m_height == 0 ? 1.0f : m_height / m_guiBackground.GetTextureHeight();
-
- m_guiBackground.SetHeight(m_height);
- m_guiBackground.SetWidth(m_width);
- m_guiBackground.Render();
-
- float fWidth = (m_guiBackground.GetTextureWidth() - m_guiMid.GetTextureWidth())*fScaleX;
-
- float fPos = m_guiBackground.GetXPosition() + GetProportion() * fWidth;
-
- if ((int)fWidth > 1)
- {
- if (m_bHasFocus && !IsDisabled())
- {
- m_guiMidFocus.SetPosition(fPos, m_guiBackground.GetYPosition() );
- m_guiMidFocus.SetWidth(m_guiMidFocus.GetTextureWidth() * fScaleX);
- m_guiMidFocus.SetHeight(m_guiMidFocus.GetTextureHeight() * fScaleY);
- m_guiMidFocus.Render();
- }
- else
- {
- m_guiMid.SetPosition(fPos, m_guiBackground.GetYPosition() );
- m_guiMid.SetWidth(m_guiMid.GetTextureWidth()*fScaleX);
- m_guiMid.SetHeight(m_guiMid.GetTextureHeight()*fScaleY);
- m_guiMid.Render();
- }
- }
- CGUIControl::Render();
-}
-
-bool CGUISliderControl::OnMessage(CGUIMessage& message)
-{
- if (message.GetControlId() == GetID() )
- {
- switch (message.GetMessage())
- {
- case GUI_MSG_ITEM_SELECT:
- SetPercentage( message.GetParam1() );
- return true;
- break;
-
- case GUI_MSG_LABEL_RESET:
- {
- SetPercentage(0);
- return true;
- }
- break;
- }
- }
-
- return CGUIControl::OnMessage(message);
-}
-
-bool CGUISliderControl::OnAction(const CAction &action)
-{
- switch ( action.GetID() )
- {
- case ACTION_MOVE_LEFT:
- //case ACTION_OSD_SHOW_VALUE_MIN:
- Move( -1);
- return true;
- break;
-
- case ACTION_MOVE_RIGHT:
- //case ACTION_OSD_SHOW_VALUE_PLUS:
- Move(1);
- return true;
- break;
- default:
- return CGUIControl::OnAction(action);
- }
-}
-
-void CGUISliderControl::Move(int iNumSteps)
-{
- switch (m_iType)
- {
- case SPIN_CONTROL_TYPE_FLOAT:
- m_fValue += m_fInterval * iNumSteps;
- if (m_fValue < m_fStart) m_fValue = m_fStart;
- if (m_fValue > m_fEnd) m_fValue = m_fEnd;
- break;
-
- case SPIN_CONTROL_TYPE_INT:
- m_iValue += m_iInterval * iNumSteps;
- if (m_iValue < m_iStart) m_iValue = m_iStart;
- if (m_iValue > m_iEnd) m_iValue = m_iEnd;
- break;
-
- default:
- m_iPercent += m_iInterval * iNumSteps;
- if (m_iPercent < 0) m_iPercent = 0;
- if (m_iPercent > 100) m_iPercent = 100;
- break;
- }
- SEND_CLICK_MESSAGE(GetID(), GetParentID(), MathUtils::round_int(100*GetProportion()));
-}
-
-void CGUISliderControl::SetPercentage(int iPercent)
-{
- if (iPercent > 100) iPercent = 100;
- if (iPercent < 0) iPercent = 0;
- m_iPercent = iPercent;
-}
-
-int CGUISliderControl::GetPercentage() const
-{
- return m_iPercent;
-}
-
-void CGUISliderControl::SetIntValue(int iValue)
-{
- if (m_iType == SPIN_CONTROL_TYPE_FLOAT)
- m_fValue = (float)iValue;
- else if (m_iType == SPIN_CONTROL_TYPE_INT)
- m_iValue = iValue;
- else
- SetPercentage(iValue);
-}
-
-int CGUISliderControl::GetIntValue() const
-{
- if (m_iType == SPIN_CONTROL_TYPE_FLOAT)
- return (int)m_fValue;
- else if (m_iType == SPIN_CONTROL_TYPE_INT)
- return m_iValue;
- else
- return m_iPercent;
-}
-
-void CGUISliderControl::SetFloatValue(float fValue)
-{
- if (m_iType == SPIN_CONTROL_TYPE_FLOAT)
- m_fValue = fValue;
- else if (m_iType == SPIN_CONTROL_TYPE_INT)
- m_iValue = (int)fValue;
- else
- SetPercentage((int)fValue);
-}
-
-float CGUISliderControl::GetFloatValue() const
-{
- if (m_iType == SPIN_CONTROL_TYPE_FLOAT)
- return m_fValue;
- else if (m_iType == SPIN_CONTROL_TYPE_INT)
- return (float)m_iValue;
- else
- return (float)m_iPercent;
-}
-
-void CGUISliderControl::SetIntInterval(int iInterval)
-{
- if (m_iType == SPIN_CONTROL_TYPE_FLOAT)
- m_fInterval = (float)iInterval;
- else
- m_iInterval = iInterval;
-}
-
-void CGUISliderControl::SetFloatInterval(float fInterval)
-{
- if (m_iType == SPIN_CONTROL_TYPE_FLOAT)
- m_fInterval = fInterval;
- else
- m_iInterval = (int)fInterval;
-}
-
-void CGUISliderControl::SetRange(int iStart, int iEnd)
-{
- if (m_iType == SPIN_CONTROL_TYPE_FLOAT)
- SetFloatRange((float)iStart,(float)iEnd);
- else
- {
- m_iStart = iStart;
- m_iEnd = iEnd;
- }
-}
-
-void CGUISliderControl::SetFloatRange(float fStart, float fEnd)
-{
- if (m_iType == SPIN_CONTROL_TYPE_INT)
- SetRange((int)fStart, (int)fEnd);
- else
- {
- m_fStart = fStart;
- m_fEnd = fEnd;
- }
-}
-
-void CGUISliderControl::FreeResources(bool immediately)
-{
- CGUIControl::FreeResources(immediately);
- m_guiBackground.FreeResources(immediately);
- m_guiMid.FreeResources(immediately);
- m_guiMidFocus.FreeResources(immediately);
-}
-
-void CGUISliderControl::DynamicResourceAlloc(bool bOnOff)
-{
- CGUIControl::DynamicResourceAlloc(bOnOff);
- m_guiBackground.DynamicResourceAlloc(bOnOff);
- m_guiMid.DynamicResourceAlloc(bOnOff);
- m_guiMidFocus.DynamicResourceAlloc(bOnOff);
-}
-
-void CGUISliderControl::AllocResources()
-{
- CGUIControl::AllocResources();
- m_guiBackground.AllocResources();
- m_guiMid.AllocResources();
- m_guiMidFocus.AllocResources();
-}
-
-void CGUISliderControl::SetInvalid()
-{
- CGUIControl::SetInvalid();
- m_guiBackground.SetInvalid();
- m_guiMid.SetInvalid();
- m_guiMidFocus.SetInvalid();
-}
-
-bool CGUISliderControl::HitTest(const CPoint &point) const
-{
- if (m_guiBackground.HitTest(point)) return true;
- if (m_guiMid.HitTest(point)) return true;
- return false;
-}
-
-void CGUISliderControl::SetFromPosition(const CPoint &point)
-{
- float fPercent = (point.x - m_guiBackground.GetXPosition()) / m_guiBackground.GetWidth();
- if (fPercent < 0) fPercent = 0;
- if (fPercent > 1) fPercent = 1;
- switch (m_iType)
- {
- case SPIN_CONTROL_TYPE_FLOAT:
- m_fValue = m_fStart + (m_fEnd - m_fStart) * fPercent;
- break;
-
- case SPIN_CONTROL_TYPE_INT:
- m_iValue = (int)(m_iStart + (float)(m_iEnd - m_iStart) * fPercent + 0.49f);
- break;
-
- default:
- m_iPercent = (int)(fPercent * 100 + 0.49f);
- break;
- }
- SEND_CLICK_MESSAGE(GetID(), GetParentID(), MathUtils::round_int(fPercent));
-}
-
-EVENT_RESULT CGUISliderControl::OnMouseEvent(const CPoint &point, const CMouseEvent &event)
-{
- if (event.m_id == ACTION_MOUSE_DRAG)
- {
- if (event.m_state == 1)
- { // grab exclusive access
- CGUIMessage msg(GUI_MSG_EXCLUSIVE_MOUSE, GetID(), GetParentID());
- SendWindowMessage(msg);
- }
- else if (event.m_state == 3)
- { // release exclusive access
- CGUIMessage msg(GUI_MSG_EXCLUSIVE_MOUSE, 0, GetParentID());
- SendWindowMessage(msg);
- }
- SetFromPosition(point);
- return EVENT_RESULT_HANDLED;
- }
- else if (event.m_id == ACTION_MOUSE_LEFT_CLICK && m_guiBackground.HitTest(point))
- {
- SetFromPosition(point);
- return EVENT_RESULT_HANDLED;
- }
- else if (event.m_id == ACTION_MOUSE_WHEEL_UP)
- {
- Move(10);
- return EVENT_RESULT_HANDLED;
- }
- else if (event.m_id == ACTION_MOUSE_WHEEL_DOWN)
- {
- Move(-10);
- return EVENT_RESULT_HANDLED;
- }
- return EVENT_RESULT_UNHANDLED;
-}
-
-void CGUISliderControl::SetInfo(int iInfo)
-{
- m_iInfoCode = iInfo;
-}
-
-CStdString CGUISliderControl::GetDescription() const
-{
- if (!m_textValue.IsEmpty())
- return m_textValue;
- CStdString description;
- if (m_iType == SPIN_CONTROL_TYPE_FLOAT)
- description.Format("%2.2f", m_fValue);
- else if (m_iType == SPIN_CONTROL_TYPE_INT)
- description.Format("%i", m_iValue);
- else
- description.Format("%i%%", m_iPercent);
- return description;
-}
-
-void CGUISliderControl::UpdateColors()
-{
- CGUIControl::UpdateColors();
- m_guiBackground.SetDiffuseColor(m_diffuseColor);
- m_guiMid.SetDiffuseColor(m_diffuseColor);
- m_guiMidFocus.SetDiffuseColor(m_diffuseColor);
-}
-
-float CGUISliderControl::GetProportion() const
-{
- if (m_iType == SPIN_CONTROL_TYPE_FLOAT)
- return (m_fValue - m_fStart) / (m_fEnd - m_fStart);
- else if (m_iType == SPIN_CONTROL_TYPE_INT)
- return (float)(m_iValue - m_iStart) / (float)(m_iEnd - m_iStart);
- return 0.01f * m_iPercent;
-}
diff --git a/guilib/GUISliderControl.h b/guilib/GUISliderControl.h
deleted file mode 100644
index 73ba9d51a1..0000000000
--- a/guilib/GUISliderControl.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*!
-\file GUISliderControl.h
-\brief
-*/
-
-#ifndef GUILIB_GUISLIDERCONTROL_H
-#define GUILIB_GUISLIDERCONTROL_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIControl.h"
-#include "GUITexture.h"
-
-#define SPIN_CONTROL_TYPE_INT 1
-#define SPIN_CONTROL_TYPE_FLOAT 2
-#define SPIN_CONTROL_TYPE_TEXT 3
-
-/*!
- \ingroup controls
- \brief
- */
-class CGUISliderControl :
- public CGUIControl
-{
-public:
- CGUISliderControl(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& backGroundTexture, const CTextureInfo& mibTexture, const CTextureInfo& nibTextureFocus, int iType);
- virtual ~CGUISliderControl(void);
- virtual CGUISliderControl *Clone() const { return new CGUISliderControl(*this); };
-
- virtual void Render();
- virtual bool OnAction(const CAction &action);
- virtual void AllocResources();
- virtual void FreeResources(bool immediately = false);
- virtual void DynamicResourceAlloc(bool bOnOff);
- virtual void SetInvalid();
- virtual void SetRange(int iStart, int iEnd);
- virtual void SetFloatRange(float fStart, float fEnd);
- virtual bool OnMessage(CGUIMessage& message);
- void SetInfo(int iInfo);
- void SetPercentage(int iPercent);
- int GetPercentage() const;
- void SetIntValue(int iValue);
- int GetIntValue() const;
- void SetFloatValue(float fValue);
- float GetFloatValue() const;
- void SetIntInterval(int iInterval);
- void SetFloatInterval(float fInterval);
- void SetType(int iType) { m_iType = iType; };
- virtual CStdString GetDescription() const;
- void SetTextValue(const CStdString &textValue) { m_textValue = textValue; };
-protected:
- virtual bool HitTest(const CPoint &point) const;
- virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event);
- virtual void UpdateColors();
- virtual void Move(int iNumSteps);
- virtual void SetFromPosition(const CPoint &point);
- /*! \brief Get the current position of the slider as a proportion
- \return slider position in the range [0,1]
- */
- float GetProportion() const;
-
- CGUITexture m_guiBackground;
- CGUITexture m_guiMid;
- CGUITexture m_guiMidFocus;
- int m_iType;
-
- int m_iPercent;
-
- int m_iValue;
- int m_iStart;
- int m_iInterval;
- int m_iEnd;
-
- float m_fValue;
- float m_fStart;
- float m_fInterval;
- float m_fEnd;
-
- int m_iInfoCode;
- CStdString m_textValue; ///< Allows overriding of the text value to be displayed (parent must update when the slider updates)
-};
-#endif
diff --git a/guilib/GUISound.cpp b/guilib/GUISound.cpp
deleted file mode 100644
index be98b26ff6..0000000000
--- a/guilib/GUISound.cpp
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "system.h"
-#include "GUISound.h"
-#include "AudioContext.h"
-#include "Settings.h"
-#include "FileSystem/File.h"
-#include "utils/log.h"
-#ifdef HAS_SDL_AUDIO
-#include <SDL/SDL_mixer.h>
-#include "FileSystem/SpecialProtocol.h"
-#endif
-#ifndef HAS_SDL_AUDIO
-
-typedef struct
-{
- char chunk_id[4];
- long chunksize;
-} WAVE_CHUNK;
-
-typedef struct
-{
- char riff[4];
- long filesize;
- char rifftype[4];
-} WAVE_RIFFHEADER;
-#else
-#define GUI_SOUND_CHANNEL 0
-#endif
-
-CGUISound::CGUISound()
-{
- m_soundBuffer=NULL;
-}
-
-CGUISound::~CGUISound()
-{
-#ifdef _WIN32
- FreeBuffer();
-#elif defined(HAS_SDL_AUDIO)
- Mix_FreeChunk(m_soundBuffer);
-#endif
-}
-
-// \brief Loads a wav file by filename
-bool CGUISound::Load(const CStdString& strFile)
-{
-#ifdef _WIN32
- LPBYTE pbData=NULL;
- WAVEFORMATEX wfx;
- int size=0;
- if (!LoadWav(strFile, &wfx, &pbData, &size))
- return false;
-
- bool bReady=(CreateBuffer(&wfx, size) && FillBuffer(pbData, size));
-
- if (!bReady)
- FreeBuffer();
-
- delete[] pbData;
-
- return bReady;
-#elif defined(HAS_SDL_AUDIO)
- m_soundBuffer = Mix_LoadWAV(_P(strFile));
- if (!m_soundBuffer)
- return false;
-
- return true;
-#else
- return false;
-#endif
-}
-
-// \brief Starts playback of the sound
-void CGUISound::Play()
-{
- if (m_soundBuffer)
- {
-#ifdef _WIN32
- m_soundBuffer->Play(0, 0, 0);
-#elif defined(HAS_SDL_AUDIO)
- Mix_PlayChannel(GUI_SOUND_CHANNEL, m_soundBuffer, 0);
-#endif
- }
-}
-
-// \brief returns true if the sound is playing
-bool CGUISound::IsPlaying()
-{
-#ifdef _WIN32
- if (m_soundBuffer)
- {
- DWORD dwStatus;
- m_soundBuffer->GetStatus(&dwStatus);
- return (dwStatus & DSBSTATUS_PLAYING);
- }
-
- return false;
-#elif defined(HAS_SDL_AUDIO)
- return Mix_Playing(GUI_SOUND_CHANNEL) != 0;
-#else
- return false;
-#endif
-}
-
-// \brief Stops playback if the sound
-void CGUISound::Stop()
-{
- if (m_soundBuffer)
- {
-#ifdef _WIN32
- m_soundBuffer->Stop();
-#elif defined(HAS_SDL_AUDIO)
- Mix_HaltChannel(GUI_SOUND_CHANNEL);
-#endif
- Wait();
- }
-}
-
-// \brief Sets the volume of the sound
-void CGUISound::SetVolume(int level)
-{
- if (m_soundBuffer)
- {
-#ifdef _WIN32
- m_soundBuffer->SetVolume(level);
-#elif defined(HAS_SDL_AUDIO)
- Mix_Volume(GUI_SOUND_CHANNEL, level);
-#endif
- }
-}
-
-void CGUISound::Wait(uint32_t millis/*=500*/)
-{
- millis /= 10;
- while (IsPlaying() && millis--)
- Sleep(10);
-}
-
-#ifdef _WIN32
-bool CGUISound::CreateBuffer(LPWAVEFORMATEX wfx, int iLength)
-{
- // Set up DSBUFFERDESC structure
- DSBUFFERDESC dsbdesc;
- memset(&dsbdesc, 0, sizeof(DSBUFFERDESC));
- dsbdesc.dwSize=sizeof(DSBUFFERDESC);
- // directsound requires ctrlvolume to be set
- dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME;
- dsbdesc.dwBufferBytes=iLength;
- dsbdesc.lpwfxFormat=wfx;
-
- LPDIRECTSOUND directSound=g_audioContext.GetDirectSoundDevice();
- if (!directSound)
- return false;
-
- // Create buffer
- if (FAILED(directSound->CreateSoundBuffer(&dsbdesc, &m_soundBuffer, NULL)))
- {
- m_soundBuffer = NULL;
- CLog::Log(LOGERROR, __FUNCTION__" Creating sound buffer failed!");
- return false;
- }
-
- // Make effects as loud as possible
- m_soundBuffer->SetVolume(g_settings.m_nVolumeLevel);
-
- return true;
-}
-
-bool CGUISound::FillBuffer(LPBYTE pbData, int iLength)
-{
- if (!m_soundBuffer)
- return false;
-
- LPVOID lpvWrite;
- DWORD dwLength;
-
- if (SUCCEEDED(m_soundBuffer->Lock(0, 0, &lpvWrite, &dwLength, NULL, NULL, DSBLOCK_ENTIREBUFFER)))
- {
- memcpy(lpvWrite, pbData, iLength);
- m_soundBuffer->Unlock(lpvWrite, dwLength, NULL, 0);
- return true;
- }
-
- CLog::Log(LOGERROR, __FUNCTION__" Filling sound buffer failed!");
-
- return false;
-}
-
-void CGUISound::FreeBuffer()
-{
- if (IsPlaying())
- Stop();
-
- SAFE_RELEASE(m_soundBuffer);
-}
-
-bool CGUISound::LoadWav(const CStdString& strFile, WAVEFORMATEX* wfx, LPBYTE* ppWavData, int* pDataSize)
-{
- XFILE::CFile file;
- if (!file.Open(strFile))
- return false;
-
- // read header
- WAVE_RIFFHEADER riffh;
- file.Read(&riffh, sizeof(WAVE_RIFFHEADER));
-
- // file valid?
- if (strncmp(riffh.riff, "RIFF", 4)!=0 && strncmp(riffh.rifftype, "WAVE", 4)!=0)
- {
- file.Close();
- return false;
- }
-
- long offset=0;
- offset += sizeof(WAVE_RIFFHEADER);
- offset -= sizeof(WAVE_CHUNK);
-
- // parse chunks
- do
- {
- WAVE_CHUNK chunk;
-
- // always seeking to the start of a chunk
- file.Seek(offset + sizeof(WAVE_CHUNK), SEEK_SET);
- file.Read(&chunk, sizeof(WAVE_CHUNK));
-
- if (!strncmp(chunk.chunk_id, "fmt ", 4))
- { // format chunk
- memset(wfx, 0, sizeof(WAVEFORMATEX));
- file.Read(wfx, 16);
- // we only need 16 bytes of the fmt chunk
- if (chunk.chunksize-16>0)
- file.Seek(chunk.chunksize-16, SEEK_CUR);
- }
- else if (!strncmp(chunk.chunk_id, "data", 4))
- { // data chunk
- *ppWavData=new BYTE[chunk.chunksize+1];
- file.Read(*ppWavData, chunk.chunksize);
- *pDataSize=chunk.chunksize;
-
- if (chunk.chunksize & 1)
- offset++;
- }
- else
- { // other chunk - unused, just skip
- file.Seek(chunk.chunksize, SEEK_CUR);
- }
-
- offset+=(chunk.chunksize+sizeof(WAVE_CHUNK));
-
- if (offset & 1)
- offset++;
-
- } while (offset+(int)sizeof(WAVE_CHUNK) < riffh.filesize);
-
- file.Close();
- return (*ppWavData!=NULL);
-}
-
-#endif
diff --git a/guilib/GUISound.h b/guilib/GUISound.h
deleted file mode 100644
index a21bceb268..0000000000
--- a/guilib/GUISound.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#pragma once
-
-#include "StdString.h"
-
-#ifdef HAS_SDL_AUDIO
-#include <SDL/SDL_mixer.h>
-#endif
-
-class CGUISound
-{
-public:
- CGUISound();
- virtual ~CGUISound();
-
- bool Load(const CStdString& strFile);
- void Play();
- void Stop();
- bool IsPlaying();
- void SetVolume(int level);
- void Wait(uint32_t millis = 500);
-
-private:
-#ifdef _WIN32
- bool LoadWav(const CStdString& strFile, WAVEFORMATEX* wfx, LPBYTE* ppWavData, int* pDataSize);
- bool CreateBuffer(LPWAVEFORMATEX wfx, int iLength);
- bool FillBuffer(LPBYTE pbData, int iLength);
- void FreeBuffer();
-
- LPDIRECTSOUNDBUFFER m_soundBuffer;
-#elif defined(HAS_SDL_AUDIO)
- Mix_Chunk* m_soundBuffer;
-#else
- void *m_soundBuffer;
-#endif
-};
diff --git a/guilib/GUISpinControl.cpp b/guilib/GUISpinControl.cpp
deleted file mode 100644
index fb69f48fd0..0000000000
--- a/guilib/GUISpinControl.cpp
+++ /dev/null
@@ -1,930 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUISpinControl.h"
-#include "utils/CharsetConverter.h"
-#include "Key.h"
-
-using namespace std;
-
-#define SPIN_BUTTON_DOWN 1
-#define SPIN_BUTTON_UP 2
-
-CGUISpinControl::CGUISpinControl(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& textureUp, const CTextureInfo& textureDown, const CTextureInfo& textureUpFocus, const CTextureInfo& textureDownFocus, const CLabelInfo &labelInfo, int iType)
- : CGUIControl(parentID, controlID, posX, posY, width, height)
- , m_imgspinUp(posX, posY, width, height, textureUp)
- , m_imgspinDown(posX, posY, width, height, textureDown)
- , m_imgspinUpFocus(posX, posY, width, height, textureUpFocus)
- , m_imgspinDownFocus(posX, posY, width, height, textureDownFocus)
- , m_label(posX, posY, width, height, labelInfo)
-{
- m_bReverse = false;
- m_iStart = 0;
- m_iEnd = 100;
- m_fStart = 0.0f;
- m_fEnd = 1.0f;
- m_fInterval = 0.1f;
- m_iValue = 0;
- m_fValue = 0.0;
- m_iType = iType;
- m_iSelect = SPIN_BUTTON_DOWN;
- m_bShowRange = false;
- m_iTypedPos = 0;
- strcpy(m_szTyped, "");
- ControlType = GUICONTROL_SPIN;
- m_currentItem = 0;
- m_numItems = 10;
- m_itemsPerPage = 10;
- m_showOnePage = true;
-}
-
-CGUISpinControl::~CGUISpinControl(void)
-{}
-
-bool CGUISpinControl::OnAction(const CAction &action)
-{
- switch (action.GetID())
- {
- case REMOTE_0:
- case REMOTE_1:
- case REMOTE_2:
- case REMOTE_3:
- case REMOTE_4:
- case REMOTE_5:
- case REMOTE_6:
- case REMOTE_7:
- case REMOTE_8:
- case REMOTE_9:
- {
- if (strlen(m_szTyped) >= 3)
- {
- m_iTypedPos = 0;
- strcpy(m_szTyped, "");
- }
- int iNumber = action.GetID() - REMOTE_0;
-
- m_szTyped[m_iTypedPos] = iNumber + '0';
- m_iTypedPos++;
- m_szTyped[m_iTypedPos] = 0;
- int iValue;
- sscanf(m_szTyped, "%i", &iValue);
- switch (m_iType)
- {
- case SPIN_CONTROL_TYPE_INT:
- {
- if (iValue < m_iStart || iValue > m_iEnd)
- {
- m_iTypedPos = 0;
- m_szTyped[m_iTypedPos] = iNumber + '0';
- m_iTypedPos++;
- m_szTyped[m_iTypedPos] = 0;
- sscanf(m_szTyped, "%i", &iValue);
- if (iValue < m_iStart || iValue > m_iEnd)
- {
- m_iTypedPos = 0;
- strcpy(m_szTyped, "");
- return true;
- }
- }
- m_iValue = iValue;
- CGUIMessage msg(GUI_MSG_CLICKED, GetID(), GetParentID());
- SendWindowMessage(msg);
- }
- break;
-
- case SPIN_CONTROL_TYPE_TEXT:
- {
- if (iValue < 0 || iValue >= (int)m_vecLabels.size())
- {
- m_iTypedPos = 0;
- m_szTyped[m_iTypedPos] = iNumber + '0';
- m_iTypedPos++;
- m_szTyped[m_iTypedPos] = 0;
- sscanf(m_szTyped, "%i", &iValue);
- if (iValue < 0 || iValue >= (int)m_vecLabels.size())
- {
- m_iTypedPos = 0;
- strcpy(m_szTyped, "");
- return true;
- }
- }
- m_iValue = iValue;
- CGUIMessage msg(GUI_MSG_CLICKED, GetID(), GetParentID());
- SendWindowMessage(msg);
- }
- break;
-
- }
- return true;
- }
- break;
- case ACTION_PAGE_UP:
- if (!m_bReverse)
- PageDown();
- else
- PageUp();
- return true;
- break;
- case ACTION_PAGE_DOWN:
- if (!m_bReverse)
- PageUp();
- else
- PageDown();
- return true;
- break;
- case ACTION_SELECT_ITEM:
- if (m_iSelect == SPIN_BUTTON_UP)
- {
- MoveUp();
- return true;
- }
- if (m_iSelect == SPIN_BUTTON_DOWN)
- {
- MoveDown();
- return true;
- }
- break;
- }
-/* static float m_fSmoothScrollOffset = 0.0f;
- if (action.GetID() == ACTION_SCROLL_UP)
- {
- m_fSmoothScrollOffset += action.GetAmount() * action.GetAmount();
- bool handled = false;
- while (m_fSmoothScrollOffset > 0.4)
- {
- handled = true;
- m_fSmoothScrollOffset -= 0.4f;
- MoveDown();
- }
- return handled;
- }*/
- return CGUIControl::OnAction(action);
-}
-
-void CGUISpinControl::OnLeft()
-{
- if (m_iSelect == SPIN_BUTTON_UP)
- {
- // select the down button
- m_iSelect = SPIN_BUTTON_DOWN;
- }
- else
- { // base class
- CGUIControl::OnLeft();
- }
-}
-
-void CGUISpinControl::OnRight()
-{
- if (m_iSelect == SPIN_BUTTON_DOWN)
- {
- // select the up button
- m_iSelect = SPIN_BUTTON_UP;
- }
- else
- { // base class
- CGUIControl::OnRight();
- }
-}
-
-void CGUISpinControl::Clear()
-{
- m_vecLabels.erase(m_vecLabels.begin(), m_vecLabels.end());
- m_vecValues.erase(m_vecValues.begin(), m_vecValues.end());
- SetValue(0);
-}
-
-bool CGUISpinControl::OnMessage(CGUIMessage& message)
-{
- if (CGUIControl::OnMessage(message) )
- return true;
- if (message.GetControlId() == GetID() )
- {
- switch (message.GetMessage())
- {
- case GUI_MSG_ITEM_SELECT:
- if (SPIN_CONTROL_TYPE_PAGE == m_iType)
- {
- m_currentItem = message.GetParam1();
- return true;
- }
- SetValue( message.GetParam1());
- if (message.GetParam2() == SPIN_BUTTON_DOWN || message.GetParam2() == SPIN_BUTTON_UP)
- m_iSelect = message.GetParam2();
- return true;
- break;
-
- case GUI_MSG_LABEL_RESET:
- if (SPIN_CONTROL_TYPE_PAGE == m_iType)
- {
- m_itemsPerPage = message.GetParam1();
- m_numItems = message.GetParam2();
- return true;
- }
- {
- Clear();
- return true;
- }
- break;
-
- case GUI_MSG_SHOWRANGE:
- if (message.GetParam1() )
- m_bShowRange = true;
- else
- m_bShowRange = false;
- break;
-
- case GUI_MSG_LABEL_ADD:
- {
- AddLabel(message.GetLabel(), message.GetParam1());
- return true;
- }
- break;
-
- case GUI_MSG_ITEM_SELECTED:
- {
- message.SetParam1( GetValue() );
- message.SetParam2(m_iSelect);
-
- if (m_iType == SPIN_CONTROL_TYPE_TEXT)
- {
- if ( m_iValue >= 0 && m_iValue < (int)m_vecLabels.size() )
- message.SetLabel( m_vecLabels[m_iValue]);
- }
- return true;
- }
-
- case GUI_MSG_PAGE_UP:
- if (CanMoveUp())
- MoveUp();
- return true;
-
- case GUI_MSG_PAGE_DOWN:
- if (CanMoveDown())
- MoveDown();
- return true;
-
- case GUI_MSG_MOVE_OFFSET:
- {
- int count = (int)message.GetParam1();
- while (count < 0)
- {
- MoveUp();
- count++;
- }
- while (count > 0)
- {
- MoveDown();
- count--;
- }
- return true;
- }
-
- }
- }
- return false;
-}
-
-void CGUISpinControl::AllocResources()
-{
- CGUIControl::AllocResources();
- m_imgspinUp.AllocResources();
- m_imgspinUpFocus.AllocResources();
- m_imgspinDown.AllocResources();
- m_imgspinDownFocus.AllocResources();
-
- m_imgspinDownFocus.SetPosition(m_posX, m_posY);
- m_imgspinDown.SetPosition(m_posX, m_posY);
- m_imgspinUp.SetPosition(m_posX + m_imgspinDown.GetWidth(), m_posY);
- m_imgspinUpFocus.SetPosition(m_posX + m_imgspinDownFocus.GetWidth(), m_posY);
-}
-
-void CGUISpinControl::FreeResources(bool immediately)
-{
- CGUIControl::FreeResources(immediately);
- m_imgspinUp.FreeResources(immediately);
- m_imgspinUpFocus.FreeResources(immediately);
- m_imgspinDown.FreeResources(immediately);
- m_imgspinDownFocus.FreeResources(immediately);
- m_iTypedPos = 0;
- strcpy(m_szTyped, "");
-}
-
-void CGUISpinControl::DynamicResourceAlloc(bool bOnOff)
-{
- CGUIControl::DynamicResourceAlloc(bOnOff);
- m_imgspinUp.DynamicResourceAlloc(bOnOff);
- m_imgspinUpFocus.DynamicResourceAlloc(bOnOff);
- m_imgspinDown.DynamicResourceAlloc(bOnOff);
- m_imgspinDownFocus.DynamicResourceAlloc(bOnOff);
-}
-
-void CGUISpinControl::SetInvalid()
-{
- CGUIControl::SetInvalid();
- m_label.SetInvalid();
- m_imgspinUp.SetInvalid();
- m_imgspinUpFocus.SetInvalid();
- m_imgspinDown.SetInvalid();
- m_imgspinDownFocus.SetInvalid();
-}
-
-void CGUISpinControl::Render()
-{
- if (!HasFocus())
- {
- m_iTypedPos = 0;
- strcpy(m_szTyped, "");
- }
-
- CStdString text;
-
- if (m_iType == SPIN_CONTROL_TYPE_INT)
- {
- if (m_bShowRange)
- {
- text.Format("%i/%i", m_iValue, m_iEnd);
- }
- else
- {
- text.Format("%i", m_iValue);
- }
- }
- else if (m_iType == SPIN_CONTROL_TYPE_PAGE)
- {
- // work out number of pages and current page
- int numPages = (m_numItems + m_itemsPerPage - 1) / m_itemsPerPage;
- int currentPage = m_currentItem / m_itemsPerPage + 1;
- if (m_currentItem >= m_numItems - m_itemsPerPage)
- currentPage = numPages;
- text.Format("%i/%i", currentPage, numPages);
- }
- else if (m_iType == SPIN_CONTROL_TYPE_FLOAT)
- {
- if (m_bShowRange)
- {
- text.Format("%02.2f/%02.2f", m_fValue, m_fEnd);
- }
- else
- {
- text.Format("%02.2f", m_fValue);
- }
- }
- else
- {
- if (m_iValue >= 0 && m_iValue < (int)m_vecLabels.size() )
- {
- if (m_bShowRange)
- {
- text.Format("(%i/%i) %s", m_iValue + 1, (int)m_vecLabels.size(), CStdString(m_vecLabels[m_iValue]).c_str() );
- }
- else
- {
- text.Format("%s", CStdString(m_vecLabels[m_iValue]).c_str() );
- }
- }
- else text.Format("?%i?", m_iValue);
-
- }
-
- m_label.SetText(text);
-
- const float space = 5;
- float textWidth = m_label.GetTextWidth() + 2 * m_label.GetLabelInfo().offsetX;
- // Position the arrows
- bool arrowsOnRight(0 != (m_label.GetLabelInfo().align & (XBFONT_RIGHT | XBFONT_CENTER_X)));
- if (!arrowsOnRight)
- {
- m_imgspinDownFocus.SetPosition(m_posX + textWidth + space, m_posY);
- m_imgspinDown.SetPosition(m_posX + textWidth + space, m_posY);
- m_imgspinUpFocus.SetPosition(m_posX + textWidth + space + m_imgspinDown.GetWidth(), m_posY);
- m_imgspinUp.SetPosition(m_posX + textWidth + space + m_imgspinDown.GetWidth(), m_posY);
- }
-
- if ( HasFocus() )
- {
- if (m_iSelect == SPIN_BUTTON_UP)
- m_imgspinUpFocus.Render();
- else
- m_imgspinUp.Render();
-
- if (m_iSelect == SPIN_BUTTON_DOWN)
- m_imgspinDownFocus.Render();
- else
- m_imgspinDown.Render();
- }
- else
- {
- m_imgspinUp.Render();
- m_imgspinDown.Render();
- }
-
- if (m_label.GetLabelInfo().font)
- {
- if (arrowsOnRight)
- RenderText(m_posX - space - textWidth, textWidth);
- else
- RenderText(m_posX + m_imgspinDown.GetWidth() + m_imgspinUp.GetWidth() + space, textWidth);
-
- // set our hit rectangle for MouseOver events
- m_hitRect = m_label.GetRenderRect();
- }
- CGUIControl::Render();
-}
-
-void CGUISpinControl::RenderText(float posX, float width)
-{
- m_label.SetMaxRect(posX, m_posY, width, m_height);
- m_label.SetColor(GetTextColor());
- m_label.Render();
-}
-
-CGUILabel::COLOR CGUISpinControl::GetTextColor() const
-{
- if (IsDisabled())
- return CGUILabel::COLOR_DISABLED;
- else if (HasFocus())
- return CGUILabel::COLOR_FOCUSED;
- return CGUILabel::COLOR_TEXT;
-}
-
-void CGUISpinControl::SetRange(int iStart, int iEnd)
-{
- m_iStart = iStart;
- m_iEnd = iEnd;
-}
-
-
-void CGUISpinControl::SetFloatRange(float fStart, float fEnd)
-{
- m_fStart = fStart;
- m_fEnd = fEnd;
-}
-
-void CGUISpinControl::SetValueFromLabel(const CStdString &label)
-{
- if (m_iType == SPIN_CONTROL_TYPE_TEXT)
- {
- m_iValue = 0;
- for (unsigned int i = 0; i < m_vecLabels.size(); i++)
- if (label == m_vecLabels[i])
- m_iValue = i;
- }
- else
- m_iValue = atoi(label.c_str());
-}
-
-void CGUISpinControl::SetValue(int iValue)
-{
- if (m_iType == SPIN_CONTROL_TYPE_TEXT)
- {
- m_iValue = 0;
- for (unsigned int i = 0; i < m_vecValues.size(); i++)
- if (iValue == m_vecValues[i])
- m_iValue = i;
- }
- else
- m_iValue = iValue;
-}
-
-void CGUISpinControl::SetFloatValue(float fValue)
-{
- m_fValue = fValue;
-}
-
-int CGUISpinControl::GetValue() const
-{
- if (m_iType == SPIN_CONTROL_TYPE_TEXT)
- {
- if (m_iValue >= 0 && m_iValue < (int)m_vecValues.size())
- return m_vecValues[m_iValue];
- }
- return m_iValue;
-}
-
-float CGUISpinControl::GetFloatValue() const
-{
- return m_fValue;
-}
-
-
-void CGUISpinControl::AddLabel(const string& strLabel, int iValue)
-{
- m_vecLabels.push_back(strLabel);
- m_vecValues.push_back(iValue);
-}
-
-const string CGUISpinControl::GetLabel() const
-{
- if (m_iValue >= 0 && m_iValue < (int)m_vecLabels.size())
- {
- return m_vecLabels[ m_iValue];
- }
- return "";
-}
-
-void CGUISpinControl::SetPosition(float posX, float posY)
-{
- CGUIControl::SetPosition(posX, posY);
-
- m_imgspinDownFocus.SetPosition(posX, posY);
- m_imgspinDown.SetPosition(posX, posY);
-
- m_imgspinUp.SetPosition(m_posX + m_imgspinDown.GetWidth(), m_posY);
- m_imgspinUpFocus.SetPosition(m_posX + m_imgspinDownFocus.GetWidth(), m_posY);
-
-}
-
-float CGUISpinControl::GetWidth() const
-{
- return m_imgspinDown.GetWidth() * 2 ;
-}
-
-bool CGUISpinControl::CanMoveUp(bool bTestReverse)
-{
- // test for reverse...
- if (bTestReverse && m_bReverse) return CanMoveDown(false);
-
- switch (m_iType)
- {
- case SPIN_CONTROL_TYPE_PAGE:
- return m_currentItem > 0;
- case SPIN_CONTROL_TYPE_INT:
- {
- if (m_iValue - 1 >= m_iStart)
- return true;
- return false;
- }
- break;
-
- case SPIN_CONTROL_TYPE_FLOAT:
- {
- if (m_fValue - m_fInterval >= m_fStart)
- return true;
- return false;
- }
- break;
-
- case SPIN_CONTROL_TYPE_TEXT:
- {
- if (m_iValue - 1 >= 0)
- return true;
- return false;
- }
- break;
- }
- return false;
-}
-
-bool CGUISpinControl::CanMoveDown(bool bTestReverse)
-{
- // test for reverse...
- if (bTestReverse && m_bReverse) return CanMoveUp(false);
- switch (m_iType)
- {
- case SPIN_CONTROL_TYPE_PAGE:
- return m_currentItem < m_numItems;
- case SPIN_CONTROL_TYPE_INT:
- {
- if (m_iValue + 1 <= m_iEnd)
- return true;
- return false;
- }
- break;
-
- case SPIN_CONTROL_TYPE_FLOAT:
- {
- if (m_fValue + m_fInterval <= m_fEnd)
- return true;
- return false;
- }
- break;
-
- case SPIN_CONTROL_TYPE_TEXT:
- {
- if (m_iValue + 1 < (int)m_vecLabels.size())
- return true;
- return false;
- }
- break;
- }
- return false;
-}
-
-void CGUISpinControl::PageUp()
-{
- switch (m_iType)
- {
- case SPIN_CONTROL_TYPE_INT:
- {
- if (m_iValue - 10 >= m_iStart)
- m_iValue -= 10;
- else
- m_iValue = m_iStart;
- CGUIMessage msg(GUI_MSG_CLICKED, GetID(), GetParentID());
- SendWindowMessage(msg);
- return ;
- }
- break;
- case SPIN_CONTROL_TYPE_PAGE:
- ChangePage(-10);
- break;
- case SPIN_CONTROL_TYPE_TEXT:
- {
- if (m_iValue - 10 >= 0)
- m_iValue -= 10;
- else
- m_iValue = 0;
- CGUIMessage msg(GUI_MSG_CLICKED, GetID(), GetParentID());
- SendWindowMessage(msg);
- return ;
- }
- break;
- }
-
-}
-
-void CGUISpinControl::PageDown()
-{
- switch (m_iType)
- {
- case SPIN_CONTROL_TYPE_INT:
- {
- if (m_iValue + 10 <= m_iEnd)
- m_iValue += 10;
- else
- m_iValue = m_iEnd;
- CGUIMessage msg(GUI_MSG_CLICKED, GetID(), GetParentID());
- SendWindowMessage(msg);
- return ;
- }
- break;
- case SPIN_CONTROL_TYPE_PAGE:
- ChangePage(10);
- break;
- case SPIN_CONTROL_TYPE_TEXT:
- {
- if (m_iValue + 10 < (int)m_vecLabels.size() )
- m_iValue += 10;
- CGUIMessage msg(GUI_MSG_CLICKED, GetID(), GetParentID());
- SendWindowMessage(msg);
- }
- break;
- }
-}
-
-void CGUISpinControl::MoveUp(bool bTestReverse)
-{
- if (bTestReverse && m_bReverse)
- { // actually should move down.
- MoveDown(false);
- return ;
- }
- switch (m_iType)
- {
- case SPIN_CONTROL_TYPE_INT:
- {
- if (m_iValue - 1 >= m_iStart)
- m_iValue--;
- else if (m_iValue == m_iStart)
- m_iValue = m_iEnd;
- CGUIMessage msg(GUI_MSG_CLICKED, GetID(), GetParentID());
- SendWindowMessage(msg);
- return ;
- }
- break;
-
- case SPIN_CONTROL_TYPE_PAGE:
- ChangePage(-1);
- break;
-
- case SPIN_CONTROL_TYPE_FLOAT:
- {
- if (m_fValue - m_fInterval >= m_fStart)
- m_fValue -= m_fInterval;
- else if (m_fValue - m_fInterval < m_fStart)
- m_fValue = m_fEnd;
- CGUIMessage msg(GUI_MSG_CLICKED, GetID(), GetParentID());
- SendWindowMessage(msg);
- return ;
- }
- break;
-
- case SPIN_CONTROL_TYPE_TEXT:
- {
- if (m_iValue - 1 >= 0)
- m_iValue--;
- else if (m_iValue == 0)
- m_iValue = (int)m_vecLabels.size() - 1;
- CGUIMessage msg(GUI_MSG_CLICKED, GetID(), GetParentID());
- SendWindowMessage(msg);
- return ;
- }
- break;
- }
-}
-
-void CGUISpinControl::MoveDown(bool bTestReverse)
-{
- if (bTestReverse && m_bReverse)
- { // actually should move up.
- MoveUp(false);
- return ;
- }
- switch (m_iType)
- {
- case SPIN_CONTROL_TYPE_INT:
- {
- if (m_iValue + 1 <= m_iEnd)
- m_iValue++;
- else if (m_iValue == m_iEnd)
- m_iValue = m_iStart;
- CGUIMessage msg(GUI_MSG_CLICKED, GetID(), GetParentID());
- SendWindowMessage(msg);
- return ;
- }
- break;
-
- case SPIN_CONTROL_TYPE_PAGE:
- ChangePage(1);
- break;
-
- case SPIN_CONTROL_TYPE_FLOAT:
- {
- if (m_fValue + m_fInterval <= m_fEnd)
- m_fValue += m_fInterval;
- else if (m_fValue + m_fInterval > m_fEnd)
- m_fValue = m_fStart;
- CGUIMessage msg(GUI_MSG_CLICKED, GetID(), GetParentID());
- SendWindowMessage(msg);
- return ;
- }
- break;
-
- case SPIN_CONTROL_TYPE_TEXT:
- {
- if (m_iValue + 1 < (int)m_vecLabels.size() )
- m_iValue++;
- else if (m_iValue == (int)m_vecLabels.size() - 1)
- m_iValue = 0;
- CGUIMessage msg(GUI_MSG_CLICKED, GetID(), GetParentID());
- SendWindowMessage(msg);
- return ;
- }
- break;
- }
-}
-void CGUISpinControl::SetReverse(bool bReverse)
-{
- m_bReverse = bReverse;
-}
-
-void CGUISpinControl::SetFloatInterval(float fInterval)
-{
- m_fInterval = fInterval;
-}
-
-void CGUISpinControl::SetShowRange(bool bOnoff)
-{
- m_bShowRange = bOnoff;
-}
-
-int CGUISpinControl::GetMinimum() const
-{
- switch (m_iType)
- {
- case SPIN_CONTROL_TYPE_PAGE:
- return 0;
- case SPIN_CONTROL_TYPE_INT:
- return m_iStart;
- break;
-
- case SPIN_CONTROL_TYPE_TEXT:
- return 1;
- break;
-
- case SPIN_CONTROL_TYPE_FLOAT:
- return (int)(m_fStart*10.0f);
- break;
- }
- return 0;
-}
-
-int CGUISpinControl::GetMaximum() const
-{
- switch (m_iType)
- {
- case SPIN_CONTROL_TYPE_PAGE:
- return m_numItems;
- case SPIN_CONTROL_TYPE_INT:
- return m_iEnd;
- break;
-
- case SPIN_CONTROL_TYPE_TEXT:
- return (int)m_vecLabels.size();
- break;
-
- case SPIN_CONTROL_TYPE_FLOAT:
- return (int)(m_fEnd*10.0f);
- break;
- }
- return 100;
-}
-
-bool CGUISpinControl::HitTest(const CPoint &point) const
-{
- if (m_imgspinUpFocus.HitTest(point) || m_imgspinDownFocus.HitTest(point))
- return true;
- return CGUIControl::HitTest(point);
-}
-
-bool CGUISpinControl::OnMouseOver(const CPoint &point)
-{
- if (m_imgspinDownFocus.HitTest(point))
- m_iSelect = SPIN_BUTTON_DOWN;
- else
- m_iSelect = SPIN_BUTTON_UP;
- return CGUIControl::OnMouseOver(point);
-}
-
-EVENT_RESULT CGUISpinControl::OnMouseEvent(const CPoint &point, const CMouseEvent &event)
-{
- if (event.m_id == ACTION_MOUSE_LEFT_CLICK)
- {
- if (m_imgspinUpFocus.HitTest(point))
- MoveUp();
- else if (m_imgspinDownFocus.HitTest(point))
- MoveDown();
- return EVENT_RESULT_HANDLED;
- }
- else if (event.m_id == ACTION_MOUSE_WHEEL_UP)
- {
- MoveUp();
- return EVENT_RESULT_HANDLED;
- }
- else if (event.m_id == ACTION_MOUSE_WHEEL_DOWN)
- {
- MoveDown();
- return EVENT_RESULT_HANDLED;
- }
- return EVENT_RESULT_UNHANDLED;
-}
-
-CStdString CGUISpinControl::GetDescription() const
-{
- CStdString strLabel;
- strLabel.Format("%i/%i", 1 + GetValue(), GetMaximum());
- return strLabel;
-}
-
-bool CGUISpinControl::IsFocusedOnUp() const
-{
- return (m_iSelect == SPIN_BUTTON_UP);
-}
-
-void CGUISpinControl::ChangePage(int amount)
-{
- m_currentItem += amount * m_itemsPerPage;
- if (m_currentItem > m_numItems - m_itemsPerPage)
- m_currentItem = m_numItems - m_itemsPerPage;
- if (m_currentItem < 0)
- m_currentItem = 0;
- CGUIMessage message(GUI_MSG_NOTIFY_ALL, GetParentID(), GetID(), GUI_MSG_PAGE_CHANGE, m_currentItem);
- SendWindowMessage(message);
-}
-
-void CGUISpinControl::UpdateColors()
-{
- m_label.UpdateColors();
- CGUIControl::UpdateColors();
- m_imgspinDownFocus.SetDiffuseColor(m_diffuseColor);
- m_imgspinDown.SetDiffuseColor(m_diffuseColor);
- m_imgspinUp.SetDiffuseColor(m_diffuseColor);
- m_imgspinUpFocus.SetDiffuseColor(m_diffuseColor);
-}
-
-bool CGUISpinControl::IsVisible() const
-{
- // page controls can be optionally disabled if the number of pages is 1
- if (m_iType == SPIN_CONTROL_TYPE_PAGE && m_numItems <= m_itemsPerPage && !m_showOnePage)
- return false;
- return CGUIControl::IsVisible();
-}
diff --git a/guilib/GUISpinControl.h b/guilib/GUISpinControl.h
deleted file mode 100644
index c1a983474a..0000000000
--- a/guilib/GUISpinControl.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/*!
-\file GUISpinControl.h
-\brief
-*/
-
-#ifndef GUILIB_SPINCONTROL_H
-#define GUILIB_SPINCONTROL_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIControl.h"
-#include "GUITexture.h"
-#include "GUILabel.h"
-
-#define SPIN_CONTROL_TYPE_INT 1
-#define SPIN_CONTROL_TYPE_FLOAT 2
-#define SPIN_CONTROL_TYPE_TEXT 3
-#define SPIN_CONTROL_TYPE_PAGE 4
-
-/*!
- \ingroup controls
- \brief
- */
-class CGUISpinControl : public CGUIControl
-{
-public:
- CGUISpinControl(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& textureUp, const CTextureInfo& textureDown, const CTextureInfo& textureUpFocus, const CTextureInfo& textureDownFocus, const CLabelInfo& labelInfo, int iType);
- virtual ~CGUISpinControl(void);
- virtual CGUISpinControl *Clone() const { return new CGUISpinControl(*this); };
-
- virtual void Render();
- virtual bool OnAction(const CAction &action);
- virtual void OnLeft();
- virtual void OnRight();
- virtual bool HitTest(const CPoint &point) const;
- virtual bool OnMouseOver(const CPoint &point);
- virtual bool OnMessage(CGUIMessage& message);
- virtual void AllocResources();
- virtual void FreeResources(bool immediately = false);
- virtual void DynamicResourceAlloc(bool bOnOff);
- virtual void SetInvalid();
- virtual void SetPosition(float posX, float posY);
- virtual float GetWidth() const;
- void SetRange(int iStart, int iEnd);
- void SetFloatRange(float fStart, float fEnd);
- void SetValue(int iValue);
- void SetValueFromLabel(const CStdString &label);
- void SetFloatValue(float fValue);
- int GetValue() const;
- float GetFloatValue() const;
- void AddLabel(const std::string& strLabel, int iValue);
- const std::string GetLabel() const;
- void SetReverse(bool bOnOff);
- int GetMaximum() const;
- int GetMinimum() const;
- void SetSpinAlign(uint32_t align, float offsetX) { m_label.GetLabelInfo().align = align; m_label.GetLabelInfo().offsetX = offsetX; };
- void SetType(int iType) { m_iType = iType; };
- float GetSpinWidth() const { return m_imgspinUp.GetWidth(); };
- float GetSpinHeight() const { return m_imgspinUp.GetHeight(); };
- void SetFloatInterval(float fInterval);
- void SetShowRange(bool bOnoff) ;
- void SetShowOnePage(bool showOnePage) { m_showOnePage = showOnePage; };
- void Clear();
- virtual CStdString GetDescription() const;
- bool IsFocusedOnUp() const;
-
- virtual bool IsVisible() const;
-
-protected:
- virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event);
- virtual void UpdateColors();
- /*! \brief Render the spinner text
- \param posX position of the left edge of the text
- \param width width of the text
- */
- virtual void RenderText(float posX, float width);
- CGUILabel::COLOR GetTextColor() const;
- void PageUp();
- void PageDown();
- bool CanMoveDown(bool bTestReverse = true);
- bool CanMoveUp(bool bTestReverse = true);
- void MoveUp(bool bTestReverse = true);
- void MoveDown(bool bTestReverse = true);
- void ChangePage(int amount);
- int m_iStart;
- int m_iEnd;
- float m_fStart;
- float m_fEnd;
- int m_iValue;
- float m_fValue;
- int m_iType;
- int m_iSelect;
- bool m_bReverse;
- float m_fInterval;
- std::vector<std::string> m_vecLabels;
- std::vector<int> m_vecValues;
- CGUITexture m_imgspinUp;
- CGUITexture m_imgspinDown;
- CGUITexture m_imgspinUpFocus;
- CGUITexture m_imgspinDownFocus;
- CGUILabel m_label;
- bool m_bShowRange;
- char m_szTyped[10];
- int m_iTypedPos;
-
- int m_currentItem;
- int m_itemsPerPage;
- int m_numItems;
- bool m_showOnePage;
-};
-#endif
diff --git a/guilib/GUISpinControlEx.cpp b/guilib/GUISpinControlEx.cpp
deleted file mode 100644
index 55319e3d80..0000000000
--- a/guilib/GUISpinControlEx.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUISpinControlEx.h"
-
-CGUISpinControlEx::CGUISpinControlEx(int parentID, int controlID, float posX, float posY, float width, float height, float spinWidth, float spinHeight, const CLabelInfo& spinInfo, const CTextureInfo &textureFocus, const CTextureInfo &textureNoFocus, const CTextureInfo& textureUp, const CTextureInfo& textureDown, const CTextureInfo& textureUpFocus, const CTextureInfo& textureDownFocus, const CLabelInfo& labelInfo, int iType)
- : CGUISpinControl(parentID, controlID, posX, posY, spinWidth, spinHeight, textureUp, textureDown, textureUpFocus, textureDownFocus, spinInfo, iType)
- , m_buttonControl(parentID, controlID, posX, posY, width, height, textureFocus, textureNoFocus, labelInfo)
-{
- ControlType = GUICONTROL_SPINEX;
- m_spinPosX = 0;
-}
-
-CGUISpinControlEx::~CGUISpinControlEx(void)
-{
-}
-
-void CGUISpinControlEx::AllocResources()
-{
- // Correct alignment - we always align the spincontrol on the right
- m_label.GetLabelInfo().align = (m_label.GetLabelInfo().align & XBFONT_CENTER_Y) | XBFONT_RIGHT;
- CGUISpinControl::AllocResources();
- m_buttonControl.AllocResources();
- if (m_height == 0)
- m_height = GetSpinHeight();
-}
-
-void CGUISpinControlEx::FreeResources(bool immediately)
-{
- CGUISpinControl::FreeResources(immediately);
- m_buttonControl.FreeResources(immediately);
-}
-
-void CGUISpinControlEx::DynamicResourceAlloc(bool bOnOff)
-{
- CGUISpinControl::DynamicResourceAlloc(bOnOff);
- m_buttonControl.DynamicResourceAlloc(bOnOff);
-}
-
-
-void CGUISpinControlEx::SetInvalid()
-{
- CGUISpinControl::SetInvalid();
- m_buttonControl.SetInvalid();
-}
-
-void CGUISpinControlEx::Render()
-{
- // make sure the button has focus if it should have...
- m_buttonControl.SetFocus(HasFocus());
- m_buttonControl.SetPulseOnSelect(m_pulseOnSelect);
- m_buttonControl.SetEnabled(m_enabled);
- m_buttonControl.Render();
- if (m_bInvalidated)
- SetPosition(GetXPosition(), GetYPosition());
-
- CGUISpinControl::Render();
-}
-
-void CGUISpinControlEx::SetPosition(float posX, float posY)
-{
- m_buttonControl.SetPosition(posX, posY);
- float spinPosX = posX + m_buttonControl.GetWidth() - GetSpinWidth() * 2 - (m_spinPosX ? m_spinPosX : m_buttonControl.GetLabelInfo().offsetX);
- float spinPosY = posY + (m_buttonControl.GetHeight() - GetSpinHeight()) * 0.5f;
- CGUISpinControl::SetPosition(spinPosX, spinPosY);
-}
-
-void CGUISpinControlEx::SetWidth(float width)
-{
- m_buttonControl.SetWidth(width);
- SetPosition(m_buttonControl.GetXPosition(), m_buttonControl.GetYPosition());
-}
-
-void CGUISpinControlEx::SetHeight(float height)
-{
- m_buttonControl.SetHeight(height);
- SetPosition(m_buttonControl.GetXPosition(), m_buttonControl.GetYPosition());
-}
-
-void CGUISpinControlEx::SetVisible(bool bVisible)
-{
- m_buttonControl.SetVisible(bVisible);
- CGUISpinControl::SetVisible(bVisible);
-}
-
-void CGUISpinControlEx::UpdateColors()
-{
- CGUISpinControl::UpdateColors();
- m_buttonControl.SetColorDiffuse(m_diffuseColor);
- m_buttonControl.UpdateColors();
-}
-
-void CGUISpinControlEx::SetEnabled(bool bEnable)
-{
- m_buttonControl.SetEnabled(bEnable);
- CGUISpinControl::SetEnabled(bEnable);
-}
-
-const CStdString CGUISpinControlEx::GetCurrentLabel() const
-{
- return CGUISpinControl::GetLabel();
-}
-
-CStdString CGUISpinControlEx::GetDescription() const
-{
- CStdString strLabel;
- strLabel.Format("%s (%s)", m_buttonControl.GetDescription(), GetLabel());
- return strLabel;
-}
-
-void CGUISpinControlEx::SetItemInvalid(bool invalid)
-{
- if (invalid)
- {
- m_label.GetLabelInfo().textColor = m_buttonControl.GetLabelInfo().disabledColor;
- m_label.GetLabelInfo().focusedColor = m_buttonControl.GetLabelInfo().disabledColor;
- }
- else
- {
- m_label.GetLabelInfo().textColor = m_buttonControl.GetLabelInfo().textColor;
- m_label.GetLabelInfo().focusedColor = m_buttonControl.GetLabelInfo().focusedColor;
- }
-}
-
-void CGUISpinControlEx::SetSpinPosition(float spinPosX)
-{
- m_spinPosX = spinPosX;
- SetPosition(m_buttonControl.GetXPosition(), m_buttonControl.GetYPosition());
-}
-
-void CGUISpinControlEx::RenderText(float posX, float width)
-{
- const float spaceWidth = 10;
- // check our limits from the button control
- float x = std::max(m_buttonControl.m_label.GetRenderRect().x2 + spaceWidth, posX);
- m_label.SetScrolling(HasFocus());
- CGUISpinControl::RenderText(x, width + posX - x);
-}
diff --git a/guilib/GUISpinControlEx.h b/guilib/GUISpinControlEx.h
deleted file mode 100644
index 19db83e652..0000000000
--- a/guilib/GUISpinControlEx.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*!
-\file GUISpinControlEx.h
-\brief
-*/
-
-#ifndef GUILIB_SPINCONTROLEX_H
-#define GUILIB_SPINCONTROLEX_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUISpinControl.h"
-#include "GUIButtonControl.h"
-
-/*!
- \ingroup controls
- \brief
- */
-class CGUISpinControlEx : public CGUISpinControl
-{
-public:
- CGUISpinControlEx(int parentID, int controlID, float posX, float posY, float width, float height, float spinWidth, float spinHeight, const CLabelInfo& spinInfo, const CTextureInfo &textureFocus, const CTextureInfo &textureNoFocus, const CTextureInfo& textureUp, const CTextureInfo& textureDown, const CTextureInfo& textureUpFocus, const CTextureInfo& textureDownFocus, const CLabelInfo& labelInfo, int iType);
- virtual ~CGUISpinControlEx(void);
- virtual CGUISpinControlEx *Clone() const { return new CGUISpinControlEx(*this); };
-
- virtual void Render();
- virtual void SetPosition(float posX, float posY);
- virtual float GetWidth() const { return m_buttonControl.GetWidth();};
- virtual void SetWidth(float width);
- virtual float GetHeight() const { return m_buttonControl.GetHeight();};
- virtual void SetHeight(float height);
- virtual void AllocResources();
- virtual void FreeResources(bool immediately = false);
- virtual void DynamicResourceAlloc(bool bOnOff);
- virtual void SetInvalid();
- const CStdString GetCurrentLabel() const;
- void SetText(const std::string & aLabel) {m_buttonControl.SetLabel(aLabel);};
- virtual void SetVisible(bool bVisible);
- virtual void SetEnabled(bool bEnable);
- virtual float GetXPosition() const { return m_buttonControl.GetXPosition();};
- virtual float GetYPosition() const { return m_buttonControl.GetYPosition();};
- virtual CStdString GetDescription() const;
- virtual bool HitTest(const CPoint &point) const { return m_buttonControl.HitTest(point); };
- void SetSpinPosition(float spinPosX);
-
- void SetItemInvalid(bool invalid);
-protected:
- virtual void RenderText(float posX, float width);
- virtual void UpdateColors();
- CGUIButtonControl m_buttonControl;
- float m_spinPosX;
-};
-#endif
diff --git a/guilib/GUIStandardWindow.cpp b/guilib/GUIStandardWindow.cpp
deleted file mode 100644
index 0d25aad763..0000000000
--- a/guilib/GUIStandardWindow.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIStandardWindow.h"
-#include "GUIWindowManager.h"
-#include "AdvancedSettings.h"
-#include "Key.h"
-
-CGUIStandardWindow::CGUIStandardWindow(int id, const CStdString &xmlFile) : CGUIWindow(id, xmlFile)
-{
-}
-
-CGUIStandardWindow::~CGUIStandardWindow(void)
-{
-}
-
-bool CGUIStandardWindow::OnAction(const CAction &action)
-{
- if (action.GetID() == ACTION_PREVIOUS_MENU)
- {
- g_windowManager.PreviousWindow();
- return true;
- }
-
- if (action.GetID() == ACTION_PARENT_DIR && g_advancedSettings.m_bUseEvilB)
- {
- g_windowManager.PreviousWindow();
- return true;
- }
-
- return CGUIWindow::OnAction(action);
-}
diff --git a/guilib/GUIStandardWindow.h b/guilib/GUIStandardWindow.h
deleted file mode 100644
index 10d8e9e6f1..0000000000
--- a/guilib/GUIStandardWindow.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIWindow.h"
-
-// This class is designed to be the base class for any standard
-// full screen window. Default implementations for action keys
-// can be placed into this class to make creating new window
-// classes that much easier.
-
-class CGUIStandardWindow :
- public CGUIWindow
-{
-public:
- CGUIStandardWindow(int id, const CStdString &xmlFile);
- virtual ~CGUIStandardWindow(void);
-
- virtual bool OnAction(const CAction &action);
-};
diff --git a/guilib/GUIStaticItem.cpp b/guilib/GUIStaticItem.cpp
deleted file mode 100644
index c9bb6ba2e7..0000000000
--- a/guilib/GUIStaticItem.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2005-2010 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIStaticItem.h"
-#include "XMLUtils.h"
-#include "GUIControlFactory.h"
-
-using namespace std;
-
-CGUIStaticItem::CGUIStaticItem(const TiXmlElement *item, int parentID) : CFileItem()
-{
- assert(item);
-
- // check whether we're using the more verbose method...
- const TiXmlNode *click = item->FirstChild("onclick");
- if (click && click->FirstChild())
- {
- CGUIInfoLabel label, label2, thumb, icon;
- CGUIControlFactory::GetInfoLabel(item, "label", label);
- CGUIControlFactory::GetInfoLabel(item, "label2", label2);
- CGUIControlFactory::GetInfoLabel(item, "thumb", thumb);
- CGUIControlFactory::GetInfoLabel(item, "icon", icon);
- const char *id = item->Attribute("id");
- int visibleCondition = 0;
- CGUIControlFactory::GetConditionalVisibility(item, visibleCondition);
- // multiple action strings are concat'd together, separated with " , "
- vector<CGUIActionDescriptor> actions;
- CGUIControlFactory::GetMultipleString(item, "onclick", actions);
- for (vector<CGUIActionDescriptor>::iterator it = actions.begin(); it != actions.end(); ++it)
- {
- (*it).m_action.Replace(",", ",,");
- if (m_strPath.length() > 0)
- {
- m_strPath += " , ";
- }
- m_strPath += (*it).m_action;
- }
- SetLabel(label.GetLabel(parentID));
- SetLabel2(label2.GetLabel(parentID));
- SetThumbnailImage(thumb.GetLabel(parentID, true));
- SetIconImage(icon.GetLabel(parentID, true));
- if (!label.IsConstant()) m_info.push_back(make_pair(label, "label"));
- if (!label2.IsConstant()) m_info.push_back(make_pair(label2, "label2"));
- if (!thumb.IsConstant()) m_info.push_back(make_pair(thumb, "thumb"));
- if (!icon.IsConstant()) m_info.push_back(make_pair(icon, "icon"));
- m_iprogramCount = id ? atoi(id) : 0;
- m_idepth = visibleCondition;
- // add any properties
- const TiXmlElement *property = item->FirstChildElement("property");
- while (property)
- {
- CStdString name = property->Attribute("name");
- CGUIInfoLabel prop;
- if (!name.IsEmpty() && CGUIControlFactory::GetInfoLabelFromElement(property, prop))
- {
- SetProperty(name, prop.GetLabel(parentID, true));
- if (!prop.IsConstant())
- m_info.push_back(make_pair(prop, name));
- }
- property = property->NextSiblingElement("property");
- }
- }
- else
- {
- CStdString label, label2, thumb, icon;
- label = item->Attribute("label"); label = CGUIControlFactory::FilterLabel(label);
- label2 = item->Attribute("label2"); label2 = CGUIControlFactory::FilterLabel(label2);
- thumb = item->Attribute("thumb"); thumb = CGUIControlFactory::FilterLabel(thumb);
- icon = item->Attribute("icon"); icon = CGUIControlFactory::FilterLabel(icon);
- const char *id = item->Attribute("id");
- SetLabel(CGUIInfoLabel::GetLabel(label, parentID));
- m_strPath = item->FirstChild()->Value();
- SetLabel2(CGUIInfoLabel::GetLabel(label2, parentID));
- SetThumbnailImage(CGUIInfoLabel::GetLabel(thumb, parentID, true));
- SetIconImage(CGUIInfoLabel::GetLabel(icon, parentID, true));
- m_iprogramCount = id ? atoi(id) : 0;
- m_idepth = 0; // no visibility condition
- }
-}
-
-void CGUIStaticItem::UpdateProperties(int contextWindow)
-{
- for (InfoVector::const_iterator i = m_info.begin(); i != m_info.end(); i++)
- {
- const CGUIInfoLabel &info = i->first;
- const CStdString &name = i->second;
- bool preferTexture = strnicmp("label", name.c_str(), 5) != 0;
- CStdString value(info.GetLabel(contextWindow, preferTexture));
- if (name.Equals("label"))
- SetLabel(value);
- else if (name.Equals("label2"))
- SetLabel2(value);
- else if (name.Equals("thumb"))
- SetThumbnailImage(value);
- else if (name.Equals("icon"))
- SetIconImage(value);
- else
- SetProperty(name, value);
- }
-}
diff --git a/guilib/GUIStaticItem.h b/guilib/GUIStaticItem.h
deleted file mode 100644
index 269db1b22f..0000000000
--- a/guilib/GUIStaticItem.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2005-2010 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#pragma once
-
-/*!
- \file GUIStaticItem.h
- \brief
- */
-
-#include "GUIInfoTypes.h"
-#include "../xbmc/FileItem.h"
-
-class TiXmlElement;
-
-/*!
- \ingroup lists,items
- \brief wrapper class for a static item in a list container
-
- A wrapper class for the items in a container specified via the <content>
- flag. Handles constructing items from XML and updating item labels, icons
- and properties.
-
- \sa CFileItem, CGUIBaseContainer
- */
-class CGUIStaticItem : public CFileItem
-{
-public:
- /*! \brief constructor
- Construct an item based on an XML description:
- <item>
- <label>$INFO[MusicPlayer.Artist]</label>
- <label2>$INFO[MusicPlayer.Album]</label2>
- <thumb>bar.png</thumb>
- <icon>foo.jpg</icon>
- <onclick>ActivateWindow(Home)</onclick>
- </item>
-
- \param element XML element to construct from
- \param contextWindow window context to use for any info labels
- */
- CGUIStaticItem(const TiXmlElement *element, int contextWindow);
- virtual ~CGUIStaticItem() {};
- virtual CGUIListItem *Clone() const { return new CGUIStaticItem(*this); };
-
- /*! \brief update any infolabels in the items properties
- Runs through all the items properties, updating any that should be
- periodically recomputed
- \param contextWindow window context to use for any info labels
- */
- void UpdateProperties(int contextWindow);
-private:
- typedef std::vector< std::pair<CGUIInfoLabel, CStdString> > InfoVector;
- InfoVector m_info;
-};
-
-typedef boost::shared_ptr<CGUIStaticItem> CGUIStaticItemPtr;
diff --git a/guilib/GUITextBox.cpp b/guilib/GUITextBox.cpp
deleted file mode 100644
index 5ea6d8e906..0000000000
--- a/guilib/GUITextBox.cpp
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUITextBox.h"
-#include "utils/CharsetConverter.h"
-#include "utils/GUIInfoManager.h"
-#include "tinyXML/tinyxml.h"
-
-using namespace std;
-
-CGUITextBox::CGUITextBox(int parentID, int controlID, float posX, float posY, float width, float height,
- const CLabelInfo& labelInfo, int scrollTime)
- : CGUIControl(parentID, controlID, posX, posY, width, height)
- , CGUITextLayout(labelInfo.font, true)
-{
- m_offset = 0;
- m_scrollOffset = 0;
- m_scrollSpeed = 0;
- m_itemsPerPage = 10;
- m_itemHeight = 10;
- ControlType = GUICONTROL_TEXTBOX;
- m_pageControl = 0;
- m_renderTime = 0;
- m_lastRenderTime = 0;
- m_scrollTime = scrollTime;
- m_autoScrollCondition = 0;
- m_autoScrollTime = 0;
- m_autoScrollDelay = 3000;
- m_autoScrollDelayTime = 0;
- m_autoScrollRepeatAnim = NULL;
- m_label = labelInfo;
-}
-
-CGUITextBox::CGUITextBox(const CGUITextBox &from)
-: CGUIControl(from), CGUITextLayout(from)
-{
- m_pageControl = from.m_pageControl;
- m_scrollTime = from.m_scrollTime;
- m_autoScrollCondition = from.m_autoScrollCondition;
- m_autoScrollTime = from.m_autoScrollTime;
- m_autoScrollDelay = from.m_autoScrollDelay;
- m_autoScrollRepeatAnim = NULL;
- if (from.m_autoScrollRepeatAnim)
- m_autoScrollRepeatAnim = new CAnimation(*from.m_autoScrollRepeatAnim);
- m_label = from.m_label;
- m_info = from.m_info;
- // defaults
- m_offset = 0;
- m_scrollOffset = 0;
- m_scrollSpeed = 0;
- m_itemsPerPage = 10;
- m_itemHeight = 10;
- m_renderTime = 0;
- m_lastRenderTime = 0;
- m_autoScrollDelayTime = 0;
- ControlType = GUICONTROL_TEXTBOX;
-}
-
-CGUITextBox::~CGUITextBox(void)
-{
- delete m_autoScrollRepeatAnim;
- m_autoScrollRepeatAnim = NULL;
-}
-
-void CGUITextBox::DoRender(unsigned int currentTime)
-{
- m_renderTime = currentTime;
-
- // render the repeat anim as appropriate
- if (m_autoScrollRepeatAnim)
- {
- m_autoScrollRepeatAnim->Animate(m_renderTime, true);
- TransformMatrix matrix;
- m_autoScrollRepeatAnim->RenderAnimation(matrix);
- g_graphicsContext.AddTransform(matrix);
- }
-
- CGUIControl::DoRender(currentTime);
- // if not visible, we reset the autoscroll timer and positioning
- if (!IsVisible() && m_autoScrollTime)
- {
- ResetAutoScrolling();
- m_lastRenderTime = 0;
- m_offset = 0;
- m_scrollOffset = 0;
- m_scrollSpeed = 0;
- }
- if (m_autoScrollRepeatAnim)
- g_graphicsContext.RemoveTransform();
-}
-
-void CGUITextBox::UpdateColors()
-{
- m_label.UpdateColors();
- CGUIControl::UpdateColors();
-}
-
-void CGUITextBox::UpdateInfo(const CGUIListItem *item)
-{
- m_textColor = m_label.textColor;
- if (!CGUITextLayout::Update(item ? m_info.GetItemLabel(item) : m_info.GetLabel(m_parentID), m_width))
- return; // nothing changed
-
- // needed update, so reset to the top of the textbox and update our sizing/page control
- m_offset = 0;
- m_scrollOffset = 0;
- ResetAutoScrolling();
-
- m_itemHeight = m_font->GetLineHeight();
- m_itemsPerPage = (unsigned int)(m_height / m_itemHeight);
-
- UpdatePageControl();
-}
-
-void CGUITextBox::Render()
-{
- // update our auto-scrolling as necessary
- if (m_autoScrollTime && m_lines.size() > m_itemsPerPage)
- {
- if (!m_autoScrollCondition || g_infoManager.GetBool(m_autoScrollCondition, m_parentID))
- {
- if (m_lastRenderTime)
- m_autoScrollDelayTime += m_renderTime - m_lastRenderTime;
- if (m_autoScrollDelayTime > (unsigned int)m_autoScrollDelay && m_scrollSpeed == 0)
- { // delay is finished - start scrolling
- if (m_offset < (int)m_lines.size() - m_itemsPerPage)
- ScrollToOffset(m_offset + 1, true);
- else
- { // at the end, run a delay and restart
- if (m_autoScrollRepeatAnim)
- {
- if (m_autoScrollRepeatAnim->GetState() == ANIM_STATE_NONE)
- m_autoScrollRepeatAnim->QueueAnimation(ANIM_PROCESS_NORMAL);
- else if (m_autoScrollRepeatAnim->GetState() == ANIM_STATE_APPLIED)
- { // reset to the start of the list and start the scrolling again
- m_offset = 0;
- m_scrollOffset = 0;
- ResetAutoScrolling();
- }
- }
- }
- }
- }
- else if (m_autoScrollCondition)
- ResetAutoScrolling(); // conditional is false, so reset the autoscrolling
- }
-
- // update our scroll position as necessary
- if (m_lastRenderTime)
- m_scrollOffset += m_scrollSpeed * (m_renderTime - m_lastRenderTime);
- if ((m_scrollSpeed < 0 && m_scrollOffset < m_offset * m_itemHeight) ||
- (m_scrollSpeed > 0 && m_scrollOffset > m_offset * m_itemHeight))
- {
- m_scrollOffset = m_offset * m_itemHeight;
- m_scrollSpeed = 0;
- }
- m_lastRenderTime = m_renderTime;
-
- int offset = (int)(m_scrollOffset / m_itemHeight);
-
- if (g_graphicsContext.SetClipRegion(m_posX, m_posY, m_width, m_height))
- {
- // we offset our draw position to take into account scrolling and whether or not our focused
- // item is offscreen "above" the list.
- float posX = m_posX;
- float posY = m_posY + offset * m_itemHeight - m_scrollOffset;
-
- // alignment correction
- if (m_label.align & XBFONT_CENTER_X)
- posX += m_width * 0.5f;
- if (m_label.align & XBFONT_RIGHT)
- posX += m_width;
-
- if (m_font)
- {
- m_font->Begin();
- int current = offset;
- while (posY < m_posY + m_height && current < (int)m_lines.size())
- {
- uint32_t align = m_label.align;
- if (m_lines[current].m_text.size() && m_lines[current].m_carriageReturn)
- align &= ~XBFONT_JUSTIFIED; // last line of a paragraph shouldn't be justified
- m_font->DrawText(posX, posY + 2, m_colors, m_label.shadowColor, m_lines[current].m_text, align, m_width);
- posY += m_itemHeight;
- current++;
- }
- m_font->End();
- }
-
- g_graphicsContext.RestoreClipRegion();
- }
-
- if (m_pageControl)
- {
- CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), m_pageControl, offset);
- SendWindowMessage(msg);
- }
- CGUIControl::Render();
-}
-
-bool CGUITextBox::OnMessage(CGUIMessage& message)
-{
- if (message.GetControlId() == GetID())
- {
- if (message.GetMessage() == GUI_MSG_LABEL_SET)
- {
- m_offset = 0;
- m_scrollOffset = 0;
- ResetAutoScrolling();
- CGUITextLayout::Reset();
- m_info.SetLabel(message.GetLabel(), "");
- }
-
- if (message.GetMessage() == GUI_MSG_LABEL_RESET)
- {
- m_offset = 0;
- m_scrollOffset = 0;
- ResetAutoScrolling();
- CGUITextLayout::Reset();
- if (m_pageControl)
- {
- CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), m_pageControl, m_itemsPerPage, m_lines.size());
- SendWindowMessage(msg);
- }
- }
-
- if (message.GetMessage() == GUI_MSG_PAGE_CHANGE)
- {
- if (message.GetSenderId() == m_pageControl)
- { // update our page
- Scroll(message.GetParam1());
- return true;
- }
- }
- }
-
- return CGUIControl::OnMessage(message);
-}
-
-void CGUITextBox::UpdatePageControl()
-{
- if (m_pageControl)
- {
- CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), m_pageControl, m_itemsPerPage, m_lines.size());
- SendWindowMessage(msg);
- }
-}
-
-bool CGUITextBox::CanFocus() const
-{
- return false;
-}
-
-void CGUITextBox::SetPageControl(int pageControl)
-{
- m_pageControl = pageControl;
-}
-
-void CGUITextBox::SetInfo(const CGUIInfoLabel &infoLabel)
-{
- m_info = infoLabel;
-}
-
-void CGUITextBox::Scroll(unsigned int offset)
-{
- ResetAutoScrolling();
- if (m_lines.size() <= m_itemsPerPage)
- return; // no need to scroll
- if (offset > m_lines.size() - m_itemsPerPage)
- offset = m_lines.size() - m_itemsPerPage; // on last page
- ScrollToOffset(offset);
-}
-
-void CGUITextBox::ScrollToOffset(int offset, bool autoScroll)
-{
- m_scrollOffset = m_offset * m_itemHeight;
- int timeToScroll = autoScroll ? m_autoScrollTime : m_scrollTime;
- m_scrollSpeed = (offset * m_itemHeight - m_scrollOffset) / timeToScroll;
- m_offset = offset;
-}
-
-void CGUITextBox::SetAutoScrolling(const TiXmlNode *node)
-{
- if (!node) return;
- const TiXmlElement *scroll = node->FirstChildElement("autoscroll");
- if (scroll)
- {
- scroll->Attribute("delay", &m_autoScrollDelay);
- scroll->Attribute("time", &m_autoScrollTime);
- if (scroll->FirstChild())
- m_autoScrollCondition = g_infoManager.TranslateString(scroll->FirstChild()->ValueStr());
- int repeatTime;
- if (scroll->Attribute("repeat", &repeatTime))
- m_autoScrollRepeatAnim = CAnimation::CreateFader(100, 0, repeatTime, 1000);
- }
-}
-
-void CGUITextBox::ResetAutoScrolling()
-{
- m_autoScrollDelayTime = 0;
- if (m_autoScrollRepeatAnim)
- m_autoScrollRepeatAnim->ResetAnimation();
-}
-
-unsigned int CGUITextBox::GetRows() const
-{
- return m_lines.size();
-}
-
-int CGUITextBox::GetCurrentPage() const
-{
- if (m_offset + m_itemsPerPage >= GetRows()) // last page
- return (GetRows() + m_itemsPerPage - 1) / m_itemsPerPage;
- return m_offset / m_itemsPerPage + 1;
-}
-
-CStdString CGUITextBox::GetLabel(int info) const
-{
- CStdString label;
- switch (info)
- {
- case CONTAINER_NUM_PAGES:
- label.Format("%u", (GetRows() + m_itemsPerPage - 1) / m_itemsPerPage);
- break;
- case CONTAINER_CURRENT_PAGE:
- label.Format("%u", GetCurrentPage());
- break;
- default:
- break;
- }
- return label;
-}
-
-void CGUITextBox::UpdateVisibility(const CGUIListItem *item)
-{
- // we have to update the page control when we become visible
- // as another control may be sharing the same page control when we're
- // not visible
- bool wasVisible = IsVisible();
- CGUIControl::UpdateVisibility(item);
- if (IsVisible() && !wasVisible)
- UpdatePageControl();
-}
diff --git a/guilib/GUITextBox.h b/guilib/GUITextBox.h
deleted file mode 100644
index e8a5150747..0000000000
--- a/guilib/GUITextBox.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*!
-\file GUITextBox.h
-\brief
-*/
-
-#ifndef GUILIB_GUITEXTBOX_H
-#define GUILIB_GUITEXTBOX_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUITextLayout.h"
-#include "GUIControl.h"
-#include "GUILabel.h"
-
-/*!
- \ingroup controls
- \brief
- */
-
-class TiXmlNode;
-
-class CGUITextBox : public CGUIControl, public CGUITextLayout
-{
-public:
- CGUITextBox(int parentID, int controlID, float posX, float posY, float width, float height,
- const CLabelInfo &labelInfo, int scrollTime = 200);
- CGUITextBox(const CGUITextBox &from);
- virtual ~CGUITextBox(void);
- virtual CGUITextBox *Clone() const { return new CGUITextBox(*this); };
-
- virtual void DoRender(unsigned int currentTime);
- virtual void Render();
- virtual bool OnMessage(CGUIMessage& message);
-
- void SetPageControl(int pageControl);
-
- virtual bool CanFocus() const;
- void SetInfo(const CGUIInfoLabel &info);
- void SetAutoScrolling(const TiXmlNode *node);
- void ResetAutoScrolling();
- CStdString GetLabel(int info) const;
-
- void Scroll(unsigned int offset);
-
-protected:
- virtual void UpdateVisibility(const CGUIListItem *item = NULL);
- virtual void UpdateColors();
- virtual void UpdateInfo(const CGUIListItem *item = NULL);
- void UpdatePageControl();
- void ScrollToOffset(int offset, bool autoScroll = false);
- unsigned int GetRows() const;
- int GetCurrentPage() const;
-
- // offset of text in the control for scrolling
- unsigned int m_offset;
- float m_scrollOffset;
- float m_scrollSpeed;
- int m_scrollTime;
- unsigned int m_itemsPerPage;
- float m_itemHeight;
- unsigned int m_renderTime;
- unsigned int m_lastRenderTime;
-
- CLabelInfo m_label;
-
- // autoscrolling
- int m_autoScrollCondition;
- int m_autoScrollTime; // time to scroll 1 line (ms)
- int m_autoScrollDelay; // delay before scroll (ms)
- unsigned int m_autoScrollDelayTime; // current offset into the delay
- CAnimation *m_autoScrollRepeatAnim;
-
- int m_pageControl;
-
- CGUIInfoLabel m_info;
-};
-#endif
diff --git a/guilib/GUITextLayout.cpp b/guilib/GUITextLayout.cpp
deleted file mode 100644
index 2eb676cd3b..0000000000
--- a/guilib/GUITextLayout.cpp
+++ /dev/null
@@ -1,628 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUITextLayout.h"
-#include "GUIFont.h"
-#include "GUIControl.h"
-#include "GUIColorManager.h"
-#include "utils/CharsetConverter.h"
-#include "StringUtils.h"
-
-using namespace std;
-
-#define WORK_AROUND_NEEDED_FOR_LINE_BREAKS
-
-CGUIString::CGUIString(iString start, iString end, bool carriageReturn)
-{
- m_text.assign(start, end);
- m_carriageReturn = carriageReturn;
-}
-
-CStdString CGUIString::GetAsString() const
-{
- CStdString text;
- for (unsigned int i = 0; i < m_text.size(); i++)
- text += (char)(m_text[i] & 0xff);
- return text;
-}
-
-CGUITextLayout::CGUITextLayout(CGUIFont *font, bool wrap, float fHeight, CGUIFont *borderFont)
-{
- m_font = font;
- m_borderFont = borderFont;
- m_textColor = 0;
- m_wrap = wrap;
- m_maxHeight = fHeight;
- m_textWidth = 0;
- m_textHeight = 0;
-}
-
-void CGUITextLayout::SetWrap(bool bWrap)
-{
- m_wrap = bWrap;
-}
-
-void CGUITextLayout::Render(float x, float y, float angle, color_t color, color_t shadowColor, uint32_t alignment, float maxWidth, bool solid)
-{
- if (!m_font)
- return;
-
- // set the main text color
- if (m_colors.size())
- m_colors[0] = color;
-
- // render the text at the required location, angle, and size
- if (angle)
- {
- static const float degrees_to_radians = 0.01745329252f;
- g_graphicsContext.AddTransform(TransformMatrix::CreateZRotation(angle * degrees_to_radians, x, y, g_graphicsContext.GetScalingPixelRatio()));
- }
- // center our text vertically
- if (alignment & XBFONT_CENTER_Y)
- {
- y -= m_font->GetTextHeight(m_lines.size()) * 0.5f;;
- alignment &= ~XBFONT_CENTER_Y;
- }
- m_font->Begin();
- for (vector<CGUIString>::iterator i = m_lines.begin(); i != m_lines.end(); i++)
- {
- const CGUIString &string = *i;
- uint32_t align = alignment;
- if (align & XBFONT_JUSTIFIED && string.m_carriageReturn)
- align &= ~XBFONT_JUSTIFIED;
- if (solid)
- m_font->DrawText(x, y, m_colors[0], shadowColor, string.m_text, align, maxWidth);
- else
- m_font->DrawText(x, y, m_colors, shadowColor, string.m_text, align, maxWidth);
- y += m_font->GetLineHeight();
- }
- m_font->End();
- if (angle)
- g_graphicsContext.RemoveTransform();
-}
-
-
-void CGUITextLayout::RenderScrolling(float x, float y, float angle, color_t color, color_t shadowColor, uint32_t alignment, float maxWidth, CScrollInfo &scrollInfo)
-{
- if (!m_font)
- return;
-
- // set the main text color
- if (m_colors.size())
- m_colors[0] = color;
-
- // render the text at the required location, angle, and size
- if (angle)
- {
- static const float degrees_to_radians = 0.01745329252f;
- g_graphicsContext.AddTransform(TransformMatrix::CreateZRotation(angle * degrees_to_radians, x, y, g_graphicsContext.GetScalingPixelRatio()));
- }
- // center our text vertically
- if (alignment & XBFONT_CENTER_Y)
- {
- y -= m_font->GetTextHeight(m_lines.size()) * 0.5f;;
- alignment &= ~XBFONT_CENTER_Y;
- }
- m_font->Begin();
- // NOTE: This workaround is needed as otherwise multi-line text that scrolls
- // will scroll in proportion to the number of lines. Ideally we should
- // do the DrawScrollingText calculation here. This probably won't make
- // any difference to the smoothness of scrolling though which will be
- // jumpy with this sort of thing. It's not exactly a well used situation
- // though, so this hack is probably OK.
- float speed = scrollInfo.pixelSpeed;
- for (vector<CGUIString>::iterator i = m_lines.begin(); i != m_lines.end(); i++)
- {
- const CGUIString &string = *i;
- m_font->DrawScrollingText(x, y, m_colors, shadowColor, string.m_text, alignment, maxWidth, scrollInfo);
- y += m_font->GetLineHeight();
- scrollInfo.pixelSpeed = 0;
- }
- scrollInfo.pixelSpeed = speed;
- m_font->End();
- if (angle)
- g_graphicsContext.RemoveTransform();
-}
-
-void CGUITextLayout::RenderOutline(float x, float y, color_t color, color_t outlineColor, uint32_t alignment, float maxWidth)
-{
- if (!m_font)
- return;
-
- // set the outline color
- vecColors outlineColors;
- if (m_colors.size())
- outlineColors.push_back(outlineColor);
-
- // center our text vertically
- if (alignment & XBFONT_CENTER_Y)
- {
- y -= m_font->GetTextHeight(m_lines.size()) * 0.5f;;
- alignment &= ~XBFONT_CENTER_Y;
- }
- if (m_borderFont)
- {
- float by = y;
- m_borderFont->Begin();
- for (vector<CGUIString>::iterator i = m_lines.begin(); i != m_lines.end(); i++)
- {
- const CGUIString &string = *i;
- uint32_t align = alignment;
- if (align & XBFONT_JUSTIFIED && string.m_carriageReturn)
- align &= ~XBFONT_JUSTIFIED;
-
- m_borderFont->DrawText(x, by, outlineColors, 0, string.m_text, align, maxWidth);
- by += m_borderFont->GetLineHeight();
- }
- m_borderFont->End();
- }
-
- // set the main text color
- if (m_colors.size())
- m_colors[0] = color;
-
- m_font->Begin();
- for (vector<CGUIString>::iterator i = m_lines.begin(); i != m_lines.end(); i++)
- {
- const CGUIString &string = *i;
- uint32_t align = alignment;
- if (align & XBFONT_JUSTIFIED && string.m_carriageReturn)
- align &= ~XBFONT_JUSTIFIED;
-
- m_font->DrawText(x, y, m_colors, 0, string.m_text, align, maxWidth);
- y += m_font->GetLineHeight();
- }
- m_font->End();
-}
-
-bool CGUITextLayout::Update(const CStdString &text, float maxWidth, bool forceUpdate /*= false*/, bool forceLTRReadingOrder /*= false*/)
-{
- if (text == m_lastText && !forceUpdate)
- return false;
-
- // convert to utf16
- CStdStringW utf16;
- utf8ToW(text, utf16);
-
- // update
- SetText(utf16, maxWidth, forceLTRReadingOrder);
-
- // and set our parameters to indicate no further update is required
- m_lastText = text;
- return true;
-}
-
-void CGUITextLayout::SetText(const CStdStringW &text, float maxWidth, bool forceLTRReadingOrder /*= false*/)
-{
- vecText parsedText;
-
- // empty out our previous string
- m_lines.clear();
- m_colors.clear();
- m_colors.push_back(m_textColor);
-
- // parse the text into our string objects
- ParseText(text, parsedText);
-
- // add \n to the end of the string
- parsedText.push_back(L'\n');
-
- // if we need to wrap the text, then do so
- if (m_wrap && maxWidth > 0)
- WrapText(parsedText, maxWidth);
- else
- LineBreakText(parsedText, m_lines);
-
- // remove any trailing blank lines
- while (!m_lines.empty() && m_lines.back().m_text.empty())
- m_lines.pop_back();
-
- BidiTransform(m_lines, forceLTRReadingOrder);
-
- // and cache the width and height for later reading
- CalcTextExtent();
-}
-
-// BidiTransform is used to handle RTL text flipping in the string
-void CGUITextLayout::BidiTransform(vector<CGUIString> &lines, bool forceLTRReadingOrder)
-{
- for (unsigned int i=0; i<lines.size(); i++)
- {
- CGUIString &line = lines[i];
-
- // reserve enough space in the flipped text
- vecText flippedText;
- flippedText.reserve(line.m_text.size());
-
- character_t sectionStyle = 0xffff0000; // impossible to achieve
- CStdStringW sectionText;
- for (vecText::iterator it = line.m_text.begin(); it != line.m_text.end(); ++it)
- {
- character_t style = *it & 0xffff0000;
- if (style != sectionStyle)
- {
- if (!sectionText.IsEmpty())
- { // style has changed, bidi flip text
- CStdStringW sectionFlipped = BidiFlip(sectionText, forceLTRReadingOrder);
- for (unsigned int j = 0; j < sectionFlipped.size(); j++)
- flippedText.push_back(sectionStyle | sectionFlipped[j]);
- }
- sectionStyle = style;
- sectionText.clear();
- }
- sectionText.push_back( (wchar_t)(*it & 0xffff) );
- }
-
- // handle the last section
- if (!sectionText.IsEmpty())
- {
- CStdStringW sectionFlipped = BidiFlip(sectionText, forceLTRReadingOrder);
- for (unsigned int j = 0; j < sectionFlipped.size(); j++)
- flippedText.push_back(sectionStyle | sectionFlipped[j]);
- }
-
- // replace the original line with the proccessed one
- lines[i] = CGUIString(flippedText.begin(), flippedText.end(), line.m_carriageReturn);
- }
-}
-
-CStdStringW CGUITextLayout::BidiFlip(const CStdStringW &text, bool forceLTRReadingOrder)
-{
- CStdStringA utf8text;
- CStdStringW visualText;
-
- // convert to utf8, and back to utf16 with bidi flipping
- g_charsetConverter.wToUTF8(text, utf8text);
- g_charsetConverter.utf8ToW(utf8text, visualText, true, forceLTRReadingOrder);
-
- return visualText;
-}
-
-void CGUITextLayout::Filter(CStdString &text)
-{
- CStdStringW utf16;
- utf8ToW(text, utf16);
- vecColors colors;
- vecText parsedText;
- ParseText(utf16, 0, colors, parsedText);
- utf16.Empty();
- for (unsigned int i = 0; i < parsedText.size(); i++)
- utf16 += (wchar_t)(0xffff & parsedText[i]);
- g_charsetConverter.wToUTF8(utf16, text);
-}
-
-void CGUITextLayout::ParseText(const CStdStringW &text, vecText &parsedText)
-{
- if (!m_font)
- return;
- ParseText(text, m_font->GetStyle(), m_colors, parsedText);
-}
-
-void CGUITextLayout::ParseText(const CStdStringW &text, uint32_t defaultStyle, vecColors &colors, vecText &parsedText)
-{
- // run through the string, searching for:
- // [B] or [/B] -> toggle bold on and off
- // [I] or [/I] -> toggle italics on and off
- // [COLOR ffab007f] or [/COLOR] -> toggle color on and off
- // [CAPS <option>] or [/CAPS] -> toggle capatilization on and off
-
- uint32_t currentStyle = defaultStyle; // start with the default font's style
- color_t currentColor = 0;
-
- stack<color_t> colorStack;
- colorStack.push(0);
-
- // these aren't independent, but that's probably not too much of an issue
- // eg [UPPERCASE]Glah[LOWERCASE]FReD[/LOWERCASE]Georeg[/UPPERCASE] will work (lower case >> upper case)
- // but [LOWERCASE]Glah[UPPERCASE]FReD[/UPPERCASE]Georeg[/LOWERCASE] won't
-#define FONT_STYLE_UPPERCASE 4
-#define FONT_STYLE_LOWERCASE 8
-
- int startPos = 0;
- size_t pos = text.Find(L'[');
- while (pos != CStdString::npos && pos + 1 < text.size())
- {
- uint32_t newStyle = 0;
- color_t newColor = currentColor;
- bool newLine = false;
- // have a [ - check if it's an ON or OFF switch
- bool on(true);
- int endPos = pos++; // finish of string
- if (text[pos] == L'/')
- {
- on = false;
- pos++;
- }
- // check for each type
- if (text.Mid(pos,2) == L"B]")
- { // bold - finish the current text block and assign the bold state
- pos += 2;
- if ((on && text.Find(L"[/B]",pos) >= 0) || // check for a matching end point
- (!on && (currentStyle & FONT_STYLE_BOLD))) // or matching start point
- newStyle = FONT_STYLE_BOLD;
- }
- else if (text.Mid(pos,2) == L"I]")
- { // italics
- pos += 2;
- if ((on && text.Find(L"[/I]",pos) >= 0) || // check for a matching end point
- (!on && (currentStyle & FONT_STYLE_ITALICS))) // or matching start point
- newStyle = FONT_STYLE_ITALICS;
- }
- else if (text.Mid(pos,10) == L"UPPERCASE]")
- {
- pos += 10;
- if ((on && text.Find(L"[/UPPERCASE]",pos) >= 0) || // check for a matching end point
- (!on && (currentStyle & FONT_STYLE_UPPERCASE))) // or matching start point
- newStyle = FONT_STYLE_UPPERCASE;
- }
- else if (text.Mid(pos,10) == L"LOWERCASE]")
- {
- pos += 10;
- if ((on && text.Find(L"[/LOWERCASE]",pos) >= 0) || // check for a matching end point
- (!on && (currentStyle & FONT_STYLE_LOWERCASE))) // or matching start point
- newStyle = FONT_STYLE_LOWERCASE;
- }
- else if (text.Mid(pos,3) == L"CR]" && on)
- {
- newLine = true;
- pos += 3;
- }
- else if (text.Mid(pos,5) == L"COLOR")
- { // color
- size_t finish = text.Find(L']', pos + 5);
- if (on && finish != CStdString::npos && (size_t)text.Find(L"[/COLOR]",finish) != CStdString::npos)
- { // create new color
- newColor = colors.size();
- colors.push_back(g_colorManager.GetColor(text.Mid(pos + 5, finish - pos - 5)));
- colorStack.push(newColor);
- }
- else if (!on && finish == pos + 5 && colorStack.size() > 1)
- { // revert to previous color
- colorStack.pop();
- newColor = colorStack.top();
- }
- pos = finish + 1;
- }
-
- if (newStyle || newColor != currentColor || newLine)
- { // we have a new style or a new color, so format up the previous segment
- CStdStringW subText = text.Mid(startPos, endPos - startPos);
- if (currentStyle & FONT_STYLE_UPPERCASE)
- subText.ToUpper();
- if (currentStyle & FONT_STYLE_LOWERCASE)
- subText.ToLower();
- AppendToUTF32(subText, ((currentStyle & 3) << 24) | (currentColor << 16), parsedText);
- if (newLine)
- parsedText.push_back(L'\n');
-
- // and switch to the new style
- startPos = pos;
- currentColor = newColor;
- if (on)
- currentStyle |= newStyle;
- else
- currentStyle &= ~newStyle;
- }
- pos = text.Find(L'[',pos);
- }
- // now grab the remainder of the string
- CStdStringW subText = text.Mid(startPos, text.GetLength() - startPos);
- if (currentStyle & FONT_STYLE_UPPERCASE)
- subText.ToUpper();
- if (currentStyle & FONT_STYLE_LOWERCASE)
- subText.ToLower();
- AppendToUTF32(subText, ((currentStyle & 3) << 24) | (currentColor << 16), parsedText);
-}
-
-void CGUITextLayout::SetMaxHeight(float fHeight)
-{
- m_maxHeight = fHeight;
-}
-
-void CGUITextLayout::WrapText(const vecText &text, float maxWidth)
-{
- if (!m_font)
- return;
-
- int nMaxLines = (m_maxHeight > 0 && m_font->GetLineHeight() > 0)?(int)ceilf(m_maxHeight / m_font->GetLineHeight()):-1;
-
- m_lines.clear();
-
- vector<CGUIString> lines;
- LineBreakText(text, lines);
-
- for (unsigned int i = 0; i < lines.size(); i++)
- {
- const CGUIString &line = lines[i];
- vecText::const_iterator lastSpace = line.m_text.begin();
- vecText::const_iterator pos = line.m_text.begin();
- unsigned int lastSpaceInLine = 0;
- vecText curLine;
- while (pos != line.m_text.end() && (nMaxLines <= 0 || m_lines.size() < (size_t)nMaxLines))
- {
- // Get the current letter in the string
- character_t letter = *pos;
- // check for a space
- if (CanWrapAtLetter(letter))
- {
- float width = m_font->GetTextWidth(curLine);
- if (width > maxWidth)
- {
- if (lastSpace != line.m_text.begin() && lastSpaceInLine > 0)
- {
- CGUIString string(curLine.begin(), curLine.begin() + lastSpaceInLine, false);
- m_lines.push_back(string);
- // skip over spaces
- pos = lastSpace;
- while (pos != line.m_text.end() && IsSpace(*pos))
- pos++;
- curLine.clear();
- lastSpaceInLine = 0;
- lastSpace = line.m_text.begin();
- continue;
- }
- }
- lastSpace = pos;
- lastSpaceInLine = curLine.size();
- }
- curLine.push_back(letter);
- pos++;
- }
- // now add whatever we have left to the string
- float width = m_font->GetTextWidth(curLine);
- if (width > maxWidth)
- {
- // too long - put up to the last space on if we can + remove it from what's left.
- if (lastSpace != line.m_text.begin() && lastSpaceInLine > 0)
- {
- CGUIString string(curLine.begin(), curLine.begin() + lastSpaceInLine, false);
- m_lines.push_back(string);
- curLine.erase(curLine.begin(), curLine.begin() + lastSpaceInLine);
- while (curLine.size() && IsSpace(curLine.at(0)))
- curLine.erase(curLine.begin());
- }
- }
- CGUIString string(curLine.begin(), curLine.end(), true);
- m_lines.push_back(string);
- }
-}
-
-void CGUITextLayout::LineBreakText(const vecText &text, vector<CGUIString> &lines)
-{
- int nMaxLines = (m_maxHeight > 0 && m_font && m_font->GetLineHeight() > 0)?(int)ceilf(m_maxHeight / m_font->GetLineHeight()):-1;
- vecText::const_iterator lineStart = text.begin();
- vecText::const_iterator pos = text.begin();
- while (pos != text.end() && (nMaxLines <= 0 || lines.size() < (size_t)nMaxLines))
- {
- // Get the current letter in the string
- character_t letter = *pos;
-
- // Handle the newline character
- if ((letter & 0xffff) == L'\n' )
- { // push back everything up till now
- CGUIString string(lineStart, pos, true);
- lines.push_back(string);
- lineStart = pos + 1;
- }
- pos++;
- }
-}
-
-void CGUITextLayout::GetTextExtent(float &width, float &height) const
-{
- width = m_textWidth;
- height = m_textHeight;
-}
-
-void CGUITextLayout::CalcTextExtent()
-{
- m_textWidth = 0;
- m_textHeight = 0;
- if (!m_font) return;
-
- for (vector<CGUIString>::iterator i = m_lines.begin(); i != m_lines.end(); i++)
- {
- const CGUIString &string = *i;
- float w = m_font->GetTextWidth(string.m_text);
- if (w > m_textWidth)
- m_textWidth = w;
- }
- m_textHeight = m_font->GetTextHeight(m_lines.size());
-}
-
-unsigned int CGUITextLayout::GetTextLength() const
-{
- unsigned int length = 0;
- for (vector<CGUIString>::const_iterator i = m_lines.begin(); i != m_lines.end(); i++)
- length += i->m_text.size();
- return length;
-}
-
-void CGUITextLayout::GetFirstText(vecText &text) const
-{
- text.clear();
- if (m_lines.size())
- text = m_lines[0].m_text;
-}
-
-float CGUITextLayout::GetTextWidth(const CStdStringW &text) const
-{
- // NOTE: Assumes a single line of text
- if (!m_font) return 0;
- vecText utf32;
- AppendToUTF32(text, (m_font->GetStyle() & 3) << 24, utf32);
- return m_font->GetTextWidth(utf32);
-}
-
-void CGUITextLayout::DrawText(CGUIFont *font, float x, float y, color_t color, color_t shadowColor, const CStdString &text, uint32_t align)
-{
- if (!font) return;
- vecText utf32;
- AppendToUTF32(text, 0, utf32);
- font->DrawText(x, y, color, shadowColor, utf32, align, 0);
-}
-
-void CGUITextLayout::AppendToUTF32(const CStdStringW &utf16, character_t colStyle, vecText &utf32)
-{
- // NOTE: Assumes a single line of text
- utf32.reserve(utf32.size() + utf16.size());
- for (unsigned int i = 0; i < utf16.size(); i++)
- utf32.push_back(utf16[i] | colStyle);
-}
-
-void CGUITextLayout::utf8ToW(const CStdString &utf8, CStdStringW &utf16)
-{
-#ifdef WORK_AROUND_NEEDED_FOR_LINE_BREAKS
- // NOTE: This appears to strip \n characters from text. This may be a consequence of incorrect
- // expression of the \n in utf8 (we just use character code 10) or it might be something
- // more sinister. For now, we use the workaround below.
- CStdStringArray multiLines;
- StringUtils::SplitString(utf8, "\n", multiLines);
- for (unsigned int i = 0; i < multiLines.size(); i++)
- {
- CStdStringW line;
- // no need to bidiflip here - it's done in BidiTransform above
- g_charsetConverter.utf8ToW(multiLines[i], line, false);
- utf16 += line;
- if (i < multiLines.size() - 1)
- utf16.push_back(L'\n');
- }
-#else
- // no need to bidiflip here - it's done in BidiTransform above
- g_charsetConverter.utf8ToW(utf8, utf16, false);
-#endif
-}
-
-void CGUITextLayout::AppendToUTF32(const CStdString &utf8, character_t colStyle, vecText &utf32)
-{
- CStdStringW utf16;
- utf8ToW(utf8, utf16);
- AppendToUTF32(utf16, colStyle, utf32);
-}
-
-void CGUITextLayout::Reset()
-{
- m_lines.clear();
- m_lastText.Empty();
- m_textWidth = m_textHeight = 0;
-}
-
-
diff --git a/guilib/GUITextLayout.h b/guilib/GUITextLayout.h
deleted file mode 100644
index 8dfba0f209..0000000000
--- a/guilib/GUITextLayout.h
+++ /dev/null
@@ -1,144 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "StdString.h"
-
-#include <vector>
-
-#ifdef __GNUC__
-// under gcc, inline will only take place if optimizations are applied (-O). this will force inline even without optimizations.
-#define XBMC_FORCE_INLINE __attribute__((always_inline))
-#else
-#define XBMC_FORCE_INLINE
-#endif
-
-class CGUIFont;
-class CScrollInfo;
-
-// Process will be:
-
-// 1. String is divided up into a "multiinfo" vector via the infomanager.
-// 2. The multiinfo vector is then parsed by the infomanager at rendertime and the resultant string is constructed.
-// 3. This is saved for comparison perhaps. If the same, we are done. If not, go to 4.
-// 4. The string is then parsed into a vector<CGUIString>.
-// 5. Each item in the vector is length-calculated, and then layout occurs governed by alignment and wrapping rules.
-// 6. A new vector<CGUIString> is constructed
-
-typedef uint32_t character_t;
-typedef uint32_t color_t;
-typedef std::vector<character_t> vecText;
-typedef std::vector<color_t> vecColors;
-
-class CGUIString
-{
-public:
- typedef vecText::const_iterator iString;
-
- CGUIString(iString start, iString end, bool carriageReturn);
-
- CStdString GetAsString() const;
-
- vecText m_text;
- bool m_carriageReturn; // true if we have a carriage return here
-};
-
-class CGUITextLayout
-{
-public:
- CGUITextLayout(CGUIFont *font, bool wrap, float fHeight=0.0f, CGUIFont *borderFont = NULL); // this may need changing - we may just use this class to replace CLabelInfo completely
-
- // main function to render strings
- void Render(float x, float y, float angle, color_t color, color_t shadowColor, uint32_t alignment, float maxWidth, bool solid = false);
- void RenderScrolling(float x, float y, float angle, color_t color, color_t shadowColor, uint32_t alignment, float maxWidth, CScrollInfo &scrollInfo);
- void RenderOutline(float x, float y, color_t color, color_t outlineColor, uint32_t alignment, float maxWidth);
-
- /*! \brief Returns the precalculated width and height of the text to be rendered (in constant time).
- \param width [out] width of text
- \param height [out] height of text
- \sa GetTextWidth, CalcTextExtent
- */
- void GetTextExtent(float &width, float &height) const;
-
- /*! \brief Returns the precalculated width of the text to be rendered (in constant time).
- \return width of text
- \sa GetTextExtent, CalcTextExtent
- */
- float GetTextWidth() const { return m_textWidth; };
-
- float GetTextWidth(const CStdStringW &text) const;
- bool Update(const CStdString &text, float maxWidth = 0, bool forceUpdate = false, bool forceLTRReadingOrder = false);
- void SetText(const CStdStringW &text, float maxWidth = 0, bool forceLTRReadingOrder = false);
-
- unsigned int GetTextLength() const;
- void GetFirstText(vecText &text) const;
- void Reset();
-
- void SetWrap(bool bWrap=true);
- void SetMaxHeight(float fHeight);
-
-
- static void DrawText(CGUIFont *font, float x, float y, color_t color, color_t shadowColor, const CStdString &text, uint32_t align);
- static void Filter(CStdString &text);
-
-protected:
- void ParseText(const CStdStringW &text, vecText &parsedText);
- void LineBreakText(const vecText &text, std::vector<CGUIString> &lines);
- void WrapText(const vecText &text, float maxWidth);
- void BidiTransform(std::vector<CGUIString> &lines, bool forceLTRReadingOrder);
- CStdStringW BidiFlip(const CStdStringW &text, bool forceLTRReadingOrder);
- void CalcTextExtent();
-
- // our text to render
- vecColors m_colors;
- std::vector<CGUIString> m_lines;
- typedef std::vector<CGUIString>::iterator iLine;
-
- // the layout and font details
- CGUIFont *m_font; // has style, colour info
- CGUIFont *m_borderFont; // only used for outlined text
-
- bool m_wrap; // wrapping (true if justify is enabled!)
- float m_maxHeight;
- // the default color (may differ from the font objects defaults)
- color_t m_textColor;
-
- CStdString m_lastText;
- float m_textWidth;
- float m_textHeight;
-private:
- inline bool IsSpace(character_t letter) const XBMC_FORCE_INLINE
- {
- return (letter & 0xffff) == L' ';
- };
- inline bool CanWrapAtLetter(character_t letter) const XBMC_FORCE_INLINE
- {
- character_t ch = letter & 0xffff;
- return ch == L' ' || (ch >=0x4e00 && ch <= 0x9fff);
- };
- static void AppendToUTF32(const CStdString &utf8, character_t colStyle, vecText &utf32);
- static void AppendToUTF32(const CStdStringW &utf16, character_t colStyle, vecText &utf32);
- static void ParseText(const CStdStringW &text, uint32_t defaultStyle, vecColors &colors, vecText &parsedText);
-
- static void utf8ToW(const CStdString &utf8, CStdStringW &utf16);
-};
-
diff --git a/guilib/GUITexture.cpp b/guilib/GUITexture.cpp
deleted file mode 100644
index 25b5ed6faa..0000000000
--- a/guilib/GUITexture.cpp
+++ /dev/null
@@ -1,626 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUITexture.h"
-#include "GraphicContext.h"
-#include "TextureManager.h"
-#include "GUILargeTextureManager.h"
-#include "MathUtils.h"
-
-using namespace std;
-
-CTextureInfo::CTextureInfo()
-{
- orientation = 0;
- useLarge = false;
-}
-
-CTextureInfo::CTextureInfo(const CStdString &file)
-{
- orientation = 0;
- useLarge = false;
- filename = file;
-}
-
-CTextureInfo& CTextureInfo::operator=(const CTextureInfo &right)
-{
- border = right.border;
- orientation = right.orientation;
- diffuse = right.diffuse;
- filename = right.filename;
- useLarge = right.useLarge;
-
- return *this;
-}
-
-CGUITextureBase::CGUITextureBase(float posX, float posY, float width, float height, const CTextureInfo& texture)
-{
- m_posX = posX;
- m_posY = posY;
- m_width = width;
- m_height = height;
- m_info = texture;
-
- // defaults
- m_visible = true;
- m_diffuseColor = 0xffffffff;
- m_alpha = 0xff;
-
- m_vertex.SetRect(m_posX, m_posY, m_posX + m_width, m_posY + m_height);
-
- m_frameWidth = 0;
- m_frameHeight = 0;
-
- m_texCoordsScaleU = 1.0f;
- m_texCoordsScaleV = 1.0f;
- m_diffuseU = 1.0f;
- m_diffuseV = 1.0f;
- m_diffuseScaleU = 1.0f;
- m_diffuseScaleV = 1.0f;
-
- // anim gifs
- m_currentFrame = 0;
- m_frameCounter = (unsigned int) -1;
- m_currentLoop = 0;
-
- m_allocateDynamically = false;
- m_isAllocated = NO;
- m_invalid = true;
-}
-
-CGUITextureBase::CGUITextureBase(const CGUITextureBase &right)
-{
- m_posX = right.m_posX;
- m_posY = right.m_posY;
- m_width = right.m_width;
- m_height = right.m_height;
- m_info = right.m_info;
-
- m_visible = right.m_visible;
- m_diffuseColor = right.m_diffuseColor;
- m_alpha = right.m_alpha;
- m_aspect = right.m_aspect;
-
- m_allocateDynamically = right.m_allocateDynamically;
-
- // defaults
- m_vertex.SetRect(m_posX, m_posY, m_posX + m_width, m_posY + m_height);
-
- m_frameWidth = 0;
- m_frameHeight = 0;
-
- m_texCoordsScaleU = 1.0f;
- m_texCoordsScaleV = 1.0f;
- m_diffuseU = 1.0f;
- m_diffuseV = 1.0f;
- m_diffuseScaleU = 1.0f;
- m_diffuseScaleV = 1.0f;
-
- m_currentFrame = 0;
- m_frameCounter = (unsigned int) -1;
- m_currentLoop = 0;
-
- m_isAllocated = NO;
- m_invalid = true;
-}
-
-CGUITextureBase::~CGUITextureBase(void)
-{
-}
-
-void CGUITextureBase::AllocateOnDemand()
-{
- if (m_visible)
- { // visible, so make sure we're allocated
- if (!IsAllocated() || (m_isAllocated == LARGE && !m_texture.size()))
- AllocResources();
- }
- else
- { // hidden, so deallocate as applicable
- if (m_allocateDynamically && IsAllocated())
- FreeResources();
- // reset animated textures (animgifs)
- m_currentLoop = 0;
- m_currentFrame = 0;
- m_frameCounter = 0;
- }
-}
-
-void CGUITextureBase::Render()
-{
- // check if we need to allocate our resources
- AllocateOnDemand();
-
- if (!m_visible || !m_texture.size())
- return;
-
- if (m_texture.size() > 1)
- UpdateAnimFrame();
-
- if (m_invalid)
- CalculateSize();
-
- // see if we need to clip the image
- if (m_vertex.Width() > m_width || m_vertex.Height() > m_height)
- {
- if (!g_graphicsContext.SetClipRegion(m_posX, m_posY, m_width, m_height))
- return;
- }
-
- // set our draw color
- #define MIX_ALPHA(a,c) (((a * (c >> 24)) / 255) << 24) | (c & 0x00ffffff)
- color_t color = m_diffuseColor;
- if (m_alpha != 0xFF) color = MIX_ALPHA(m_alpha, m_diffuseColor);
- color = g_graphicsContext.MergeAlpha(color);
-
- // setup our renderer
- Begin(color);
-
- // compute the texture coordinates
- float u1, u2, u3, v1, v2, v3;
- u1 = m_info.border.x1;
- u2 = m_frameWidth - m_info.border.x2;
- u3 = m_frameWidth;
- v1 = m_info.border.y1;
- v2 = m_frameHeight - m_info.border.y2;
- v3 = m_frameHeight;
-
- if (!m_texture.m_texCoordsArePixels)
- {
- u1 *= m_texCoordsScaleU;
- u2 *= m_texCoordsScaleU;
- u3 *= m_texCoordsScaleU;
- v1 *= m_texCoordsScaleV;
- v2 *= m_texCoordsScaleV;
- v3 *= m_texCoordsScaleV;
- }
-
- // TODO: The diffuse coloring applies to all vertices, which will
- // look weird for stuff with borders, as will the -ve height/width
- // for flipping
-
- // left segment (0,0,u1,v3)
- if (m_info.border.x1)
- {
- if (m_info.border.y1)
- Render(m_vertex.x1, m_vertex.y1, m_vertex.x1 + m_info.border.x1, m_vertex.y1 + m_info.border.y1, 0, 0, u1, v1, u3, v3);
- Render(m_vertex.x1, m_vertex.y1 + m_info.border.y1, m_vertex.x1 + m_info.border.x1, m_vertex.y2 - m_info.border.y2, 0, v1, u1, v2, u3, v3);
- if (m_info.border.y2)
- Render(m_vertex.x1, m_vertex.y2 - m_info.border.y2, m_vertex.x1 + m_info.border.x1, m_vertex.y2, 0, v2, u1, v3, u3, v3);
- }
- // middle segment (u1,0,u2,v3)
- if (m_info.border.y1)
- Render(m_vertex.x1 + m_info.border.x1, m_vertex.y1, m_vertex.x2 - m_info.border.x2, m_vertex.y1 + m_info.border.y1, u1, 0, u2, v1, u3, v3);
- Render(m_vertex.x1 + m_info.border.x1, m_vertex.y1 + m_info.border.y1, m_vertex.x2 - m_info.border.x2, m_vertex.y2 - m_info.border.y2, u1, v1, u2, v2, u3, v3);
- if (m_info.border.y2)
- Render(m_vertex.x1 + m_info.border.x1, m_vertex.y2 - m_info.border.y2, m_vertex.x2 - m_info.border.x2, m_vertex.y2, u1, v2, u2, v3, u3, v3);
- // right segment
- if (m_info.border.x2)
- { // have a left border
- if (m_info.border.y1)
- Render(m_vertex.x2 - m_info.border.x2, m_vertex.y1, m_vertex.x2, m_vertex.y1 + m_info.border.y1, u2, 0, u3, v1, u3, v3);
- Render(m_vertex.x2 - m_info.border.x2, m_vertex.y1 + m_info.border.y1, m_vertex.x2, m_vertex.y2 - m_info.border.y2, u2, v1, u3, v2, u3, v3);
- if (m_info.border.y2)
- Render(m_vertex.x2 - m_info.border.x2, m_vertex.y2 - m_info.border.y2, m_vertex.x2, m_vertex.y2, u2, v2, u3, v3, u3, v3);
- }
-
- // close off our renderer
- End();
-
- if (m_vertex.Width() > m_width || m_vertex.Height() > m_height)
- g_graphicsContext.RestoreClipRegion();
-}
-
-void CGUITextureBase::Render(float left, float top, float right, float bottom, float u1, float v1, float u2, float v2, float u3, float v3)
-{
- CRect diffuse(u1, v1, u2, v2);
- CRect texture(u1, v1, u2, v2);
- CRect vertex(left, top, right, bottom);
- g_graphicsContext.ClipRect(vertex, texture, m_diffuse.size() ? &diffuse : NULL);
-
- if (vertex.IsEmpty())
- return; // nothing to render
-
- int orientation = GetOrientation();
- OrientateTexture(texture, u3, v3, orientation);
-
- if (m_diffuse.size())
- {
- // flip the texture as necessary. Diffuse just gets flipped according to m_info.orientation.
- // Main texture gets flipped according to GetOrientation().
- diffuse.x1 *= m_diffuseScaleU / u3; diffuse.x2 *= m_diffuseScaleU / u3;
- diffuse.y1 *= m_diffuseScaleV / v3; diffuse.y2 *= m_diffuseScaleV / v3;
- diffuse += m_diffuseOffset;
- OrientateTexture(diffuse, m_diffuseU, m_diffuseV, m_info.orientation);
- }
-
- float x[4], y[4], z[4];
-
-#define ROUND_TO_PIXEL(x) (float)(MathUtils::round_int(x))
-
- x[0] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalXCoord(vertex.x1, vertex.y1));
- y[0] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalYCoord(vertex.x1, vertex.y1));
- z[0] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalZCoord(vertex.x1, vertex.y1));
- x[1] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalXCoord(vertex.x2, vertex.y1));
- y[1] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalYCoord(vertex.x2, vertex.y1));
- z[1] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalZCoord(vertex.x2, vertex.y1));
- x[2] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalXCoord(vertex.x2, vertex.y2));
- y[2] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalYCoord(vertex.x2, vertex.y2));
- z[2] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalZCoord(vertex.x2, vertex.y2));
- x[3] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalXCoord(vertex.x1, vertex.y2));
- y[3] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalYCoord(vertex.x1, vertex.y2));
- z[3] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalZCoord(vertex.x1, vertex.y2));
-
- if (y[2] == y[0]) y[2] += 1.0f; if (x[2] == x[0]) x[2] += 1.0f;
- if (y[3] == y[1]) y[3] += 1.0f; if (x[3] == x[1]) x[3] += 1.0f;
-
- Draw(x, y, z, texture, diffuse, orientation);
-}
-
-void CGUITextureBase::AllocResources()
-{
- if (m_info.filename.IsEmpty())
- return;
-
- if (m_texture.size())
- return; // already have our texture
-
- // reset our animstate
- m_frameCounter = 0;
- m_currentFrame = 0;
- m_currentLoop = 0;
-
- bool useLarge = m_info.useLarge || !g_TextureManager.CanLoad(m_info.filename);
- if (useLarge)
- { // we want to use the large image loader, but we first check for bundled textures
- if (!IsAllocated())
- {
- int images = g_TextureManager.Load(m_info.filename, true);
- if (images)
- {
- m_isAllocated = NORMAL;
- m_texture = g_TextureManager.GetTexture(m_info.filename);
- }
- }
- if (m_isAllocated != NORMAL)
- { // use our large image background loader
- CTextureArray texture;
- if (g_largeTextureManager.GetImage(m_info.filename, texture, !IsAllocated()))
- {
- m_isAllocated = LARGE;
-
- if (!texture.size()) // not ready as yet
- return;
-
- m_texture = texture;
- }
- else
- m_isAllocated = LARGE_FAILED;
- }
- }
- else if (!IsAllocated())
- {
- int images = g_TextureManager.Load(m_info.filename);
-
- // set allocated to true even if we couldn't load the image to save
- // us hitting the disk every frame
- m_isAllocated = images ? NORMAL : NORMAL_FAILED;
- if (!images)
- return;
-
- m_texture = g_TextureManager.GetTexture(m_info.filename);
- }
- m_frameWidth = (float)m_texture.m_width;
- m_frameHeight = (float)m_texture.m_height;
-
- // load the diffuse texture (if necessary)
- if (!m_info.diffuse.IsEmpty())
- {
- g_TextureManager.Load(m_info.diffuse);
- m_diffuse = g_TextureManager.GetTexture(m_info.diffuse);
- }
-
- CalculateSize();
-
- // call our implementation
- Allocate();
-}
-
-void CGUITextureBase::CalculateSize()
-{
- if (m_currentFrame >= m_texture.size())
- return;
-
- m_texCoordsScaleU = 1.0f / m_texture.m_texWidth;
- m_texCoordsScaleV = 1.0f / m_texture.m_texHeight;
-
- if (m_width == 0)
- m_width = m_frameWidth;
- if (m_height == 0)
- m_height = m_frameHeight;
-
- float newPosX = m_posX;
- float newPosY = m_posY;
- float newWidth = m_width;
- float newHeight = m_height;
-
- if (m_aspect.ratio != CAspectRatio::AR_STRETCH && m_frameWidth && m_frameHeight)
- {
- // to get the pixel ratio, we must use the SCALED output sizes
- float pixelRatio = g_graphicsContext.GetScalingPixelRatio();
-
- float fSourceFrameRatio = m_frameWidth / m_frameHeight;
- if (GetOrientation() & 4)
- fSourceFrameRatio = m_frameHeight / m_frameWidth;
- float fOutputFrameRatio = fSourceFrameRatio / pixelRatio;
-
- // maximize the width
- newHeight = m_width / fOutputFrameRatio;
-
- if ((m_aspect.ratio == CAspectRatio::AR_SCALE && newHeight < m_height) ||
- (m_aspect.ratio == CAspectRatio::AR_KEEP && newHeight > m_height))
- {
- newHeight = m_height;
- newWidth = newHeight * fOutputFrameRatio;
- }
- if (m_aspect.ratio == CAspectRatio::AR_CENTER)
- { // keep original size + center
- newWidth = m_frameWidth;
- newHeight = m_frameHeight;
- }
-
- if (m_aspect.align & ASPECT_ALIGN_LEFT)
- newPosX = m_posX;
- else if (m_aspect.align & ASPECT_ALIGN_RIGHT)
- newPosX = m_posX + m_width - newWidth;
- else
- newPosX = m_posX + (m_width - newWidth) * 0.5f;
- if (m_aspect.align & ASPECT_ALIGNY_TOP)
- newPosY = m_posY;
- else if (m_aspect.align & ASPECT_ALIGNY_BOTTOM)
- newPosY = m_posY + m_height - newHeight;
- else
- newPosY = m_posY + (m_height - newHeight) * 0.5f;
- }
- m_vertex.SetRect(newPosX, newPosY, newPosX + newWidth, newPosY + newHeight);
-
- // scale the diffuse coords as well
- if (m_diffuse.size())
- { // calculate scaling for the texcoords
- if (m_diffuse.m_texCoordsArePixels)
- {
- m_diffuseU = float(m_diffuse.m_width);
- m_diffuseV = float(m_diffuse.m_height);
- }
- else
- {
- m_diffuseU = float(m_diffuse.m_width) / float(m_diffuse.m_texWidth);
- m_diffuseV = float(m_diffuse.m_height) / float(m_diffuse.m_texHeight);
- }
-
- if (m_aspect.scaleDiffuse)
- {
- m_diffuseScaleU = m_diffuseU;
- m_diffuseScaleV = m_diffuseV;
- m_diffuseOffset = CPoint(0,0);
- }
- else // stretch'ing diffuse
- { // scale diffuse up or down to match output rect size, rather than image size
- //(m_fX, mfY) -> (m_fX + m_fNW, m_fY + m_fNH)
- //(0,0) -> (m_fU*m_diffuseScaleU, m_fV*m_diffuseScaleV)
- // x = u/(m_fU*m_diffuseScaleU)*m_fNW + m_fX
- // -> u = (m_posX - m_fX) * m_fU * m_diffuseScaleU / m_fNW
- m_diffuseScaleU = m_diffuseU * m_vertex.Width() / m_width;
- m_diffuseScaleV = m_diffuseV * m_vertex.Height() / m_height;
- m_diffuseOffset = CPoint((m_vertex.x1 - m_posX) / m_vertex.Width() * m_diffuseScaleU, (m_vertex.y1 - m_posY) / m_vertex.Height() * m_diffuseScaleV);
- }
- }
- m_invalid = false;
-}
-
-void CGUITextureBase::FreeResources(bool immediately /* = false */)
-{
- if (m_isAllocated == LARGE || m_isAllocated == LARGE_FAILED)
- g_largeTextureManager.ReleaseImage(m_info.filename, immediately || (m_isAllocated == LARGE_FAILED));
- else if (m_isAllocated == NORMAL && m_texture.size())
- g_TextureManager.ReleaseTexture(m_info.filename);
-
- if (m_diffuse.size())
- g_TextureManager.ReleaseTexture(m_info.diffuse);
- m_diffuse.Reset();
-
- m_texture.Reset();
-
- m_currentFrame = 0;
- m_currentLoop = 0;
- m_texCoordsScaleU = 1.0f;
- m_texCoordsScaleV = 1.0f;
-
- // call our implementation
- Free();
-
- m_isAllocated = NO;
-}
-
-void CGUITextureBase::DynamicResourceAlloc(bool allocateDynamically)
-{
- m_allocateDynamically = allocateDynamically;
-}
-
-void CGUITextureBase::SetInvalid()
-{
- m_invalid = true;
-}
-
-void CGUITextureBase::UpdateAnimFrame()
-{
- m_frameCounter++;
- unsigned int delay = m_texture.m_delays[m_currentFrame];
- if (!delay) delay = 100;
- if (m_frameCounter * 40 >= delay)
- {
- m_frameCounter = 0;
- if (m_currentFrame + 1 >= m_texture.size())
- {
- if (m_texture.m_loops > 0)
- {
- if (m_currentLoop + 1 < m_texture.m_loops)
- {
- m_currentLoop++;
- m_currentFrame = 0;
- }
- }
- else
- {
- // 0 == loop forever
- m_currentFrame = 0;
- }
- }
- else
- {
- m_currentFrame++;
- }
- }
-}
-
-void CGUITextureBase::SetVisible(bool visible)
-{
- m_visible = visible;
-}
-
-void CGUITextureBase::SetAlpha(unsigned char alpha)
-{
- m_alpha = alpha;
-}
-
-void CGUITextureBase::SetDiffuseColor(color_t color)
-{
- m_diffuseColor = color;
-}
-
-bool CGUITextureBase::ReadyToRender() const
-{
- return m_texture.size() > 0;
-}
-
-void CGUITextureBase::OrientateTexture(CRect &rect, float width, float height, int orientation)
-{
- switch (orientation & 3)
- {
- case 0:
- // default
- break;
- case 1:
- // flip in X direction
- rect.x1 = width - rect.x1;
- rect.x2 = width - rect.x2;
- break;
- case 2:
- // rotate 180 degrees
- rect.x1 = width - rect.x1;
- rect.x2 = width - rect.x2;
- rect.y1 = height - rect.y1;
- rect.y2 = height - rect.y2;
- break;
- case 3:
- // flip in Y direction
- rect.y1 = height - rect.y1;
- rect.y2 = height - rect.y2;
- break;
- }
- if (orientation & 4)
- {
- // we need to swap x and y coordinates but only within the width,height block
- float temp = rect.x1;
- rect.x1 = rect.y1 * width/height;
- rect.y1 = temp * height/width;
- temp = rect.x2;
- rect.x2 = rect.y2 * width/height;
- rect.y2 = temp * height/width;
- }
-}
-
-void CGUITextureBase::SetWidth(float width)
-{
- if (width < m_info.border.x1 + m_info.border.x2)
- width = m_info.border.x1 + m_info.border.x2;
- if (m_width != width)
- {
- m_width = width;
- m_invalid = true;
- }
-}
-
-void CGUITextureBase::SetHeight(float height)
-{
- if (height < m_info.border.y1 + m_info.border.y2)
- height = m_info.border.y1 + m_info.border.y2;
- if (m_height != height)
- {
- m_height = height;
- m_invalid = true;
- }
-}
-
-void CGUITextureBase::SetPosition(float posX, float posY)
-{
- if (m_posX != posX || m_posY != posY)
- {
- m_posX = posX;
- m_posY = posY;
- m_invalid = true;
- }
-}
-
-void CGUITextureBase::SetAspectRatio(const CAspectRatio &aspect)
-{
- if (m_aspect != aspect)
- {
- m_aspect = aspect;
- m_invalid = true;
- }
-}
-
-void CGUITextureBase::SetFileName(const CStdString& filename)
-{
- if (m_info.filename.Equals(filename)) return;
- // Don't completely free resources here - we may be just changing
- // filenames mid-animation
- FreeResources();
- m_info.filename = filename;
- // Don't allocate resources here as this is done at render time
-}
-
-int CGUITextureBase::GetOrientation() const
-{
- if (m_isAllocated == LARGE)
- return m_info.orientation;
- // otherwise multiply our orientations
- static char orient_table[] = { 0, 1, 2, 3, 4, 5, 6, 7,
- 1, 0, 3, 2, 5, 4, 7, 6,
- 2, 3, 0, 1, 6, 7, 4, 5,
- 3, 2, 1, 0, 7, 6, 5, 4,
- 4, 7, 6, 5, 0, 3, 2, 1,
- 5, 6, 7, 4, 1, 2, 3, 0,
- 6, 5, 4, 7, 2, 1, 0, 3,
- 7, 4, 5, 6, 3, 0, 1, 2 };
- return (int)orient_table[8 * m_info.orientation + m_texture.m_orientation];
-}
diff --git a/guilib/GUITexture.h b/guilib/GUITexture.h
deleted file mode 100644
index 75f53fffa1..0000000000
--- a/guilib/GUITexture.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/*!
-\file GUITexture.h
-\brief
-*/
-
-#ifndef GUILIB_GUITEXTURE_H
-#define GUILIB_GUITEXTURE_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "TextureManager.h"
-#include "Geometry.h"
-#include "system.h" // HAS_GL, HAS_DX, etc
-
-typedef uint32_t color_t;
-
-// image alignment for <aspect>keep</aspect>, <aspect>scale</aspect> or <aspect>center</aspect>
-#define ASPECT_ALIGN_CENTER 0
-#define ASPECT_ALIGN_LEFT 1
-#define ASPECT_ALIGN_RIGHT 2
-#define ASPECT_ALIGNY_CENTER 0
-#define ASPECT_ALIGNY_TOP 4
-#define ASPECT_ALIGNY_BOTTOM 8
-#define ASPECT_ALIGN_MASK 3
-#define ASPECT_ALIGNY_MASK ~3
-
-class CAspectRatio
-{
-public:
- enum ASPECT_RATIO { AR_STRETCH = 0, AR_SCALE, AR_KEEP, AR_CENTER };
- CAspectRatio(ASPECT_RATIO aspect = AR_STRETCH)
- {
- ratio = aspect;
- align = ASPECT_ALIGN_CENTER | ASPECT_ALIGNY_CENTER;
- scaleDiffuse = true;
- };
- bool operator!=(const CAspectRatio &right) const
- {
- if (ratio != right.ratio) return true;
- if (align != right.align) return true;
- if (scaleDiffuse != right.scaleDiffuse) return true;
- return false;
- };
-
- ASPECT_RATIO ratio;
- uint32_t align;
- bool scaleDiffuse;
-};
-
-class CTextureInfo
-{
-public:
- CTextureInfo();
- CTextureInfo(const CStdString &file);
- CTextureInfo& operator=(const CTextureInfo &right);
- bool useLarge;
- CRect border; // scaled - unneeded if we get rid of scale on load
- int orientation; // orientation of the texture (0 - 7 == EXIForientation - 1)
- CStdString diffuse; // diffuse overlay texture
- CStdString filename; // main texture file
-};
-
-class CGUITextureBase
-{
-public:
- CGUITextureBase(float posX, float posY, float width, float height, const CTextureInfo& texture);
- CGUITextureBase(const CGUITextureBase &left);
- virtual ~CGUITextureBase(void);
-
- void Render();
-
- void DynamicResourceAlloc(bool bOnOff);
- void AllocResources();
- void FreeResources(bool immediately = false);
- void SetInvalid();
-
- void SetVisible(bool visible);
- void SetAlpha(unsigned char alpha);
- void SetDiffuseColor(color_t color);
- void SetPosition(float x, float y);
- void SetWidth(float width);
- void SetHeight(float height);
- void SetFileName(const CStdString &filename);
- void SetAspectRatio(const CAspectRatio &aspect);
-
- const CStdString& GetFileName() const { return m_info.filename; };
- float GetTextureWidth() const { return m_frameWidth; };
- float GetTextureHeight() const { return m_frameHeight; };
- float GetWidth() const { return m_width; };
- float GetHeight() const { return m_height; };
- float GetXPosition() const { return m_posX; };
- float GetYPosition() const { return m_posY; };
- int GetOrientation() const;
- const CRect &GetRenderRect() const { return m_vertex; };
- bool IsLazyLoaded() const { return m_info.useLarge; };
-
- bool HitTest(const CPoint &point) const { return CRect(m_posX, m_posY, m_posX + m_width, m_posY + m_height).PtInRect(point); };
- bool IsAllocated() const { return m_isAllocated != NO; };
- bool FailedToAlloc() const { return m_isAllocated == NORMAL_FAILED || m_isAllocated == LARGE_FAILED; };
- bool ReadyToRender() const;
-protected:
- void CalculateSize();
- void LoadDiffuseImage();
- void AllocateOnDemand();
- void UpdateAnimFrame();
- void Render(float left, float top, float bottom, float right, float u1, float v1, float u2, float v2, float u3, float v3);
- void OrientateTexture(CRect &rect, float width, float height, int orientation);
-
- // functions that our implementation classes handle
- virtual void Allocate() {}; ///< called after our textures have been allocated
- virtual void Free() {}; ///< called after our textures have been freed
- virtual void Begin(color_t color) {};
- virtual void Draw(float *x, float *y, float *z, const CRect &texture, const CRect &diffuse, int orientation)=0;
- virtual void End() {};
-
- bool m_visible;
- color_t m_diffuseColor;
-
- float m_posX; // size of the frame
- float m_posY;
- float m_width;
- float m_height;
-
- CRect m_vertex; // vertex coords to render
- bool m_invalid; // if true, we need to recalculate
-
- unsigned char m_alpha;
-
- float m_frameWidth, m_frameHeight; // size in pixels of the actual frame within the texture
- float m_texCoordsScaleU, m_texCoordsScaleV; // scale factor for pixel->texture coordinates
-
- // animations
- int m_currentLoop;
- unsigned int m_currentFrame;
- uint32_t m_frameCounter;
-
- float m_diffuseU, m_diffuseV; // size of the diffuse frame (in tex coords)
- float m_diffuseScaleU, m_diffuseScaleV; // scale factor of the diffuse frame (from texture coords to diffuse tex coords)
- CPoint m_diffuseOffset; // offset into the diffuse frame (it's not always the origin)
-
- bool m_allocateDynamically;
- enum ALLOCATE_TYPE { NO = 0, NORMAL, LARGE, NORMAL_FAILED, LARGE_FAILED };
- ALLOCATE_TYPE m_isAllocated;
-
- CTextureInfo m_info;
- CAspectRatio m_aspect;
-
- CTextureArray m_diffuse;
- CTextureArray m_texture;
-};
-
-
-#if defined(HAS_GL)
-#include "GUITextureGL.h"
-#define CGUITexture CGUITextureGL
-#elif defined(HAS_GLES)
-#include "GUITextureGLES.h"
-#define CGUITexture CGUITextureGLES
-#elif defined(HAS_DX)
-#include "GUITextureD3D.h"
-#define CGUITexture CGUITextureD3D
-#endif
-
-#endif
diff --git a/guilib/GUITextureD3D.cpp b/guilib/GUITextureD3D.cpp
deleted file mode 100644
index c052591032..0000000000
--- a/guilib/GUITextureD3D.cpp
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "Texture.h"
-#include "GUITextureD3D.h"
-#include "WindowingFactory.h"
-
-#ifdef HAS_DX
-
-CGUITextureD3D::CGUITextureD3D(float posX, float posY, float width, float height, const CTextureInfo &texture)
-: CGUITextureBase(posX, posY, width, height, texture)
-{
-}
-
-void CGUITextureD3D::Begin(color_t color)
-{
- CBaseTexture* texture = m_texture.m_textures[m_currentFrame];
- LPDIRECT3DDEVICE9 p3DDevice = g_Windowing.Get3DDevice();
-
- texture->LoadToGPU();
- if (m_diffuse.size())
- m_diffuse.m_textures[0]->LoadToGPU();
- // Set state to render the image
- p3DDevice->SetTexture( 0, texture->GetTextureObject() );
- p3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
- p3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
- p3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
- p3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
- p3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
- p3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
- p3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
- p3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
- p3DDevice->SetSamplerState( 0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP );
- p3DDevice->SetSamplerState( 0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP );
- if (m_diffuse.size())
- {
- p3DDevice->SetTexture( 1, m_diffuse.m_textures[0]->GetTextureObject() );
- p3DDevice->SetSamplerState( 1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
- p3DDevice->SetSamplerState( 1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
- p3DDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
- p3DDevice->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT );
- p3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_MODULATE );
- p3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
- p3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAARG2, D3DTA_CURRENT );
- p3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
- p3DDevice->SetSamplerState( 1, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP );
- p3DDevice->SetSamplerState( 1, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP );
- p3DDevice->SetTextureStageState( 2, D3DTSS_COLOROP, D3DTOP_DISABLE);
- p3DDevice->SetTextureStageState( 2, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
- }
- else
- {
- p3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE);
- p3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
- }
- p3DDevice->SetRenderState( D3DRS_ALPHATESTENABLE, TRUE );
- p3DDevice->SetRenderState( D3DRS_ALPHAREF, 0 );
- p3DDevice->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL );
- p3DDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
- p3DDevice->SetRenderState( D3DRS_FOGENABLE, FALSE );
- p3DDevice->SetRenderState( D3DRS_FOGTABLEMODE, D3DFOG_NONE );
- p3DDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
- p3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
- p3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
- p3DDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
- p3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
- p3DDevice->SetRenderState( D3DRS_LIGHTING, FALSE);
-
- p3DDevice->SetFVF( D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX2 );
- m_col = color;
-}
-
-void CGUITextureD3D::End()
-{
- // unset the texture and palette or the texture caching crashes because the runtime still has a reference
- g_Windowing.Get3DDevice()->SetTexture( 0, NULL );
- if (m_diffuse.size())
- g_Windowing.Get3DDevice()->SetTexture( 1, NULL );
-}
-
-void CGUITextureD3D::Draw(float *x, float *y, float *z, const CRect &texture, const CRect &diffuse, int orientation)
-{
- struct CUSTOMVERTEX {
- FLOAT x, y, z;
- DWORD color;
- FLOAT tu, tv; // Texture coordinates
- FLOAT tu2, tv2;
- };
-
- // D3D aligns to half pixel boundaries
- for (int i = 0; i < 4; i++)
- {
- x[i] -= 0.5f;
- y[i] -= 0.5f;
- };
-
- CUSTOMVERTEX verts[4];
- verts[0].x = x[0]; verts[0].y = y[0]; verts[0].z = z[0];
- verts[0].tu = texture.x1; verts[0].tv = texture.y1;
- verts[0].tu2 = diffuse.x1; verts[0].tv2 = diffuse.y1;
- verts[0].color = m_col;
-
- verts[1].x = x[1]; verts[1].y = y[1]; verts[1].z = z[1];
- if (orientation & 4)
- {
- verts[1].tu = texture.x1;
- verts[1].tv = texture.y2;
- }
- else
- {
- verts[1].tu = texture.x2;
- verts[1].tv = texture.y1;
- }
- if (m_info.orientation & 4)
- {
- verts[1].tu2 = diffuse.x1;
- verts[1].tv2 = diffuse.y2;
- }
- else
- {
- verts[1].tu2 = diffuse.x2;
- verts[1].tv2 = diffuse.y1;
- }
- verts[1].color = m_col;
-
- verts[2].x = x[2]; verts[2].y = y[2]; verts[2].z = z[2];
- verts[2].tu = texture.x2; verts[2].tv = texture.y2;
- verts[2].tu2 = diffuse.x2; verts[2].tv2 = diffuse.y2;
- verts[2].color = m_col;
-
- verts[3].x = x[3]; verts[3].y = y[3]; verts[3].z = z[3];
- if (orientation & 4)
- {
- verts[3].tu = texture.x2;
- verts[3].tv = texture.y1;
- }
- else
- {
- verts[3].tu = texture.x1;
- verts[3].tv = texture.y2;
- }
- if (m_info.orientation & 4)
- {
- verts[3].tu2 = diffuse.x2;
- verts[3].tv2 = diffuse.y1;
- }
- else
- {
- verts[3].tu2 = diffuse.x1;
- verts[3].tv2 = diffuse.y2;
- }
- verts[3].color = m_col;
-
- g_Windowing.Get3DDevice()->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts, sizeof(CUSTOMVERTEX));
-}
-
-void CGUITextureD3D::DrawQuad(const CRect &rect, color_t color, CBaseTexture *texture, const CRect *texCoords)
-{
- struct CUSTOMVERTEX {
- FLOAT x, y, z;
- DWORD color;
- FLOAT tu, tv; // Texture coordinates
- FLOAT tu2, tv2;
- };
-
- LPDIRECT3DDEVICE9 p3DDevice = g_Windowing.Get3DDevice();
-
- if (texture)
- {
- texture->LoadToGPU();
- // Set state to render the image
- p3DDevice->SetTexture( 0, texture->GetTextureObject() );
- p3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
- p3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
- p3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
- p3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
- p3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
- p3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
- p3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
- p3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
- p3DDevice->SetSamplerState( 0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP );
- p3DDevice->SetSamplerState( 0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP );
- p3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE);
- p3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
- }
-
- p3DDevice->SetRenderState( D3DRS_ALPHATESTENABLE, TRUE );
- p3DDevice->SetRenderState( D3DRS_ALPHAREF, 0 );
- p3DDevice->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL );
- p3DDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
- p3DDevice->SetRenderState( D3DRS_FOGENABLE, FALSE );
- p3DDevice->SetRenderState( D3DRS_FOGTABLEMODE, D3DFOG_NONE );
- p3DDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
- p3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
- p3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
- p3DDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
- p3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
- p3DDevice->SetRenderState( D3DRS_LIGHTING, FALSE);
-
- p3DDevice->SetFVF( D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX2 );
-
- CRect coords = texCoords ? *texCoords : CRect(0.0f, 0.0f, 1.0f, 1.0f);
- CUSTOMVERTEX verts[4] = {
- { rect.x1 - 0.5f, rect.y1 - 0.5f, 0, color, coords.x1, coords.y1, 0, 0 },
- { rect.x2 - 0.5f, rect.y1 - 0.5f, 0, color, coords.x2, coords.y1, 0, 0 },
- { rect.x2 - 0.5f, rect.y2 - 0.5f, 0, color, coords.x2, coords.y2, 0, 0 },
- { rect.x1 - 0.5f, rect.y2 - 0.5f, 0, color, coords.x1, coords.y2, 0, 0 },
- };
- p3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts, sizeof(CUSTOMVERTEX));
-
- p3DDevice->SetTexture( 0, NULL );
-}
-
-#endif \ No newline at end of file
diff --git a/guilib/GUITextureD3D.h b/guilib/GUITextureD3D.h
deleted file mode 100644
index 9681fe37f9..0000000000
--- a/guilib/GUITextureD3D.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*!
-\file GUITextureD3D.h
-\brief
-*/
-
-#ifndef GUILIB_GUITEXTURED3D_H
-#define GUILIB_GUITEXTURED3D_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUITexture.h"
-
-#ifdef HAS_DX
-
-class CGUITextureD3D : public CGUITextureBase
-{
-public:
- CGUITextureD3D(float posX, float posY, float width, float height, const CTextureInfo& texture);
- static void DrawQuad(const CRect &coords, color_t color, CBaseTexture *texture = NULL, const CRect *texCoords = NULL);
-protected:
- void Begin(color_t color);
- void Draw(float *x, float *y, float *z, const CRect &texture, const CRect &diffuse, int orientation);
- void End();
-private:
- color_t m_col;
-};
-
-#endif
-
-#endif \ No newline at end of file
diff --git a/guilib/GUITextureGL.cpp b/guilib/GUITextureGL.cpp
deleted file mode 100644
index 570183a38c..0000000000
--- a/guilib/GUITextureGL.cpp
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "system.h"
-#if defined(HAS_GL)
-#include "GUITextureGL.h"
-#endif
-#include "Texture.h"
-#include "utils/log.h"
-
-#if defined(HAS_GL)
-
-CGUITextureGL::CGUITextureGL(float posX, float posY, float width, float height, const CTextureInfo &texture)
-: CGUITextureBase(posX, posY, width, height, texture)
-{
-}
-
-void CGUITextureGL::Begin(color_t color)
-{
- m_col[0] = (GLubyte)GET_R(color);
- m_col[1] = (GLubyte)GET_G(color);
- m_col[2] = (GLubyte)GET_B(color);
- m_col[3] = (GLubyte)GET_A(color);
-
- CBaseTexture* texture = m_texture.m_textures[m_currentFrame];
- glActiveTextureARB(GL_TEXTURE0_ARB);
- texture->LoadToGPU();
- if (m_diffuse.size())
- m_diffuse.m_textures[0]->LoadToGPU();
-
- glBindTexture(GL_TEXTURE_2D, texture->GetTextureObject());
- glEnable(GL_TEXTURE_2D);
-
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND); // Turn Blending On
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-
- // diffuse coloring
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
- glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
- VerifyGLState();
-
- if (m_diffuse.size())
- {
- glActiveTextureARB(GL_TEXTURE1_ARB);
- glBindTexture(GL_TEXTURE_2D, m_diffuse.m_textures[0]->GetTextureObject());
- glEnable(GL_TEXTURE_2D);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
- glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE1);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PREVIOUS);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
- VerifyGLState();
- }
- //glDisable(GL_TEXTURE_2D); // uncomment these 2 lines to switch to wireframe rendering
- //glBegin(GL_LINE_LOOP);
- glBegin(GL_QUADS);
-}
-
-void CGUITextureGL::End()
-{
- glEnd();
- if (m_diffuse.size())
- {
- glDisable(GL_TEXTURE_2D);
- glActiveTextureARB(GL_TEXTURE0_ARB);
- }
- glDisable(GL_TEXTURE_2D);
-}
-
-void CGUITextureGL::Draw(float *x, float *y, float *z, const CRect &texture, const CRect &diffuse, int orientation)
-{
- // Top-left vertex (corner)
- glColor4ub(m_col[0], m_col[1], m_col[2], m_col[3]);
- glMultiTexCoord2fARB(GL_TEXTURE0_ARB, texture.x1, texture.y1);
- if (m_diffuse.size())
- glMultiTexCoord2fARB(GL_TEXTURE1_ARB, diffuse.x1, diffuse.y1);
- glVertex3f(x[0], y[0], z[0]);
-
- // Top-right vertex (corner)
- glColor4ub(m_col[0], m_col[1], m_col[2], m_col[3]);
- if (orientation & 4)
- glMultiTexCoord2fARB(GL_TEXTURE0_ARB, texture.x1, texture.y2);
- else
- glMultiTexCoord2fARB(GL_TEXTURE0_ARB, texture.x2, texture.y1);
- if (m_diffuse.size())
- {
- if (m_info.orientation & 4)
- glMultiTexCoord2fARB(GL_TEXTURE1_ARB, diffuse.x1, diffuse.y2);
- else
- glMultiTexCoord2fARB(GL_TEXTURE1_ARB, diffuse.x2, diffuse.y1);
- }
- glVertex3f(x[1], y[1], z[1]);
-
- // Bottom-right vertex (corner)
- glColor4ub(m_col[0], m_col[1], m_col[2], m_col[3]);
- glMultiTexCoord2fARB(GL_TEXTURE0_ARB, texture.x2, texture.y2);
- if (m_diffuse.size())
- glMultiTexCoord2fARB(GL_TEXTURE1_ARB, diffuse.x2, diffuse.y2);
- glVertex3f(x[2], y[2], z[2]);
-
- // Bottom-left vertex (corner)
- glColor4ub(m_col[0], m_col[1], m_col[2], m_col[3]);
- if (orientation & 4)
- glMultiTexCoord2fARB(GL_TEXTURE0_ARB, texture.x2, texture.y1);
- else
- glMultiTexCoord2fARB(GL_TEXTURE0_ARB, texture.x1, texture.y2);
- if (m_diffuse.size())
- {
- if (m_info.orientation & 4)
- glMultiTexCoord2fARB(GL_TEXTURE1_ARB, diffuse.x2, diffuse.y1);
- else
- glMultiTexCoord2fARB(GL_TEXTURE1_ARB, diffuse.x1, diffuse.y2);
- }
- glVertex3f(x[3], y[3], z[3]);
-}
-
-void CGUITextureGL::DrawQuad(const CRect &rect, color_t color, CBaseTexture *texture, const CRect *texCoords)
-{
- if (texture)
- {
- glActiveTextureARB(GL_TEXTURE0_ARB);
- texture->LoadToGPU();
- glBindTexture(GL_TEXTURE_2D, texture->GetTextureObject());
- glEnable(GL_TEXTURE_2D);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
- glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE1);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PREVIOUS);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
- }
- else
- glDisable(GL_TEXTURE_2D);
-
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND); // Turn Blending On
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-
- // diffuse coloring
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
- glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
- VerifyGLState();
-
- glBegin(GL_QUADS);
-
- glColor4ub((GLubyte)GET_R(color), (GLubyte)GET_G(color), (GLubyte)GET_B(color), (GLubyte)GET_A(color));
-
- CRect coords = texCoords ? *texCoords : CRect(0.0f, 0.0f, 1.0f, 1.0f);
- glTexCoord2f(coords.x1, coords.y1);
- glVertex3f(rect.x1, rect.y1, 0);
- glTexCoord2f(coords.x2, coords.y1);
- glVertex3f(rect.x2, rect.y1, 0);
- glTexCoord2f(coords.x2, coords.y2);
- glVertex3f(rect.x2, rect.y2, 0);
- glTexCoord2f(coords.x1, coords.y2);
- glVertex3f(rect.x1, rect.y2, 0);
-
- glEnd();
- if (texture)
- glDisable(GL_TEXTURE_2D);
-}
-
-#endif
diff --git a/guilib/GUITextureGL.h b/guilib/GUITextureGL.h
deleted file mode 100644
index be7ca24386..0000000000
--- a/guilib/GUITextureGL.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*!
-\file GUITextureGL.h
-\brief
-*/
-
-#ifndef GUILIB_GUITEXTUREGL_H
-#define GUILIB_GUITEXTUREGL_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUITexture.h"
-
-class CGUITextureGL : public CGUITextureBase
-{
-public:
- CGUITextureGL(float posX, float posY, float width, float height, const CTextureInfo& texture);
- static void DrawQuad(const CRect &coords, color_t color, CBaseTexture *texture = NULL, const CRect *texCoords = NULL);
-protected:
- void Begin(color_t color);
- void Draw(float *x, float *y, float *z, const CRect &texture, const CRect &diffuse, int orientation);
- void End();
-private:
- GLubyte m_col[4];
-};
-
-#endif
diff --git a/guilib/GUITextureGLES.cpp b/guilib/GUITextureGLES.cpp
deleted file mode 100644
index 8c4bbbef57..0000000000
--- a/guilib/GUITextureGLES.cpp
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "system.h"
-#if defined(HAS_GLES)
-#include "GUITextureGLES.h"
-#endif
-#include "Texture.h"
-#include "utils/log.h"
-#include "WindowingFactory.h"
-
-#if defined(HAS_GLES)
-
-CGUITextureGLES::CGUITextureGLES(float posX, float posY, float width, float height, const CTextureInfo &texture)
-: CGUITextureBase(posX, posY, width, height, texture)
-{
-}
-
-void CGUITextureGLES::Begin(color_t color)
-{
- CBaseTexture* texture = m_texture.m_textures[m_currentFrame];
- glActiveTexture(GL_TEXTURE0);
- texture->LoadToGPU();
- if (m_diffuse.size())
- m_diffuse.m_textures[0]->LoadToGPU();
-
- glBindTexture(GL_TEXTURE_2D, texture->GetTextureObject());
- glEnable(GL_TEXTURE_2D);
-
- if (m_diffuse.size())
- {
- glActiveTexture(GL_TEXTURE1);
- glBindTexture(GL_TEXTURE_2D, m_diffuse.m_textures[0]->GetTextureObject());
- glEnable(GL_TEXTURE_2D);
- }
- else
- {
- g_Windowing.EnableGUIShader(SM_TEXTURE);
- }
-
- GLint posLoc = g_Windowing.GUIShaderGetPos();
- GLint colLoc = g_Windowing.GUIShaderGetCol();
- GLint tex0Loc = g_Windowing.GUIShaderGetCoord0();
-
- glVertexAttribPointer(posLoc, 3, GL_FLOAT, 0, 0, m_vert);
- glVertexAttribPointer(colLoc, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, m_col);
- glVertexAttribPointer(tex0Loc, 2, GL_FLOAT, 0, 0, m_tex0);
-
- glEnableVertexAttribArray(posLoc);
- glEnableVertexAttribArray(colLoc);
- glEnableVertexAttribArray(tex0Loc);
-
- // Setup Colors
- for (int i = 0; i < 4; i++)
- {
- m_col[i][0] = (GLubyte)GET_R(color);
- m_col[i][1] = (GLubyte)GET_G(color);
- m_col[i][2] = (GLubyte)GET_B(color);
- m_col[i][3] = (GLubyte)GET_A(color);
- }
-
- if (m_diffuse.size())
- {
- GLint tex1Loc = g_Windowing.GUIShaderGetCoord1();
- glVertexAttribPointer(tex1Loc, 2, GL_FLOAT, 0, 0, m_tex1);
- glEnableVertexAttribArray(tex1Loc);
- glEnable( GL_BLEND );
- g_Windowing.EnableGUIShader(SM_MULTI);
- }
- else
- {
- CBaseTexture* textureObject = m_texture.m_textures[m_currentFrame];
- if (textureObject->HasAlpha() || m_col[0][3] < 255 )
- {
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND); // Turn Blending On
- g_Windowing.EnableGUIShader(SM_TEXTURE);
- }
- else
- {
- glDisable(GL_BLEND);
- g_Windowing.EnableGUIShader(SM_TEXTURE_NOBLEND);
- }
- }
-
-}
-
-void CGUITextureGLES::End()
-{
- if (m_diffuse.size())
- {
- glDisable(GL_TEXTURE_2D);
- glDisableVertexAttribArray(g_Windowing.GUIShaderGetCoord1());
- glActiveTexture(GL_TEXTURE0);
- }
-
- glDisable(GL_TEXTURE_2D);
- glDisableVertexAttribArray(g_Windowing.GUIShaderGetPos());
- glDisableVertexAttribArray(g_Windowing.GUIShaderGetCol());
- glDisableVertexAttribArray(g_Windowing.GUIShaderGetCoord0());
-
- glEnable(GL_BLEND);
- g_Windowing.DisableGUIShader();
-}
-
-void CGUITextureGLES::Draw(float *x, float *y, float *z, const CRect &texture, const CRect &diffuse, int orientation)
-{
- GLubyte idx[4] = {0, 1, 3, 2}; //determines order of triangle strip
-
- // Setup vertex position values
- for (int i=0; i<4; i++)
- {
- m_vert[i][0] = x[i];
- m_vert[i][1] = y[i];
- m_vert[i][2] = z[i];
- }
-
- // Setup texture coordinates
- //TopLeft
- m_tex0[0][0] = texture.x1;
- m_tex0[0][1] = texture.y1;
- //TopRight
- if (orientation & 4)
- {
- m_tex0[1][0] = texture.x1;
- m_tex0[1][1] = texture.y2;
- }
- else
- {
- m_tex0[1][0] = texture.x2;
- m_tex0[1][1] = texture.y1;
- }
- //BottomRight
- m_tex0[2][0] = texture.x2;
- m_tex0[2][1] = texture.y2;
- //BottomLeft
- if (orientation & 4)
- {
- m_tex0[3][0] = texture.x2;
- m_tex0[3][1] = texture.y1;
- }
- else
- {
- m_tex0[3][0] = texture.x1;
- m_tex0[3][1] = texture.y2;
- }
-
- if (m_diffuse.size())
- {
- //TopLeft
- m_tex1[0][0] = diffuse.x1;
- m_tex1[0][1] = diffuse.y1;
- //TopRight
- if (m_info.orientation & 4)
- {
- m_tex1[1][0] = diffuse.x1;
- m_tex1[1][1] = diffuse.y2;
- }
- else
- {
- m_tex1[1][0] = diffuse.x2;
- m_tex1[1][1] = diffuse.y1;
- }
- //BottomRight
- m_tex1[2][0] = diffuse.x2;
- m_tex1[2][1] = diffuse.y2;
- //BottomLeft
- if (m_info.orientation & 4)
- {
- m_tex1[3][0] = diffuse.x2;
- m_tex1[3][1] = diffuse.y1;
- }
- else
- {
- m_tex1[3][0] = diffuse.x1;
- m_tex1[3][1] = diffuse.y2;
- }
- }
-
- glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, idx);
-}
-
-void CGUITextureGLES::DrawQuad(const CRect &rect, color_t color, CBaseTexture *texture, const CRect *texCoords)
-{
- if (texture)
- {
- glActiveTexture(GL_TEXTURE0);
- texture->LoadToGPU();
- glBindTexture(GL_TEXTURE_2D, texture->GetTextureObject());
- glEnable(GL_TEXTURE_2D);
- }
- else
- glDisable(GL_TEXTURE_2D);
-
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND); // Turn Blending On
-
- VerifyGLState();
-
- GLfloat col[4][4];
- GLfloat ver[4][3];
- GLfloat tex[4][2];
- GLubyte idx[4] = {0, 1, 3, 2}; //determines order of triangle strip
-
- g_Windowing.EnableGUIShader(SM_TEXTURE);
-
- GLint posLoc = g_Windowing.GUIShaderGetPos();
- GLint colLoc = g_Windowing.GUIShaderGetCol();
- GLint tex0Loc = g_Windowing.GUIShaderGetCoord0();
-
- glVertexAttribPointer(posLoc, 3, GL_FLOAT, 0, 0, ver);
- glVertexAttribPointer(colLoc, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, col);
- glVertexAttribPointer(tex0Loc, 2, GL_FLOAT, 0, 0, tex);
-
- glEnableVertexAttribArray(posLoc);
- glEnableVertexAttribArray(tex0Loc);
- glEnableVertexAttribArray(colLoc);
-
- for (int i=0; i<4; i++)
- {
- // Setup Colour Values
- col[i][0] = (GLubyte)GET_R(color);
- col[i][1] = (GLubyte)GET_G(color);
- col[i][2] = (GLubyte)GET_B(color);
- col[i][3] = (GLubyte)GET_A(color);
- }
-
- // Setup vertex position values
- // ver[0][3] = ver[1][3] = ver[2][3] = ver[3][3] = 0.0f; // FIXME, ver has only 3 elements - this is not correct
- ver[0][0] = ver[3][0] = rect.x1;
- ver[0][1] = ver[1][1] = rect.y1;
- ver[1][0] = ver[2][0] = rect.x2;
- ver[2][1] = ver[3][1] = rect.y2;
-
- // Setup texture coordinates
- CRect coords = texCoords ? *texCoords : CRect(0.0f, 0.0f, 1.0f, 1.0f);
- tex[0][0] = tex[3][0] = coords.x1;
- tex[0][1] = tex[1][1] = coords.y1;
- tex[1][0] = tex[2][0] = coords.x2;
- tex[2][1] = tex[3][1] = coords.y2;
-
- glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, idx);
-
- glDisableVertexAttribArray(posLoc);
- glDisableVertexAttribArray(colLoc);
- glDisableVertexAttribArray(tex0Loc);
-
- g_Windowing.DisableGUIShader();
-
- if (texture)
- glDisable(GL_TEXTURE_2D);
-}
-
-#endif
diff --git a/guilib/GUITextureGLES.h b/guilib/GUITextureGLES.h
deleted file mode 100644
index 3fdb05ea46..0000000000
--- a/guilib/GUITextureGLES.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*!
-\file GUITextureGLES.h
-\brief
-*/
-
-#ifndef GUILIB_GUITEXTUREGLES_H
-#define GUILIB_GUITEXTUREGLES_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUITexture.h"
-
-class CGUITextureGLES : public CGUITextureBase
-{
-public:
- CGUITextureGLES(float posX, float posY, float width, float height, const CTextureInfo& texture);
- static void DrawQuad(const CRect &coords, color_t color, CBaseTexture *texture = NULL, const CRect *texCoords = NULL);
-protected:
- void Begin(color_t color);
- void Draw(float *x, float *y, float *z, const CRect &texture, const CRect &diffuse, int orientation);
- void End();
-
- GLubyte m_col [4][4];
- GLfloat m_vert[4][3];
- GLfloat m_tex0[4][2];
- GLfloat m_tex1[4][2];
-};
-
-#endif
diff --git a/guilib/GUIToggleButtonControl.cpp b/guilib/GUIToggleButtonControl.cpp
deleted file mode 100644
index 33fd1c5d66..0000000000
--- a/guilib/GUIToggleButtonControl.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIToggleButtonControl.h"
-#include "GUIWindowManager.h"
-#include "GUIDialog.h"
-#include "utils/CharsetConverter.h"
-#include "utils/GUIInfoManager.h"
-
-using namespace std;
-
-CGUIToggleButtonControl::CGUIToggleButtonControl(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& textureFocus, const CTextureInfo& textureNoFocus, const CTextureInfo& altTextureFocus, const CTextureInfo& altTextureNoFocus, const CLabelInfo &labelInfo)
- : CGUIButtonControl(parentID, controlID, posX, posY, width, height, textureFocus, textureNoFocus, labelInfo)
- , m_selectButton(parentID, controlID, posX, posY, width, height, altTextureFocus, altTextureNoFocus, labelInfo)
-{
- m_toggleSelect = 0;
- ControlType = GUICONTROL_TOGGLEBUTTON;
-}
-
-CGUIToggleButtonControl::~CGUIToggleButtonControl(void)
-{
-}
-
-void CGUIToggleButtonControl::Render()
-{
- // ask our infoManager whether we are selected or not...
- if (m_toggleSelect)
- m_bSelected = g_infoManager.GetBool(m_toggleSelect, m_parentID);
-
- if (m_bSelected)
- {
- // render our Alternate textures...
- m_selectButton.SetFocus(HasFocus());
- m_selectButton.SetVisible(IsVisible());
- m_selectButton.SetEnabled(!IsDisabled());
- m_selectButton.SetPulseOnSelect(m_pulseOnSelect);
- m_selectButton.Render();
- CGUIControl::Render();
- }
- else
- { // render our Normal textures...
- CGUIButtonControl::Render();
- }
-}
-
-bool CGUIToggleButtonControl::OnAction(const CAction &action)
-{
- if (action.GetID() == ACTION_SELECT_ITEM)
- {
- m_bSelected = !m_bSelected;
- }
- return CGUIButtonControl::OnAction(action);
-}
-
-void CGUIToggleButtonControl::AllocResources()
-{
- CGUIButtonControl::AllocResources();
- m_selectButton.AllocResources();
-}
-
-void CGUIToggleButtonControl::FreeResources(bool immediately)
-{
- CGUIButtonControl::FreeResources(immediately);
- m_selectButton.FreeResources(immediately);
-}
-
-void CGUIToggleButtonControl::DynamicResourceAlloc(bool bOnOff)
-{
- CGUIButtonControl::DynamicResourceAlloc(bOnOff);
- m_selectButton.DynamicResourceAlloc(bOnOff);
-}
-
-void CGUIToggleButtonControl::SetInvalid()
-{
- CGUIButtonControl::SetInvalid();
- m_selectButton.SetInvalid();
-}
-
-void CGUIToggleButtonControl::SetPosition(float posX, float posY)
-{
- CGUIButtonControl::SetPosition(posX, posY);
- m_selectButton.SetPosition(posX, posY);
-}
-
-void CGUIToggleButtonControl::SetWidth(float width)
-{
- CGUIButtonControl::SetWidth(width);
- m_selectButton.SetWidth(width);
-}
-
-void CGUIToggleButtonControl::SetHeight(float height)
-{
- CGUIButtonControl::SetHeight(height);
- m_selectButton.SetHeight(height);
-}
-
-void CGUIToggleButtonControl::UpdateColors()
-{
- CGUIButtonControl::UpdateColors();
- m_selectButton.UpdateColors();
-}
-
-void CGUIToggleButtonControl::SetLabel(const string &strLabel)
-{
- CGUIButtonControl::SetLabel(strLabel);
- m_selectButton.SetLabel(strLabel);
-}
-
-void CGUIToggleButtonControl::SetAltLabel(const string &label)
-{
- if (label.size())
- m_selectButton.SetLabel(label);
-}
-
-CStdString CGUIToggleButtonControl::GetDescription() const
-{
- if (m_bSelected)
- return m_selectButton.GetDescription();
- return CGUIButtonControl::GetDescription();
-}
-
-void CGUIToggleButtonControl::SetAltClickActions(const vector<CGUIActionDescriptor> &clickActions)
-{
- m_selectButton.SetClickActions(clickActions);
-}
-
-void CGUIToggleButtonControl::OnClick()
-{
- // the ! is here as m_bSelected gets updated before this is called
- if (!m_bSelected && m_selectButton.HasClickActions())
- m_selectButton.OnClick();
- else
- CGUIButtonControl::OnClick();
-}
diff --git a/guilib/GUIToggleButtonControl.h b/guilib/GUIToggleButtonControl.h
deleted file mode 100644
index eea73621ff..0000000000
--- a/guilib/GUIToggleButtonControl.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*!
-\file GUIToggleButtonControl.h
-\brief
-*/
-
-#ifndef GUILIB_GUITOGGLEBUTTONCONTROL_H
-#define GUILIB_GUITOGGLEBUTTONCONTROL_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIButtonControl.h"
-
-/*!
- \ingroup controls
- \brief
- */
-class CGUIToggleButtonControl : public CGUIButtonControl
-{
-public:
- CGUIToggleButtonControl(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& textureFocus, const CTextureInfo& textureNoFocus, const CTextureInfo& altTextureFocus, const CTextureInfo& altTextureNoFocus, const CLabelInfo &labelInfo);
- virtual ~CGUIToggleButtonControl(void);
- virtual CGUIToggleButtonControl *Clone() const { return new CGUIToggleButtonControl(*this); };
-
- virtual void Render();
- virtual bool OnAction(const CAction &action);
- virtual void AllocResources();
- virtual void FreeResources(bool immediately = false);
- virtual void DynamicResourceAlloc(bool bOnOff);
- virtual void SetInvalid();
- virtual void SetPosition(float posX, float posY);
- virtual void SetWidth(float width);
- virtual void SetHeight(float height);
- void SetLabel(const std::string& strLabel);
- void SetAltLabel(const std::string& label);
- virtual CStdString GetDescription() const;
- void SetToggleSelect(int toggleSelect) { m_toggleSelect = toggleSelect; };
- void SetAltClickActions(const std::vector<CGUIActionDescriptor> &clickActions);
-
-protected:
- virtual void UpdateColors();
- virtual void OnClick();
- CGUIButtonControl m_selectButton;
- int m_toggleSelect;
-};
-#endif
diff --git a/guilib/GUIVideoControl.cpp b/guilib/GUIVideoControl.cpp
deleted file mode 100644
index 565e7e46ed..0000000000
--- a/guilib/GUIVideoControl.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "system.h"
-#include "GUIVideoControl.h"
-#include "GUIWindowManager.h"
-#include "Application.h"
-#ifdef HAS_VIDEO_PLAYBACK
-#include "cores/VideoRenderers/RenderManager.h"
-#else
-#include "cores/DummyVideoPlayer.h"
-#endif
-
-CGUIVideoControl::CGUIVideoControl(int parentID, int controlID, float posX, float posY, float width, float height)
- : CGUIControl(parentID, controlID, posX, posY, width, height)
-{
- ControlType = GUICONTROL_VIDEO;
-}
-
-CGUIVideoControl::~CGUIVideoControl(void)
-{}
-
-
-void CGUIVideoControl::Render()
-{
-#ifdef HAS_VIDEO_PLAYBACK
- // don't render if we aren't playing video, or if the renderer isn't started
- // (otherwise the lock we have from CApplication::Render() may clash with the startup
- // locks in the RenderManager.)
- if (g_application.IsPlayingVideo() && g_renderManager.IsStarted())
- {
-#else
- if (g_application.IsPlayingVideo())
- {
-#endif
- if (!g_application.m_pPlayer->IsPaused())
- g_application.ResetScreenSaver();
-
- g_graphicsContext.SetViewWindow(m_posX, m_posY, m_posX + m_width, m_posY + m_height);
-
-#ifdef HAS_VIDEO_PLAYBACK
- color_t alpha = g_graphicsContext.MergeAlpha(0xFF000000) >> 24;
- g_renderManager.RenderUpdate(false, 0, alpha);
-#else
- ((CDummyVideoPlayer *)g_application.m_pPlayer)->Render();
-#endif
- }
- CGUIControl::Render();
-}
-
-EVENT_RESULT CGUIVideoControl::OnMouseEvent(const CPoint &point, const CMouseEvent &event)
-{
- if (!g_application.IsPlayingVideo()) return EVENT_RESULT_UNHANDLED;
- if (event.m_id == ACTION_MOUSE_LEFT_CLICK)
- { // switch to fullscreen
- CGUIMessage message(GUI_MSG_FULLSCREEN, GetID(), GetParentID());
- g_windowManager.SendMessage(message);
- return EVENT_RESULT_HANDLED;
- }
- else if (event.m_id == ACTION_MOUSE_RIGHT_CLICK)
- { // toggle the playlist window
- if (g_windowManager.GetActiveWindow() == WINDOW_VIDEO_PLAYLIST)
- g_windowManager.PreviousWindow();
- else
- g_windowManager.ActivateWindow(WINDOW_VIDEO_PLAYLIST);
- return EVENT_RESULT_HANDLED;
- }
- return EVENT_RESULT_UNHANDLED;
-}
-
-bool CGUIVideoControl::CanFocus() const
-{ // unfocusable
- return false;
-}
-
-bool CGUIVideoControl::CanFocusFromPoint(const CPoint &point) const
-{ // mouse is allowed to focus this control, but it doesn't actually receive focus
- return IsVisible() && HitTest(point);
-}
diff --git a/guilib/GUIVideoControl.h b/guilib/GUIVideoControl.h
deleted file mode 100644
index 3ed7089054..0000000000
--- a/guilib/GUIVideoControl.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*!
-\file GUIVideoControl.h
-\brief
-*/
-
-#ifndef GUILIB_GUIVIDEOCONTROL_H
-#define GUILIB_GUIVIDEOCONTROL_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIControl.h"
-
-/*!
- \ingroup controls
- \brief
- */
-class CGUIVideoControl :
- public CGUIControl
-{
-public:
- CGUIVideoControl(int parentID, int controlID, float posX, float posY, float width, float height);
- virtual ~CGUIVideoControl(void);
- virtual CGUIVideoControl *Clone() const { return new CGUIVideoControl(*this); };
-
- virtual void Render();
- virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event);
- virtual bool CanFocus() const;
- virtual bool CanFocusFromPoint(const CPoint &point) const;
-};
-#endif
diff --git a/guilib/GUIVisualisationControl.cpp b/guilib/GUIVisualisationControl.cpp
deleted file mode 100644
index 686f19172c..0000000000
--- a/guilib/GUIVisualisationControl.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2005-2010 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIVisualisationControl.h"
-#include "GUIWindowManager.h"
-#include "GUIUserMessages.h"
-#include "Application.h"
-#include "addons/AddonManager.h"
-#include "addons/Visualisation.h"
-#include "utils/log.h"
-
-using namespace std;
-using namespace ADDON;
-
-#define LABEL_ROW1 10
-#define LABEL_ROW2 11
-#define LABEL_ROW3 12
-
-CGUIVisualisationControl::CGUIVisualisationControl(int parentID, int controlID, float posX, float posY, float width, float height)
- : CGUIRenderingControl(parentID, controlID, posX, posY, width, height), m_bAttemptedLoad(false)
-{
- ControlType = GUICONTROL_VISUALISATION;
-}
-
-CGUIVisualisationControl::CGUIVisualisationControl(const CGUIVisualisationControl &from)
-: CGUIRenderingControl(from)
-{
- ControlType = GUICONTROL_VISUALISATION;
-}
-
-bool CGUIVisualisationControl::OnMessage(CGUIMessage &message)
-{
- switch (message.GetMessage())
- {
- case GUI_MSG_GET_VISUALISATION:
- message.SetPointer(m_addon.get());
- return m_addon;
- case GUI_MSG_VISUALISATION_RELOAD:
- FreeResources(true);
- return true;
- case GUI_MSG_PLAYBACK_STARTED:
- if (m_addon)
- {
- m_addon->UpdateTrack();
- return true;
- }
- break;
- }
- return CGUIRenderingControl::OnMessage(message);
-}
-
-bool CGUIVisualisationControl::OnAction(const CAction &action)
-{
- if (!m_addon)
- return false;
-
- switch (action.GetID())
- {
- case ACTION_VIS_PRESET_NEXT:
- return m_addon->OnAction(VIS_ACTION_NEXT_PRESET);
- case ACTION_VIS_PRESET_PREV:
- return m_addon->OnAction(VIS_ACTION_PREV_PRESET);
- case ACTION_VIS_PRESET_RANDOM:
- return m_addon->OnAction(VIS_ACTION_RANDOM_PRESET);
- case ACTION_VIS_RATE_PRESET_PLUS:
- return m_addon->OnAction(VIS_ACTION_RATE_PRESET_PLUS);
- case ACTION_VIS_RATE_PRESET_MINUS:
- return m_addon->OnAction(VIS_ACTION_RATE_PRESET_MINUS);
- case ACTION_VIS_PRESET_LOCK:
- return m_addon->OnAction(VIS_ACTION_LOCK_PRESET);
- default:
- return CGUIRenderingControl::OnAction(action);
- }
-}
-
-void CGUIVisualisationControl::Render()
-{
- if (g_application.IsPlayingAudio())
- {
- if (m_bInvalidated)
- FreeResources(true);
-
- if (!m_addon && !m_bAttemptedLoad)
- {
- AddonPtr viz;
- if (ADDON::CAddonMgr::Get().GetDefault(ADDON_VIZ, viz))
- LoadAddon(viz);
-
- m_bAttemptedLoad = true;
- }
- }
- CGUIRenderingControl::Render();
-}
-
-void CGUIVisualisationControl::FreeResources(bool immediately)
-{
- m_bAttemptedLoad = false;
- // tell our app that we're going
- if (!m_addon)
- return;
-
- CGUIMessage msg(GUI_MSG_VISUALISATION_UNLOADING, m_controlID, 0);
- g_windowManager.SendMessage(msg);
- CLog::Log(LOGDEBUG, "FreeVisualisation() started");
- CGUIRenderingControl::FreeResources(immediately);
- CLog::Log(LOGDEBUG, "FreeVisualisation() done");
-}
-
diff --git a/guilib/GUIVisualisationControl.h b/guilib/GUIVisualisationControl.h
deleted file mode 100644
index 3d355a1bc5..0000000000
--- a/guilib/GUIVisualisationControl.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#pragma once
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIRenderingControl.h"
-
-class CGUIVisualisationControl : public CGUIRenderingControl
-{
-public:
- CGUIVisualisationControl(int parentID, int controlID, float posX, float posY, float width, float height);
- CGUIVisualisationControl(const CGUIVisualisationControl &from);
- virtual CGUIVisualisationControl *Clone() const { return new CGUIVisualisationControl(*this); }; //TODO check for naughties
- virtual void FreeResources(bool immediately = false);
- virtual void Render();
- virtual bool OnAction(const CAction &action);
- virtual bool OnMessage(CGUIMessage &message);
-private:
- bool m_bAttemptedLoad;
-};
diff --git a/guilib/GUIWindow.cpp b/guilib/GUIWindow.cpp
deleted file mode 100644
index 6c049a5722..0000000000
--- a/guilib/GUIWindow.cpp
+++ /dev/null
@@ -1,950 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "system.h"
-#include "GUIWindow.h"
-#include "GUIWindowManager.h"
-#include "Key.h"
-#include "LocalizeStrings.h"
-#include "Settings.h"
-#include "GUIControlFactory.h"
-#include "GUIControlGroup.h"
-#include "GUIControlProfiler.h"
-#ifdef PRE_SKIN_VERSION_9_10_COMPATIBILITY
-#include "GUIEditControl.h"
-#endif
-
-#include "addons/Skin.h"
-#include "utils/GUIInfoManager.h"
-#include "utils/log.h"
-#include "utils/SingleLock.h"
-#include "utils/TimeUtils.h"
-#include "ButtonTranslator.h"
-#include "XMLUtils.h"
-
-#ifdef HAS_PERFORMANCE_SAMPLE
-#include "utils/PerformanceSample.h"
-#endif
-
-using namespace std;
-
-CGUIWindow::CGUIWindow(int id, const CStdString &xmlFile)
-{
- SetID(id);
- SetProperty("xmlfile", xmlFile);
- m_idRange = 1;
- m_lastControlID = 0;
- m_bRelativeCoords = false;
- m_overlayState = OVERLAY_STATE_PARENT_WINDOW; // Use parent or previous window's state
- m_coordsRes = g_guiSettings.m_LookAndFeelResolution;
- m_isDialog = false;
- m_needsScaling = true;
- m_windowLoaded = false;
- m_loadOnDemand = true;
- m_renderOrder = 0;
- m_dynamicResourceAlloc = true;
- m_previousWindow = WINDOW_INVALID;
- m_animationsEnabled = true;
- m_manualRunActions = false;
- m_exclusiveMouseControl = 0;
- m_clearBackground = 0xff000000; // opaque black -> always clear
-}
-
-CGUIWindow::~CGUIWindow(void)
-{}
-
-bool CGUIWindow::Load(const CStdString& strFileName, bool bContainsPath)
-{
-#ifdef HAS_PERFORMANCE_SAMPLE
- CPerformanceSample aSample("WindowLoad-" + strFileName, true);
-#endif
-
- if (m_windowLoaded || g_SkinInfo == NULL)
- return true; // no point loading if it's already there
-
-#ifdef _DEBUG
- int64_t start;
- start = CurrentHostCounter();
-#endif
- RESOLUTION resToUse = RES_INVALID;
- CLog::Log(LOGINFO, "Loading skin file: %s", strFileName.c_str());
-
- // Find appropriate skin folder + resolution to load from
- CStdString strPath;
- CStdString strLowerPath;
- if (bContainsPath)
- strPath = strFileName;
- else
- {
- // FIXME: strLowerPath needs to eventually go since resToUse can get incorrectly overridden
- strLowerPath = g_SkinInfo->GetSkinPath(CStdString(strFileName).ToLower(), &resToUse);
- strPath = g_SkinInfo->GetSkinPath(strFileName, &resToUse);
- }
-
- if (!bContainsPath)
- m_coordsRes = resToUse;
-
- bool ret = LoadXML(strPath.c_str(), strLowerPath.c_str());
-
-#ifdef _DEBUG
- int64_t end, freq;
- end = CurrentHostCounter();
- freq = CurrentHostFrequency();
- CLog::Log(LOGDEBUG,"Load %s: %.2fms", GetProperty("xmlfile").c_str(), 1000.f * (end - start) / freq);
-#endif
- return ret;
-}
-
-bool CGUIWindow::LoadXML(const CStdString &strPath, const CStdString &strLowerPath)
-{
- TiXmlDocument xmlDoc;
- if ( !xmlDoc.LoadFile(strPath) && !xmlDoc.LoadFile(CStdString(strPath).ToLower()) && !xmlDoc.LoadFile(strLowerPath))
- {
- CLog::Log(LOGERROR, "unable to load:%s, Line %d\n%s", strPath.c_str(), xmlDoc.ErrorRow(), xmlDoc.ErrorDesc());
- SetID(WINDOW_INVALID);
- return false;
- }
-
- return Load(xmlDoc);
-}
-
-bool CGUIWindow::Load(TiXmlDocument &xmlDoc)
-{
- TiXmlElement* pRootElement = xmlDoc.RootElement();
- if (strcmpi(pRootElement->Value(), "window"))
- {
- CLog::Log(LOGERROR, "file : XML file doesnt contain <window>");
- return false;
- }
-
- // set the scaling resolution so that any control creation or initialisation can
- // be done with respect to the correct aspect ratio
- g_graphicsContext.SetScalingResolution(m_coordsRes, m_needsScaling);
-
- // Resolve any includes that may be present
- g_SkinInfo->ResolveIncludes(pRootElement);
- // now load in the skin file
- SetDefaults();
-
- CGUIControlFactory::GetInfoColor(pRootElement, "backgroundcolor", m_clearBackground);
- CGUIControlFactory::GetMultipleString(pRootElement, "onload", m_loadActions);
- CGUIControlFactory::GetMultipleString(pRootElement, "onunload", m_unloadActions);
- CGUIControlFactory::GetHitRect(pRootElement, m_hitRect);
-
- TiXmlElement *pChild = pRootElement->FirstChildElement();
- while (pChild)
- {
- CStdString strValue = pChild->Value();
- if (strValue == "type" && pChild->FirstChild())
- {
- // if we have are a window type (ie not a dialog), and we have <type>dialog</type>
- // then make this window act like a dialog
- if (!IsDialog() && strcmpi(pChild->FirstChild()->Value(), "dialog") == 0)
- m_isDialog = true;
- }
- else if (strValue == "previouswindow" && pChild->FirstChild())
- {
- m_previousWindow = CButtonTranslator::TranslateWindow(pChild->FirstChild()->Value());
- }
- else if (strValue == "defaultcontrol" && pChild->FirstChild())
- {
- const char *always = pChild->Attribute("always");
- if (always && strcmpi(always, "true") == 0)
- m_defaultAlways = true;
- m_defaultControl = atoi(pChild->FirstChild()->Value());
- }
- else if (strValue == "visible" && pChild->FirstChild())
- {
- CGUIControlFactory::GetConditionalVisibility(pRootElement, m_visibleCondition);
- }
- else if (strValue == "animation" && pChild->FirstChild())
- {
- CRect rect(0, 0, (float)g_settings.m_ResInfo[m_coordsRes].iWidth, (float)g_settings.m_ResInfo[m_coordsRes].iHeight);
- CAnimation anim;
- anim.Create(pChild, rect);
- m_animations.push_back(anim);
- }
- else if (strValue == "zorder" && pChild->FirstChild())
- {
- m_renderOrder = atoi(pChild->FirstChild()->Value());
- }
- else if (strValue == "coordinates")
- {
- TiXmlNode* pSystem = pChild->FirstChild("system");
- if (pSystem)
- {
- int iCoordinateSystem = atoi(pSystem->FirstChild()->Value());
- m_bRelativeCoords = (iCoordinateSystem == 1);
- }
-
- XMLUtils::GetFloat(pChild, "posx", m_posX);
- XMLUtils::GetFloat(pChild, "posy", m_posY);
-
- TiXmlElement *originElement = pChild->FirstChildElement("origin");
- while (originElement)
- {
- COrigin origin;
- originElement->QueryFloatAttribute("x", &origin.x);
- originElement->QueryFloatAttribute("y", &origin.y);
- if (originElement->FirstChild())
- origin.condition = g_infoManager.TranslateString(originElement->FirstChild()->Value());
- m_origins.push_back(origin);
- originElement = originElement->NextSiblingElement("origin");
- }
- }
- else if (strValue == "camera")
- { // z is fixed
- pChild->QueryFloatAttribute("x", &m_camera.x);
- pChild->QueryFloatAttribute("y", &m_camera.y);
- m_hasCamera = true;
- }
- else if (strValue == "controls")
- {
- TiXmlElement *pControl = pChild->FirstChildElement();
- while (pControl)
- {
- if (strcmpi(pControl->Value(), "control") == 0)
- {
- LoadControl(pControl, NULL);
- }
- pControl = pControl->NextSiblingElement();
- }
- }
- else if (strValue == "allowoverlay")
- {
- bool overlay = false;
- if (XMLUtils::GetBoolean(pRootElement, "allowoverlay", overlay))
- m_overlayState = overlay ? OVERLAY_STATE_SHOWN : OVERLAY_STATE_HIDDEN;
- }
-
- pChild = pChild->NextSiblingElement();
- }
- LoadAdditionalTags(pRootElement);
-
- m_windowLoaded = true;
- OnWindowLoaded();
- return true;
-}
-
-void CGUIWindow::LoadControl(TiXmlElement* pControl, CGUIControlGroup *pGroup)
-{
- // get control type
- CGUIControlFactory factory;
-
- CRect rect(0, 0, (float)g_settings.m_ResInfo[m_coordsRes].iWidth, (float)g_settings.m_ResInfo[m_coordsRes].iHeight);
- if (pGroup)
- {
- rect.x1 = pGroup->GetXPosition();
- rect.y1 = pGroup->GetYPosition();
- rect.x2 = rect.x1 + pGroup->GetWidth();
- rect.y2 = rect.y1 + pGroup->GetHeight();
- }
- CGUIControl* pGUIControl = factory.Create(GetID(), rect, pControl);
- if (pGUIControl)
- {
- float maxX = pGUIControl->GetXPosition() + pGUIControl->GetWidth();
- if (maxX > m_width)
- {
- m_width = maxX;
- }
-
- float maxY = pGUIControl->GetYPosition() + pGUIControl->GetHeight();
- if (maxY > m_height)
- {
- m_height = maxY;
- }
- // if we are in a group, add to the group, else add to our window
- if (pGroup)
- pGroup->AddControl(pGUIControl);
- else
- AddControl(pGUIControl);
- // if the new control is a group, then add it's controls
- if (pGUIControl->IsGroup())
- {
- TiXmlElement *pSubControl = pControl->FirstChildElement("control");
- while (pSubControl)
- {
- LoadControl(pSubControl, (CGUIControlGroup *)pGUIControl);
- pSubControl = pSubControl->NextSiblingElement("control");
- }
- }
- }
-}
-
-void CGUIWindow::OnWindowLoaded()
-{
- DynamicResourceAlloc(true);
-}
-
-void CGUIWindow::CenterWindow()
-{
- if (m_bRelativeCoords)
- {
- m_posX = (g_settings.m_ResInfo[m_coordsRes].iWidth - GetWidth()) / 2;
- m_posY = (g_settings.m_ResInfo[m_coordsRes].iHeight - GetHeight()) / 2;
- }
-}
-
-void CGUIWindow::Render()
-{
- // If we're rendering from a different thread, then we should wait for the main
- // app thread to finish AllocResources(), as dynamic resources (images in particular)
- // will try and be allocated from 2 different threads, which causes nasty things
- // to occur.
- if (!m_bAllocated) return;
-
- g_graphicsContext.SetRenderingResolution(m_coordsRes, m_needsScaling);
-
- m_renderTime = CTimeUtils::GetFrameTime();
- // render our window animation - returns false if it needs to stop rendering
- if (!RenderAnimation(m_renderTime))
- return;
-
- if (m_hasCamera)
- g_graphicsContext.SetCameraPosition(m_camera);
-
- CGUIControlGroup::Render();
-
- if (CGUIControlProfiler::IsRunning()) CGUIControlProfiler::Instance().EndFrame();
-}
-
-void CGUIWindow::Close(bool forceClose)
-{
- CLog::Log(LOGERROR,"%s - should never be called on the base class!", __FUNCTION__);
-}
-
-bool CGUIWindow::OnAction(const CAction &action)
-{
- if (action.IsMouse() || action.IsGesture())
- return EVENT_RESULT_UNHANDLED != OnMouseAction(action);
-
- CGUIControl *focusedControl = GetFocusedControl();
- if (focusedControl)
- return focusedControl->OnAction(action);
-
- // no control has focus?
- // set focus to the default control then
- CGUIMessage msg(GUI_MSG_SETFOCUS, GetID(), m_defaultControl);
- OnMessage(msg);
- return false;
-}
-
-CPoint CGUIWindow::GetPosition() const
-{
- for (unsigned int i = 0; i < m_origins.size(); i++)
- {
- // no condition implies true
- if (!m_origins[i].condition || g_infoManager.GetBool(m_origins[i].condition, GetID()))
- { // found origin
- return CPoint(m_origins[i].x, m_origins[i].y);
- }
- }
- return CGUIControlGroup::GetPosition();
-}
-
-// OnMouseAction - called by OnAction()
-EVENT_RESULT CGUIWindow::OnMouseAction(const CAction &action)
-{
- g_graphicsContext.SetScalingResolution(m_coordsRes, m_needsScaling);
- CPoint mousePoint(action.GetAmount(0), action.GetAmount(1));
- g_graphicsContext.InvertFinalCoords(mousePoint.x, mousePoint.y);
-
- // create the mouse event
- CMouseEvent event(action.GetID(), action.GetHoldTime(), action.GetAmount(2), action.GetAmount(3));
- if (m_exclusiveMouseControl)
- {
- CGUIControl *child = (CGUIControl *)GetControl(m_exclusiveMouseControl);
- if (child)
- {
- CPoint renderPos = child->GetRenderPosition() - CPoint(child->GetXPosition(), child->GetYPosition());
- return child->OnMouseEvent(mousePoint - renderPos, event);
- }
- }
-
- UnfocusFromPoint(mousePoint);
-
- return SendMouseEvent(mousePoint, event);
-}
-
-EVENT_RESULT CGUIWindow::OnMouseEvent(const CPoint &point, const CMouseEvent &event)
-{
- if (event.m_id == ACTION_MOUSE_RIGHT_CLICK)
- { // no control found to absorb this click - go to previous menu
- return OnAction(CAction(ACTION_PREVIOUS_MENU)) ? EVENT_RESULT_HANDLED : EVENT_RESULT_UNHANDLED;
- }
- return EVENT_RESULT_UNHANDLED;
-}
-
-/// \brief Called on window open.
-/// * Restores the control state(s)
-/// * Sets initial visibility of controls
-/// * Queue WindowOpen animation
-/// * Set overlay state
-/// Override this function and do any window-specific initialisation such
-/// as filling control contents and setting control focus before
-/// calling the base method.
-void CGUIWindow::OnInitWindow()
-{
- // set our rendered state
- m_hasRendered = false;
- ResetAnimations(); // we need to reset our animations as those windows that don't dynamically allocate
- // need their anims reset. An alternative solution is turning off all non-dynamic
- // allocation (which in some respects may be nicer, but it kills hdd spindown and the like)
-
- // set our initial control visibility before restoring control state and
- // focusing the default control, and again afterward to make sure that
- // any controls that depend on the state of the focused control (and or on
- // control states) are active.
- SetInitialVisibility();
- RestoreControlStates();
- SetInitialVisibility();
- QueueAnimation(ANIM_TYPE_WINDOW_OPEN);
- g_windowManager.ShowOverlay(m_overlayState);
-
- if (!m_manualRunActions)
- {
- RunLoadActions();
- }
-}
-
-// Called on window close.
-// * Executes the window close animation(s)
-// * Saves control state(s)
-// Override this function and call the base class before doing any dynamic memory freeing
-void CGUIWindow::OnDeinitWindow(int nextWindowID)
-{
- if (!m_manualRunActions)
- {
- RunUnloadActions();
- }
-
- if (nextWindowID != WINDOW_FULLSCREEN_VIDEO)
- {
- // Dialog animations are handled in Close() rather than here
- if (HasAnimation(ANIM_TYPE_WINDOW_CLOSE) && !IsDialog() && IsActive())
- {
- // Perform the window out effect
- QueueAnimation(ANIM_TYPE_WINDOW_CLOSE);
- while (IsAnimating(ANIM_TYPE_WINDOW_CLOSE))
- {
- g_windowManager.Process(true);
- }
- }
- }
- SaveControlStates();
-}
-
-bool CGUIWindow::OnMessage(CGUIMessage& message)
-{
- switch ( message.GetMessage() )
- {
- case GUI_MSG_WINDOW_INIT:
- {
- CLog::Log(LOGDEBUG, "------ Window Init (%s) ------", GetProperty("xmlfile").c_str());
- if (m_dynamicResourceAlloc || !m_bAllocated) AllocResources();
- OnInitWindow();
- return true;
- }
- break;
-
- case GUI_MSG_WINDOW_DEINIT:
- {
- CLog::Log(LOGDEBUG, "------ Window Deinit (%s) ------", GetProperty("xmlfile").c_str());
- OnDeinitWindow(message.GetParam1());
- // now free the window
- if (m_dynamicResourceAlloc) FreeResources();
- return true;
- }
- break;
-
- case GUI_MSG_CLICKED:
- {
- // a specific control was clicked
- CLICK_EVENT clickEvent = m_mapClickEvents[ message.GetSenderId() ];
-
- // determine if there are any handlers for this event
- if (clickEvent.HasAHandler())
- {
- // fire the message to all handlers
- clickEvent.Fire(message);
- }
- break;
- }
-
- case GUI_MSG_SELCHANGED:
- {
- // a selection within a specific control has changed
- SELECTED_EVENT selectedEvent = m_mapSelectedEvents[ message.GetSenderId() ];
-
- // determine if there are any handlers for this event
- if (selectedEvent.HasAHandler())
- {
- // fire the message to all handlers
- selectedEvent.Fire(message);
- }
- break;
- }
- case GUI_MSG_FOCUSED:
- { // a control has been focused
- if (HasID(message.GetSenderId()))
- {
- m_focusedControl = message.GetControlId();
- return true;
- }
- break;
- }
- case GUI_MSG_LOSTFOCUS:
- {
- // nothing to do at the window level when we lose focus
- return true;
- }
- case GUI_MSG_MOVE:
- {
- if (HasID(message.GetSenderId()))
- return OnMove(message.GetControlId(), message.GetParam1());
- break;
- }
- case GUI_MSG_SETFOCUS:
- {
-// CLog::Log(LOGDEBUG,"set focus to control:%i window:%i (%i)\n", message.GetControlId(),message.GetSenderId(), GetID());
- if ( message.GetControlId() )
- {
- // first unfocus the current control
- CGUIControl *control = GetFocusedControl();
- if (control)
- {
- CGUIMessage msgLostFocus(GUI_MSG_LOSTFOCUS, GetID(), control->GetID(), message.GetControlId());
- control->OnMessage(msgLostFocus);
- }
-
- // get the control to focus
- CGUIControl* pFocusedControl = GetFirstFocusableControl(message.GetControlId());
- if (!pFocusedControl) pFocusedControl = (CGUIControl *)GetControl(message.GetControlId());
-
- // and focus it
- if (pFocusedControl)
- return pFocusedControl->OnMessage(message);
- }
- return true;
- }
- break;
- case GUI_MSG_EXCLUSIVE_MOUSE:
- {
- m_exclusiveMouseControl = message.GetSenderId();
- return true;
- }
- break;
- case GUI_MSG_GESTURE_NOTIFY:
- {
- CAction action(ACTION_GESTURE_NOTIFY, 0, (float)message.GetParam1(), (float)message.GetParam2(), 0, 0);
- EVENT_RESULT result = OnMouseAction(action);
- message.SetParam1(result);
- return result != EVENT_RESULT_UNHANDLED;
- }
- case GUI_MSG_NOTIFY_ALL:
- {
- // only process those notifications that come from this window, or those intended for every window
- if (HasID(message.GetSenderId()) || !message.GetSenderId())
- {
- if (message.GetParam1() == GUI_MSG_PAGE_CHANGE ||
- message.GetParam1() == GUI_MSG_REFRESH_THUMBS ||
- message.GetParam1() == GUI_MSG_REFRESH_LIST)
- { // alter the message accordingly, and send to all controls
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- {
- CGUIControl *control = *it;
- CGUIMessage msg(message.GetParam1(), message.GetControlId(), control->GetID(), message.GetParam2());
- control->OnMessage(msg);
- }
- }
- if (message.GetParam1() == GUI_MSG_WINDOW_RESIZE)
- {
- // invalidate controls to get them to recalculate sizing information
- SetInvalid();
- return true;
- }
- }
- }
- break;
- }
-
- return SendControlMessage(message);
-}
-
-void CGUIWindow::AllocResources(bool forceLoad /*= FALSE */)
-{
- CSingleLock lock(g_graphicsContext);
-
-#ifdef _DEBUG
- int64_t start;
- start = CurrentHostCounter();
-#endif
- // load skin xml fil
- CStdString xmlFile = GetProperty("xmlfile");
- bool bHasPath=false;
- if (xmlFile.Find("\\") > -1 || xmlFile.Find("/") > -1 )
- bHasPath = true;
- if (xmlFile.size() && (forceLoad || m_loadOnDemand || !m_windowLoaded))
- Load(xmlFile,bHasPath);
-
- int64_t slend;
- slend = CurrentHostCounter();
-
- // and now allocate resources
- CGUIControlGroup::AllocResources();
-
-#ifdef _DEBUG
- int64_t end, freq;
- end = CurrentHostCounter();
- freq = CurrentHostFrequency();
- CLog::Log(LOGDEBUG,"Alloc resources: %.2fms (%.2f ms skin load)", 1000.f * (end - start) / freq, 1000.f * (slend - start) / freq);
-#endif
- m_bAllocated = true;
-}
-
-void CGUIWindow::FreeResources(bool forceUnload /*= FALSE */)
-{
- m_bAllocated = false;
- CGUIControlGroup::FreeResources();
- //g_TextureManager.Dump();
- // unload the skin
- if (m_loadOnDemand || forceUnload) ClearAll();
-}
-
-void CGUIWindow::DynamicResourceAlloc(bool bOnOff)
-{
- m_dynamicResourceAlloc = bOnOff;
- CGUIControlGroup::DynamicResourceAlloc(bOnOff);
-}
-
-void CGUIWindow::ClearAll()
-{
- OnWindowUnload();
- CGUIControlGroup::ClearAll();
- m_windowLoaded = false;
- m_dynamicResourceAlloc = true;
-}
-
-bool CGUIWindow::Initialize()
-{
- if (!g_windowManager.Initialized())
- return false; // can't load if we have no skin yet
- return Load(GetProperty("xmlfile"));
-}
-
-void CGUIWindow::SetInitialVisibility()
-{
- // reset our info manager caches
- g_infoManager.ResetCache();
- CGUIControlGroup::SetInitialVisibility();
-}
-
-bool CGUIWindow::IsActive() const
-{
- return g_windowManager.IsWindowActive(GetID());
-}
-
-bool CGUIWindow::CheckAnimation(ANIMATION_TYPE animType)
-{
- // special cases first
- if (animType == ANIM_TYPE_WINDOW_CLOSE)
- {
- if (!m_bAllocated || !m_hasRendered) // can't render an animation if we aren't allocated or haven't rendered
- return false;
- // make sure we update our visibility prior to queuing the window close anim
- for (unsigned int i = 0; i < m_children.size(); i++)
- m_children[i]->UpdateVisibility();
- }
- return true;
-}
-
-bool CGUIWindow::IsAnimating(ANIMATION_TYPE animType)
-{
- if (!m_animationsEnabled)
- return false;
- return CGUIControlGroup::IsAnimating(animType);
-}
-
-bool CGUIWindow::RenderAnimation(unsigned int time)
-{
- g_graphicsContext.ResetWindowTransform();
- if (m_animationsEnabled)
- CGUIControlGroup::Animate(time);
- else
- m_transform.Reset();
- return true;
-}
-
-void CGUIWindow::DisableAnimations()
-{
- m_animationsEnabled = false;
-}
-
-// returns true if the control group with id groupID has controlID as
-// its focused control
-bool CGUIWindow::ControlGroupHasFocus(int groupID, int controlID)
-{
- // 1. Run through and get control with groupID (assume unique)
- // 2. Get it's selected item.
- CGUIControl *group = GetFirstFocusableControl(groupID);
- if (!group) group = (CGUIControl *)GetControl(groupID);
-
- if (group && group->IsGroup())
- {
- if (controlID == 0)
- { // just want to know if the group is focused
- return group->HasFocus();
- }
- else
- {
- CGUIMessage message(GUI_MSG_ITEM_SELECTED, GetID(), group->GetID());
- group->OnMessage(message);
- return (controlID == (int) message.GetParam1());
- }
- }
- return false;
-}
-
-void CGUIWindow::SaveControlStates()
-{
- ResetControlStates();
- if (!m_defaultAlways)
- m_lastControlID = GetFocusedControlID();
- for (iControls it = m_children.begin(); it != m_children.end(); ++it)
- (*it)->SaveStates(m_controlStates);
-}
-
-void CGUIWindow::RestoreControlStates()
-{
- for (vector<CControlState>::iterator it = m_controlStates.begin(); it != m_controlStates.end(); ++it)
- {
- CGUIMessage message(GUI_MSG_ITEM_SELECT, GetID(), (*it).m_id, (*it).m_data);
- OnMessage(message);
- }
- int focusControl = (!m_defaultAlways && m_lastControlID) ? m_lastControlID : m_defaultControl;
- SET_CONTROL_FOCUS(focusControl, 0);
-}
-
-void CGUIWindow::ResetControlStates()
-{
- m_lastControlID = 0;
- m_focusedControl = 0;
- m_controlStates.clear();
-}
-
-bool CGUIWindow::OnMove(int fromControl, int moveAction)
-{
- const CGUIControl *control = GetFirstFocusableControl(fromControl);
- if (!control) control = GetControl(fromControl);
- if (!control)
- { // no current control??
- CLog::Log(LOGERROR, "Unable to find control %i in window %u",
- fromControl, GetID());
- return false;
- }
- vector<int> moveHistory;
- int nextControl = fromControl;
- while (control)
- { // grab the next control direction
- moveHistory.push_back(nextControl);
- nextControl = control->GetNextControl(moveAction);
- // check our history - if the nextControl is in it, we can't focus it
- for (unsigned int i = 0; i < moveHistory.size(); i++)
- {
- if (nextControl == moveHistory[i])
- return false; // no control to focus so do nothing
- }
- control = GetFirstFocusableControl(nextControl);
- if (control)
- break; // found a focusable control
- control = GetControl(nextControl); // grab the next control and try again
- }
- if (!control)
- return false; // no control to focus
- // if we get here we have our new control so focus it (and unfocus the current control)
- SET_CONTROL_FOCUS(nextControl, 0);
- return true;
-}
-
-void CGUIWindow::SetDefaults()
-{
- m_renderOrder = 0;
- m_defaultAlways = false;
- m_defaultControl = 0;
- m_bRelativeCoords = false;
- m_posX = m_posY = m_width = m_height = 0;
- m_overlayState = OVERLAY_STATE_PARENT_WINDOW; // Use parent or previous window's state
- m_visibleCondition = 0;
- m_previousWindow = WINDOW_INVALID;
- m_animations.clear();
- m_origins.clear();
- m_hasCamera = false;
- m_animationsEnabled = true;
- m_clearBackground = 0xff000000; // opaque black -> clear
- m_hitRect.SetRect(0, 0, (float)g_settings.m_ResInfo[m_coordsRes].iWidth, (float)g_settings.m_ResInfo[m_coordsRes].iHeight);
-}
-
-CRect CGUIWindow::GetScaledBounds() const
-{
- CSingleLock lock(g_graphicsContext);
- g_graphicsContext.SetScalingResolution(m_coordsRes, m_needsScaling);
- CPoint pos(GetPosition());
- CRect rect(pos.x, pos.y, pos.x + m_width, pos.y + m_height);
- float z = 0;
- g_graphicsContext.ScaleFinalCoords(rect.x1, rect.y1, z);
- g_graphicsContext.ScaleFinalCoords(rect.x2, rect.y2, z);
- return rect;
-}
-
-void CGUIWindow::OnEditChanged(int id, CStdString &text)
-{
- CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), id);
- OnMessage(msg);
- text = msg.GetLabel();
-}
-
-bool CGUIWindow::SendMessage(int message, int id, int param1 /* = 0*/, int param2 /* = 0*/)
-{
- CGUIMessage msg(message, GetID(), id, param1, param2);
- return OnMessage(msg);
-}
-
-#ifdef _DEBUG
-void CGUIWindow::DumpTextureUse()
-{
- CLog::Log(LOGDEBUG, "%s for window %u", __FUNCTION__, GetID());
- CGUIControlGroup::DumpTextureUse();
-}
-#endif
-
-void CGUIWindow::ChangeButtonToEdit(int id, bool singleLabel /* = false*/)
-{
-#ifdef PRE_SKIN_VERSION_9_10_COMPATIBILITY
- CGUIControl *name = (CGUIControl *)GetControl(id);
- if (name && name->GetControlType() == CGUIControl::GUICONTROL_BUTTON)
- { // change it to an edit control
- CGUIEditControl *edit = new CGUIEditControl(*(const CGUIButtonControl *)name);
- if (edit)
- {
- if (singleLabel)
- edit->SetLabel("");
- InsertControl(edit, name);
- RemoveControl(name);
- name->FreeResources();
- delete name;
- }
- }
-#endif
-}
-
-void CGUIWindow::SetProperty(const CStdString &key, const CStdString &value)
-{
- m_mapProperties[key] = value;
-}
-
-void CGUIWindow::SetProperty(const CStdString &key, const char *value)
-{
- m_mapProperties[key] = value;
-}
-
-void CGUIWindow::SetProperty(const CStdString &key, int value)
-{
- CStdString strVal;
- strVal.Format("%d", value);
- SetProperty(key, strVal);
-}
-
-void CGUIWindow::SetProperty(const CStdString &key, bool value)
-{
- SetProperty(key, value ? "1" : "0");
-}
-
-void CGUIWindow::SetProperty(const CStdString &key, double value)
-{
- CStdString strVal;
- strVal.Format("%f", value);
- SetProperty(key, strVal);
-}
-
-CStdString CGUIWindow::GetProperty(const CStdString &key) const
-{
- std::map<CStdString,CStdString,icompare>::const_iterator iter = m_mapProperties.find(key);
- if (iter == m_mapProperties.end())
- return "";
-
- return iter->second;
-}
-
-int CGUIWindow::GetPropertyInt(const CStdString &key) const
-{
- return atoi(GetProperty(key).c_str());
-}
-
-bool CGUIWindow::GetPropertyBool(const CStdString &key) const
-{
- return GetProperty(key) == "1";
-}
-
-double CGUIWindow::GetPropertyDouble(const CStdString &key) const
-{
- return atof(GetProperty(key).c_str());
-}
-
-void CGUIWindow::ClearProperties()
-{
- m_mapProperties.clear();
-}
-
-void CGUIWindow::RunActions(std::vector<CGUIActionDescriptor>& actions)
-{
- vector<CGUIActionDescriptor> tempActions = actions;
-
- // and execute our actions
- for (unsigned int i = 0; i < tempActions.size(); i++)
- {
- CGUIMessage message(GUI_MSG_EXECUTE, 0, GetID());
- message.SetAction(tempActions[i]);
- g_windowManager.SendMessage(message);
- }
-}
-
-void CGUIWindow::SetRunActionsManually()
-{
- m_manualRunActions = true;
-}
-
-void CGUIWindow::RunLoadActions()
-{
- RunActions(m_loadActions);
-}
-
-void CGUIWindow::RunUnloadActions()
-{
- RunActions(m_unloadActions);
-}
-
-void CGUIWindow::ClearBackground()
-{
- m_clearBackground.Update();
- color_t color = m_clearBackground;
- if (color)
- g_graphicsContext.Clear(color);
-}
diff --git a/guilib/GUIWindow.h b/guilib/GUIWindow.h
deleted file mode 100644
index 27a4541c35..0000000000
--- a/guilib/GUIWindow.h
+++ /dev/null
@@ -1,295 +0,0 @@
-/*!
-\file GUIWindow.h
-\brief
-*/
-
-#ifndef GUILIB_GUIWINDOW_H
-#define GUILIB_GUIWINDOW_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIControlGroup.h"
-#include "boost/shared_ptr.hpp"
-
-class CFileItem; typedef boost::shared_ptr<CFileItem> CFileItemPtr;
-
-#include "GUICallback.h" // for GUIEvent
-
-#include <map>
-#include <vector>
-
-#define ON_CLICK_MESSAGE(i,c,m) \
-{ \
- GUIEventHandler<c, CGUIMessage&> clickHandler(this, &m); \
- m_mapClickEvents[i] = clickHandler; \
-} \
-
-#define ON_SELECTED_MESSAGE(i,c,m) \
-{ \
- GUIEventHandler<c, CGUIMessage&> selectedHandler(this, &m); \
- m_mapSelectedEvents[i] = selectedHandler; \
-} \
-
-// forward
-class TiXmlNode;
-class TiXmlElement;
-class TiXmlDocument;
-
-class COrigin
-{
-public:
- COrigin()
- {
- x = y = 0;
- condition = 0;
- };
- float x;
- float y;
- int condition;
-};
-
-/*!
- \ingroup winmsg
- \brief
- */
-class CGUIWindow : public CGUIControlGroup
-{
-public:
- enum WINDOW_TYPE { WINDOW = 0, MODAL_DIALOG, MODELESS_DIALOG, BUTTON_MENU, SUB_MENU };
-
- CGUIWindow(int id, const CStdString &xmlFile);
- virtual ~CGUIWindow(void);
-
- bool Initialize(); // loads the window
- bool Load(const CStdString& strFileName, bool bContainsPath = false);
-
- void CenterWindow();
-
- /*! \brief Main render function, called every frame.
- Window classes should override this only if they need to alter how something is rendered.
- General updating on a per-frame basis should be handled in FrameMove instead, as Render
- is not necessarily re-entrant.
- \sa FrameMove
- */
- virtual void Render();
-
- /*! \brief Main update function, called every frame prior to rendering
- Any window that requires updating on a frame by frame basis (such as to maintain
- timers and the like) should override this function.
- */
- virtual void FrameMove() {};
-
- // Close should never be called on this base class (only on derivatives) - its here so that window-manager can use a general close
- virtual void Close(bool forceClose = false);
-
- // OnAction() is called by our window manager. We should process any messages
- // that should be handled at the window level in the derived classes, and any
- // unhandled messages should be dropped through to here where we send the message
- // on to the currently focused control. Returns true if the action has been handled
- // and does not need to be passed further down the line (to our global action handlers)
- virtual bool OnAction(const CAction &action);
-
- /*! \brief Clear the background (if necessary) prior to rendering the window
- */
- virtual void ClearBackground();
-
- bool OnMove(int fromControl, int moveAction);
- virtual bool OnMessage(CGUIMessage& message);
-
- bool ControlGroupHasFocus(int groupID, int controlID);
- virtual bool HasID(int controlID) const { return controlID >= m_controlID && controlID < m_controlID + m_idRange; };
- void SetIDRange(int range) { m_idRange = range; };
- int GetIDRange() const { return m_idRange; };
- int GetPreviousWindow() { return m_previousWindow; };
- CRect GetScaledBounds() const;
- virtual void ClearAll();
- virtual void AllocResources(bool forceLoad = false);
- virtual void FreeResources(bool forceUnLoad = false);
- virtual void DynamicResourceAlloc(bool bOnOff);
- virtual bool IsDialog() const { return false; };
- virtual bool IsDialogRunning() const { return false; };
- virtual bool IsModalDialog() const { return false; };
- virtual bool IsMediaWindow() const { return false; };
- virtual bool HasListItems() const { return false; };
- virtual CFileItemPtr GetCurrentListItem(int offset = 0) { return CFileItemPtr(); };
- virtual int GetViewContainerID() const { return 0; };
- virtual bool IsActive() const;
- void SetCoordsRes(RESOLUTION res) { m_coordsRes = res; };
- RESOLUTION GetCoordsRes() const { return m_coordsRes; };
- void LoadOnDemand(bool loadOnDemand) { m_loadOnDemand = loadOnDemand; };
- bool GetLoadOnDemand() { return m_loadOnDemand; }
- int GetRenderOrder() { return m_renderOrder; };
- virtual void SetInitialVisibility();
-
- enum OVERLAY_STATE { OVERLAY_STATE_PARENT_WINDOW=0, OVERLAY_STATE_SHOWN, OVERLAY_STATE_HIDDEN };
-
- OVERLAY_STATE GetOverlayState() const { return m_overlayState; };
-
- virtual bool IsAnimating(ANIMATION_TYPE animType);
- void DisableAnimations();
-
- virtual void ResetControlStates();
-
- void SetRunActionsManually();
- void RunLoadActions();
- void RunUnloadActions();
-
- /*! \brief Set a property
- Sets the value of a property referenced by a key.
- \param key name of the property to set
- \param value value to set, may be a string, integer, boolean or double.
- \sa GetProperty
- */
- void SetProperty(const CStdString &key, const CStdString &value);
- void SetProperty(const CStdString &key, const char *value);
- void SetProperty(const CStdString &key, int value);
- void SetProperty(const CStdString &key, bool value);
- void SetProperty(const CStdString &key, double value);
-
- /*! \brief Retreive a property
- \param key name of the property to retrieve
- \return value of the property, empty if it doesn't exist
- \sa SetProperty, GetPropertyInt, GetPropertyBool, GetPropertyDouble
- */
- CStdString GetProperty(const CStdString &key) const;
-
- /*! \brief Retreive an integer property
- \param key name of the property to retrieve
- \return value of the property, 0 if it doesn't exist
- \sa SetProperty, GetProperty
- */
- int GetPropertyInt(const CStdString &key) const;
-
- /*! \brief Retreive a boolean property
- \param key name of the property to retrieve
- \return value of the property, false if it doesn't exist
- \sa SetProperty, GetProperty
- */
- bool GetPropertyBool(const CStdString &key) const;
-
- /*! \brief Retreive a double precision property
- \param key name of the property to retrieve
- \return value of the property, 0 if it doesn't exist
- \sa SetProperty, GetProperty
- */
- double GetPropertyDouble(const CStdString &key) const;
-
- /*! \brief Clear a all the window's properties
- \sa SetProperty, HasProperty, GetProperty
- */
- void ClearProperties();
-
-#ifdef _DEBUG
- void DumpTextureUse();
-#endif
-
- bool HasSaveLastControl() const { return !m_defaultAlways; };
-
-protected:
- virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event);
- virtual bool LoadXML(const CStdString& strPath, const CStdString &strLowerPath); ///< Loads from the given file
- bool Load(TiXmlDocument &xmlDoc); ///< Loads from the given XML document
- virtual void LoadAdditionalTags(TiXmlElement *root) {}; ///< Load additional information from the XML document
-
- virtual void SetDefaults();
- virtual void OnWindowUnload() {}
- virtual void OnWindowLoaded();
- virtual void OnInitWindow();
- virtual void OnDeinitWindow(int nextWindowID);
- EVENT_RESULT OnMouseAction(const CAction &action);
- virtual bool RenderAnimation(unsigned int time);
- virtual bool CheckAnimation(ANIMATION_TYPE animType);
-
- CAnimation *GetAnimation(ANIMATION_TYPE animType, bool checkConditions = true);
-
- // control state saving on window close
- virtual void SaveControlStates();
- virtual void RestoreControlStates();
-
- // methods for updating controls and sending messages
- void OnEditChanged(int id, CStdString &text);
- bool SendMessage(int message, int id, int param1 = 0, int param2 = 0);
-
- typedef GUIEvent<CGUIMessage&> CLICK_EVENT;
- typedef std::map<int, CLICK_EVENT> MAPCONTROLCLICKEVENTS;
- MAPCONTROLCLICKEVENTS m_mapClickEvents;
-
- typedef GUIEvent<CGUIMessage&> SELECTED_EVENT;
- typedef std::map<int, SELECTED_EVENT> MAPCONTROLSELECTEDEVENTS;
- MAPCONTROLSELECTEDEVENTS m_mapSelectedEvents;
-
- void LoadControl(TiXmlElement* pControl, CGUIControlGroup *pGroup);
-
-//#ifdef PRE_SKIN_VERSION_9_10_COMPATIBILITY
- void ChangeButtonToEdit(int id, bool singleLabel = false);
-//#endif
-
- void RunActions(std::vector<CGUIActionDescriptor>& actions);
-
- int m_idRange;
- bool m_bRelativeCoords;
- OVERLAY_STATE m_overlayState;
- RESOLUTION m_coordsRes; // resolution that the window coordinates are in.
- bool m_needsScaling;
- bool m_windowLoaded; // true if the window's xml file has been loaded
- bool m_loadOnDemand; // true if the window should be loaded only as needed
- bool m_isDialog; // true if we have a dialog, false otherwise.
- bool m_dynamicResourceAlloc;
- CGUIInfoColor m_clearBackground; // colour to clear the window
-
- int m_renderOrder; // for render order of dialogs
-
- /*! \brief Grabs the window's top,left position in skin coordinates
- The window origin may change based on <origin> tag conditions in the skin.
-
- \return the window's origin in skin coordinates
- */
- virtual CPoint GetPosition() const;
- std::vector<COrigin> m_origins; // positions of dialogs depending on base window
-
- // control states
- int m_lastControlID;
- std::vector<CControlState> m_controlStates;
- int m_previousWindow;
-
- bool m_animationsEnabled;
- struct icompare
- {
- bool operator()(const CStdString &s1, const CStdString &s2) const
- {
- return s1.CompareNoCase(s2) < 0;
- }
- };
-
- std::map<CStdString, CStdString, icompare> m_mapProperties;
-
- std::vector<CGUIActionDescriptor> m_loadActions;
- std::vector<CGUIActionDescriptor> m_unloadActions;
-
- bool m_manualRunActions;
-
- int m_exclusiveMouseControl; ///< \brief id of child control that wishes to receive all mouse events \sa GUI_MSG_EXCLUSIVE_MOUSE
-};
-
-#endif
diff --git a/guilib/GUIWindowManager.cpp b/guilib/GUIWindowManager.cpp
deleted file mode 100644
index dc6968d136..0000000000
--- a/guilib/GUIWindowManager.cpp
+++ /dev/null
@@ -1,924 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIWindowManager.h"
-#include "GUIAudioManager.h"
-#include "GUIDialog.h"
-#include "Application.h"
-#include "GUIPassword.h"
-#include "utils/GUIInfoManager.h"
-#include "utils/SingleLock.h"
-#include "Util.h"
-#include "GUISettings.h"
-#include "Settings.h"
-#include "addons/Skin.h"
-
-using namespace std;
-
-CGUIWindowManager::CGUIWindowManager(void)
-{
- m_pCallback = NULL;
- m_bShowOverlay = true;
- m_iNested = 0;
- m_initialized = false;
-}
-
-CGUIWindowManager::~CGUIWindowManager(void)
-{
-}
-
-void CGUIWindowManager::Initialize()
-{
- LoadNotOnDemandWindows();
- m_initialized = true;
-}
-
-bool CGUIWindowManager::SendMessage(int message, int senderID, int destID, int param1, int param2)
-{
- CGUIMessage msg(message, senderID, destID, param1, param2);
- return SendMessage(msg);
-}
-
-bool CGUIWindowManager::SendMessage(CGUIMessage& message)
-{
- bool handled = false;
-// CLog::Log(LOGDEBUG,"SendMessage: mess=%d send=%d control=%d param1=%d", message.GetMessage(), message.GetSenderId(), message.GetControlId(), message.GetParam1());
- // Send the message to all none window targets
- for (int i = 0; i < (int) m_vecMsgTargets.size(); i++)
- {
- IMsgTargetCallback* pMsgTarget = m_vecMsgTargets[i];
-
- if (pMsgTarget)
- {
- if (pMsgTarget->OnMessage( message )) handled = true;
- }
- }
-
- // A GUI_MSG_NOTIFY_ALL is send to any active modal dialog
- // and all windows whether they are active or not
- if (message.GetMessage()==GUI_MSG_NOTIFY_ALL)
- {
- CSingleLock lock(g_graphicsContext);
- for (rDialog it = m_activeDialogs.rbegin(); it != m_activeDialogs.rend(); ++it)
- {
- CGUIWindow *dialog = *it;
- dialog->OnMessage(message);
- }
-
- for (WindowMap::iterator it = m_mapWindows.begin(); it != m_mapWindows.end(); it++)
- {
- CGUIWindow *pWindow = (*it).second;
- pWindow->OnMessage(message);
- }
- return true;
- }
-
- // Normal messages are sent to:
- // 1. All active modeless dialogs
- // 2. The topmost dialog that accepts the message
- // 3. The underlying window (only if it is the sender or receiver if a modal dialog is active)
-
- bool hasModalDialog(false);
- bool modalAcceptedMessage(false);
- // don't use an iterator for this loop, as some messages mean that m_activeDialogs is altered,
- // which will invalidate any iterator
- CSingleLock lock(g_graphicsContext);
- unsigned int topWindow = m_activeDialogs.size();
- while (topWindow)
- {
- CGUIWindow* dialog = m_activeDialogs[--topWindow];
- lock.Leave();
- if (!modalAcceptedMessage && dialog->IsModalDialog())
- { // modal window
- hasModalDialog = true;
- if (!modalAcceptedMessage && dialog->OnMessage( message ))
- {
- modalAcceptedMessage = handled = true;
- }
- }
- else if (!dialog->IsModalDialog())
- { // modeless
- if (dialog->OnMessage( message ))
- handled = true;
- }
- lock.Enter();
- if (topWindow > m_activeDialogs.size())
- topWindow = m_activeDialogs.size();
- }
- lock.Leave();
-
- // now send to the underlying window
- CGUIWindow* window = GetWindow(GetActiveWindow());
- if (window)
- {
- if (hasModalDialog)
- {
- // only send the message to the underlying window if it's the recipient
- // or sender (or we have no sender)
- if (message.GetSenderId() == window->GetID() ||
- message.GetControlId() == window->GetID() ||
- message.GetSenderId() == 0 )
- {
- if (window->OnMessage(message)) handled = true;
- }
- }
- else
- {
- if (window->OnMessage(message)) handled = true;
- }
- }
- return handled;
-}
-
-bool CGUIWindowManager::SendMessage(CGUIMessage& message, int window)
-{
- CGUIWindow* pWindow = GetWindow(window);
- if(pWindow)
- return pWindow->OnMessage(message);
- else
- return false;
-}
-
-void CGUIWindowManager::AddUniqueInstance(CGUIWindow *window)
-{
- CSingleLock lock(g_graphicsContext);
- // increment our instance (upper word of windowID)
- // until we get a window we don't have
- int instance = 0;
- while (GetWindow(window->GetID()))
- window->SetID(window->GetID() + (++instance << 16));
- Add(window);
-}
-
-void CGUIWindowManager::Add(CGUIWindow* pWindow)
-{
- if (!pWindow)
- {
- CLog::Log(LOGERROR, "Attempted to add a NULL window pointer to the window manager.");
- return;
- }
- // push back all the windows if there are more than one covered by this class
- CSingleLock lock(g_graphicsContext);
- for (int i = 0; i < pWindow->GetIDRange(); i++)
- {
- WindowMap::iterator it = m_mapWindows.find(pWindow->GetID() + i);
- if (it != m_mapWindows.end())
- {
- CLog::Log(LOGERROR, "Error, trying to add a second window with id %u "
- "to the window manager",
- pWindow->GetID());
- return;
- }
- m_mapWindows.insert(pair<int, CGUIWindow *>(pWindow->GetID() + i, pWindow));
- }
-}
-
-void CGUIWindowManager::AddCustomWindow(CGUIWindow* pWindow)
-{
- CSingleLock lock(g_graphicsContext);
- Add(pWindow);
- m_vecCustomWindows.push_back(pWindow);
-}
-
-void CGUIWindowManager::AddModeless(CGUIWindow* dialog)
-{
- CSingleLock lock(g_graphicsContext);
- // only add the window if it's not already added
- for (iDialog it = m_activeDialogs.begin(); it != m_activeDialogs.end(); ++it)
- if (*it == dialog) return;
- m_activeDialogs.push_back(dialog);
-}
-
-void CGUIWindowManager::Remove(int id)
-{
- CSingleLock lock(g_graphicsContext);
- WindowMap::iterator it = m_mapWindows.find(id);
- if (it != m_mapWindows.end())
- {
- for(vector<CGUIWindow*>::iterator it2 = m_activeDialogs.begin(); it2 != m_activeDialogs.end();)
- {
- if(*it2 == it->second)
- it2 = m_activeDialogs.erase(it2);
- else
- it2++;
- }
-
- m_mapWindows.erase(it);
- }
- else
- {
- CLog::Log(LOGWARNING, "Attempted to remove window %u "
- "from the window manager when it didn't exist",
- id);
- }
-}
-
-// removes and deletes the window. Should only be called
-// from the class that created the window using new.
-void CGUIWindowManager::Delete(int id)
-{
- CSingleLock lock(g_graphicsContext);
- CGUIWindow *pWindow = GetWindow(id);
- if (pWindow)
- {
- Remove(id);
- m_deleteWindows.push_back(pWindow);
- }
-}
-
-void CGUIWindowManager::PreviousWindow()
-{
- // deactivate any window
- CSingleLock lock(g_graphicsContext);
- CLog::Log(LOGDEBUG,"CGUIWindowManager::PreviousWindow: Deactivate");
- int currentWindow = GetActiveWindow();
- CGUIWindow *pCurrentWindow = GetWindow(currentWindow);
- if (!pCurrentWindow)
- return; // no windows or window history yet
-
- // check to see whether our current window has a <previouswindow> tag
- if (pCurrentWindow->GetPreviousWindow() != WINDOW_INVALID)
- {
- // TODO: we may need to test here for the
- // whether our history should be changed
-
- // don't reactivate the previouswindow if it is ourselves.
- if (currentWindow != pCurrentWindow->GetPreviousWindow())
- ActivateWindow(pCurrentWindow->GetPreviousWindow());
- return;
- }
- // get the previous window in our stack
- if (m_windowHistory.size() < 2)
- { // no previous window history yet - check if we should just activate home
- if (GetActiveWindow() != WINDOW_INVALID && GetActiveWindow() != WINDOW_HOME)
- {
- ClearWindowHistory();
- ActivateWindow(WINDOW_HOME);
- }
- return;
- }
- m_windowHistory.pop();
- int previousWindow = GetActiveWindow();
- m_windowHistory.push(currentWindow);
-
- CGUIWindow *pNewWindow = GetWindow(previousWindow);
- if (!pNewWindow)
- {
- CLog::Log(LOGERROR, "Unable to activate the previous window");
- ClearWindowHistory();
- ActivateWindow(WINDOW_HOME);
- return;
- }
-
- // ok to go to the previous window now
-
- // tell our info manager which window we are going to
- g_infoManager.SetNextWindow(previousWindow);
-
- // set our overlay state (enables out animations on window change)
- HideOverlay(pNewWindow->GetOverlayState());
-
- // deinitialize our window
- g_audioManager.PlayWindowSound(pCurrentWindow->GetID(), SOUND_DEINIT);
- CGUIMessage msg(GUI_MSG_WINDOW_DEINIT, 0, 0);
- pCurrentWindow->OnMessage(msg);
-
- g_infoManager.SetNextWindow(WINDOW_INVALID);
- g_infoManager.SetPreviousWindow(currentWindow);
-
- // remove the current window off our window stack
- m_windowHistory.pop();
-
- // ok, initialize the new window
- CLog::Log(LOGDEBUG,"CGUIWindowManager::PreviousWindow: Activate new");
- g_audioManager.PlayWindowSound(pNewWindow->GetID(), SOUND_INIT);
- CGUIMessage msg2(GUI_MSG_WINDOW_INIT, 0, 0, WINDOW_INVALID, GetActiveWindow());
- pNewWindow->OnMessage(msg2);
-
- g_infoManager.SetPreviousWindow(WINDOW_INVALID);
- return;
-}
-
-void CGUIWindowManager::ChangeActiveWindow(int newWindow, const CStdString& strPath)
-{
- vector<CStdString> params;
- if (!strPath.IsEmpty())
- params.push_back(strPath);
- ActivateWindow(newWindow, params, true);
-}
-
-void CGUIWindowManager::ActivateWindow(int iWindowID, const CStdString& strPath)
-{
- vector<CStdString> params;
- if (!strPath.IsEmpty())
- params.push_back(strPath);
- ActivateWindow(iWindowID, params, false);
-}
-
-void CGUIWindowManager::ActivateWindow(int iWindowID, const vector<CStdString>& params, bool swappingWindows)
-{
- if (!g_application.IsCurrentThread())
- {
- // make sure graphics lock is not held
- int nCount = ExitCriticalSection(g_graphicsContext);
- g_application.getApplicationMessenger().ActivateWindow(iWindowID, params, swappingWindows);
- RestoreCriticalSection(g_graphicsContext, nCount);
- }
- else
- ActivateWindow_Internal(iWindowID, params, swappingWindows);
-}
-
-void CGUIWindowManager::ActivateWindow_Internal(int iWindowID, const vector<CStdString>& params, bool swappingWindows)
-{
- // translate virtual windows
- // virtual music window which returns the last open music window (aka the music start window)
- if (iWindowID == WINDOW_MUSIC)
- {
- iWindowID = g_settings.m_iMyMusicStartWindow;
- // ensure the music virtual window only returns music files and music library windows
- if (iWindowID != WINDOW_MUSIC_NAV)
- iWindowID = WINDOW_MUSIC_FILES;
- }
- // virtual video window which returns the last open video window (aka the video start window)
- if (iWindowID == WINDOW_VIDEOS)
- {
- iWindowID = g_settings.m_iVideoStartWindow;
- // ensure the virtual video window only returns video windows
- if (iWindowID != WINDOW_VIDEO_NAV)
- iWindowID = WINDOW_VIDEO_FILES;
- }
- if (iWindowID == WINDOW_SCRIPTS)
- { // backward compatibility for pre-Dharma
- iWindowID = WINDOW_PROGRAMS;
- }
- if (iWindowID == WINDOW_START)
- { // virtual start window
- iWindowID = g_SkinInfo->GetStartWindow();
- }
-
- // debug
- CLog::Log(LOGDEBUG, "Activating window ID: %i", iWindowID);
-
- if (!g_passwordManager.CheckMenuLock(iWindowID))
- {
- CLog::Log(LOGERROR, "MasterCode is Wrong: Window with id %d will not be loaded! Enter a correct MasterCode!", iWindowID);
- if (GetActiveWindow() == WINDOW_INVALID && iWindowID != WINDOW_HOME)
- ActivateWindow(WINDOW_HOME);
- return;
- }
-
- // first check existence of the window we wish to activate.
- CGUIWindow *pNewWindow = GetWindow(iWindowID);
- if (!pNewWindow)
- { // nothing to see here - move along
- CLog::Log(LOGERROR, "Unable to locate window with id %d. Check skin files", iWindowID - WINDOW_HOME);
- return ;
- }
- else if (pNewWindow->IsDialog())
- { // if we have a dialog, we do a DoModal() rather than activate the window
- if (!pNewWindow->IsDialogRunning())
- ((CGUIDialog *)pNewWindow)->DoModal(iWindowID, params.size() ? params[0] : "");
- return;
- }
-
- g_infoManager.SetNextWindow(iWindowID);
-
- // set our overlay state
- HideOverlay(pNewWindow->GetOverlayState());
-
- // deactivate any window
- int currentWindow = GetActiveWindow();
- CGUIWindow *pWindow = GetWindow(currentWindow);
- if (pWindow)
- {
- // Play the window specific deinit sound
- g_audioManager.PlayWindowSound(pWindow->GetID(), SOUND_DEINIT);
- CGUIMessage msg(GUI_MSG_WINDOW_DEINIT, 0, 0, iWindowID);
- pWindow->OnMessage(msg);
- }
- g_infoManager.SetNextWindow(WINDOW_INVALID);
-
- // Add window to the history list (we must do this before we activate it,
- // as all messages done in WINDOW_INIT will want to be sent to the new
- // topmost window). If we are swapping windows, we pop the old window
- // off the history stack
- if (swappingWindows && m_windowHistory.size())
- m_windowHistory.pop();
- AddToWindowHistory(iWindowID);
-
- g_infoManager.SetPreviousWindow(currentWindow);
- g_audioManager.PlayWindowSound(pNewWindow->GetID(), SOUND_INIT);
- // Send the init message
- CGUIMessage msg(GUI_MSG_WINDOW_INIT, 0, 0, currentWindow, iWindowID);
- msg.SetStringParams(params);
- pNewWindow->OnMessage(msg);
-// g_infoManager.SetPreviousWindow(WINDOW_INVALID);
-}
-
-void CGUIWindowManager::CloseDialogs(bool forceClose)
-{
- CSingleLock lock(g_graphicsContext);
- while (m_activeDialogs.size() > 0)
- {
- CGUIWindow* win = m_activeDialogs[0];
- win->Close(forceClose);
- }
-}
-
-bool CGUIWindowManager::OnAction(const CAction &action)
-{
- CSingleLock lock(g_graphicsContext);
- unsigned int topMost = m_activeDialogs.size();
- while (topMost)
- {
- CGUIWindow *dialog = m_activeDialogs[--topMost];
- lock.Leave();
- if (dialog->IsModalDialog())
- { // we have the topmost modal dialog
- if (!dialog->IsAnimating(ANIM_TYPE_WINDOW_CLOSE))
- {
- bool fallThrough = (dialog->GetID() == WINDOW_DIALOG_FULLSCREEN_INFO);
- if (dialog->OnAction(action))
- return true;
- // dialog didn't want the action - we'd normally return false
- // but for some dialogs we want to drop the actions through
- if (fallThrough)
- break;
- return false;
- }
- return true; // do nothing with the action until the anim is finished
- }
- // music or video overlay are handled as a special case, as they're modeless, but we allow
- // clicking on them with the mouse.
- if (action.IsMouse() && (dialog->GetID() == WINDOW_VIDEO_OVERLAY ||
- dialog->GetID() == WINDOW_MUSIC_OVERLAY))
- {
- if (dialog->OnAction(action))
- return true;
- }
- lock.Enter();
- if (topMost > m_activeDialogs.size())
- topMost = m_activeDialogs.size();
- }
- lock.Leave();
- CGUIWindow* window = GetWindow(GetActiveWindow());
- if (window)
- return window->OnAction(action);
- return false;
-}
-
-bool RenderOrderSortFunction(CGUIWindow *first, CGUIWindow *second)
-{
- return first->GetRenderOrder() < second->GetRenderOrder();
-}
-
-void CGUIWindowManager::Render()
-{
- assert(g_application.IsCurrentThread());
- CSingleLock lock(g_graphicsContext);
- CGUIWindow* pWindow = GetWindow(GetActiveWindow());
- if (pWindow)
- {
- pWindow->ClearBackground();
- pWindow->Render();
- }
-
- // we render the dialogs based on their render order.
- vector<CGUIWindow *> renderList = m_activeDialogs;
- stable_sort(renderList.begin(), renderList.end(), RenderOrderSortFunction);
-
- for (iDialog it = renderList.begin(); it != renderList.end(); ++it)
- {
- if ((*it)->IsDialogRunning())
- (*it)->Render();
- }
-}
-
-void CGUIWindowManager::FrameMove()
-{
- assert(g_application.IsCurrentThread());
- CSingleLock lock(g_graphicsContext);
-
- if(m_iNested == 0)
- {
- // delete any windows queued for deletion
- for(iDialog it = m_deleteWindows.begin(); it != m_deleteWindows.end(); it++)
- {
- // Free any window resources
- (*it)->FreeResources(true);
- delete *it;
- }
- m_deleteWindows.clear();
- }
-
- CGUIWindow* pWindow = GetWindow(GetActiveWindow());
- if (pWindow)
- pWindow->FrameMove();
- // update any dialogs - we take a copy of the vector as some dialogs may close themselves
- // during this call
- vector<CGUIWindow *> dialogs = m_activeDialogs;
- for (iDialog it = dialogs.begin(); it != dialogs.end(); ++it)
- (*it)->FrameMove();
-}
-
-CGUIWindow* CGUIWindowManager::GetWindow(int id) const
-{
- if (id == WINDOW_INVALID)
- {
- return NULL;
- }
-
- CSingleLock lock(g_graphicsContext);
- WindowMap::const_iterator it = m_mapWindows.find(id);
- if (it != m_mapWindows.end())
- return (*it).second;
- return NULL;
-}
-
-// Shows and hides modeless dialogs as necessary.
-void CGUIWindowManager::UpdateModelessVisibility()
-{
- CSingleLock lock(g_graphicsContext);
- for (WindowMap::iterator it = m_mapWindows.begin(); it != m_mapWindows.end(); it++)
- {
- CGUIWindow *pWindow = (*it).second;
- if (pWindow && pWindow->IsDialog() && pWindow->GetVisibleCondition())
- {
- if (g_infoManager.GetBool(pWindow->GetVisibleCondition(), GetActiveWindow()))
- ((CGUIDialog *)pWindow)->Show();
- else
- ((CGUIDialog *)pWindow)->Close();
- }
- }
-}
-
-void CGUIWindowManager::Process(bool renderOnly /*= false*/)
-{
- if (g_application.IsCurrentThread() && m_pCallback)
- {
- m_iNested++;
- if (!renderOnly)
- {
- m_pCallback->Process();
- m_pCallback->FrameMove();
- }
- m_pCallback->Render();
- m_iNested--;
- }
-}
-
-void CGUIWindowManager::SetCallback(IWindowManagerCallback& callback)
-{
- m_pCallback = &callback;
-}
-
-void CGUIWindowManager::DeInitialize()
-{
- CSingleLock lock(g_graphicsContext);
- for (WindowMap::iterator it = m_mapWindows.begin(); it != m_mapWindows.end(); it++)
- {
- CGUIWindow* pWindow = (*it).second;
- if (IsWindowActive(it->first))
- {
- pWindow->DisableAnimations();
- CGUIMessage msg(GUI_MSG_WINDOW_DEINIT, 0, 0);
- pWindow->OnMessage(msg);
- }
- pWindow->ResetControlStates();
- pWindow->FreeResources(true);
- }
- UnloadNotOnDemandWindows();
-
- m_vecMsgTargets.erase( m_vecMsgTargets.begin(), m_vecMsgTargets.end() );
-
- // destroy our custom windows...
- for (int i = 0; i < (int)m_vecCustomWindows.size(); i++)
- {
- CGUIWindow *pWindow = m_vecCustomWindows[i];
- Remove(pWindow->GetID());
- delete pWindow;
- }
-
- // clear our vectors of windows
- m_vecCustomWindows.clear();
- m_activeDialogs.clear();
-
- m_initialized = false;
-}
-
-/// \brief Route to a window
-/// \param pWindow Window to route to
-void CGUIWindowManager::RouteToWindow(CGUIWindow* dialog)
-{
- CSingleLock lock(g_graphicsContext);
- // Just to be sure: Unroute this window,
- // #we may have routed to it before
- RemoveDialog(dialog->GetID());
-
- m_activeDialogs.push_back(dialog);
-}
-
-/// \brief Unroute window
-/// \param id ID of the window routed
-void CGUIWindowManager::RemoveDialog(int id)
-{
- CSingleLock lock(g_graphicsContext);
- for (iDialog it = m_activeDialogs.begin(); it != m_activeDialogs.end(); ++it)
- {
- if ((*it)->GetID() == id)
- {
- m_activeDialogs.erase(it);
- return;
- }
- }
-}
-
-bool CGUIWindowManager::HasModalDialog() const
-{
- CSingleLock lock(g_graphicsContext);
- for (ciDialog it = m_activeDialogs.begin(); it != m_activeDialogs.end(); ++it)
- {
- CGUIWindow *window = *it;
- if (window->IsModalDialog())
- { // have a modal window
- if (!window->IsAnimating(ANIM_TYPE_WINDOW_CLOSE))
- return true;
- }
- }
- return false;
-}
-
-bool CGUIWindowManager::HasDialogOnScreen() const
-{
- return (m_activeDialogs.size() > 0);
-}
-
-/// \brief Get the ID of the top most routed window
-/// \return id ID of the window or WINDOW_INVALID if no routed window available
-int CGUIWindowManager::GetTopMostModalDialogID() const
-{
- CSingleLock lock(g_graphicsContext);
- for (crDialog it = m_activeDialogs.rbegin(); it != m_activeDialogs.rend(); ++it)
- {
- CGUIWindow *dialog = *it;
- if (dialog->IsModalDialog())
- { // have a modal window
- return dialog->GetID();
- }
- }
- return WINDOW_INVALID;
-}
-
-void CGUIWindowManager::SendThreadMessage(CGUIMessage& message)
-{
- CSingleLock lock(m_critSection);
-
- CGUIMessage* msg = new CGUIMessage(message);
- m_vecThreadMessages.push_back( pair<CGUIMessage*,int>(msg,0) );
-}
-
-void CGUIWindowManager::SendThreadMessage(CGUIMessage& message, int window)
-{
- CSingleLock lock(m_critSection);
-
- CGUIMessage* msg = new CGUIMessage(message);
- m_vecThreadMessages.push_back( pair<CGUIMessage*,int>(msg,window) );
-}
-
-void CGUIWindowManager::DispatchThreadMessages()
-{
- CSingleLock lock(m_critSection);
- vector< pair<CGUIMessage*,int> > messages(m_vecThreadMessages);
- m_vecThreadMessages.erase(m_vecThreadMessages.begin(), m_vecThreadMessages.end());
- lock.Leave();
-
- while ( messages.size() > 0 )
- {
- vector< pair<CGUIMessage*,int> >::iterator it = messages.begin();
- CGUIMessage* pMsg = it->first;
- int window = it->second;
- // first remove the message from the queue,
- // else the message could be processed more then once
- it = messages.erase(it);
-
- if (window)
- SendMessage( *pMsg, window );
- else
- SendMessage( *pMsg );
- delete pMsg;
- }
-}
-
-void CGUIWindowManager::AddMsgTarget( IMsgTargetCallback* pMsgTarget )
-{
- m_vecMsgTargets.push_back( pMsgTarget );
-}
-
-int CGUIWindowManager::GetActiveWindow() const
-{
- if (!m_windowHistory.empty())
- return m_windowHistory.top();
- return WINDOW_INVALID;
-}
-
-// same as GetActiveWindow() except it first grabs dialogs
-int CGUIWindowManager::GetFocusedWindow() const
-{
- int dialog = GetTopMostModalDialogID();
- if (dialog != WINDOW_INVALID)
- return dialog;
-
- return GetActiveWindow();
-}
-
-bool CGUIWindowManager::IsWindowActive(int id, bool ignoreClosing /* = true */) const
-{
- // mask out multiple instances of the same window
- id &= WINDOW_ID_MASK;
- if ((GetActiveWindow() & WINDOW_ID_MASK) == id) return true;
- // run through the dialogs
- CSingleLock lock(g_graphicsContext);
- for (ciDialog it = m_activeDialogs.begin(); it != m_activeDialogs.end(); ++it)
- {
- CGUIWindow *window = *it;
- if ((window->GetID() & WINDOW_ID_MASK) == id && (!ignoreClosing || !window->IsAnimating(ANIM_TYPE_WINDOW_CLOSE)))
- return true;
- }
- return false; // window isn't active
-}
-
-bool CGUIWindowManager::IsWindowActive(const CStdString &xmlFile, bool ignoreClosing /* = true */) const
-{
- CSingleLock lock(g_graphicsContext);
- CGUIWindow *window = GetWindow(GetActiveWindow());
- if (window && CUtil::GetFileName(window->GetProperty("xmlfile")).Equals(xmlFile)) return true;
- // run through the dialogs
- for (ciDialog it = m_activeDialogs.begin(); it != m_activeDialogs.end(); ++it)
- {
- CGUIWindow *window = *it;
- if (CUtil::GetFileName(window->GetProperty("xmlfile")).Equals(xmlFile) && (!ignoreClosing || !window->IsAnimating(ANIM_TYPE_WINDOW_CLOSE)))
- return true;
- }
- return false; // window isn't active
-}
-
-bool CGUIWindowManager::IsWindowVisible(int id) const
-{
- return IsWindowActive(id, false);
-}
-
-bool CGUIWindowManager::IsWindowVisible(const CStdString &xmlFile) const
-{
- return IsWindowActive(xmlFile, false);
-}
-
-void CGUIWindowManager::LoadNotOnDemandWindows()
-{
- CSingleLock lock(g_graphicsContext);
- for (WindowMap::iterator it = m_mapWindows.begin(); it != m_mapWindows.end(); it++)
- {
- CGUIWindow *pWindow = (*it).second;
- if (!pWindow ->GetLoadOnDemand())
- {
- pWindow->FreeResources(true);
- pWindow->Initialize();
- }
- }
-}
-
-void CGUIWindowManager::UnloadNotOnDemandWindows()
-{
- CSingleLock lock(g_graphicsContext);
- for (WindowMap::iterator it = m_mapWindows.begin(); it != m_mapWindows.end(); it++)
- {
- CGUIWindow *pWindow = (*it).second;
- if (!pWindow->GetLoadOnDemand())
- {
- pWindow->FreeResources(true);
- }
- }
-}
-
-bool CGUIWindowManager::IsOverlayAllowed() const
-{
- if (GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO ||
- GetActiveWindow() == WINDOW_SCREENSAVER)
- return false;
- return m_bShowOverlay;
-}
-
-void CGUIWindowManager::ShowOverlay(CGUIWindow::OVERLAY_STATE state)
-{
- if (state != CGUIWindow::OVERLAY_STATE_PARENT_WINDOW)
- m_bShowOverlay = state == CGUIWindow::OVERLAY_STATE_SHOWN;
-}
-
-void CGUIWindowManager::HideOverlay(CGUIWindow::OVERLAY_STATE state)
-{
- if (state == CGUIWindow::OVERLAY_STATE_HIDDEN)
- m_bShowOverlay = false;
-}
-
-void CGUIWindowManager::AddToWindowHistory(int newWindowID)
-{
- // Check the window stack to see if this window is in our history,
- // and if so, pop all the other windows off the stack so that we
- // always have a predictable "Back" behaviour for each window
- stack<int> historySave = m_windowHistory;
- while (historySave.size())
- {
- if (historySave.top() == newWindowID)
- break;
- historySave.pop();
- }
- if (!historySave.empty())
- { // found window in history
- m_windowHistory = historySave;
- }
- else
- { // didn't find window in history - add it to the stack
- m_windowHistory.push(newWindowID);
- }
-}
-
-void CGUIWindowManager::GetActiveModelessWindows(vector<int> &ids)
-{
- // run through our modeless windows, and construct a vector of them
- // useful for saving and restoring the modeless windows on skin change etc.
- CSingleLock lock(g_graphicsContext);
- for (iDialog it = m_activeDialogs.begin(); it != m_activeDialogs.end(); ++it)
- {
- if (!(*it)->IsModalDialog())
- ids.push_back((*it)->GetID());
- }
-}
-
-CGUIWindow *CGUIWindowManager::GetTopMostDialog() const
-{
- CSingleLock lock(g_graphicsContext);
- // find the window with the lowest render order
- vector<CGUIWindow *> renderList = m_activeDialogs;
- stable_sort(renderList.begin(), renderList.end(), RenderOrderSortFunction);
-
- if (!renderList.size())
- return NULL;
-
- // return the last window in the list
- return *renderList.rbegin();
-}
-
-bool CGUIWindowManager::IsWindowTopMost(int id) const
-{
- CGUIWindow *topMost = GetTopMostDialog();
- if (topMost && (topMost->GetID() & WINDOW_ID_MASK) == id)
- return true;
- return false;
-}
-
-bool CGUIWindowManager::IsWindowTopMost(const CStdString &xmlFile) const
-{
- CGUIWindow *topMost = GetTopMostDialog();
- if (topMost && CUtil::GetFileName(topMost->GetProperty("xmlfile")).Equals(xmlFile))
- return true;
- return false;
-}
-
-void CGUIWindowManager::ClearWindowHistory()
-{
- while (m_windowHistory.size())
- m_windowHistory.pop();
-}
-
-#ifdef _DEBUG
-void CGUIWindowManager::DumpTextureUse()
-{
- CGUIWindow* pWindow = GetWindow(GetActiveWindow());
- if (pWindow)
- pWindow->DumpTextureUse();
-
- CSingleLock lock(g_graphicsContext);
- for (iDialog it = m_activeDialogs.begin(); it != m_activeDialogs.end(); ++it)
- {
- if ((*it)->IsDialogRunning())
- (*it)->DumpTextureUse();
- }
-}
-#endif
diff --git a/guilib/GUIWindowManager.h b/guilib/GUIWindowManager.h
deleted file mode 100644
index 7597d9c8dc..0000000000
--- a/guilib/GUIWindowManager.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/*!
-\file GUIWindowManager.h
-\brief
-*/
-
-#ifndef GUILIB_CGUIWindowManager_H
-#define GUILIB_CGUIWindowManager_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIWindow.h"
-#include "IWindowManagerCallback.h"
-#include "IMsgTargetCallback.h"
-
-class CGUIDialog;
-
-#define WINDOW_ID_MASK 0xffff
-
-/*!
- \ingroup winman
- \brief
- */
-class CGUIWindowManager
-{
-public:
- CGUIWindowManager(void);
- virtual ~CGUIWindowManager(void);
- bool SendMessage(CGUIMessage& message);
- bool SendMessage(int message, int senderID, int destID, int param1 = 0, int param2 = 0);
- bool SendMessage(CGUIMessage& message, int window);
- void Initialize();
- void Add(CGUIWindow* pWindow);
- void AddUniqueInstance(CGUIWindow *window);
- void AddCustomWindow(CGUIWindow* pWindow);
- void Remove(int id);
- void Delete(int id);
- void ActivateWindow(int iWindowID, const CStdString &strPath = "");
- void ChangeActiveWindow(int iNewID, const CStdString &strPath = "");
- void ActivateWindow(int iWindowID, const std::vector<CStdString>& params, bool swappingWindows = false);
- void PreviousWindow();
-
- void CloseDialogs(bool forceClose = false);
-
- // OnAction() runs through our active dialogs and windows and sends the message
- // off to the callbacks (application, python, playlist player) and to the
- // currently focused window(s). Returns true only if the message is handled.
- bool OnAction(const CAction &action);
-
- /*! \brief Rendering of the current window and any dialogs
- Render is called every frame to draw the current window and any dialogs.
- It should only be called from the application thread.
- */
- void Render();
-
- /*! \brief Per-frame updating of the current window and any dialogs
- FrameMove is called every frame to update the current window and any dialogs
- on screen. It should only be called from the application thread.
- */
- void FrameMove();
-
- /*! \brief Return whether the window manager is initialized.
- The window manager is initialized on skin load - if the skin isn't yet loaded,
- no windows should be able to be initialized.
- \return true if the window manager is initialized, false otherwise.
- */
- bool Initialized() const { return m_initialized; };
-
- CGUIWindow* GetWindow(int id) const;
- void Process(bool renderOnly = false);
- void SetCallback(IWindowManagerCallback& callback);
- void DeInitialize();
-
- void RouteToWindow(CGUIWindow* dialog);
- void AddModeless(CGUIWindow* dialog);
- void RemoveDialog(int id);
- int GetTopMostModalDialogID() const;
-
- void SendThreadMessage(CGUIMessage& message);
- void SendThreadMessage(CGUIMessage& message, int window);
- void DispatchThreadMessages();
- void AddMsgTarget( IMsgTargetCallback* pMsgTarget );
- int GetActiveWindow() const;
- int GetFocusedWindow() const;
- bool HasModalDialog() const;
- bool HasDialogOnScreen() const;
- void UpdateModelessVisibility();
- bool IsWindowActive(int id, bool ignoreClosing = true) const;
- bool IsWindowVisible(int id) const;
- bool IsWindowTopMost(int id) const;
- bool IsWindowActive(const CStdString &xmlFile, bool ignoreClosing = true) const;
- bool IsWindowVisible(const CStdString &xmlFile) const;
- bool IsWindowTopMost(const CStdString &xmlFile) const;
- bool IsOverlayAllowed() const;
- void ShowOverlay(CGUIWindow::OVERLAY_STATE state);
- void GetActiveModelessWindows(std::vector<int> &ids);
-#ifdef _DEBUG
- void DumpTextureUse();
-#endif
-private:
- void LoadNotOnDemandWindows();
- void UnloadNotOnDemandWindows();
- void HideOverlay(CGUIWindow::OVERLAY_STATE state);
- void AddToWindowHistory(int newWindowID);
- void ClearWindowHistory();
- CGUIWindow *GetTopMostDialog() const;
-
- friend class CApplicationMessenger;
- void ActivateWindow_Internal(int windowID, const std::vector<CStdString> &params, bool swappingWindows);
-
- typedef std::map<int, CGUIWindow *> WindowMap;
- WindowMap m_mapWindows;
- std::vector <CGUIWindow*> m_vecCustomWindows;
- std::vector <CGUIWindow*> m_activeDialogs;
- std::vector <CGUIWindow*> m_deleteWindows;
- typedef std::vector<CGUIWindow*>::iterator iDialog;
- typedef std::vector<CGUIWindow*>::const_iterator ciDialog;
- typedef std::vector<CGUIWindow*>::reverse_iterator rDialog;
- typedef std::vector<CGUIWindow*>::const_reverse_iterator crDialog;
-
- std::stack<int> m_windowHistory;
-
- IWindowManagerCallback* m_pCallback;
- std::vector < std::pair<CGUIMessage*,int> > m_vecThreadMessages;
- CCriticalSection m_critSection;
- std::vector <IMsgTargetCallback*> m_vecMsgTargets;
-
- bool m_bShowOverlay;
- int m_iNested;
- bool m_initialized;
-};
-
-/*!
- \ingroup winman
- \brief
- */
-extern CGUIWindowManager g_windowManager;
-#endif
-
diff --git a/guilib/GUIWrappingListContainer.cpp b/guilib/GUIWrappingListContainer.cpp
deleted file mode 100644
index 7c9c648ecc..0000000000
--- a/guilib/GUIWrappingListContainer.cpp
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIWrappingListContainer.h"
-#include "FileItem.h"
-#include "Key.h"
-#include "utils/log.h"
-
-CGUIWrappingListContainer::CGUIWrappingListContainer(int parentID, int controlID, float posX, float posY, float width, float height, ORIENTATION orientation, int scrollTime, int preloadItems, int fixedPosition)
- : CGUIBaseContainer(parentID, controlID, posX, posY, width, height, orientation, scrollTime, preloadItems)
-{
- m_cursor = fixedPosition;
- ControlType = GUICONTAINER_WRAPLIST;
- m_type = VIEW_TYPE_LIST;
- m_extraItems = 0;
-}
-
-CGUIWrappingListContainer::~CGUIWrappingListContainer(void)
-{
-}
-
-void CGUIWrappingListContainer::UpdatePageControl(int offset)
-{
- if (m_pageControl)
- { // tell our pagecontrol (scrollbar or whatever) to update (offset it by our cursor position)
- CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), m_pageControl, CorrectOffset(offset, m_cursor));
- SendWindowMessage(msg);
- }
-}
-
-bool CGUIWrappingListContainer::OnAction(const CAction &action)
-{
- switch (action.GetID())
- {
- case ACTION_PAGE_UP:
- Scroll(-m_itemsPerPage);
- return true;
- case ACTION_PAGE_DOWN:
- Scroll(m_itemsPerPage);
- return true;
- // smooth scrolling (for analog controls)
- case ACTION_SCROLL_UP:
- {
- m_analogScrollCount += action.GetAmount() * action.GetAmount();
- bool handled = false;
- while (m_analogScrollCount > 0.4)
- {
- handled = true;
- m_analogScrollCount -= 0.4f;
- Scroll(-1);
- }
- return handled;
- }
- break;
- case ACTION_SCROLL_DOWN:
- {
- m_analogScrollCount += action.GetAmount() * action.GetAmount();
- bool handled = false;
- while (m_analogScrollCount > 0.4)
- {
- handled = true;
- m_analogScrollCount -= 0.4f;
- Scroll(1);
- }
- return handled;
- }
- break;
- }
- return CGUIBaseContainer::OnAction(action);
-}
-
-bool CGUIWrappingListContainer::OnMessage(CGUIMessage& message)
-{
- if (message.GetControlId() == GetID() )
- {
- if (message.GetMessage() == GUI_MSG_ITEM_SELECT)
- {
- SelectItem(message.GetParam1());
- return true;
- }
- else if (message.GetMessage() == GUI_MSG_PAGE_CHANGE)
- {
- if (message.GetSenderId() == m_pageControl && IsVisible())
- { // offset by our cursor position
- message.SetParam1(message.GetParam1() - m_cursor);
- }
- }
- }
- return CGUIBaseContainer::OnMessage(message);
-}
-
-bool CGUIWrappingListContainer::MoveUp(bool wrapAround)
-{
- Scroll(-1);
- return true;
-}
-
-bool CGUIWrappingListContainer::MoveDown(bool wrapAround)
-{
- Scroll(+1);
- return true;
-}
-
-// scrolls the said amount
-void CGUIWrappingListContainer::Scroll(int amount)
-{
- ScrollToOffset(m_offset + amount);
-}
-
-void CGUIWrappingListContainer::ValidateOffset()
-{
- if (m_itemsPerPage <= (int)m_items.size())
- return;
-
- // no need to check the range here, but we need to check we have
- // more items than slots.
- ResetExtraItems();
- if (m_items.size())
- {
- unsigned int numItems = m_items.size();
- while (m_items.size() < (unsigned int)m_itemsPerPage)
- {
- // add additional copies of items, as we require extras at render time
- for (unsigned int i = 0; i < numItems; i++)
- {
- m_items.push_back(CGUIListItemPtr(m_items[i]->Clone()));
- m_extraItems++;
- }
- }
- }
-}
-
-int CGUIWrappingListContainer::CorrectOffset(int offset, int cursor) const
-{
- if (m_items.size())
- {
- int correctOffset = (offset + cursor) % (int)m_items.size();
- if (correctOffset < 0) correctOffset += m_items.size();
- return correctOffset;
- }
- return 0;
-}
-
-int CGUIWrappingListContainer::GetSelectedItem() const
-{
- if (m_items.size() > m_extraItems)
- {
- int numItems = (int)(m_items.size() - m_extraItems);
- int correctOffset = (m_offset + m_cursor) % numItems;
- if (correctOffset < 0) correctOffset += numItems;
- return correctOffset;
- }
- return 0;
-}
-
-bool CGUIWrappingListContainer::SelectItemFromPoint(const CPoint &point)
-{
- if (!m_focusedLayout || !m_layout)
- return false;
-
- const float mouse_scroll_speed = 0.05f;
- const float mouse_max_amount = 1.0f; // max speed: 1 item per frame
- float sizeOfItem = m_layout->Size(m_orientation);
- // see if the point is either side of our focused item
- float start = m_cursor * sizeOfItem;
- float end = start + m_focusedLayout->Size(m_orientation);
- float pos = (m_orientation == VERTICAL) ? point.y : point.x;
- if (pos < start - 0.5f * sizeOfItem)
- { // scroll backward
- if (!InsideLayout(m_layout, point))
- return false;
- float amount = std::min((start - pos) / sizeOfItem, mouse_max_amount);
- m_analogScrollCount += amount * amount * mouse_scroll_speed;
- if (m_analogScrollCount > 1)
- {
- Scroll(-1);
- m_analogScrollCount-=1.0f;
- }
- return true;
- }
- else if (pos > end + 0.5f * sizeOfItem)
- { // scroll forward
- if (!InsideLayout(m_layout, point))
- return false;
-
- float amount = std::min((pos - end) / sizeOfItem, mouse_max_amount);
- m_analogScrollCount += amount * amount * mouse_scroll_speed;
- if (m_analogScrollCount > 1)
- {
- Scroll(1);
- m_analogScrollCount-=1.0f;
- }
- return true;
- }
- return InsideLayout(m_focusedLayout, point);
-}
-
-void CGUIWrappingListContainer::SelectItem(int item)
-{
- if (item >= 0 && item < (int)m_items.size())
- ScrollToOffset(item - m_cursor);
-}
-
-void CGUIWrappingListContainer::ResetExtraItems()
-{
- // delete any extra items
- if (m_extraItems)
- m_items.erase(m_items.begin() + m_items.size() - m_extraItems, m_items.end());
- m_extraItems = 0;
-}
-
-void CGUIWrappingListContainer::Reset()
-{
- ResetExtraItems();
- CGUIBaseContainer::Reset();
-}
-
-int CGUIWrappingListContainer::GetCurrentPage() const
-{
- int offset = CorrectOffset(m_offset, m_cursor);
- if (offset + m_itemsPerPage - m_cursor >= (int)GetRows()) // last page
- return (GetRows() + m_itemsPerPage - 1) / m_itemsPerPage;
- return offset / m_itemsPerPage + 1;
-}
-
-void CGUIWrappingListContainer::SetPageControlRange()
-{
- if (m_pageControl)
- {
- CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), m_pageControl, m_itemsPerPage, m_items.size() + m_itemsPerPage - 1);
- SendWindowMessage(msg);
- }
-}
diff --git a/guilib/GUIWrappingListContainer.h b/guilib/GUIWrappingListContainer.h
deleted file mode 100644
index 7f2f8edea8..0000000000
--- a/guilib/GUIWrappingListContainer.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*!
-\file GUIListContainer.h
-\brief
-*/
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIBaseContainer.h"
-/*!
- \ingroup controls
- \brief
- */
-class CGUIWrappingListContainer : public CGUIBaseContainer
-{
-public:
- CGUIWrappingListContainer(int parentID, int controlID, float posX, float posY, float width, float height, ORIENTATION orientation, int scrollTime, int preloadItems, int fixedPosition);
- virtual ~CGUIWrappingListContainer(void);
- virtual CGUIWrappingListContainer *Clone() const { return new CGUIWrappingListContainer(*this); };
-
- virtual bool OnAction(const CAction &action);
- virtual bool OnMessage(CGUIMessage& message);
- virtual int GetSelectedItem() const;
-
-protected:
- virtual void Scroll(int amount);
- virtual bool MoveDown(bool wrapAround);
- virtual bool MoveUp(bool wrapAround);
- virtual void ValidateOffset();
- virtual int CorrectOffset(int offset, int cursor) const;
- virtual bool SelectItemFromPoint(const CPoint &point);
- virtual void SelectItem(int item);
- virtual void Reset();
- virtual unsigned int GetNumItems() const { return m_items.size() - m_extraItems; };
- virtual int GetCurrentPage() const;
- virtual void SetPageControlRange();
- virtual void UpdatePageControl(int offset);
-
- void ResetExtraItems();
- unsigned int m_extraItems;
-};
-
diff --git a/guilib/Geometry.h b/guilib/Geometry.h
deleted file mode 100644
index 2de87d2d64..0000000000
--- a/guilib/Geometry.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#pragma once
-
-#ifdef __GNUC__
-// under gcc, inline will only take place if optimizations are applied (-O). this will force inline even whith optimizations.
-#define XBMC_FORCE_INLINE __attribute__((always_inline))
-#else
-#define XBMC_FORCE_INLINE
-#endif
-
-
-class CPoint
-{
-public:
- CPoint()
- {
- x = 0; y = 0;
- };
-
- CPoint(float a, float b)
- {
- x = a;
- y = b;
- };
-
- CPoint operator+(const CPoint &point) const
- {
- CPoint ans;
- ans.x = x + point.x;
- ans.y = y + point.y;
- return ans;
- };
-
- const CPoint &operator+=(const CPoint &point)
- {
- x += point.x;
- y += point.y;
- return *this;
- };
-
- CPoint operator-(const CPoint &point) const
- {
- CPoint ans;
- ans.x = x - point.x;
- ans.y = y - point.y;
- return ans;
- };
-
- const CPoint &operator-=(const CPoint &point)
- {
- x -= point.x;
- y -= point.y;
- return *this;
- };
-
- float x, y;
-};
-
-class CRect
-{
-public:
- CRect() { x1 = y1 = x2 = y2 = 0;};
- CRect(float left, float top, float right, float bottom) { x1 = left; y1 = top; x2 = right; y2 = bottom; };
-
- void SetRect(float left, float top, float right, float bottom) { x1 = left; y1 = top; x2 = right; y2 = bottom; };
-
- bool PtInRect(const CPoint &point) const
- {
- if (x1 <= point.x && point.x <= x2 && y1 <= point.y && point.y <= y2)
- return true;
- return false;
- };
-
- inline const CRect &operator -=(const CPoint &point) XBMC_FORCE_INLINE
- {
- x1 -= point.x;
- y1 -= point.y;
- x2 -= point.x;
- y2 -= point.y;
- return *this;
- };
-
- inline const CRect &operator +=(const CPoint &point) XBMC_FORCE_INLINE
- {
- x1 += point.x;
- y1 += point.y;
- x2 += point.x;
- y2 += point.y;
- return *this;
- };
-
- const CRect &Intersect(const CRect &rect)
- {
- if (rect.x2 < x2) x2 = rect.x2;
- if (rect.y2 < y2) y2 = rect.y2;
- if (rect.x1 > x1) x1 = rect.x1;
- if (rect.y1 > y1) y1 = rect.y1;
- if (x1 > x2) x1 = x2;
- if (y1 > y2) y1 = y2;
- return *this;
- };
-
- inline bool IsEmpty() const XBMC_FORCE_INLINE
- {
- return (x2 - x1) * (y2 - y1) == 0;
- };
-
- inline float Width() const XBMC_FORCE_INLINE
- {
- return x2 - x1;
- };
-
- inline float Height() const XBMC_FORCE_INLINE
- {
- return y2 - y1;
- };
-
- bool operator !=(const CRect &rect) const
- {
- if (x1 != rect.x1) return true;
- if (x2 != rect.x2) return true;
- if (y1 != rect.y1) return true;
- if (y2 != rect.y2) return true;
- return false;
- };
-
- float x1, y1, x2, y2;
-};
-
diff --git a/guilib/GraphicContext.cpp b/guilib/GraphicContext.cpp
deleted file mode 100644
index 2d5ef63ec3..0000000000
--- a/guilib/GraphicContext.cpp
+++ /dev/null
@@ -1,775 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "system.h"
-#include "GraphicContext.h"
-#include "utils/SingleLock.h"
-#include "Application.h"
-#include "GUISettings.h"
-#include "Settings.h"
-#include "AdvancedSettings.h"
-#include "cores/VideoRenderers/RenderManager.h"
-#include "WindowingFactory.h"
-#include "TextureManager.h"
-#include "MouseStat.h"
-#include "GUIWindowManager.h"
-#include "utils/JobManager.h"
-#include "VideoReferenceClock.h"
-
-using namespace std;
-
-extern bool g_fullScreen;
-
-/* quick access to a skin setting, fine unless we starts clearing video settings */
-static CSettingInt* g_guiSkinzoom = NULL;
-
-CGraphicContext::CGraphicContext(void)
-{
- m_iScreenWidth = 720;
- m_iScreenHeight = 576;
- m_iScreenId = 0;
- m_strMediaDir = "";
- m_bCalibrating = false;
- m_Resolution = RES_INVALID;
- m_guiScaleX = m_guiScaleY = 1.0f;
- m_windowResolution = RES_INVALID;
- m_bFullScreenRoot = false;
-}
-
-CGraphicContext::~CGraphicContext(void)
-{
-}
-
-void CGraphicContext::SetOrigin(float x, float y)
-{
- if (m_origins.size())
- m_origins.push(CPoint(x,y) + m_origins.top());
- else
- m_origins.push(CPoint(x,y));
-
- AddTransform(TransformMatrix::CreateTranslation(x, y));
-}
-
-void CGraphicContext::RestoreOrigin()
-{
- if (m_origins.size())
- m_origins.pop();
- RemoveTransform();
-}
-
-// add a new clip region, intersecting with the previous clip region.
-bool CGraphicContext::SetClipRegion(float x, float y, float w, float h)
-{ // transform from our origin
- CPoint origin;
- if (m_origins.size())
- origin = m_origins.top();
-
- // ok, now intersect with our old clip region
- CRect rect(x, y, x + w, y + h);
- rect += origin;
- if (m_clipRegions.size())
- {
- // intersect with original clip region
- rect.Intersect(m_clipRegions.top());
- }
-
- if (rect.IsEmpty())
- return false;
-
- m_clipRegions.push(rect);
-
- // here we could set the hardware clipping, if applicable
- return true;
-}
-
-void CGraphicContext::RestoreClipRegion()
-{
- if (m_clipRegions.size())
- m_clipRegions.pop();
-
- // here we could reset the hardware clipping, if applicable
-}
-
-void CGraphicContext::ClipRect(CRect &vertex, CRect &texture, CRect *texture2)
-{
- // this is the software clipping routine. If the graphics hardware is set to do the clipping
- // (eg via SetClipPlane in D3D for instance) then this routine is unneeded.
- if (m_clipRegions.size())
- {
- // take a copy of the vertex rectangle and intersect
- // it with our clip region (moved to the same coordinate system)
- CRect clipRegion(m_clipRegions.top());
- if (m_origins.size())
- clipRegion -= m_origins.top();
- CRect original(vertex);
- vertex.Intersect(clipRegion);
- // and use the original to compute the texture coordinates
- if (original != vertex)
- {
- float scaleX = texture.Width() / original.Width();
- float scaleY = texture.Height() / original.Height();
- texture.x1 += (vertex.x1 - original.x1) * scaleX;
- texture.y1 += (vertex.y1 - original.y1) * scaleY;
- texture.x2 += (vertex.x2 - original.x2) * scaleX;
- texture.y2 += (vertex.y2 - original.y2) * scaleY;
- if (texture2)
- {
- scaleX = texture2->Width() / original.Width();
- scaleY = texture2->Height() / original.Height();
- texture2->x1 += (vertex.x1 - original.x1) * scaleX;
- texture2->y1 += (vertex.y1 - original.y1) * scaleY;
- texture2->x2 += (vertex.x2 - original.x2) * scaleX;
- texture2->y2 += (vertex.y2 - original.y2) * scaleY;
- }
- }
- }
-}
-
-bool CGraphicContext::SetViewPort(float fx, float fy, float fwidth, float fheight, bool intersectPrevious /* = false */)
-{
- CRect oldviewport;
- g_Windowing.GetViewPort(oldviewport);
-
- // transform coordinates - we may have a rotation which changes the positioning of the
- // minimal and maximal viewport extents. We currently go to the maximal extent.
- float x[4], y[4];
- x[0] = x[3] = fx;
- x[1] = x[2] = fx + fwidth;
- y[0] = y[1] = fy;
- y[2] = y[3] = fy + fheight;
- float minX = (float)m_iScreenWidth;
- float maxX = 0;
- float minY = (float)m_iScreenHeight;
- float maxY = 0;
- for (int i = 0; i < 4; i++)
- {
- float z = 0;
- ScaleFinalCoords(x[i], y[i], z);
- if (x[i] < minX) minX = x[i];
- if (x[i] > maxX) maxX = x[i];
- if (y[i] < minY) minY = y[i];
- if (y[i] > maxY) maxY = y[i];
- }
-
- int newLeft = (int)(minX + 0.5f);
- int newTop = (int)(minY + 0.5f);
- int newRight = (int)(maxX + 0.5f);
- int newBottom = (int)(maxY + 0.5f);
- if (intersectPrevious)
- {
- // do the intersection
- int oldLeft = (int)oldviewport.x1;
- int oldTop = (int)oldviewport.y1;
- int oldRight = (int)oldviewport.x2;
- int oldBottom = (int)oldviewport.y2;
- if (newLeft >= oldRight || newTop >= oldBottom || newRight <= oldLeft || newBottom <= oldTop)
- { // empty intersection - return false to indicate no rendering should occur
- return false;
- }
- // ok, they intersect, do the intersection
- if (newLeft < oldLeft) newLeft = oldLeft;
- if (newTop < oldTop) newTop = oldTop;
- if (newRight > oldRight) newRight = oldRight;
- if (newBottom > oldBottom) newBottom = oldBottom;
- }
- // check range against screen size
- if (newRight <= 0 || newBottom <= 0 ||
- newTop >= m_iScreenHeight || newLeft >= m_iScreenWidth ||
- newLeft >= newRight || newTop >= newBottom)
- { // no intersection with the screen
- return false;
- }
- // intersection with the screen
- if (newLeft < 0) newLeft = 0;
- if (newTop < 0) newTop = 0;
- if (newRight > m_iScreenWidth) newRight = m_iScreenWidth;
- if (newBottom > m_iScreenHeight) newBottom = m_iScreenHeight;
-
- ASSERT(newLeft < newRight);
- ASSERT(newTop < newBottom);
-
- CRect newviewport((float)newLeft, (float)newTop, (float)newRight, (float)newBottom);
- g_Windowing.SetViewPort(newviewport);
-
- m_viewStack.push(oldviewport);
-
- UpdateCameraPosition(m_cameras.top());
- return true;
-}
-
-void CGraphicContext::RestoreViewPort()
-{
- if (!m_viewStack.size()) return;
-
- CRect oldviewport = m_viewStack.top();
- g_Windowing.SetViewPort(oldviewport);
-
- m_viewStack.pop();
-
- UpdateCameraPosition(m_cameras.top());
-}
-
-const CRect CGraphicContext::GetViewWindow() const
-{
- if (m_bCalibrating || m_bFullScreenVideo)
- {
- CRect rect;
- rect.x1 = (float)g_settings.m_ResInfo[m_Resolution].Overscan.left;
- rect.y1 = (float)g_settings.m_ResInfo[m_Resolution].Overscan.top;
- rect.x2 = (float)g_settings.m_ResInfo[m_Resolution].Overscan.right;
- rect.y2 = (float)g_settings.m_ResInfo[m_Resolution].Overscan.bottom;
- return rect;
- }
- return m_videoRect;
-}
-
-void CGraphicContext::SetViewWindow(float left, float top, float right, float bottom)
-{
- m_videoRect.x1 = ScaleFinalXCoord(left, top);
- m_videoRect.y1 = ScaleFinalYCoord(left, top);
- m_videoRect.x2 = ScaleFinalXCoord(right, bottom);
- m_videoRect.y2 = ScaleFinalYCoord(right, bottom);
-}
-
-void CGraphicContext::SetFullScreenVideo(bool bOnOff)
-{
- Lock();
- m_bFullScreenVideo = bOnOff;
-
-#if defined(HAS_VIDEO_PLAYBACK)
- if(m_bFullScreenRoot)
- {
- if(m_bFullScreenVideo)
- g_graphicsContext.SetVideoResolution(g_renderManager.GetResolution());
- else if(g_guiSettings.m_LookAndFeelResolution > RES_DESKTOP)
- g_graphicsContext.SetVideoResolution(g_guiSettings.m_LookAndFeelResolution);
- else
- g_graphicsContext.SetVideoResolution(RES_DESKTOP);
- }
- else
- g_graphicsContext.SetVideoResolution(RES_WINDOW);
-#endif
-
- Unlock();
-}
-
-bool CGraphicContext::IsFullScreenVideo() const
-{
- return m_bFullScreenVideo;
-}
-
-bool CGraphicContext::IsCalibrating() const
-{
- return m_bCalibrating;
-}
-
-void CGraphicContext::SetCalibrating(bool bOnOff)
-{
- m_bCalibrating = bOnOff;
-}
-
-bool CGraphicContext::IsValidResolution(RESOLUTION res)
-{
- if (res >= RES_WINDOW && (size_t) res <= g_settings.m_ResInfo.size())
- {
- return true;
- }
-
- return false;
-}
-
-void CGraphicContext::SetVideoResolution(RESOLUTION res, bool forceUpdate)
-{
- RESOLUTION lastRes = m_Resolution;
-
- // If the user asked us to guess, go with desktop
- if (res == RES_AUTORES || !IsValidResolution(res))
- {
- res = RES_DESKTOP;
- }
-
- // If we are switching to the same resolution and same window/full-screen, no need to do anything
- if (!forceUpdate && res == lastRes && m_bFullScreenRoot == g_advancedSettings.m_fullScreen)
- {
- return;
- }
-
- //pause the player during the refreshrate change
- int delay = g_guiSettings.GetInt("videoplayer.pauseafterrefreshchange");
- if (delay > 0 && g_guiSettings.GetBool("videoplayer.adjustrefreshrate") && g_application.IsPlayingVideo() && !g_application.IsPaused())
- {
- g_application.m_pPlayer->Pause();
- ThreadMessage msg = {TMSG_MEDIA_UNPAUSE};
- CDelayedMessage* pauseMessage = new CDelayedMessage(msg, delay * 500);
- pauseMessage->Create(true);
- }
-
- if (res >= RES_DESKTOP)
- {
- g_advancedSettings.m_fullScreen = true;
- m_bFullScreenRoot = true;
- }
- else
- {
- g_advancedSettings.m_fullScreen = false;
- m_bFullScreenRoot = false;
- }
-
- Lock();
-
- m_iScreenWidth = g_settings.m_ResInfo[res].iWidth;
- m_iScreenHeight = g_settings.m_ResInfo[res].iHeight;
- m_iScreenId = g_settings.m_ResInfo[res].iScreen;
- m_Resolution = res;
-
- //tell the videoreferenceclock that we're about to change the refreshrate
- g_VideoReferenceClock.RefreshChanged();
-
- if (g_advancedSettings.m_fullScreen)
- {
-#if defined (__APPLE__) || defined (_WIN32)
- bool blankOtherDisplays = g_guiSettings.GetBool("videoscreen.blankdisplays");
- g_Windowing.SetFullScreen(true, g_settings.m_ResInfo[res], blankOtherDisplays);
-#else
- g_Windowing.SetFullScreen(true, g_settings.m_ResInfo[res], false);
-#endif
- }
- else if (lastRes >= RES_DESKTOP )
- g_Windowing.SetFullScreen(false, g_settings.m_ResInfo[res], false);
- else
- g_Windowing.ResizeWindow(m_iScreenWidth, m_iScreenHeight, -1, -1);
-
- // update anyone that relies on sizing information
- g_renderManager.Recover();
- g_Mouse.SetResolution(m_iScreenWidth, m_iScreenHeight, 1, 1);
- g_windowManager.SendMessage(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_WINDOW_RESIZE);
-
- Unlock();
-}
-
-RESOLUTION CGraphicContext::GetVideoResolution() const
-{
- return m_Resolution;
-}
-
-void CGraphicContext::ResetOverscan(RESOLUTION_INFO &res)
-{
- res.Overscan.left = 0;
- res.Overscan.top = 0;
- res.Overscan.right = res.iWidth;
- res.Overscan.bottom = res.iHeight;
-}
-
-void CGraphicContext::ResetOverscan(RESOLUTION res, OVERSCAN &overscan)
-{
- overscan.left = 0;
- overscan.top = 0;
- switch (res)
- {
- case RES_HDTV_1080i:
- overscan.right = 1920;
- overscan.bottom = 1080;
- break;
- case RES_HDTV_720p:
- overscan.right = 1280;
- overscan.bottom = 720;
- break;
- case RES_HDTV_480p_16x9:
- case RES_HDTV_480p_4x3:
- case RES_NTSC_16x9:
- case RES_NTSC_4x3:
- case RES_PAL60_16x9:
- case RES_PAL60_4x3:
- overscan.right = 720;
- overscan.bottom = 480;
- break;
- case RES_PAL_16x9:
- case RES_PAL_4x3:
- overscan.right = 720;
- overscan.bottom = 576;
- break;
- default:
- overscan.right = g_settings.m_ResInfo[res].iWidth;
- overscan.bottom = g_settings.m_ResInfo[res].iHeight;
- break;
- }
-}
-
-void CGraphicContext::ResetScreenParameters(RESOLUTION res)
-{
- // For now these are all on the first screen.
- g_settings.m_ResInfo[res].iScreen = 0;
-
- // 1080i
- switch (res)
- {
- case RES_HDTV_1080i:
- g_settings.m_ResInfo[res].iSubtitles = (int)(0.965 * 1080);
- g_settings.m_ResInfo[res].iWidth = 1920;
- g_settings.m_ResInfo[res].iHeight = 1080;
- g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_INTERLACED | D3DPRESENTFLAG_WIDESCREEN;
- g_settings.m_ResInfo[res].fPixelRatio = 1.0f;
- g_settings.m_ResInfo[res].strMode ="1080i 16:9";
- break;
- case RES_HDTV_720p:
- g_settings.m_ResInfo[res].iSubtitles = (int)(0.965 * 720);
- g_settings.m_ResInfo[res].iWidth = 1280;
- g_settings.m_ResInfo[res].iHeight = 720;
- g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN;
- g_settings.m_ResInfo[res].fPixelRatio = 1.0f;
- g_settings.m_ResInfo[res].strMode = "720p 16:9";
- break;
- case RES_HDTV_480p_4x3:
- g_settings.m_ResInfo[res].iSubtitles = (int)(0.9 * 480);
- g_settings.m_ResInfo[res].iWidth = 720;
- g_settings.m_ResInfo[res].iHeight = 480;
- g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_PROGRESSIVE;
- g_settings.m_ResInfo[res].fPixelRatio = 4320.0f / 4739.0f;
- g_settings.m_ResInfo[res].strMode = "480p 4:3";
- break;
- case RES_HDTV_480p_16x9:
- g_settings.m_ResInfo[res].iSubtitles = (int)(0.965 * 480);
- g_settings.m_ResInfo[res].iWidth = 720;
- g_settings.m_ResInfo[res].iHeight = 480;
- g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN;
- g_settings.m_ResInfo[res].fPixelRatio = 4320.0f / 4739.0f*4.0f / 3.0f;
- g_settings.m_ResInfo[res].strMode = "480p 16:9";
- break;
- case RES_NTSC_4x3:
- g_settings.m_ResInfo[res].iSubtitles = (int)(0.9 * 480);
- g_settings.m_ResInfo[res].iWidth = 720;
- g_settings.m_ResInfo[res].iHeight = 480;
- g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_INTERLACED;
- g_settings.m_ResInfo[res].fPixelRatio = 4320.0f / 4739.0f;
- g_settings.m_ResInfo[res].strMode = "NTSC 4:3";
- break;
- case RES_NTSC_16x9:
- g_settings.m_ResInfo[res].iSubtitles = (int)(0.965 * 480);
- g_settings.m_ResInfo[res].iWidth = 720;
- g_settings.m_ResInfo[res].iHeight = 480;
- g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_INTERLACED | D3DPRESENTFLAG_WIDESCREEN;
- g_settings.m_ResInfo[res].fPixelRatio = 4320.0f / 4739.0f*4.0f / 3.0f;
- g_settings.m_ResInfo[res].strMode = "NTSC 16:9";
- break;
- case RES_PAL_4x3:
- g_settings.m_ResInfo[res].iSubtitles = (int)(0.9 * 576);
- g_settings.m_ResInfo[res].iWidth = 720;
- g_settings.m_ResInfo[res].iHeight = 576;
- g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_INTERLACED;
- g_settings.m_ResInfo[res].fPixelRatio = 128.0f / 117.0f;
- g_settings.m_ResInfo[res].strMode = "PAL 4:3";
- break;
- case RES_PAL_16x9:
- g_settings.m_ResInfo[res].iSubtitles = (int)(0.965 * 576);
- g_settings.m_ResInfo[res].iWidth = 720;
- g_settings.m_ResInfo[res].iHeight = 576;
- g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_INTERLACED | D3DPRESENTFLAG_WIDESCREEN;
- g_settings.m_ResInfo[res].fPixelRatio = 128.0f / 117.0f*4.0f / 3.0f;
- g_settings.m_ResInfo[res].strMode = "PAL 16:9";
- break;
- case RES_PAL60_4x3:
- g_settings.m_ResInfo[res].iSubtitles = (int)(0.9 * 480);
- g_settings.m_ResInfo[res].iWidth = 720;
- g_settings.m_ResInfo[res].iHeight = 480;
- g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_INTERLACED;
- g_settings.m_ResInfo[res].fPixelRatio = 4320.0f / 4739.0f;
- g_settings.m_ResInfo[res].strMode = "PAL60 4:3";
- break;
- case RES_PAL60_16x9:
- g_settings.m_ResInfo[res].iSubtitles = (int)(0.965 * 480);
- g_settings.m_ResInfo[res].iWidth = 720;
- g_settings.m_ResInfo[res].iHeight = 480;
- g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_INTERLACED | D3DPRESENTFLAG_WIDESCREEN;
- g_settings.m_ResInfo[res].fPixelRatio = 4320.0f / 4739.0f*4.0f / 3.0f;
- g_settings.m_ResInfo[res].strMode = "PAL60 16:9";
- break;
- default:
- break;
- }
- ResetOverscan(res, g_settings.m_ResInfo[res].Overscan);
-}
-
-float CGraphicContext::GetPixelRatio(RESOLUTION iRes) const
-{
- if (iRes >= 0 && iRes < (int)g_settings.m_ResInfo.size())
- return g_settings.m_ResInfo[iRes].fPixelRatio;
- return 0.0f;
-}
-
-void CGraphicContext::Clear(color_t color)
-{
- g_Windowing.ClearBuffers(color);
-}
-
-void CGraphicContext::CaptureStateBlock()
-{
- g_Windowing.CaptureStateBlock();
-}
-
-void CGraphicContext::ApplyStateBlock()
-{
- g_Windowing.ApplyStateBlock();
-}
-
-void CGraphicContext::SetScalingResolution(RESOLUTION res, bool needsScaling)
-{
- Lock();
- m_windowResolution = res;
- if (needsScaling && m_Resolution != RES_INVALID)
- {
- // calculate necessary scalings
- float fFromWidth;
- float fFromHeight;
- float fToPosX;
- float fToPosY;
- float fToWidth;
- float fToHeight;
-
- {
- fFromWidth = (float)g_settings.m_ResInfo[res].iWidth;
- fFromHeight = (float)g_settings.m_ResInfo[res].iHeight;
- fToPosX = (float)g_settings.m_ResInfo[m_Resolution].Overscan.left;
- fToPosY = (float)g_settings.m_ResInfo[m_Resolution].Overscan.top;
- fToWidth = (float)g_settings.m_ResInfo[m_Resolution].Overscan.right - fToPosX;
- fToHeight = (float)g_settings.m_ResInfo[m_Resolution].Overscan.bottom - fToPosY;
- }
-
- if(!g_guiSkinzoom) // lookup gui setting if we didn't have it already
- g_guiSkinzoom = (CSettingInt*)g_guiSettings.GetSetting("lookandfeel.skinzoom");
-
- float fZoom = 1.0f;
- if(g_guiSkinzoom)
- fZoom *= (100 + g_guiSkinzoom->GetData()) * 0.01f;
-
- fZoom -= 1.0f;
- fToPosX -= fToWidth * fZoom * 0.5f;
- fToWidth *= fZoom + 1.0f;
-
- // adjust for aspect ratio as zoom is given in the vertical direction and we don't
- // do aspect ratio corrections in the gui code
- fZoom = fZoom / g_settings.m_ResInfo[m_Resolution].fPixelRatio;
- fToPosY -= fToHeight * fZoom * 0.5f;
- fToHeight *= fZoom + 1.0f;
-
- m_guiScaleX = fFromWidth / fToWidth;
- m_guiScaleY = fFromHeight / fToHeight;
- TransformMatrix guiScaler = TransformMatrix::CreateScaler(fToWidth / fFromWidth, fToHeight / fFromHeight, fToHeight / fFromHeight);
- TransformMatrix guiOffset = TransformMatrix::CreateTranslation(fToPosX, fToPosY);
- m_guiTransform = guiOffset * guiScaler;
- }
- else
- {
- m_guiTransform.Reset();
- m_guiScaleX = 1.0f;
- m_guiScaleY = 1.0f;
- }
- // reset our origin and camera
- while (m_origins.size())
- m_origins.pop();
- m_origins.push(CPoint(0, 0));
- while (m_cameras.size())
- m_cameras.pop();
- m_cameras.push(CPoint(0.5f*m_iScreenWidth, 0.5f*m_iScreenHeight));
-
- // and reset the final transform
- UpdateFinalTransform(m_guiTransform);
- Unlock();
-}
-
-void CGraphicContext::SetRenderingResolution(RESOLUTION res, bool needsScaling)
-{
- Lock();
- SetScalingResolution(res, needsScaling);
- UpdateCameraPosition(m_cameras.top());
- Unlock();
-}
-
-void CGraphicContext::UpdateFinalTransform(const TransformMatrix &matrix)
-{
- m_finalTransform = matrix;
- // We could set the world transform here to GPU-ize the animation system.
- // trouble is that we require the resulting x,y coords to be rounded to
- // the nearest pixel (vertex shader perhaps?)
-}
-
-void CGraphicContext::InvertFinalCoords(float &x, float &y) const
-{
- m_finalTransform.InverseTransformPosition(x, y);
-}
-
-float CGraphicContext::GetScalingPixelRatio() const
-{
- if (m_Resolution == m_windowResolution)
- return GetPixelRatio(m_windowResolution);
-
- RESOLUTION checkRes = m_windowResolution;
- if (checkRes == RES_INVALID)
- checkRes = m_Resolution;
- // resolutions are different - we want to return the aspect ratio of the video resolution
- // but only once it's been corrected for the skin -> screen coordinates scaling
- float winWidth = (float)g_settings.m_ResInfo[checkRes].iWidth;
- float winHeight = (float)g_settings.m_ResInfo[checkRes].iHeight;
- float outWidth = (float)g_settings.m_ResInfo[m_Resolution].iWidth;
- float outHeight = (float)g_settings.m_ResInfo[m_Resolution].iHeight;
- float outPR = GetPixelRatio(m_Resolution);
-
- return outPR * (outWidth / outHeight) / (winWidth / winHeight);
-}
-
-void CGraphicContext::SetCameraPosition(const CPoint &camera)
-{
- // offset the camera from our current location (this is in XML coordinates) and scale it up to
- // the screen resolution
- CPoint cam(camera);
- if (m_origins.size())
- cam += m_origins.top();
-
- RESOLUTION windowRes = (m_windowResolution == RES_INVALID) ? m_Resolution : m_windowResolution;
- cam.x *= (float)m_iScreenWidth / g_settings.m_ResInfo[windowRes].iWidth;
- cam.y *= (float)m_iScreenHeight / g_settings.m_ResInfo[windowRes].iHeight;
-
- m_cameras.push(cam);
- UpdateCameraPosition(m_cameras.top());
-}
-
-void CGraphicContext::RestoreCameraPosition()
-{ // remove the top camera from the stack
- ASSERT(m_cameras.size());
- m_cameras.pop();
- UpdateCameraPosition(m_cameras.top());
-}
-
-// NOTE: This routine is currently called (twice) every time there is a <camera>
-// tag in the skin. It actually only has to be called before we render
-// something, so another option is to just save the camera coordinates
-// and then have a routine called before every draw that checks whether
-// the camera has changed, and if so, changes it. Similarly, it could set
-// the world transform at that point as well (or even combine world + view
-// to cut down on one setting)
-void CGraphicContext::UpdateCameraPosition(const CPoint &camera)
-{
- g_Windowing.SetCameraPosition(camera, m_iScreenWidth, m_iScreenHeight);
-}
-
-bool CGraphicContext::RectIsAngled(float x1, float y1, float x2, float y2) const
-{ // need only test 3 points, as they must be co-planer
- if (m_finalTransform.TransformZCoord(x1, y1, 0)) return true;
- if (m_finalTransform.TransformZCoord(x2, y2, 0)) return true;
- if (m_finalTransform.TransformZCoord(x1, y2, 0)) return true;
- return false;
-}
-
-float CGraphicContext::GetFPS() const
-{
- if (m_Resolution != RES_INVALID)
- {
- if (g_settings.m_ResInfo[m_Resolution].fRefreshRate > 0)
- return g_settings.m_ResInfo[m_Resolution].fRefreshRate;
- if (m_Resolution == RES_PAL_4x3 || m_Resolution == RES_PAL_16x9)
- return 50.0f;
- if (m_Resolution == RES_HDTV_1080i)
- return 30.0f;
- }
- return 60.0f;
-}
-
-void CGraphicContext::BeginPaint(bool lock)
-{
- if (lock) Lock();
-}
-
-void CGraphicContext::EndPaint(bool lock)
-{
- if (lock) Unlock();
-}
-
-bool CGraphicContext::IsFullScreenRoot () const
-{
- return m_bFullScreenRoot;
-}
-
-bool CGraphicContext::ToggleFullScreenRoot ()
-{
- RESOLUTION newRes;
- RESOLUTION uiRes; ///< resolution to save - not necessarily the same as the one we switch to (e.g. during video playback)
-
- if (m_bFullScreenRoot)
- {
- newRes = uiRes = RES_WINDOW;
- }
- else
- {
- if (g_guiSettings.m_LookAndFeelResolution > RES_DESKTOP)
- newRes = g_guiSettings.m_LookAndFeelResolution;
- else
- newRes = RES_DESKTOP;
- uiRes = newRes;
-
-#if defined(HAS_VIDEO_PLAYBACK)
- if (g_graphicsContext.IsFullScreenVideo() || g_graphicsContext.IsCalibrating())
- {
- /* we need to trick renderer that we are fullscreen already so it gives us a valid value */
- m_bFullScreenRoot = true;
- newRes = g_renderManager.GetResolution();
- m_bFullScreenRoot = false;
- }
-#endif
- }
-
- SetVideoResolution(newRes);
- g_guiSettings.SetResolution(uiRes);
-
- return m_bFullScreenRoot;
-}
-
-void CGraphicContext::SetMediaDir(const CStdString &strMediaDir)
-{
- g_TextureManager.SetTexturePath(strMediaDir);
- m_strMediaDir = strMediaDir;
-}
-
-void CGraphicContext::Flip()
-{
- g_Windowing.PresentRender();
-}
-
-void CGraphicContext::ApplyHardwareTransform()
-{
- g_Windowing.ApplyHardwareTransform(m_finalTransform);
-}
-
-void CGraphicContext::RestoreHardwareTransform()
-{
- g_Windowing.RestoreHardwareTransform();
-}
-
-void CGraphicContext::GetAllowedResolutions(vector<RESOLUTION> &res)
-{
- res.clear();
-
- res.push_back(RES_WINDOW);
- res.push_back(RES_DESKTOP);
- for (size_t r = (size_t) RES_CUSTOM; r < g_settings.m_ResInfo.size(); r++)
- {
- res.push_back((RESOLUTION) r);
- }
-}
-
diff --git a/guilib/GraphicContext.h b/guilib/GraphicContext.h
deleted file mode 100644
index 3a1ac98ba1..0000000000
--- a/guilib/GraphicContext.h
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-/*!
-\file GraphicContext.h
-\brief
-*/
-
-#ifndef GUILIB_GRAPHICCONTEXT_H
-#define GUILIB_GRAPHICCONTEXT_H
-
-#pragma once
-
-#ifdef __GNUC__
-// under gcc, inline will only take place if optimizations are applied (-O). this will force inline even whith optimizations.
-#define XBMC_FORCE_INLINE __attribute__((always_inline))
-#else
-#define XBMC_FORCE_INLINE
-#endif
-
-
-#include <vector>
-#include <stack>
-#include <map>
-#include "utils/CriticalSection.h" // base class
-#include "TransformMatrix.h" // for the members m_guiTransform etc.
-#include "Geometry.h" // for CRect/CPoint
-#include "gui3d.h"
-#include "StdString.h"
-#include "Resolution.h"
-
-enum VIEW_TYPE { VIEW_TYPE_NONE = 0,
- VIEW_TYPE_LIST,
- VIEW_TYPE_ICON,
- VIEW_TYPE_BIG_LIST,
- VIEW_TYPE_BIG_ICON,
- VIEW_TYPE_WIDE,
- VIEW_TYPE_BIG_WIDE,
- VIEW_TYPE_WRAP,
- VIEW_TYPE_BIG_WRAP,
- VIEW_TYPE_AUTO,
- VIEW_TYPE_MAX };
-
-
-class CGraphicContext : public CCriticalSection
-{
-public:
- CGraphicContext(void);
- virtual ~CGraphicContext(void);
-
- // the following two functions should wrap any
- // GL calls to maintain thread safety
- void BeginPaint(bool lock=true);
- void EndPaint(bool lock=true);
-
- int GetWidth() const { return m_iScreenWidth; }
- int GetHeight() const { return m_iScreenHeight; }
- float GetFPS() const;
- const CStdString& GetMediaDir() const { return m_strMediaDir; }
- void SetMediaDir(const CStdString& strMediaDir);
- bool SetViewPort(float fx, float fy , float fwidth, float fheight, bool intersectPrevious = false);
- void RestoreViewPort();
- const CRect GetViewWindow() const;
- void SetViewWindow(float left, float top, float right, float bottom);
- bool IsFullScreenRoot() const;
- bool ToggleFullScreenRoot();
- void SetFullScreenVideo(bool bOnOff);
- bool IsFullScreenVideo() const;
- bool IsCalibrating() const;
- void SetCalibrating(bool bOnOff);
- bool IsValidResolution(RESOLUTION res);
- void SetVideoResolution(RESOLUTION res, bool forceUpdate = false);
- RESOLUTION GetVideoResolution() const;
- void ResetOverscan(RESOLUTION res, OVERSCAN &overscan);
- void ResetOverscan(RESOLUTION_INFO &resinfo);
- void ResetScreenParameters(RESOLUTION res);
- void Lock() { EnterCriticalSection(*this); }
- void Unlock() { LeaveCriticalSection(*this); }
- float GetPixelRatio(RESOLUTION iRes) const;
- void CaptureStateBlock();
- void ApplyStateBlock();
- void Clear(color_t color = 0);
- void GetAllowedResolutions(std::vector<RESOLUTION> &res);
-
- // output scaling
- void SetRenderingResolution(RESOLUTION res, bool needsScaling); ///< Sets scaling up for rendering
- void SetScalingResolution(RESOLUTION res, bool needsScaling); ///< Sets scaling up for skin loading etc.
- float GetScalingPixelRatio() const;
- void Flip();
- void InvertFinalCoords(float &x, float &y) const;
- inline float ScaleFinalXCoord(float x, float y) const XBMC_FORCE_INLINE { return m_finalTransform.TransformXCoord(x, y, 0); }
- inline float ScaleFinalYCoord(float x, float y) const XBMC_FORCE_INLINE { return m_finalTransform.TransformYCoord(x, y, 0); }
- inline float ScaleFinalZCoord(float x, float y) const XBMC_FORCE_INLINE { return m_finalTransform.TransformZCoord(x, y, 0); }
- inline void ScaleFinalCoords(float &x, float &y, float &z) const XBMC_FORCE_INLINE { m_finalTransform.TransformPosition(x, y, z); }
- bool RectIsAngled(float x1, float y1, float x2, float y2) const;
-
- inline float GetGUIScaleX() const XBMC_FORCE_INLINE { return m_guiScaleX; }
- inline float GetGUIScaleY() const XBMC_FORCE_INLINE { return m_guiScaleY; }
- inline color_t MergeAlpha(color_t color) const XBMC_FORCE_INLINE
- {
- color_t alpha = m_finalTransform.TransformAlpha((color >> 24) & 0xff);
- if (alpha > 255) alpha = 255;
- return ((alpha << 24) & 0xff000000) | (color & 0xffffff);
- }
-
- void SetOrigin(float x, float y);
- void RestoreOrigin();
- void SetCameraPosition(const CPoint &camera);
- void RestoreCameraPosition();
- /*! \brief Set a region in which to clip all rendering
- Anything that is rendered after setting a clip region will be clipped so that no part renders
- outside of the clip region. Successive calls to SetClipRegion intersect the clip region, which
- means the clip region may eventually become an empty set. In this case SetClipRegion returns false
- to indicate that no rendering need be performed.
-
- This call must be matched with a RestoreClipRegion call unless SetClipRegion returns false.
-
- Usage should be of the form:
-
- if (SetClipRegion(x, y, w, h))
- {
- ...
- perform rendering
- ...
- RestoreClipRegion();
- }
-
- \param x the left-most coordinate of the clip region
- \param y the top-most coordinate of the clip region
- \param w the width of the clip region
- \param h the height of the clip region
- \returns true if the region is set and the result is non-empty. Returns false if the resulting region is empty.
- \sa RestoreClipRegion
- */
- bool SetClipRegion(float x, float y, float w, float h);
-
- /*! \brief Restore a clip region to the previous clip region (if any) prior to the last SetClipRegion call
- This function should be within an if (SetClipRegion(x,y,w,h)) block.
- \sa SetClipRegion
- */
- void RestoreClipRegion();
- void ApplyHardwareTransform();
- void RestoreHardwareTransform();
- void ClipRect(CRect &vertex, CRect &texture, CRect *diffuse = NULL);
- inline void ResetWindowTransform()
- {
- while (m_groupTransform.size())
- m_groupTransform.pop();
- m_groupTransform.push(m_guiTransform);
- }
- inline void AddTransform(const TransformMatrix &matrix)
- {
- ASSERT(m_groupTransform.size());
- if (m_groupTransform.size())
- m_groupTransform.push(m_groupTransform.top() * matrix);
- else
- m_groupTransform.push(matrix);
- UpdateFinalTransform(m_groupTransform.top());
- }
- inline void RemoveTransform()
- {
- ASSERT(m_groupTransform.size() > 1);
- if (m_groupTransform.size())
- m_groupTransform.pop();
- if (m_groupTransform.size())
- UpdateFinalTransform(m_groupTransform.top());
- else
- UpdateFinalTransform(TransformMatrix());
- }
-
-protected:
- std::stack<CRect> m_viewStack;
-
- int m_iScreenHeight;
- int m_iScreenWidth;
- int m_iScreenId;
- CStdString m_strMediaDir;
- CRect m_videoRect;
- bool m_bFullScreenRoot;
- bool m_bFullScreenVideo;
- bool m_bCalibrating;
- RESOLUTION m_Resolution;
-
-private:
- void UpdateCameraPosition(const CPoint &camera);
- void UpdateFinalTransform(const TransformMatrix &matrix);
- RESOLUTION m_windowResolution;
- float m_guiScaleX;
- float m_guiScaleY;
- std::stack<CPoint> m_cameras;
- std::stack<CPoint> m_origins;
- std::stack<CRect> m_clipRegions;
-
- TransformMatrix m_guiTransform;
- TransformMatrix m_finalTransform;
- std::stack<TransformMatrix> m_groupTransform;
-};
-
-/*!
- \ingroup graphics
- \brief
- */
-extern CGraphicContext g_graphicsContext;
-#endif
diff --git a/guilib/IAudioDeviceChangedCallback.h b/guilib/IAudioDeviceChangedCallback.h
deleted file mode 100644
index c9d55b7a23..0000000000
--- a/guilib/IAudioDeviceChangedCallback.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-class IAudioDeviceChangedCallback
-{
-public:
- virtual void Initialize(int iDevice)=0;
- virtual void DeInitialize(int iDevice)=0;
- virtual ~IAudioDeviceChangedCallback() {}
-};
-
diff --git a/guilib/IMsgTargetCallback.h b/guilib/IMsgTargetCallback.h
deleted file mode 100644
index 7af60fded2..0000000000
--- a/guilib/IMsgTargetCallback.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*!
-\file IMsgTargetCallback.h
-\brief
-*/
-
-#ifndef GUILIB_IMSGTARGETCALLBACK
-#define GUILIB_IMSGTARGETCALLBACK
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "GUIMessage.h"
-
-/*!
- \ingroup winman
- \brief
- */
-class IMsgTargetCallback
-{
-public:
- virtual bool OnMessage(CGUIMessage& message) = 0;
- virtual ~IMsgTargetCallback() {}
-};
-
-#endif
diff --git a/guilib/IWindowManagerCallback.cpp b/guilib/IWindowManagerCallback.cpp
deleted file mode 100644
index a47634c498..0000000000
--- a/guilib/IWindowManagerCallback.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "IWindowManagerCallback.h"
-
-
-IWindowManagerCallback::IWindowManagerCallback(void)
-{}
-
-IWindowManagerCallback::~IWindowManagerCallback(void)
-{}
diff --git a/guilib/IWindowManagerCallback.h b/guilib/IWindowManagerCallback.h
deleted file mode 100644
index 25391b228c..0000000000
--- a/guilib/IWindowManagerCallback.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*!
-\file IWindowManagerCallback.h
-\brief
-*/
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-/*!
- \ingroup winman
- \brief
- */
-class IWindowManagerCallback
-{
-public:
- IWindowManagerCallback(void);
- virtual ~IWindowManagerCallback(void);
-
- virtual void FrameMove() = 0;
- virtual void Render() = 0;
- virtual void Process() = 0;
-};
diff --git a/guilib/Key.cpp b/guilib/Key.cpp
deleted file mode 100644
index 12f6a6408a..0000000000
--- a/guilib/Key.cpp
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "system.h"
-#include "Key.h"
-
-CKey::CKey(void)
-{
- Reset();
-}
-
-CKey::~CKey(void)
-{}
-
-CKey::CKey(uint32_t buttonCode, uint8_t leftTrigger, uint8_t rightTrigger, float leftThumbX, float leftThumbY, float rightThumbX, float rightThumbY, float repeat)
-{
- Reset();
- m_buttonCode = buttonCode;
- m_leftTrigger = leftTrigger;
- m_rightTrigger = rightTrigger;
- m_leftThumbX = leftThumbX;
- m_leftThumbY = leftThumbY;
- m_rightThumbX = rightThumbX;
- m_rightThumbY = rightThumbY;
- m_repeat = repeat;
-}
-
-CKey::CKey(uint32_t buttonCode, unsigned int held)
-{
- Reset();
- m_buttonCode = buttonCode;
- m_held = held;
-}
-
-CKey::CKey(uint8_t vkey, wchar_t unicode, char ascii, uint32_t modifiers, unsigned int held)
-{
- Reset();
- if (vkey) // FIXME: This needs cleaning up - should we always use the unicode key where available?
- m_buttonCode = vkey | KEY_VKEY;
- else
- m_buttonCode = KEY_UNICODE;
- m_buttonCode |= modifiers;
- m_vkey = vkey;
- m_unicode = unicode;
- m_ascii = ascii;
- m_modifiers = modifiers;
- m_held = held;
-}
-
-CKey::CKey(const CKey& key)
-{
- *this = key;
-}
-
-void CKey::Reset()
-{
- m_leftTrigger = 0;
- m_rightTrigger = 0;
- m_leftThumbX = 0.0f;
- m_leftThumbY = 0.0f;
- m_rightThumbX = 0.0f;
- m_rightThumbY = 0.0f;
- m_repeat = 0.0f;
- m_fromHttpApi = false;
- m_buttonCode = KEY_INVALID;
- m_vkey = 0;
- m_unicode = 0;
- m_ascii = 0;
- m_modifiers = 0;
- m_held = 0;
-}
-
-const CKey& CKey::operator=(const CKey& key)
-{
- if (&key == this) return * this;
- m_leftTrigger = key.m_leftTrigger;
- m_rightTrigger = key.m_rightTrigger;
- m_leftThumbX = key.m_leftThumbX;
- m_leftThumbY = key.m_leftThumbY;
- m_rightThumbX = key.m_rightThumbX;
- m_rightThumbY = key.m_rightThumbY;
- m_repeat = key.m_repeat;
- m_fromHttpApi = key.m_fromHttpApi;
- m_buttonCode = key.m_buttonCode;
- m_vkey = key.m_vkey;
- m_unicode = key.m_unicode;
- m_ascii = key.m_ascii;
- m_modifiers = key.m_modifiers;
- m_held = key.m_held;
- return *this;
-}
-
-BYTE CKey::GetLeftTrigger() const
-{
- return m_leftTrigger;
-}
-
-BYTE CKey::GetRightTrigger() const
-{
- return m_rightTrigger;
-}
-
-float CKey::GetLeftThumbX() const
-{
- return m_leftThumbX;
-}
-
-float CKey::GetLeftThumbY() const
-{
- return m_leftThumbY;
-}
-
-
-float CKey::GetRightThumbX() const
-{
- return m_rightThumbX;
-}
-
-float CKey::GetRightThumbY() const
-{
- return m_rightThumbY;
-}
-
-bool CKey::FromKeyboard() const
-{
- return (m_buttonCode >= KEY_VKEY && m_buttonCode != KEY_INVALID);
-}
-
-bool CKey::IsAnalogButton() const
-{
- if ((GetButtonCode() > 261 && GetButtonCode() < 270) || (GetButtonCode() > 279 && GetButtonCode() < 284))
- return true;
-
- return false;
-}
-
-bool CKey::IsIRRemote() const
-{
- if (GetButtonCode() < 256)
- return true;
- return false;
-}
-
-float CKey::GetRepeat() const
-{
- return m_repeat;
-}
-
-bool CKey::GetFromHttpApi() const
-{
- return m_fromHttpApi;
-}
-
-void CKey::SetFromHttpApi(bool bFromHttpApi)
-{
- m_fromHttpApi = bFromHttpApi;
-}
-
-CAction::CAction(int actionID, float amount1 /* = 1.0f */, float amount2 /* = 0.0f */, const CStdString &name /* = "" */)
-{
- m_id = actionID;
- m_amount[0] = amount1;
- m_amount[1] = amount2;
- for (unsigned int i = 2; i < max_amounts; i++)
- m_amount[i] = 0;
- m_name = name;
- m_repeat = 0;
- m_buttonCode = 0;
- m_unicode = 0;
- m_holdTime = 0;
-}
-
-CAction::CAction(int actionID, unsigned int state, float posX, float posY, float offsetX, float offsetY)
-{
- m_id = actionID;
- m_amount[0] = posX;
- m_amount[1] = posY;
- m_amount[2] = offsetX;
- m_amount[3] = offsetY;
- for (unsigned int i = 4; i < max_amounts; i++)
- m_amount[i] = 0;
- m_repeat = 0;
- m_buttonCode = 0;
- m_unicode = 0;
- m_holdTime = state;
-}
-
-CAction::CAction(int actionID, wchar_t unicode)
-{
- m_id = actionID;
- for (unsigned int i = 0; i < max_amounts; i++)
- m_amount[i] = 0;
- m_repeat = 0;
- m_buttonCode = 0;
- m_unicode = unicode;
- m_holdTime = 0;
-}
-
-CAction::CAction(int actionID, const CStdString &name, const CKey &key)
-{
- m_id = actionID;
- m_name = name;
- m_amount[0] = 1; // digital button (could change this for repeat acceleration)
- for (unsigned int i = 1; i < max_amounts; i++)
- m_amount[i] = 0;
- m_repeat = key.GetRepeat();
- m_buttonCode = key.GetButtonCode();
- m_unicode = 0;
- m_holdTime = key.GetHeld();
- // get the action amounts of the analog buttons
- if (key.GetButtonCode() == KEY_BUTTON_LEFT_ANALOG_TRIGGER)
- m_amount[0] = (float)key.GetLeftTrigger() / 255.0f;
- else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_ANALOG_TRIGGER)
- m_amount[0] = (float)key.GetRightTrigger() / 255.0f;
- else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK)
- {
- m_amount[0] = key.GetLeftThumbX();
- m_amount[1] = key.GetLeftThumbY();
- }
- else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK)
- {
- m_amount[0] = key.GetRightThumbX();
- m_amount[1] = key.GetRightThumbY();
- }
- else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK_UP)
- m_amount[0] = key.GetLeftThumbY();
- else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK_DOWN)
- m_amount[0] = -key.GetLeftThumbY();
- else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK_LEFT)
- m_amount[0] = -key.GetLeftThumbX();
- else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK_RIGHT)
- m_amount[0] = key.GetLeftThumbX();
- else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK_UP)
- m_amount[0] = key.GetRightThumbY();
- else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK_DOWN)
- m_amount[0] = -key.GetRightThumbY();
- else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK_LEFT)
- m_amount[0] = -key.GetRightThumbX();
- else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK_RIGHT)
- m_amount[0] = key.GetRightThumbX();
-}
diff --git a/guilib/Key.h b/guilib/Key.h
deleted file mode 100644
index d50f60a404..0000000000
--- a/guilib/Key.h
+++ /dev/null
@@ -1,565 +0,0 @@
-/*!
- \file Key.h
- \brief
- */
-
-#ifndef GUILIB_KEY
-#define GUILIB_KEY
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "XBIRRemote.h"
-#include <StdString.h>
-
-// Analogue - don't change order
-#define KEY_BUTTON_A 256
-#define KEY_BUTTON_B 257
-#define KEY_BUTTON_X 258
-#define KEY_BUTTON_Y 259
-#define KEY_BUTTON_BLACK 260
-#define KEY_BUTTON_WHITE 261
-#define KEY_BUTTON_LEFT_TRIGGER 262
-#define KEY_BUTTON_RIGHT_TRIGGER 263
-
-#define KEY_BUTTON_LEFT_THUMB_STICK 264
-#define KEY_BUTTON_RIGHT_THUMB_STICK 265
-
-#define KEY_BUTTON_RIGHT_THUMB_STICK_UP 266 // right thumb stick directions
-#define KEY_BUTTON_RIGHT_THUMB_STICK_DOWN 267 // for defining different actions per direction
-#define KEY_BUTTON_RIGHT_THUMB_STICK_LEFT 268
-#define KEY_BUTTON_RIGHT_THUMB_STICK_RIGHT 269
-
-// Digital - don't change order
-#define KEY_BUTTON_DPAD_UP 270
-#define KEY_BUTTON_DPAD_DOWN 271
-#define KEY_BUTTON_DPAD_LEFT 272
-#define KEY_BUTTON_DPAD_RIGHT 273
-
-#define KEY_BUTTON_START 274
-#define KEY_BUTTON_BACK 275
-
-#define KEY_BUTTON_LEFT_THUMB_BUTTON 276
-#define KEY_BUTTON_RIGHT_THUMB_BUTTON 277
-
-#define KEY_BUTTON_LEFT_ANALOG_TRIGGER 278
-#define KEY_BUTTON_RIGHT_ANALOG_TRIGGER 279
-
-#define KEY_BUTTON_LEFT_THUMB_STICK_UP 280 // left thumb stick directions
-#define KEY_BUTTON_LEFT_THUMB_STICK_DOWN 281 // for defining different actions per direction
-#define KEY_BUTTON_LEFT_THUMB_STICK_LEFT 282
-#define KEY_BUTTON_LEFT_THUMB_STICK_RIGHT 283
-
-#define KEY_VMOUSE 0xEFFF
-
-// 0xF000 -> 0xF200 is reserved for the keyboard; a keyboard press is either
-#define KEY_VKEY 0xF000 // a virtual key/functional key e.g. cursor left
-#define KEY_ASCII 0xF100 // a printable character in the range of TRUE ASCII (from 0 to 127) // FIXME make it clean and pure unicode! remove the need for KEY_ASCII
-#define KEY_UNICODE 0xF200 // another printable character whose range is not included in this KEY code
-
-#define KEY_INVALID 0xFFFF
-
-// actions that we have defined...
-#define ACTION_NONE 0
-#define ACTION_MOVE_LEFT 1
-#define ACTION_MOVE_RIGHT 2
-#define ACTION_MOVE_UP 3
-#define ACTION_MOVE_DOWN 4
-#define ACTION_PAGE_UP 5
-#define ACTION_PAGE_DOWN 6
-#define ACTION_SELECT_ITEM 7
-#define ACTION_HIGHLIGHT_ITEM 8
-#define ACTION_PARENT_DIR 9
-#define ACTION_PREVIOUS_MENU 10
-#define ACTION_SHOW_INFO 11
-
-#define ACTION_PAUSE 12
-#define ACTION_STOP 13
-#define ACTION_NEXT_ITEM 14
-#define ACTION_PREV_ITEM 15
-#define ACTION_FORWARD 16 // Can be used to specify specific action in a window, Playback control is handled in ACTION_PLAYER_*
-#define ACTION_REWIND 17 // Can be used to specify specific action in a window, Playback control is handled in ACTION_PLAYER_*
-
-#define ACTION_SHOW_GUI 18 // toggle between GUI and movie or GUI and visualisation.
-#define ACTION_ASPECT_RATIO 19 // toggle quick-access zoom modes. Can b used in videoFullScreen.zml window id=2005
-#define ACTION_STEP_FORWARD 20 // seek +1% in the movie. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_STEP_BACK 21 // seek -1% in the movie. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_BIG_STEP_FORWARD 22 // seek +10% in the movie. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_BIG_STEP_BACK 23 // seek -10% in the movie. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_SHOW_OSD 24 // show/hide OSD. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_SHOW_SUBTITLES 25 // turn subtitles on/off. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_NEXT_SUBTITLE 26 // switch to next subtitle of movie. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_SHOW_CODEC 27 // show information about file. Can b used in videoFullScreen.xml window id=2005 and in slideshow.xml window id=2007
-#define ACTION_NEXT_PICTURE 28 // show next picture of slideshow. Can b used in slideshow.xml window id=2007
-#define ACTION_PREV_PICTURE 29 // show previous picture of slideshow. Can b used in slideshow.xml window id=2007
-#define ACTION_ZOOM_OUT 30 // zoom in picture during slideshow. Can b used in slideshow.xml window id=2007
-#define ACTION_ZOOM_IN 31 // zoom out picture during slideshow. Can b used in slideshow.xml window id=2007
-#define ACTION_TOGGLE_SOURCE_DEST 32 // used to toggle between source view and destination view. Can be used in myfiles.xml window id=3
-#define ACTION_SHOW_PLAYLIST 33 // used to toggle between current view and playlist view. Can b used in all mymusic xml files
-#define ACTION_QUEUE_ITEM 34 // used to queue a item to the playlist. Can b used in all mymusic xml files
-#define ACTION_REMOVE_ITEM 35 // not used anymore
-#define ACTION_SHOW_FULLSCREEN 36 // not used anymore
-#define ACTION_ZOOM_LEVEL_NORMAL 37 // zoom 1x picture during slideshow. Can b used in slideshow.xml window id=2007
-#define ACTION_ZOOM_LEVEL_1 38 // zoom 2x picture during slideshow. Can b used in slideshow.xml window id=2007
-#define ACTION_ZOOM_LEVEL_2 39 // zoom 3x picture during slideshow. Can b used in slideshow.xml window id=2007
-#define ACTION_ZOOM_LEVEL_3 40 // zoom 4x picture during slideshow. Can b used in slideshow.xml window id=2007
-#define ACTION_ZOOM_LEVEL_4 41 // zoom 5x picture during slideshow. Can b used in slideshow.xml window id=2007
-#define ACTION_ZOOM_LEVEL_5 42 // zoom 6x picture during slideshow. Can b used in slideshow.xml window id=2007
-#define ACTION_ZOOM_LEVEL_6 43 // zoom 7x picture during slideshow. Can b used in slideshow.xml window id=2007
-#define ACTION_ZOOM_LEVEL_7 44 // zoom 8x picture during slideshow. Can b used in slideshow.xml window id=2007
-#define ACTION_ZOOM_LEVEL_8 45 // zoom 9x picture during slideshow. Can b used in slideshow.xml window id=2007
-#define ACTION_ZOOM_LEVEL_9 46 // zoom 10x picture during slideshow. Can b used in slideshow.xml window id=2007
-
-#define ACTION_CALIBRATE_SWAP_ARROWS 47 // select next arrow. Can b used in: settingsScreenCalibration.xml windowid=11
-#define ACTION_CALIBRATE_RESET 48 // reset calibration to defaults. Can b used in: settingsScreenCalibration.xml windowid=11/settingsUICalibration.xml windowid=10
-#define ACTION_ANALOG_MOVE 49 // analog thumbstick move. Can b used in: slideshow.xml window id=2007/settingsScreenCalibration.xml windowid=11/settingsUICalibration.xml windowid=10
-#define ACTION_ROTATE_PICTURE 50 // rotate current picture during slideshow. Can b used in slideshow.xml window id=2007
-#define ACTION_CLOSE_DIALOG 51 // action for closing the dialog. Can b used in any dialog
-#define ACTION_SUBTITLE_DELAY_MIN 52 // Decrease subtitle/movie Delay. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_SUBTITLE_DELAY_PLUS 53 // Increase subtitle/movie Delay. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_AUDIO_DELAY_MIN 54 // Increase avsync delay. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_AUDIO_DELAY_PLUS 55 // Decrease avsync delay. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_AUDIO_NEXT_LANGUAGE 56 // Select next language in movie. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_CHANGE_RESOLUTION 57 // switch 2 next resolution. Can b used during screen calibration settingsScreenCalibration.xml windowid=11
-
-#define REMOTE_0 58 // remote keys 0-9. are used by multiple windows
-#define REMOTE_1 59 // for example in videoFullScreen.xml window id=2005 you can
-#define REMOTE_2 60 // enter time (mmss) to jump to particular point in the movie
-#define REMOTE_3 61
-#define REMOTE_4 62 // with spincontrols you can enter 3digit number to quickly set
-#define REMOTE_5 63 // spincontrol to desired value
-#define REMOTE_6 64
-#define REMOTE_7 65
-#define REMOTE_8 66
-#define REMOTE_9 67
-
-#define ACTION_PLAY 68 // Unused at the moment
-#define ACTION_OSD_SHOW_LEFT 69 // Move left in OSD. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_OSD_SHOW_RIGHT 70 // Move right in OSD. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_OSD_SHOW_UP 71 // Move up in OSD. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_OSD_SHOW_DOWN 72 // Move down in OSD. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_OSD_SHOW_SELECT 73 // toggle/select option in OSD. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_OSD_SHOW_VALUE_PLUS 74 // increase value of current option in OSD. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_OSD_SHOW_VALUE_MIN 75 // decrease value of current option in OSD. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_SMALL_STEP_BACK 76 // jumps a few seconds back during playback of movie. Can b used in videoFullScreen.xml window id=2005
-
-#define ACTION_PLAYER_FORWARD 77 // FF in current file played. global action, can be used anywhere
-#define ACTION_PLAYER_REWIND 78 // RW in current file played. global action, can be used anywhere
-#define ACTION_PLAYER_PLAY 79 // Play current song. Unpauses song and sets playspeed to 1x. global action, can be used anywhere
-
-#define ACTION_DELETE_ITEM 80 // delete current selected item. Can be used in myfiles.xml window id=3 and in myvideoTitle.xml window id=25
-#define ACTION_COPY_ITEM 81 // copy current selected item. Can be used in myfiles.xml window id=3
-#define ACTION_MOVE_ITEM 82 // move current selected item. Can be used in myfiles.xml window id=3
-#define ACTION_SHOW_MPLAYER_OSD 83 // toggles mplayers OSD. Can be used in videofullscreen.xml window id=2005
-#define ACTION_OSD_HIDESUBMENU 84 // removes an OSD sub menu. Can be used in videoOSD.xml window id=2901
-#define ACTION_TAKE_SCREENSHOT 85 // take a screenshot
-#define ACTION_RENAME_ITEM 87 // rename item
-
-#define ACTION_VOLUME_UP 88
-#define ACTION_VOLUME_DOWN 89
-#define ACTION_MUTE 91
-
-#define ACTION_MOUSE_START 100
-#define ACTION_MOUSE_LEFT_CLICK 100
-#define ACTION_MOUSE_RIGHT_CLICK 101
-#define ACTION_MOUSE_MIDDLE_CLICK 102
-#define ACTION_MOUSE_DOUBLE_CLICK 103
-#define ACTION_MOUSE_WHEEL_UP 104
-#define ACTION_MOUSE_WHEEL_DOWN 105
-#define ACTION_MOUSE_DRAG 106
-#define ACTION_MOUSE_MOVE 107
-#define ACTION_MOUSE_END 109
-
-#define ACTION_BACKSPACE 110
-#define ACTION_SCROLL_UP 111
-#define ACTION_SCROLL_DOWN 112
-#define ACTION_ANALOG_FORWARD 113
-#define ACTION_ANALOG_REWIND 114
-
-#define ACTION_MOVE_ITEM_UP 115 // move item up in playlist
-#define ACTION_MOVE_ITEM_DOWN 116 // move item down in playlist
-#define ACTION_CONTEXT_MENU 117 // pops up the context menu
-
-
-// stuff for virtual keyboard shortcuts
-#define ACTION_SHIFT 118
-#define ACTION_SYMBOLS 119
-#define ACTION_CURSOR_LEFT 120
-#define ACTION_CURSOR_RIGHT 121
-
-#define ACTION_BUILT_IN_FUNCTION 122
-
-#define ACTION_SHOW_OSD_TIME 123 // displays current time, can be used in videoFullScreen.xml window id=2005
-#define ACTION_ANALOG_SEEK_FORWARD 124 // seeks forward, and displays the seek bar.
-#define ACTION_ANALOG_SEEK_BACK 125 // seeks backward, and displays the seek bar.
-
-#define ACTION_VIS_PRESET_SHOW 126
-#define ACTION_VIS_PRESET_LIST 127
-#define ACTION_VIS_PRESET_NEXT 128
-#define ACTION_VIS_PRESET_PREV 129
-#define ACTION_VIS_PRESET_LOCK 130
-#define ACTION_VIS_PRESET_RANDOM 131
-#define ACTION_VIS_RATE_PRESET_PLUS 132
-#define ACTION_VIS_RATE_PRESET_MINUS 133
-
-#define ACTION_SHOW_VIDEOMENU 134
-#define ACTION_ENTER 135
-
-#define ACTION_INCREASE_RATING 136
-#define ACTION_DECREASE_RATING 137
-
-#define ACTION_NEXT_SCENE 138 // switch to next scene/cutpoint in movie
-#define ACTION_PREV_SCENE 139 // switch to previous scene/cutpoint in movie
-
-#define ACTION_NEXT_LETTER 140 // jump through a list or container by letter
-#define ACTION_PREV_LETTER 141
-
-#define ACTION_JUMP_SMS2 142 // jump direct to a particular letter using SMS-style input
-#define ACTION_JUMP_SMS3 143
-#define ACTION_JUMP_SMS4 144
-#define ACTION_JUMP_SMS5 145
-#define ACTION_JUMP_SMS6 146
-#define ACTION_JUMP_SMS7 147
-#define ACTION_JUMP_SMS8 148
-#define ACTION_JUMP_SMS9 149
-
-#define ACTION_FILTER_CLEAR 150
-#define ACTION_FILTER_SMS2 151
-#define ACTION_FILTER_SMS3 152
-#define ACTION_FILTER_SMS4 153
-#define ACTION_FILTER_SMS5 154
-#define ACTION_FILTER_SMS6 155
-#define ACTION_FILTER_SMS7 156
-#define ACTION_FILTER_SMS8 157
-#define ACTION_FILTER_SMS9 158
-
-#define ACTION_FIRST_PAGE 159
-#define ACTION_LAST_PAGE 160
-
-#define ACTION_AUDIO_DELAY 161
-#define ACTION_SUBTITLE_DELAY 162
-
-#define ACTION_PASTE 180
-#define ACTION_NEXT_CONTROL 181
-#define ACTION_PREV_CONTROL 182
-#define ACTION_CHANNEL_SWITCH 183
-
-#define ACTION_TOGGLE_FULLSCREEN 199 // switch 2 desktop resolution
-#define ACTION_TOGGLE_WATCHED 200 // Toggle watched status (videos)
-#define ACTION_SCAN_ITEM 201 // scan item
-#define ACTION_TOGGLE_DIGITAL_ANALOG 202 // switch digital <-> analog
-#define ACTION_RELOAD_KEYMAPS 203 // reloads CButtonTranslator's keymaps
-#define ACTION_GUIPROFILE_BEGIN 204 // start the GUIControlProfiler running
-
-#define ACTION_TELETEXT_RED 215 // Teletext Color buttons to control TopText
-#define ACTION_TELETEXT_GREEN 216 // " " " " " "
-#define ACTION_TELETEXT_YELLOW 217 // " " " " " "
-#define ACTION_TELETEXT_BLUE 218 // " " " " " "
-
-#define ACTION_INCREASE_PAR 219
-#define ACTION_DECREASE_PAR 220
-
-#define ACTION_GESTURE_NOTIFY 221
-#define ACTION_GESTURE_BEGIN 222
-#define ACTION_GESTURE_ZOOM 223
-#define ACTION_GESTURE_ROTATE 224
-#define ACTION_GESTURE_PAN 225
-#define ACTION_GESTURE_END 226
-#define ACTION_VSHIFT_UP 227 // shift up video image in DVDPlayer
-#define ACTION_VSHIFT_DOWN 228 // shift down video image in DVDPlayer
-
-#define ACTION_PLAYER_PLAYPAUSE 227 // Play/pause. If playing it pauses, if paused it plays.
-
-// Window ID defines to make the code a bit more readable
-#define WINDOW_INVALID 9999
-#define WINDOW_HOME 10000
-#define WINDOW_PROGRAMS 10001
-#define WINDOW_PICTURES 10002
-#define WINDOW_FILES 10003
-#define WINDOW_SETTINGS_MENU 10004
-#define WINDOW_MUSIC 10005 // virtual window to return the music start window.
-#define WINDOW_VIDEOS 10006
-#define WINDOW_SYSTEM_INFORMATION 10007
-#define WINDOW_TEST_PATTERN 10008
-#define WINDOW_SCREEN_CALIBRATION 10011
-
-#define WINDOW_SETTINGS_MYPICTURES 10012
-#define WINDOW_SETTINGS_MYPROGRAMS 10013
-#define WINDOW_SETTINGS_MYWEATHER 10014
-#define WINDOW_SETTINGS_MYMUSIC 10015
-#define WINDOW_SETTINGS_SYSTEM 10016
-#define WINDOW_SETTINGS_MYVIDEOS 10017
-#define WINDOW_SETTINGS_NETWORK 10018
-#define WINDOW_SETTINGS_APPEARANCE 10019
-
-#define WINDOW_SCRIPTS 10020 // virtual window for backward compatibility
-
-#define WINDOW_VIDEO_FILES 10024
-#define WINDOW_VIDEO_NAV 10025
-#define WINDOW_VIDEO_PLAYLIST 10028
-
-#define WINDOW_LOGIN_SCREEN 10029
-#define WINDOW_SETTINGS_PROFILES 10034
-
-#define WINDOW_ADDON_BROWSER 10040
-
-#define WINDOW_DIALOG_YES_NO 10100
-#define WINDOW_DIALOG_PROGRESS 10101
-#define WINDOW_DIALOG_KEYBOARD 10103
-#define WINDOW_DIALOG_VOLUME_BAR 10104
-#define WINDOW_DIALOG_SUB_MENU 10105
-#define WINDOW_DIALOG_CONTEXT_MENU 10106
-#define WINDOW_DIALOG_KAI_TOAST 10107
-#define WINDOW_DIALOG_NUMERIC 10109
-#define WINDOW_DIALOG_GAMEPAD 10110
-#define WINDOW_DIALOG_BUTTON_MENU 10111
-#define WINDOW_DIALOG_MUSIC_SCAN 10112
-#define WINDOW_DIALOG_MUTE_BUG 10113
-#define WINDOW_DIALOG_PLAYER_CONTROLS 10114
-#define WINDOW_DIALOG_SEEK_BAR 10115
-#define WINDOW_DIALOG_MUSIC_OSD 10120
-#define WINDOW_DIALOG_VIS_SETTINGS 10121
-#define WINDOW_DIALOG_VIS_PRESET_LIST 10122
-#define WINDOW_DIALOG_VIDEO_OSD_SETTINGS 10123
-#define WINDOW_DIALOG_AUDIO_OSD_SETTINGS 10124
-#define WINDOW_DIALOG_VIDEO_BOOKMARKS 10125
-#define WINDOW_DIALOG_FILE_BROWSER 10126
-#define WINDOW_DIALOG_NETWORK_SETUP 10128
-#define WINDOW_DIALOG_MEDIA_SOURCE 10129
-#define WINDOW_DIALOG_PROFILE_SETTINGS 10130
-#define WINDOW_DIALOG_LOCK_SETTINGS 10131
-#define WINDOW_DIALOG_CONTENT_SETTINGS 10132
-#define WINDOW_DIALOG_VIDEO_SCAN 10133
-#define WINDOW_DIALOG_FAVOURITES 10134
-#define WINDOW_DIALOG_SONG_INFO 10135
-#define WINDOW_DIALOG_SMART_PLAYLIST_EDITOR 10136
-#define WINDOW_DIALOG_SMART_PLAYLIST_RULE 10137
-#define WINDOW_DIALOG_BUSY 10138
-#define WINDOW_DIALOG_PICTURE_INFO 10139
-#define WINDOW_DIALOG_ADDON_SETTINGS 10140
-#define WINDOW_DIALOG_ACCESS_POINTS 10141
-#define WINDOW_DIALOG_FULLSCREEN_INFO 10142
-#define WINDOW_DIALOG_KARAOKE_SONGSELECT 10143
-#define WINDOW_DIALOG_KARAOKE_SELECTOR 10144
-#define WINDOW_DIALOG_SLIDER 10145
-#define WINDOW_DIALOG_ADDON_INFO 10146
-#define WINDOW_DIALOG_TEXT_VIEWER 10147
-
-#define WINDOW_MUSIC_PLAYLIST 10500
-#define WINDOW_MUSIC_FILES 10501
-#define WINDOW_MUSIC_NAV 10502
-#define WINDOW_MUSIC_PLAYLIST_EDITOR 10503
-
-#define WINDOW_DIALOG_OSD_TELETEXT 10600
-
-//#define WINDOW_VIRTUAL_KEYBOARD 11000
-#define WINDOW_DIALOG_SELECT 12000
-#define WINDOW_MUSIC_INFO 12001
-#define WINDOW_DIALOG_OK 12002
-#define WINDOW_VIDEO_INFO 12003
-#define WINDOW_FULLSCREEN_VIDEO 12005
-#define WINDOW_VISUALISATION 12006
-#define WINDOW_SLIDESHOW 12007
-#define WINDOW_DIALOG_FILESTACKING 12008
-#define WINDOW_KARAOKELYRICS 12009
-#define WINDOW_WEATHER 12600
-#define WINDOW_SCREENSAVER 12900
-#define WINDOW_OSD 12901
-
-#define WINDOW_VIDEO_MENU 12902
-#define WINDOW_MUSIC_OVERLAY 12903
-#define WINDOW_VIDEO_OVERLAY 12904
-#define WINDOW_VIDEO_TIME_SEEK 12905 // virtual window for time seeking during fullscreen video
-
-#define WINDOW_START 12998 // first window to load
-#define WINDOW_STARTUP_ANIM 12999 // for startup animations
-
-// WINDOW_ID's from 13000 to 13099 reserved for Python
-
-#define WINDOW_PYTHON_START 13000
-#define WINDOW_PYTHON_END 13099
-
-#define ICON_TYPE_NONE 101
-#define ICON_TYPE_PROGRAMS 102
-#define ICON_TYPE_MUSIC 103
-#define ICON_TYPE_PICTURES 104
-#define ICON_TYPE_VIDEOS 105
-#define ICON_TYPE_FILES 106
-#define ICON_TYPE_WEATHER 107
-#define ICON_TYPE_SETTINGS 109
-
-class CKey;
-
-/*!
- \ingroup actionkeys
- \brief class encapsulating information regarding a particular user action to be sent to windows and controls
- */
-class CAction
-{
-public:
- CAction(int actionID, float amount1 = 1.0f, float amount2 = 0.0f, const CStdString &name = "");
- CAction(int actionID, wchar_t unicode);
- CAction(int actionID, unsigned int state, float posX, float posY, float offsetX, float offsetY);
- CAction(int actionID, const CStdString &name, const CKey &key);
-
- /*! \brief Identifier of the action
- \return id of the action
- */
- int GetID() const { return m_id; };
-
- /*! \brief Is this an action from the mouse
- \return true if this is a mouse action, false otherwise
- */
- bool IsMouse() const { return (m_id >= ACTION_MOUSE_START && m_id <= ACTION_MOUSE_END); };
-
- bool IsGesture() const { return (m_id >= ACTION_GESTURE_NOTIFY && m_id <= ACTION_GESTURE_END); };
-
- /*! \brief Human-readable name of the action
- \return name of the action
- */
- const CStdString &GetName() const { return m_name; };
-
- /*! \brief Get an amount associated with this action
- \param zero-based index of amount to retrieve, defaults to 0
- \return an amount associated with this action
- */
- float GetAmount(unsigned int index = 0) const { return (index < max_amounts) ? m_amount[index] : 0; };
-
- /*! \brief Unicode value associated with this action
- \return unicode value associated with this action, for keyboard input.
- */
- wchar_t GetUnicode() const { return m_unicode; };
-
- /*! \brief Time in ms that the key has been held
- \return time that the key has been held down in ms.
- */
- unsigned int GetHoldTime() const { return m_holdTime; };
-
- /*! \brief Time since last repeat in ms
- \return time since last repeat in ms. Returns 0 if unknown.
- */
- float GetRepeat() const { return m_repeat; };
-
- /*! \brief Button code that triggered this action
- \return button code
- */
- unsigned int GetButtonCode() const { return m_buttonCode; };
-
-private:
- int m_id;
- CStdString m_name;
-
- static const unsigned int max_amounts = 4; // Must be at least 4.
- float m_amount[max_amounts];
-
- float m_repeat;
- unsigned int m_holdTime;
- unsigned int m_buttonCode;
- wchar_t m_unicode;
-};
-
-/*!
- \ingroup actionkeys, mouse
- \brief Simple class for mouse events
- */
-class CMouseEvent
-{
-public:
- CMouseEvent(int actionID, int state = 0, float offsetX = 0, float offsetY = 0)
- {
- m_id = actionID;
- m_state = state;
- m_offsetX = offsetX;
- m_offsetY = offsetY;
- };
-
- int m_id;
- int m_state;
- float m_offsetX;
- float m_offsetY;
-};
-
-/*!
- \ingroup actionkeys
- \brief
- */
-class CKey
-{
-public:
- CKey(void);
- CKey(uint32_t buttonCode, uint8_t leftTrigger = 0, uint8_t rightTrigger = 0, float leftThumbX = 0.0f, float leftThumbY = 0.0f, float rightThumbX = 0.0f, float rightThumbY = 0.0f, float repeat = 0.0f);
- CKey(uint32_t buttonCode, unsigned int held);
- CKey(uint8_t vkey, wchar_t unicode, char ascii, uint32_t modifiers, unsigned int held);
- CKey(const CKey& key);
-
- virtual ~CKey(void);
- const CKey& operator=(const CKey& key);
- uint8_t GetLeftTrigger() const;
- uint8_t GetRightTrigger() const;
- float GetLeftThumbX() const;
- float GetLeftThumbY() const;
- float GetRightThumbX() const;
- float GetRightThumbY() const;
- float GetRepeat() const;
- bool FromKeyboard() const;
- bool IsAnalogButton() const;
- bool IsIRRemote() const;
- void SetFromHttpApi(bool);
- bool GetFromHttpApi() const;
-
- inline uint32_t GetButtonCode() const { return m_buttonCode; }
- inline uint8_t GetVKey() const { return m_vkey; }
- inline wchar_t GetUnicode() const { return m_unicode; }
- inline char GetAscii() const { return m_ascii; }
- inline uint32_t GetModifiers() const { return m_modifiers; };
- inline unsigned int GetHeld() const { return m_held; }
-
- enum Modifier {
- MODIFIER_CTRL = 0x00010000,
- MODIFIER_SHIFT = 0x00020000,
- MODIFIER_ALT = 0x00040000,
- MODIFIER_RALT = 0x00080000,
- MODIFIER_SUPER = 0x00100000
- };
-
-private:
- void Reset();
-
- uint32_t m_buttonCode;
- uint8_t m_vkey;
- wchar_t m_unicode;
- char m_ascii;
- uint32_t m_modifiers;
- unsigned int m_held;
-
- uint8_t m_leftTrigger;
- uint8_t m_rightTrigger;
- float m_leftThumbX;
- float m_leftThumbY;
- float m_rightThumbX;
- float m_rightThumbY;
- float m_repeat; // time since last keypress
- bool m_fromHttpApi;
-};
-#endif
-
diff --git a/guilib/LocalizeStrings.cpp b/guilib/LocalizeStrings.cpp
deleted file mode 100644
index 194ad85cf2..0000000000
--- a/guilib/LocalizeStrings.cpp
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "system.h"
-#include "LocalizeStrings.h"
-#include "utils/CharsetConverter.h"
-#include "utils/log.h"
-#include "FileSystem/SpecialProtocol.h"
-#include "XMLUtils.h"
-
-CLocalizeStrings::CLocalizeStrings(void)
-{
-
-}
-
-CLocalizeStrings::~CLocalizeStrings(void)
-{
-
-}
-
-CStdString CLocalizeStrings::ToUTF8(const CStdString& strEncoding, const CStdString& str)
-{
- if (strEncoding.IsEmpty())
- return str;
-
- CStdString ret;
- g_charsetConverter.stringCharsetToUtf8(strEncoding, str, ret);
- return ret;
-}
-
-void CLocalizeStrings::ClearSkinStrings()
-{
- // clear the skin strings
- Clear(31000, 31999);
-}
-
-bool CLocalizeStrings::LoadSkinStrings(const CStdString& path, const CStdString& fallbackPath)
-{
- ClearSkinStrings();
- // load the skin strings in.
- CStdString encoding;
- if (!LoadXML(path, encoding))
- {
- if (path == fallbackPath) // no fallback, nothing to do
- return false;
- }
-
- // load the fallback
- if (path != fallbackPath)
- LoadXML(fallbackPath, encoding);
-
- return true;
-}
-
-bool CLocalizeStrings::LoadXML(const CStdString &filename, CStdString &encoding, uint32_t offset /* = 0 */)
-{
- TiXmlDocument xmlDoc;
- if (!xmlDoc.LoadFile(PTH_IC(filename)))
- {
- CLog::Log(LOGDEBUG, "unable to load %s: %s at line %d", filename.c_str(), xmlDoc.ErrorDesc(), xmlDoc.ErrorRow());
- return false;
- }
-
- XMLUtils::GetEncoding(&xmlDoc, encoding);
-
- TiXmlElement* pRootElement = xmlDoc.RootElement();
- if (!pRootElement || pRootElement->NoChildren() ||
- pRootElement->ValueStr()!=CStdString("strings"))
- {
- CLog::Log(LOGERROR, "%s Doesn't contain <strings>", filename.c_str());
- return false;
- }
-
- const TiXmlElement *pChild = pRootElement->FirstChildElement("string");
- while (pChild)
- {
- // Load new style language file with id as attribute
- const char* attrId=pChild->Attribute("id");
- if (attrId && !pChild->NoChildren())
- {
- int id = atoi(attrId) + offset;
- if (m_strings.find(id) == m_strings.end())
- m_strings[id] = ToUTF8(encoding, pChild->FirstChild()->Value());
- }
- pChild = pChild->NextSiblingElement("string");
- }
- return true;
-}
-
-bool CLocalizeStrings::Load(const CStdString& strFileName, const CStdString& strFallbackFileName)
-{
- bool bLoadFallback = !strFileName.Equals(strFallbackFileName);
-
- CStdString encoding;
- Clear();
-
- if (!LoadXML(strFileName, encoding))
- {
- // try loading the fallback
- if (!bLoadFallback || !LoadXML(strFallbackFileName, encoding))
- return false;
-
- bLoadFallback = false;
- }
-
- if (bLoadFallback)
- LoadXML(strFallbackFileName, encoding);
-
- // fill in the constant strings
- m_strings[20022] = "";
- m_strings[20027] = ToUTF8(encoding, "°F");
- m_strings[20028] = ToUTF8(encoding, "K");
- m_strings[20029] = ToUTF8(encoding, "°C");
- m_strings[20030] = ToUTF8(encoding, "°Ré");
- m_strings[20031] = ToUTF8(encoding, "°Ra");
- m_strings[20032] = ToUTF8(encoding, "°Rø");
- m_strings[20033] = ToUTF8(encoding, "°De");
- m_strings[20034] = ToUTF8(encoding, "°N");
-
- m_strings[20200] = ToUTF8(encoding, "km/h");
- m_strings[20201] = ToUTF8(encoding, "m/min");
- m_strings[20202] = ToUTF8(encoding, "m/s");
- m_strings[20203] = ToUTF8(encoding, "ft/h");
- m_strings[20204] = ToUTF8(encoding, "ft/min");
- m_strings[20205] = ToUTF8(encoding, "ft/s");
- m_strings[20206] = ToUTF8(encoding, "mph");
- m_strings[20207] = ToUTF8(encoding, "kts");
- m_strings[20208] = ToUTF8(encoding, "Beaufort");
- m_strings[20209] = ToUTF8(encoding, "inch/s");
- m_strings[20210] = ToUTF8(encoding, "yard/s");
- m_strings[20211] = ToUTF8(encoding, "Furlong/Fortnight");
-
- return true;
-}
-
-static CStdString szEmptyString = "";
-
-const CStdString& CLocalizeStrings::Get(uint32_t dwCode) const
-{
- ciStrings i = m_strings.find(dwCode);
- if (i == m_strings.end())
- {
- return szEmptyString;
- }
- return i->second;
-}
-
-void CLocalizeStrings::Clear()
-{
- m_strings.clear();
-}
-
-void CLocalizeStrings::Clear(uint32_t start, uint32_t end)
-{
- iStrings it = m_strings.begin();
- while (it != m_strings.end())
- {
- if (it->first >= start && it->first <= end)
- m_strings.erase(it++);
- else
- ++it;
- }
-}
-
-uint32_t CLocalizeStrings::LoadBlock(const CStdString &id, const CStdString &path, const CStdString &fallbackPath)
-{
- iBlocks it = m_blocks.find(id);
- if (it != m_blocks.end())
- return it->second; // already loaded
-
- // grab a new block
- uint32_t offset = block_start + m_blocks.size()*block_size;
- m_blocks.insert(make_pair(id, offset));
-
- // load the strings
- CStdString encoding;
- bool success = LoadXML(path, encoding, offset);
- if (!success)
- {
- if (path == fallbackPath) // no fallback, nothing to do
- return 0;
- }
-
- // load the fallback
- if (path != fallbackPath)
- success |= LoadXML(fallbackPath, encoding, offset);
-
- return success ? offset : 0;
-}
-
-void CLocalizeStrings::ClearBlock(const CStdString &id)
-{
- iBlocks it = m_blocks.find(id);
- if (it == m_blocks.end())
- {
- CLog::Log(LOGERROR, "%s: Trying to clear non existent block %s", __FUNCTION__, id.c_str());
- return; // doesn't exist
- }
-
- // clear our block
- Clear(it->second, it->second + block_size);
- m_blocks.erase(it);
-}
diff --git a/guilib/LocalizeStrings.h b/guilib/LocalizeStrings.h
deleted file mode 100644
index 725f0276ca..0000000000
--- a/guilib/LocalizeStrings.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*!
-\file LocalizeStrings.h
-\brief
-*/
-
-#ifndef GUILIB_LOCALIZESTRINGS_H
-#define GUILIB_LOCALIZESTRINGS_H
-
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "StdString.h"
-
-#include <map>
-
-/*!
- \ingroup strings
- \brief
- */
-class CLocalizeStrings
-{
-public:
- CLocalizeStrings(void);
- virtual ~CLocalizeStrings(void);
- bool Load(const CStdString& strFileName, const CStdString& strFallbackFileName="special://xbmc/language/english/strings.xml");
- bool LoadSkinStrings(const CStdString& path, const CStdString& fallbackPath);
- void ClearSkinStrings();
- const CStdString& Get(uint32_t code) const;
- void Clear();
- uint32_t LoadBlock(const CStdString &id, const CStdString &path, const CStdString &fallbackPath);
- void ClearBlock(const CStdString &id);
-protected:
- void Clear(uint32_t start, uint32_t end);
- bool LoadXML(const CStdString &filename, CStdString &encoding, uint32_t offset = 0);
- CStdString ToUTF8(const CStdString &encoding, const CStdString &str);
- std::map<uint32_t, CStdString> m_strings;
- typedef std::map<uint32_t, CStdString>::const_iterator ciStrings;
- typedef std::map<uint32_t, CStdString>::iterator iStrings;
-
- static const uint32_t block_start = 0xf000000;
- static const uint32_t block_size = 4096;
- std::map<CStdString, uint32_t> m_blocks;
- typedef std::map<CStdString, uint32_t>::iterator iBlocks;
-};
-
-/*!
- \ingroup strings
- \brief
- */
-extern CLocalizeStrings g_localizeStrings;
-extern CLocalizeStrings g_localizeStringsTemp;
-#endif
diff --git a/guilib/Makefile.in b/guilib/Makefile.in
deleted file mode 100644
index 7b346050c2..0000000000
--- a/guilib/Makefile.in
+++ /dev/null
@@ -1,97 +0,0 @@
-INCLUDES=-I. -I../ -Icommon -I../xbmc -I../xbmc/linux -I../xbmc/utils -I/usr/include/freetype2 -I/usr/include/SDL -I../xbmc/lib/libsquish
-ifneq (@USE_EXTERNAL_FFMPEG@,1)
- INCLUDES+=-I../xbmc/cores/dvdplayer/Codecs/ffmpeg
-endif
-
-SRCS=AnimatedGif.cpp \
- AudioContext.cpp \
- DirectXGraphics.cpp \
- DDSImage.cpp \
- GraphicContext.cpp \
- GUIAudioManager.cpp \
- GUIBaseContainer.cpp \
- GUIButtonControl.cpp \
- GUIButtonScroller.cpp \
- GUICheckMarkControl.cpp \
- GUIControl.cpp \
- GUIControlFactory.cpp \
- GUIControlGroup.cpp \
- GUIControlGroupList.cpp \
- GUIDialog.cpp \
- GUIEditControl.cpp \
- GUIFadeLabelControl.cpp \
- GUIFixedListContainer.cpp \
- GUIFont.cpp \
- GUIFontManager.cpp \
- GUIFontTTF.cpp \
- GUIImage.cpp \
- GUIIncludes.cpp \
- GUILabel.cpp \
- GUILabelControl.cpp \
- GUIListContainer.cpp \
- GUIListGroup.cpp \
- GUIListItem.cpp \
- GUIListItemLayout.cpp \
- GUIMessage.cpp \
- GUIMoverControl.cpp \
- GUIMultiImage.cpp \
- GUIPanelContainer.cpp \
- GUIProgressControl.cpp \
- GUIRadioButtonControl.cpp \
- GUIResizeControl.cpp \
- GUIRenderingControl.cpp \
- GUIRSSControl.cpp \
- GUIScrollBarControl.cpp \
- GUISelectButtonControl.cpp \
- GUISettingsSliderControl.cpp \
- GUISliderControl.cpp \
- GUISpinControl.cpp \
- GUISpinControlEx.cpp \
- GUIStandardWindow.cpp \
- GUIStaticItem.cpp \
- GUITextBox.cpp \
- GUITexture.cpp \
- GUITextureGL.cpp \
- GUITextureGLES.cpp \
- GUIToggleButtonControl.cpp \
- GUIVideoControl.cpp \
- GUIVisualisationControl.cpp \
- GUIWindow.cpp \
- GUIWindowManager.cpp \
- GUIWrappingListContainer.cpp \
- IWindowManagerCallback.cpp \
- Key.cpp \
- LocalizeStrings.cpp \
- TextureBundleXPR.cpp \
- TextureBundleXBT.cpp \
- TextureBundle.cpp \
- TextureManager.cpp \
- VisibleEffect.cpp \
- XMLUtils.cpp \
- GUISound.cpp \
- GUIColorManager.cpp \
- FrameBufferObject.cpp \
- Shader.cpp \
- GUIShader.cpp \
- MatrixGLES.cpp \
- GUIListLabel.cpp \
- GUIBorderedImage.cpp \
- GUITextLayout.cpp \
- GUIMultiSelectText.cpp \
- GUIInfoTypes.cpp \
- GUIFontTTFGL.cpp \
- Texture.cpp \
- TextureGL.cpp \
- GUIControlProfiler.cpp \
- XBTF.cpp \
- XBTFReader.cpp \
-
-LIB=guilib.a
-
-include ../Makefile.include
--include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS)))
-
-try : try.o TextureBundle.o DirectXGraphics.o GUIFontTTF.o
- g++ -o try try.o TextureBundle.o DirectXGraphics.o GraphicContext.o GUIIncludes.o ../xbmc/utils/CriticalSection.o ../xbmc/XBVideoConfig.o SkinInfo.o tinyXML/tinyxml.a ../xbmc/linux/CriticalSection.o GUIFontTTF.o GUIFontBase.o GUIFontManager.o GUIFont.o XMLUtils.o GUIImage.o GUIControl.o TextureManager.o GUIMessage.o ../xbmc/utils/SingleLock.o VisibleEffect.o GUIWindowManager.o AnimatedGif.o -lSDL_image -lSDL_gfx -lSDL -llzo -lfreetype
-
-
diff --git a/guilib/MatrixGLES.cpp b/guilib/MatrixGLES.cpp
deleted file mode 100644
index f87a3f3b9f..0000000000
--- a/guilib/MatrixGLES.cpp
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
-* Copyright (C) 2005-2008 Team XBMC
-* http://www.xbmc.org
-*
-* This Program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, 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 General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with XBMC; see the file COPYING. If not, write to
-* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-* http://www.gnu.org/copyleft/gpl.html
-*
-*/
-
-
-#include "system.h"
-
-#if HAS_GLES == 2
-
-#include <cmath>
-#include "MatrixGLES.h"
-#include "utils/log.h"
-
-CMatrixGLES g_matrices;
-
-#define MODE_WITHIN_RANGE(m) ((m >= 0) && (m < (int)MM_MATRIXSIZE))
-
-CMatrixGLES::CMatrixGLES()
-{
- for (int i=0; i<(int)MM_MATRIXSIZE; i++)
- {
- m_matrices[i].push_back(new GLfloat[16]);
- MatrixMode((EMATRIXMODE)i);
- LoadIdentity();
- }
- m_matrixMode = (EMATRIXMODE)-1;
- m_pMatrix = NULL;
-}
-
-CMatrixGLES::~CMatrixGLES()
-{
- for (int i=0; i<(int)MM_MATRIXSIZE; i++)
- {
- while (!m_matrices[i].empty())
- {
- m_matrices[i].pop_back();
- }
- }
- m_matrixMode = (EMATRIXMODE)-1;
- m_pMatrix = NULL;
-}
-
-GLfloat* CMatrixGLES::GetMatrix(EMATRIXMODE mode)
-{
- if (MODE_WITHIN_RANGE(mode))
- {
- if (!m_matrices[mode].empty())
- {
- return m_matrices[mode].back();
- }
- }
- return NULL;
-}
-
-void CMatrixGLES::MatrixMode(EMATRIXMODE mode)
-{
- if (MODE_WITHIN_RANGE(mode))
- {
- m_matrixMode = mode;
- m_pMatrix = m_matrices[mode].back();
- }
- else
- {
- m_matrixMode = (EMATRIXMODE)-1;
- m_pMatrix = NULL;
- }
-}
-
-void CMatrixGLES::PushMatrix()
-{
- if (m_pMatrix && MODE_WITHIN_RANGE(m_matrixMode))
- {
- GLfloat *matrix = new GLfloat[16];
- memcpy(matrix, m_pMatrix, sizeof(GLfloat)*16);
- m_matrices[m_matrixMode].push_back(matrix);
- }
-}
-
-void CMatrixGLES::PopMatrix()
-{
- if (MODE_WITHIN_RANGE(m_matrixMode) && (m_matrices[m_matrixMode].size() > 1))
- {
- m_matrices[m_matrixMode].pop_back();
- m_pMatrix = m_matrices[m_matrixMode].back();
- }
-}
-
-void CMatrixGLES::LoadIdentity()
-{
- if (m_pMatrix)
- {
- m_pMatrix[0] = 1.0f; m_pMatrix[4] = 0.0f; m_pMatrix[8] = 0.0f; m_pMatrix[12] = 0.0f;
- m_pMatrix[1] = 0.0f; m_pMatrix[5] = 1.0f; m_pMatrix[9] = 0.0f; m_pMatrix[13] = 0.0f;
- m_pMatrix[2] = 0.0f; m_pMatrix[6] = 0.0f; m_pMatrix[10] = 1.0f; m_pMatrix[14] = 0.0f;
- m_pMatrix[3] = 0.0f; m_pMatrix[7] = 0.0f; m_pMatrix[11] = 0.0f; m_pMatrix[15] = 1.0f;
- }
-}
-
-void CMatrixGLES::Ortho(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f)
-{
- GLfloat u = 2.0f / (r - l);
- GLfloat v = 2.0f / (t - b);
- GLfloat w = -2.0f / (f - n);
- GLfloat x = - (r + l) / (r - l);
- GLfloat y = - (t + b) / (t - b);
- GLfloat z = - (f + n) / (f - n);
- GLfloat matrix[16] = { u, 0.0f, 0.0f, 0.0f,
- 0.0f, v, 0.0f, 0.0f,
- 0.0f, 0.0f, w, 0.0f,
- x, y, z, 1.0f};
- MultMatrixf(matrix);
-}
-
-void CMatrixGLES::Ortho2D(GLfloat l, GLfloat r, GLfloat b, GLfloat t)
-{
- GLfloat u = 2.0f / (r - l);
- GLfloat v = 2.0f / (t - b);
- GLfloat x = - (r + l) / (r - l);
- GLfloat y = - (t + b) / (t - b);
- GLfloat matrix[16] = { u, 0.0f, 0.0f, 0.0f,
- 0.0f, v, 0.0f, 0.0f,
- 0.0f, 0.0f,-1.0f, 0.0f,
- x, y, 0.0f, 1.0f};
- MultMatrixf(matrix);
-}
-
-void CMatrixGLES::Frustum(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f)
-{
- GLfloat u = (2.0f * n) / (r - l);
- GLfloat v = (2.0f * n) / (t - b);
- GLfloat w = (r + l) / (r - l);
- GLfloat x = (t + b) / (t - b);
- GLfloat y = - (f + n) / (f - n);
- GLfloat z = - (2.0f * f * n) / (f - n);
- GLfloat matrix[16] = { u, 0.0f, 0.0f, 0.0f,
- 0.0f, v, 0.0f, 0.0f,
- w, x, y,-1.0f,
- 0.0f, 0.0f, z, 0.0f};
- MultMatrixf(matrix);
-}
-
-void CMatrixGLES::Translatef(GLfloat x, GLfloat y, GLfloat z)
-{
- GLfloat matrix[16] = {1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f, 0.0f,
- x, y, z, 1.0f};
- MultMatrixf(matrix);
-}
-
-void CMatrixGLES::Scalef(GLfloat x, GLfloat y, GLfloat z)
-{
- GLfloat matrix[16] = { x, 0.0f, 0.0f, 0.0f,
- 0.0f, y, 0.0f, 0.0f,
- 0.0f, 0.0f, z, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f};
- MultMatrixf(matrix);
-}
-
-void CMatrixGLES::Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
-{
- GLfloat modulous = sqrt((x*x)+(y*y)+(z*z));
- if (modulous != 0.0)
- {
- x /= modulous;
- y /= modulous;
- z /= modulous;
- }
- GLfloat cosine = cos(angle);
- GLfloat sine = sin(angle);
- GLfloat cos1 = 1 - cosine;
- GLfloat a = (x*x*cos1) + cosine;
- GLfloat b = (x*y*cos1) - (z*sine);
- GLfloat c = (x*z*cos1) + (y*sine);
- GLfloat d = (y*x*cos1) + (z*sine);
- GLfloat e = (y*y*cos1) + cosine;
- GLfloat f = (y*z*cos1) - (x*sine);
- GLfloat g = (z*x*cos1) - (y*sine);
- GLfloat h = (z*y*cos1) + (x*sine);
- GLfloat i = (z*z*cos1) + cosine;
- GLfloat matrix[16] = { a, d, g, 0.0f,
- b, e, h, 0.0f,
- c, f, i, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f};
- MultMatrixf(matrix);
-}
-
-void CMatrixGLES::MultMatrixf(const GLfloat *matrix)
-{
- if (m_pMatrix)
- {
- GLfloat a = (matrix[0] * m_pMatrix[0]) + (matrix[1] * m_pMatrix[4]) + (matrix[2] * m_pMatrix[8]) + (matrix[3] * m_pMatrix[12]);
- GLfloat b = (matrix[0] * m_pMatrix[1]) + (matrix[1] * m_pMatrix[5]) + (matrix[2] * m_pMatrix[9]) + (matrix[3] * m_pMatrix[13]);
- GLfloat c = (matrix[0] * m_pMatrix[2]) + (matrix[1] * m_pMatrix[6]) + (matrix[2] * m_pMatrix[10]) + (matrix[3] * m_pMatrix[14]);
- GLfloat d = (matrix[0] * m_pMatrix[3]) + (matrix[1] * m_pMatrix[7]) + (matrix[2] * m_pMatrix[11]) + (matrix[3] * m_pMatrix[15]);
- GLfloat e = (matrix[4] * m_pMatrix[0]) + (matrix[5] * m_pMatrix[4]) + (matrix[6] * m_pMatrix[8]) + (matrix[7] * m_pMatrix[12]);
- GLfloat f = (matrix[4] * m_pMatrix[1]) + (matrix[5] * m_pMatrix[5]) + (matrix[6] * m_pMatrix[9]) + (matrix[7] * m_pMatrix[13]);
- GLfloat g = (matrix[4] * m_pMatrix[2]) + (matrix[5] * m_pMatrix[6]) + (matrix[6] * m_pMatrix[10]) + (matrix[7] * m_pMatrix[14]);
- GLfloat h = (matrix[4] * m_pMatrix[3]) + (matrix[5] * m_pMatrix[7]) + (matrix[6] * m_pMatrix[11]) + (matrix[7] * m_pMatrix[15]);
- GLfloat i = (matrix[8] * m_pMatrix[0]) + (matrix[9] * m_pMatrix[4]) + (matrix[10] * m_pMatrix[8]) + (matrix[11] * m_pMatrix[12]);
- GLfloat j = (matrix[8] * m_pMatrix[1]) + (matrix[9] * m_pMatrix[5]) + (matrix[10] * m_pMatrix[9]) + (matrix[11] * m_pMatrix[13]);
- GLfloat k = (matrix[8] * m_pMatrix[2]) + (matrix[9] * m_pMatrix[6]) + (matrix[10] * m_pMatrix[10]) + (matrix[11] * m_pMatrix[14]);
- GLfloat l = (matrix[8] * m_pMatrix[3]) + (matrix[9] * m_pMatrix[7]) + (matrix[10] * m_pMatrix[11]) + (matrix[11] * m_pMatrix[15]);
- GLfloat m = (matrix[12] * m_pMatrix[0]) + (matrix[13] * m_pMatrix[4]) + (matrix[14] * m_pMatrix[8]) + (matrix[15] * m_pMatrix[12]);
- GLfloat n = (matrix[12] * m_pMatrix[1]) + (matrix[13] * m_pMatrix[5]) + (matrix[14] * m_pMatrix[9]) + (matrix[15] * m_pMatrix[13]);
- GLfloat o = (matrix[12] * m_pMatrix[2]) + (matrix[13] * m_pMatrix[6]) + (matrix[14] * m_pMatrix[10]) + (matrix[15] * m_pMatrix[14]);
- GLfloat p = (matrix[12] * m_pMatrix[3]) + (matrix[13] * m_pMatrix[7]) + (matrix[14] * m_pMatrix[11]) + (matrix[15] * m_pMatrix[15]);
- m_pMatrix[0] = a; m_pMatrix[4] = e; m_pMatrix[8] = i; m_pMatrix[12] = m;
- m_pMatrix[1] = b; m_pMatrix[5] = f; m_pMatrix[9] = j; m_pMatrix[13] = n;
- m_pMatrix[2] = c; m_pMatrix[6] = g; m_pMatrix[10] = k; m_pMatrix[14] = o;
- m_pMatrix[3] = d; m_pMatrix[7] = h; m_pMatrix[11] = l; m_pMatrix[15] = p;
- }
-}
-
-// gluLookAt implementation taken from Mesa3D
-void CMatrixGLES::LookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez, GLfloat centerx, GLfloat centery, GLfloat centerz, GLfloat upx, GLfloat upy, GLfloat upz)
-{
- GLfloat forward[3], side[3], up[3];
- GLfloat m[4][4];
-
- forward[0] = centerx - eyex;
- forward[1] = centery - eyey;
- forward[2] = centerz - eyez;
-
- up[0] = upx;
- up[1] = upy;
- up[2] = upz;
-
- GLfloat tmp = sqrt(forward[0]*forward[0] + forward[1]*forward[1] + forward[2]*forward[2]);
- if (tmp != 0.0)
- {
- forward[0] /= tmp;
- forward[1] /= tmp;
- forward[2] /= tmp;
- }
-
- side[0] = forward[1]*up[2] - forward[2]*up[1];
- side[1] = forward[2]*up[0] - forward[0]*up[2];
- side[2] = forward[0]*up[1] - forward[1]*up[0];
-
- tmp = sqrt(side[0]*side[0] + side[1]*side[1] + side[2]*side[2]);
- if (tmp != 0.0)
- {
- side[0] /= tmp;
- side[1] /= tmp;
- side[2] /= tmp;
- }
-
- up[0] = side[1]*forward[2] - side[2]*forward[1];
- up[1] = side[2]*forward[0] - side[0]*forward[2];
- up[2] = side[0]*forward[1] - side[1]*forward[0];
-
- m[0][0] = 1.0f; m[0][1] = 0.0f; m[0][2] = 0.0f; m[0][3] = 0.0f;
- m[1][0] = 0.0f; m[1][1] = 1.0f; m[1][2] = 0.0f; m[1][3] = 0.0f;
- m[2][0] = 0.0f; m[2][1] = 0.0f; m[2][2] = 1.0f; m[2][3] = 0.0f;
- m[3][0] = 0.0f; m[3][1] = 0.0f; m[3][2] = 0.0f; m[3][3] = 1.0f;
-
- m[0][0] = side[0];
- m[1][0] = side[1];
- m[2][0] = side[2];
-
- m[0][1] = up[0];
- m[1][1] = up[1];
- m[2][1] = up[2];
-
- m[0][2] = -forward[0];
- m[1][2] = -forward[1];
- m[2][2] = -forward[2];
-
- MultMatrixf(&m[0][0]);
- Translatef(-eyex, -eyey, -eyez);
-}
-
-void CMatrixGLES::PrintMatrix(void)
-{
- for (int i=0; i<(int)MM_MATRIXSIZE; i++)
- {
- GLfloat *m = GetMatrix((EMATRIXMODE)i);
- CLog::Log(LOGDEBUG, "MatrixGLES - Matrix:%d", i);
- CLog::Log(LOGDEBUG, "%f %f %f %f", m[0], m[4], m[8], m[12]);
- CLog::Log(LOGDEBUG, "%f %f %f %f", m[1], m[5], m[9], m[13]);
- CLog::Log(LOGDEBUG, "%f %f %f %f", m[2], m[6], m[10], m[14]);
- CLog::Log(LOGDEBUG, "%f %f %f %f", m[3], m[7], m[11], m[15]);
- }
-}
-
-#endif
diff --git a/guilib/MatrixGLES.h b/guilib/MatrixGLES.h
deleted file mode 100644
index 8de26f3afd..0000000000
--- a/guilib/MatrixGLES.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
-* Copyright (C) 2005-2008 Team XBMC
-* http://www.xbmc.org
-*
-* This Program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, 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 General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with XBMC; see the file COPYING. If not, write to
-* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-* http://www.gnu.org/copyleft/gpl.html
-*
-*/
-
-#ifndef MATRIX_GLES_H
-#define MATRIX_GLES_H
-
-#pragma once
-
-#include <vector>
-
-using namespace std;
-
-enum EMATRIXMODE
-{
- MM_PROJECTION = 0,
- MM_MODELVIEW,
- MM_TEXTURE,
- MM_MATRIXSIZE // Must be last! used for size of matrices
-};
-
-class CMatrixGLES
-{
-public:
- CMatrixGLES();
- ~CMatrixGLES();
-
- GLfloat* GetMatrix(EMATRIXMODE mode);
-
- void MatrixMode(EMATRIXMODE mode);
- void PushMatrix();
- void PopMatrix();
- void LoadIdentity();
- void Ortho(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f);
- void Ortho2D(GLfloat l, GLfloat r, GLfloat b, GLfloat t);
- void Frustum(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f);
- void Translatef(GLfloat x, GLfloat y, GLfloat z);
- void Scalef(GLfloat x, GLfloat y, GLfloat z);
- void Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
- void MultMatrixf(const GLfloat *matrix);
- void LookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez, GLfloat centerx, GLfloat centery, GLfloat centerz, GLfloat upx, GLfloat upy, GLfloat upz);
- void PrintMatrix(void);
-
-protected:
- vector<GLfloat*> m_matrices[(int)MM_MATRIXSIZE];
- GLfloat *m_pMatrix;
- EMATRIXMODE m_matrixMode;
-};
-
-extern CMatrixGLES g_matrices;
-
-#endif // MATRIX_GLES_H
diff --git a/guilib/Resolution.h b/guilib/Resolution.h
deleted file mode 100644
index 0d09f313fc..0000000000
--- a/guilib/Resolution.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
-* Copyright (C) 2005-2008 Team XBMC
-* http://www.xbmc.org
-*
-* This Program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, 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 General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with XBMC; see the file COPYING. If not, write to
-* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-* http://www.gnu.org/copyleft/gpl.html
-*
-*/
-
-#pragma once
-
-#include <stdint.h>
-#include "StdString.h"
-
-typedef int DisplayMode;
-#define DM_WINDOWED -1
-#define DM_FULLSCREEN1 0
-#define DM_FULLSCREEN2 1
-// DM_FULLSCREEN3 2
-// etc.
-
-enum RESOLUTION {
- RES_INVALID = -1,
- RES_HDTV_1080i = 0,
- RES_HDTV_720p = 1,
- RES_HDTV_480p_4x3 = 2,
- RES_HDTV_480p_16x9 = 3,
- RES_NTSC_4x3 = 4,
- RES_NTSC_16x9 = 5,
- RES_PAL_4x3 = 6,
- RES_PAL_16x9 = 7,
- RES_PAL60_4x3 = 8,
- RES_PAL60_16x9 = 9,
- RES_AUTORES = 10,
- RES_WINDOW = 11,
- RES_DESKTOP = 12, // Desktop resolution for primary screen
- RES_CUSTOM = 12 + 1, // Desktop resolution for screen #2
-// ...
-// 12 + N - 1 // Desktop resolution for screen N
-// 12 + N // First additional resolution, in a N screen configuration.
-// 12 + N + ... // Other resolutions, in any order
-};
-
-enum VSYNC {
- VSYNC_DISABLED = 0,
- VSYNC_VIDEO = 1,
- VSYNC_ALWAYS = 2,
- VSYNC_DRIVER = 3
-};
-
-struct OVERSCAN
-{
- int left;
- int top;
- int right;
- int bottom;
-public:
- OVERSCAN()
- {
- left = top = right = bottom = 0;
- }
- OVERSCAN(const OVERSCAN& os)
- {
- left = os.left; top = os.top;
- right = os.right; bottom = os.bottom;
- }
-};
-
-struct RESOLUTION_INFO
-{
- OVERSCAN Overscan;
- bool bFullScreen;
- int iScreen;
- int iWidth;
- int iHeight;
- int iSubtitles;
- uint32_t dwFlags;
- float fPixelRatio;
- float fRefreshRate;
- CStdString strMode;
- CStdString strOutput;
- CStdString strId;
- public:
- RESOLUTION_INFO()
- {
- bFullScreen = false;
- iScreen = iWidth = iHeight = iSubtitles = dwFlags = 0;
- fPixelRatio = fRefreshRate = 0.f;
- }
- RESOLUTION_INFO(const RESOLUTION_INFO& res)
- {
- Overscan = res.Overscan; bFullScreen = res.bFullScreen;
- iScreen = res.iScreen; iWidth = res.iWidth; iHeight = res.iHeight;
- iSubtitles = res.iSubtitles; dwFlags = res.dwFlags;
- fPixelRatio = res.fPixelRatio; fRefreshRate = res.fRefreshRate;
- strMode = res.strMode; strOutput = res.strOutput; strId = res.strId;
- }
-};
diff --git a/guilib/Shader.cpp b/guilib/Shader.cpp
deleted file mode 100644
index ee2aa83977..0000000000
--- a/guilib/Shader.cpp
+++ /dev/null
@@ -1,516 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "system.h"
-
-#if defined(HAS_GL) || HAS_GLES == 2
-#include "../xbmc/Settings.h"
-#include "../xbmc/FileSystem/File.h"
-#include "Shader.h"
-#include "utils/log.h"
-
-#define LOG_SIZE 1024
-
-using namespace Shaders;
-using namespace XFILE;
-using namespace std;
-
-//////////////////////////////////////////////////////////////////////
-// CShader
-//////////////////////////////////////////////////////////////////////
-bool CShader::LoadSource(const string& filename, const string& prefix)
-{
- if(filename.empty())
- return true;
-
- CFileStream file;
-
- if(!file.Open("special://xbmc/system/shaders/" + filename))
- {
- CLog::Log(LOGERROR, "CYUVShaderGLSL::CYUVShaderGLSL - failed to open file %s", filename.c_str());
- return false;
- }
-#ifdef _ARMEL
- CLog::Log(LOGDEBUG, "Shader - Loading shader file %s", filename.c_str());
- m_source.assign(file.ReadFile());
-#else
- getline(file, m_source, '\0');
-#endif
- m_source.insert(0, prefix);
- return true;
-}
-
-//////////////////////////////////////////////////////////////////////
-// CGLSLVertexShader
-//////////////////////////////////////////////////////////////////////
-
-bool CGLSLVertexShader::Compile()
-{
- GLint params[4];
-
- Free();
-
-#ifdef HAS_GL
- if(!GLEW_VERSION_2_0)
- {
- CLog::Log(LOGERROR, "GL: GLSL vertex shaders not supported");
- return false;
- }
-#endif
-
- m_vertexShader = glCreateShader(GL_VERTEX_SHADER);
- const char *ptr = m_source.c_str();
- glShaderSource(m_vertexShader, 1, &ptr, 0);
- glCompileShader(m_vertexShader);
- glGetShaderiv(m_vertexShader, GL_COMPILE_STATUS, params);
- VerifyGLState();
- if (params[0]!=GL_TRUE)
- {
- GLchar log[LOG_SIZE];
- CLog::Log(LOGERROR, "GL: Error compiling vertex shader");
- glGetShaderInfoLog(m_vertexShader, LOG_SIZE, NULL, log);
- CLog::Log(LOGERROR, "%s", log);
- m_lastLog = log;
- m_compiled = false;
- }
- else
- {
- GLchar log[LOG_SIZE];
- CLog::Log(LOGDEBUG, "GL: Vertex Shader compilation log:");
- glGetShaderInfoLog(m_vertexShader, LOG_SIZE, NULL, log);
- CLog::Log(LOGDEBUG, "%s", log);
- m_lastLog = log;
- m_compiled = true;
- }
- return m_compiled;
-}
-
-void CGLSLVertexShader::Free()
-{
-#ifdef HAS_GL
- if(!GLEW_VERSION_2_0)
- return;
-#endif
-
- if (m_vertexShader)
- glDeleteShader(m_vertexShader);
- m_vertexShader = 0;
-}
-
-#ifndef HAS_GLES
-
-//////////////////////////////////////////////////////////////////////
-// CARBVertexShader
-//////////////////////////////////////////////////////////////////////
-bool CARBVertexShader::Compile()
-{
- GLint err = 0;
-
- Free();
-
- // Pixel shaders are not mandatory.
- if (m_source.length()==0)
- {
- CLog::Log(LOGNOTICE, "GL: No vertex shader, fixed pipeline in use");
- return true;
- }
-
- glEnable(GL_VERTEX_PROGRAM_ARB);
- glGenProgramsARB(1, &m_vertexShader);
- glBindProgramARB(GL_VERTEX_PROGRAM_ARB, m_vertexShader);
-
- glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
- m_source.length(), m_source.c_str());
-
- glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &err);
- if (err>0)
- {
- CLog::Log(LOGERROR, "GL: Error compiling ARB vertex shader");
- m_compiled = false;
- }
- else
- {
- m_compiled = true;
- }
- glDisable(GL_VERTEX_PROGRAM_ARB);
- return m_compiled;
-}
-
-void CARBVertexShader::Free()
-{
- if (m_vertexShader)
- glDeleteProgramsARB(1, &m_vertexShader);
- m_vertexShader = 0;
-}
-#endif
-
-//////////////////////////////////////////////////////////////////////
-// CGLSLPixelShader
-//////////////////////////////////////////////////////////////////////
-bool CGLSLPixelShader::Compile()
-{
-#ifdef HAS_GL
- if(!GLEW_VERSION_2_0)
- {
- CLog::Log(LOGERROR, "GL: GLSL pixel shaders not supported");
- return false;
- }
-#endif
-
- GLint params[4];
-
- Free();
-
- // Pixel shaders are not mandatory.
- if (m_source.length()==0)
- {
- CLog::Log(LOGNOTICE, "GL: No pixel shader, fixed pipeline in use");
- return true;
- }
-
- m_pixelShader = glCreateShader(GL_FRAGMENT_SHADER);
- const char *ptr = m_source.c_str();
- glShaderSource(m_pixelShader, 1, &ptr, 0);
- glCompileShader(m_pixelShader);
- glGetShaderiv(m_pixelShader, GL_COMPILE_STATUS, params);
- if (params[0]!=GL_TRUE)
- {
- GLchar log[LOG_SIZE];
- CLog::Log(LOGERROR, "GL: Error compiling pixel shader");
- glGetShaderInfoLog(m_pixelShader, LOG_SIZE, NULL, log);
- CLog::Log(LOGERROR, "%s", log);
- m_lastLog = log;
- m_compiled = false;
- }
- else
- {
- GLchar log[LOG_SIZE];
- CLog::Log(LOGDEBUG, "GL: Pixel Shader compilation log:");
- glGetShaderInfoLog(m_pixelShader, LOG_SIZE, NULL, log);
- CLog::Log(LOGDEBUG, "%s", log);
- m_lastLog = log;
- m_compiled = true;
- }
- return m_compiled;
-}
-
-void CGLSLPixelShader::Free()
-{
-#ifdef HAS_GL
- if(!GLEW_VERSION_2_0)
- return;
-#endif
- if (m_pixelShader)
- glDeleteShader(m_pixelShader);
- m_pixelShader = 0;
-}
-
-#ifndef HAS_GLES
-
-//////////////////////////////////////////////////////////////////////
-// CARBPixelShader
-//////////////////////////////////////////////////////////////////////
-bool CARBPixelShader::Compile()
-{
- GLint err = 0;
-
- Free();
-
- // Pixel shaders are not mandatory.
- if (m_source.length()==0)
- {
- CLog::Log(LOGNOTICE, "GL: No pixel shader, fixed pipeline in use");
- return true;
- }
-
- glEnable(GL_FRAGMENT_PROGRAM_ARB);
- glGenProgramsARB(1, &m_pixelShader);
- glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, m_pixelShader);
-
- glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
- m_source.length(), m_source.c_str());
-
- glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &err);
- if (err>0)
- {
- const char* errStr = (const char*)glGetString(GL_PROGRAM_ERROR_STRING_ARB);
- if (!errStr)
- errStr = "NULL";
- CLog::Log(LOGERROR, "GL: Error compiling ARB pixel shader, GL_PROGRAM_ERROR_STRING_ARB = %s", errStr);
- m_compiled = false;
- }
- else
- {
- m_compiled = true;
- }
- glDisable(GL_FRAGMENT_PROGRAM_ARB);
- return m_compiled;
-}
-
-void CARBPixelShader::Free()
-{
- if (m_pixelShader)
- glDeleteProgramsARB(1, &m_pixelShader);
- m_pixelShader = 0;
-}
-
-#endif
-
-//////////////////////////////////////////////////////////////////////
-// CGLSLShaderProgram
-//////////////////////////////////////////////////////////////////////
-void CGLSLShaderProgram::Free()
-{
-#ifdef HAS_GL
- if(!GLEW_VERSION_2_0)
- return;
-#endif
- m_pVP->Free();
- VerifyGLState();
- m_pFP->Free();
- VerifyGLState();
- if (m_shaderProgram)
- {
- glDeleteProgram(m_shaderProgram);
- }
- m_shaderProgram = 0;
- m_ok = false;
- m_lastProgram = 0;
-}
-
-bool CGLSLShaderProgram::CompileAndLink()
-{
-#ifdef HAS_GL
- // check that we support shaders
- if(!GLEW_VERSION_2_0)
- {
- CLog::Log(LOGERROR, "GL: GLSL shaders not supported");
- return false;
- }
-#endif
-
- GLint params[4];
-
- // free resources
- Free();
-
- // compiled vertex shader
- if (!m_pVP->Compile())
- {
- CLog::Log(LOGERROR, "GL: Error compiling vertex shader");
- return false;
- }
- CLog::Log(LOGDEBUG, "GL: Vertex Shader compiled successfully");
-
- // compile pixel shader
- if (!m_pFP->Compile())
- {
- m_pVP->Free();
- CLog::Log(LOGERROR, "GL: Error compiling fragment shader");
- return false;
- }
- CLog::Log(LOGDEBUG, "GL: Fragment Shader compiled successfully");
-
- // create program object
- if (!(m_shaderProgram = glCreateProgram()))
- {
- CLog::Log(LOGERROR, "GL: Error creating shader program handle");
- goto error;
- }
-
- // attach the vertex shader
- glAttachShader(m_shaderProgram, m_pVP->Handle());
- VerifyGLState();
-
- // if we have a pixel shader, attach it. If not, fixed pipeline
- // will be used.
- if (m_pFP->Handle())
- {
- glAttachShader(m_shaderProgram, m_pFP->Handle());
- VerifyGLState();
- }
-
- // link the program
- glLinkProgram(m_shaderProgram);
- glGetProgramiv(m_shaderProgram, GL_LINK_STATUS, params);
- if (params[0]!=GL_TRUE)
- {
- GLchar log[LOG_SIZE];
- CLog::Log(LOGERROR, "GL: Error linking shader");
- glGetProgramInfoLog(m_shaderProgram, LOG_SIZE, NULL, log);
- CLog::Log(LOGERROR, "%s", log);
- goto error;
- }
- VerifyGLState();
-
- m_validated = false;
- m_ok = true;
- OnCompiledAndLinked();
- VerifyGLState();
- return true;
-
- error:
- m_ok = false;
- Free();
- return false;
-}
-
-bool CGLSLShaderProgram::Enable()
-{
-#ifdef HAS_GL
- if(!GLEW_VERSION_2_0)
- return false;
-#endif
-
- if (OK())
- {
- glUseProgram(m_shaderProgram);
- if (OnEnabled())
- {
- if (!m_validated)
- {
- // validate the program
- GLint params[4];
- glValidateProgram(m_shaderProgram);
- glGetProgramiv(m_shaderProgram, GL_VALIDATE_STATUS, params);
- if (params[0]!=GL_TRUE)
- {
- GLchar log[LOG_SIZE];
- CLog::Log(LOGERROR, "GL: Error validating shader");
- glGetProgramInfoLog(m_shaderProgram, LOG_SIZE, NULL, log);
- CLog::Log(LOGERROR, "%s", log);
- }
- m_validated = true;
- }
- VerifyGLState();
- return true;
- }
- else
- {
- glUseProgram(0);
- return false;
- }
- return true;
- }
- return false;
-}
-
-void CGLSLShaderProgram::Disable()
-{
-#ifdef HAS_GL
- if(!GLEW_VERSION_2_0)
- return;
-#endif
-
- if (OK())
- {
- glUseProgram(0);
- OnDisabled();
- }
-}
-
-#ifndef HAS_GLES
-
-//////////////////////////////////////////////////////////////////////
-// CARBShaderProgram
-//////////////////////////////////////////////////////////////////////
-void CARBShaderProgram::Free()
-{
- m_pVP->Free();
- VerifyGLState();
- m_pFP->Free();
- VerifyGLState();
- m_ok = false;
-}
-
-bool CARBShaderProgram::CompileAndLink()
-{
- // free resources
- Free();
-
- // compiled vertex shader
- if (!m_pVP->Compile())
- {
- CLog::Log(LOGERROR, "GL: Error compiling vertex shader");
- goto error;
- }
-
- // compile pixel shader
- if (!m_pFP->Compile())
- {
- m_pVP->Free();
- CLog::Log(LOGERROR, "GL: Error compiling fragment shader");
- goto error;
- }
-
- m_ok = true;
- OnCompiledAndLinked();
- VerifyGLState();
- return true;
-
- error:
- m_ok = false;
- Free();
- return false;
-}
-
-bool CARBShaderProgram::Enable()
-{
- if (OK())
- {
- if (m_pFP->OK())
- {
- glEnable(GL_FRAGMENT_PROGRAM_ARB);
- glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, m_pFP->Handle());
- }
- if (m_pVP->OK())
- {
- glEnable(GL_VERTEX_PROGRAM_ARB);
- glBindProgramARB(GL_VERTEX_PROGRAM_ARB, m_pVP->Handle());
- }
- if (OnEnabled())
- {
- VerifyGLState();
- return true;
- }
- else
- {
- glDisable(GL_FRAGMENT_PROGRAM_ARB);
- glDisable(GL_VERTEX_PROGRAM_ARB);
- return false;
- }
- }
- return false;
-}
-
-void CARBShaderProgram::Disable()
-{
- if (OK())
- {
- glDisable(GL_FRAGMENT_PROGRAM_ARB);
- glDisable(GL_VERTEX_PROGRAM_ARB);
- OnDisabled();
- }
-}
-
-#endif
-
-#endif
diff --git a/guilib/Shader.h b/guilib/Shader.h
deleted file mode 100644
index d4f387a67a..0000000000
--- a/guilib/Shader.h
+++ /dev/null
@@ -1,264 +0,0 @@
-#ifndef __SHADER_H__
-#define __SHADER_H__
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "system.h" // for HAS_GL/HAS_GLES
-
-#include <vector>
-#include <string>
-
-#if defined(HAS_GL) || defined(HAS_GLES)
-
-namespace Shaders {
-
- using namespace std;
-
- //////////////////////////////////////////////////////////////////////
- // CShader - base class
- //////////////////////////////////////////////////////////////////////
- class CShader
- {
- public:
- CShader() { m_compiled = false; }
- virtual ~CShader() {}
- virtual bool Compile() = 0;
- virtual void Free() = 0;
- virtual GLuint Handle() = 0;
- virtual void SetSource(const string& src) { m_source = src; }
- virtual bool LoadSource(const string& filename, const string& prefix = "");
- bool OK() { return m_compiled; }
-
- protected:
- string m_source;
- string m_lastLog;
- vector<string> m_attr;
- bool m_compiled;
-
- };
-
-
- //////////////////////////////////////////////////////////////////////
- // CVertexShader - vertex shader class
- //////////////////////////////////////////////////////////////////////
- class CVertexShader : public CShader
- {
- public:
- CVertexShader() { m_vertexShader = 0; }
- virtual ~CVertexShader() { Free(); }
- virtual void Free() {}
- virtual GLuint Handle() { return m_vertexShader; }
-
- protected:
- GLuint m_vertexShader;
- };
-
- class CGLSLVertexShader : public CVertexShader
- {
- public:
- virtual void Free();
- virtual bool Compile();
- };
-
-#ifndef HAS_GLES
- class CARBVertexShader : public CVertexShader
- {
- public:
- virtual void Free();
- virtual bool Compile();
- };
-#endif
-
-
- //////////////////////////////////////////////////////////////////////
- // CPixelShader - abstract pixel shader class
- //////////////////////////////////////////////////////////////////////
- class CPixelShader : public CShader
- {
- public:
- CPixelShader() { m_pixelShader = 0; }
- virtual ~CPixelShader() { Free(); }
- virtual void Free() {}
- virtual GLuint Handle() { return m_pixelShader; }
-
- protected:
- GLuint m_pixelShader;
- };
-
-
- class CGLSLPixelShader : public CPixelShader
- {
- public:
- virtual void Free();
- virtual bool Compile();
- };
-
-#ifndef HAS_GLES
- class CARBPixelShader : public CPixelShader
- {
- public:
- virtual void Free();
- virtual bool Compile();
- };
-#endif
-
- //////////////////////////////////////////////////////////////////////
- // CShaderProgram - the complete shader consisting of both the vertex
- // and pixel programs. (abstract)
- //////////////////////////////////////////////////////////////////////
- class CShaderProgram
- {
- public:
- CShaderProgram()
- {
- m_ok = false;
- m_shaderProgram = 0;
- m_pFP = NULL;
- m_pVP = NULL;
- }
-
- virtual ~CShaderProgram()
- {
- Free();
- delete m_pFP;
- delete m_pVP;
- }
-
- // enable the shader
- virtual bool Enable() = 0;
-
- // disable the shader
- virtual void Disable() = 0;
-
- // returns true if shader is compiled and linked
- bool OK() { return m_ok; }
-
- // free resources
- virtual void Free() {}
-
- // return the vertex shader object
- CVertexShader* VertexShader() { return m_pVP; }
-
- // return the pixel shader object
- CPixelShader* PixelShader() { return m_pFP; }
-
- // compile and link the shaders
- virtual bool CompileAndLink() = 0;
-
- // override to to perform custom tasks on successfull compilation
- // and linkage. E.g. obtaining handles to shader attributes.
- virtual void OnCompiledAndLinked() {}
-
- // override to to perform custom tasks before shader is enabled
- // and after it is disabled. Return false in OnDisabled() to
- // disable shader.
- // E.g. setting attributes, disabling texture unites, etc
- virtual bool OnEnabled() { return true; }
- virtual void OnDisabled() { }
-
- virtual GLuint ProgramHandle() { return m_shaderProgram; }
-
- protected:
- CVertexShader* m_pVP;
- CPixelShader* m_pFP;
- GLuint m_shaderProgram;
- bool m_ok;
- };
-
-
- class CGLSLShaderProgram
- : virtual public CShaderProgram
- {
- public:
- CGLSLShaderProgram()
- {
- m_pFP = new CGLSLPixelShader();
- m_pVP = new CGLSLVertexShader();
- }
- CGLSLShaderProgram(const std::string& vert
- , const std::string& frag)
- {
- m_pFP = new CGLSLPixelShader();
- m_pFP->LoadSource(frag);
- m_pVP = new CGLSLVertexShader();
- m_pVP->LoadSource(vert);
- }
-
- // enable the shader
- virtual bool Enable();
-
- // disable the shader
- virtual void Disable();
-
- // free resources
- virtual void Free();
-
- // compile and link the shaders
- virtual bool CompileAndLink();
-
- protected:
- GLint m_lastProgram;
- bool m_validated;
- };
-
-
-#ifndef HAS_GLES
- class CARBShaderProgram
- : virtual public CShaderProgram
- {
- public:
- CARBShaderProgram()
- {
- m_pFP = new CARBPixelShader();
- m_pVP = new CARBVertexShader();
- }
- CARBShaderProgram(const std::string& vert
- , const std::string& frag)
- {
- m_pFP = new CARBPixelShader();
- m_pFP->LoadSource(vert);
- m_pVP = new CARBVertexShader();
- m_pVP->LoadSource(vert);
- }
-
- // enable the shader
- virtual bool Enable();
-
- // disable the shader
- virtual void Disable();
-
- // free resources
- virtual void Free();
-
- // compile and link the shaders
- virtual bool CompileAndLink();
-
- protected:
-
- };
-#endif
-
-} // close namespace
-
-#endif
-
-#endif //__SHADER_H__
diff --git a/guilib/StdString.h b/guilib/StdString.h
deleted file mode 100644
index 9800f946b2..0000000000
--- a/guilib/StdString.h
+++ /dev/null
@@ -1,4336 +0,0 @@
-#pragma once
-#include <string>
-#include <stdint.h>
-#include <vector>
-
-#if defined(_WIN32) && !defined(va_copy)
-#define va_copy(dst, src) ((dst) = (src))
-#endif
-
-// =============================================================================
-// FILE: StdString.h
-// AUTHOR: Joe O'Leary (with outside help noted in comments)
-//
-// If you find any bugs in this code, please let me know:
-//
-// jmoleary@earthlink.net
-// http://www.joeo.net/stdstring.htm (a bit outdated)
-//
-// The latest version of this code should always be available at the
-// following link:
-//
-// http://www.joeo.net/code/StdString.zip (Dec 6, 2003)
-//
-//
-// REMARKS:
-// This header file declares the CStdStr template. This template derives
-// the Standard C++ Library basic_string<> template and add to it the
-// the following conveniences:
-// - The full MFC CString set of functions (including implicit cast)
-// - writing to/reading from COM IStream interfaces
-// - Functional objects for use in STL algorithms
-//
-// From this template, we intstantiate two classes: CStdStringA and
-// CStdStringW. The name "CStdString" is just a #define of one of these,
-// based upone the UNICODE macro setting
-//
-// This header also declares our own version of the MFC/ATL UNICODE-MBCS
-// conversion macros. Our version looks exactly like the Microsoft's to
-// facilitate portability.
-//
-// NOTE:
-// If you you use this in an MFC or ATL build, you should include either
-// afx.h or atlbase.h first, as appropriate.
-//
-// PEOPLE WHO HAVE CONTRIBUTED TO THIS CLASS:
-//
-// Several people have helped me iron out problems and othewise improve
-// this class. OK, this is a long list but in my own defense, this code
-// has undergone two major rewrites. Many of the improvements became
-// necessary after I rewrote the code as a template. Others helped me
-// improve the CString facade.
-//
-// Anyway, these people are (in chronological order):
-//
-// - Pete the Plumber (???)
-// - Julian Selman
-// - Chris (of Melbsys)
-// - Dave Plummer
-// - John C Sipos
-// - Chris Sells
-// - Nigel Nunn
-// - Fan Xia
-// - Matthew Williams
-// - Carl Engman
-// - Mark Zeren
-// - Craig Watson
-// - Rich Zuris
-// - Karim Ratib
-// - Chris Conti
-// - Baptiste Lepilleur
-// - Greg Pickles
-// - Jim Cline
-// - Jeff Kohn
-// - Todd Heckel
-// - Ullrich Poll�hne
-// - Joe Vitaterna
-// - Joe Woodbury
-// - Aaron (no last name)
-// - Joldakowski (???)
-// - Scott Hathaway
-// - Eric Nitzche
-// - Pablo Presedo
-// - Farrokh Nejadlotfi
-// - Jason Mills
-// - Igor Kholodov
-// - Mike Crusader
-// - John James
-// - Wang Haifeng
-// - Tim Dowty
-// - Arnt Witteveen
-// - Glen Maynard
-// - Paul DeMarco
-// - Bagira (full name?)
-// - Ronny Schulz
-// - Jakko Van Hunen
-// - Charles Godwin
-// - Henk Demper
-// - Greg Marr
-// - Bill Carducci
-// - Brian Groose
-// - MKingman
-// - Don Beusee
-//
-// REVISION HISTORY
-//
-// 2005-JAN-10 - Thanks to Don Beusee for pointing out the danger in mapping
-// length-checked formatting functions to non-length-checked
-// CRT equivalents. Also thanks to him for motivating me to
-// optimize my implementation of Replace()
-//
-// 2004-APR-22 - A big, big thank you to "MKingman" (whoever you are) for
-// finally spotting a silly little error in StdCodeCvt that
-// has been causing me (and users of CStdString) problems for
-// years in some relatively rare conversions. I had reversed
-// two length arguments.
-//
-// 2003-NOV-24 - Thanks to a bunch of people for helping me clean up many
-// compiler warnings (and yes, even a couple of actual compiler
-// errors). These include Henk Demper for figuring out how
-// to make the Intellisense work on with CStdString on VC6,
-// something I was never able to do. Greg Marr pointed out
-// a compiler warning about an unreferenced symbol and a
-// problem with my version of Load in MFC builds. Bill
-// Carducci took a lot of time with me to help me figure out
-// why some implementations of the Standard C++ Library were
-// returning error codes for apparently successful conversions
-// between ASCII and UNICODE. Finally thanks to Brian Groose
-// for helping me fix compiler signed unsigned warnings in
-// several functions.
-//
-// 2003-JUL-10 - Thanks to Charles Godwin for making me realize my 'FmtArg'
-// fixes had inadvertently broken the DLL-export code (which is
-// normally commented out. I had to move it up higher. Also
-// this helped me catch a bug in ssicoll that would prevent
-// compilation, otherwise.
-//
-// 2003-MAR-14 - Thanks to Jakko Van Hunen for pointing out a copy-and-paste
-// bug in one of the overloads of FmtArg.
-//
-// 2003-MAR-10 - Thanks to Ronny Schulz for (twice!) sending me some changes
-// to help CStdString build on SGI and for pointing out an
-// error in placement of my preprocessor macros for ssfmtmsg.
-//
-// 2002-NOV-26 - Thanks to Bagira for pointing out that my implementation of
-// SpanExcluding was not properly handling the case in which
-// the string did NOT contain any of the given characters
-//
-// 2002-OCT-21 - Many thanks to Paul DeMarco who was invaluable in helping me
-// get this code working with Borland's free compiler as well
-// as the Dev-C++ compiler (available free at SourceForge).
-//
-// 2002-SEP-13 - Thanks to Glen Maynard who helped me get rid of some loud
-// but harmless warnings that were showing up on g++. Glen
-// also pointed out that some pre-declarations of FmtArg<>
-// specializations were unnecessary (and no good on G++)
-//
-// 2002-JUN-26 - Thanks to Arnt Witteveen for pointing out that I was using
-// static_cast<> in a place in which I should have been using
-// reinterpret_cast<> (the ctor for unsigned char strings).
-// That's what happens when I don't unit-test properly!
-// Arnt also noticed that CString was silently correcting the
-// 'nCount' argument to Left() and Right() where CStdString was
-// not (and crashing if it was bad). That is also now fixed!
-//
-// 2002-FEB-25 - Thanks to Tim Dowty for pointing out (and giving me the fix
-// for) a conversion problem with non-ASCII MBCS characters.
-// CStdString is now used in my favorite commercial MP3 player!
-//
-// 2001-DEC-06 - Thanks to Wang Haifeng for spotting a problem in one of the
-// assignment operators (for _bstr_t) that would cause compiler
-// errors when refcounting protection was turned off.
-//
-// 2001-NOV-27 - Remove calls to operator!= which involve reverse_iterators
-// due to a conflict with the rel_ops operator!=. Thanks to
-// John James for pointing this out.
-//
-// 2001-OCT-29 - Added a minor range checking fix for the Mid function to
-// make it as forgiving as CString's version is. Thanks to
-// Igor Kholodov for noticing this.
-// - Added a specialization of std::swap for CStdString. Thanks
-// to Mike Crusader for suggesting this! It's commented out
-// because you're not supposed to inject your own code into the
-// 'std' namespace. But if you don't care about that, it's
-// there if you want it
-// - Thanks to Jason Mills for catching a case where CString was
-// more forgiving in the Delete() function than I was.
-//
-// 2001-JUN-06 - I was violating the Standard name lookup rules stated
-// in [14.6.2(3)]. None of the compilers I've tried so
-// far apparently caught this but HP-UX aCC 3.30 did. The
-// fix was to add 'this->' prefixes in many places.
-// Thanks to Farrokh Nejadlotfi for this!
-//
-// 2001-APR-27 - StreamLoad was calculating the number of BYTES in one
-// case, not characters. Thanks to Pablo Presedo for this.
-//
-// 2001-FEB-23 - Replace() had a bug which caused infinite loops if the
-// source string was empty. Fixed thanks to Eric Nitzsche.
-//
-// 2001-FEB-23 - Scott Hathaway was a huge help in providing me with the
-// ability to build CStdString on Sun Unix systems. He
-// sent me detailed build reports about what works and what
-// does not. If CStdString compiles on your Unix box, you
-// can thank Scott for it.
-//
-// 2000-DEC-29 - Joldakowski noticed one overload of Insert failed to do a
-// range check as CString's does. Now fixed -- thanks!
-//
-// 2000-NOV-07 - Aaron pointed out that I was calling static member
-// functions of char_traits via a temporary. This was not
-// technically wrong, but it was unnecessary and caused
-// problems for poor old buggy VC5. Thanks Aaron!
-//
-// 2000-JUL-11 - Joe Woodbury noted that the CString::Find docs don't match
-// what the CString::Find code really ends up doing. I was
-// trying to match the docs. Now I match the CString code
-// - Joe also caught me truncating strings for GetBuffer() calls
-// when the supplied length was less than the current length.
-//
-// 2000-MAY-25 - Better support for STLPORT's Standard library distribution
-// - Got rid of the NSP macro - it interfered with Koenig lookup
-// - Thanks to Joe Woodbury for catching a TrimLeft() bug that
-// I introduced in January. Empty strings were not getting
-// trimmed
-//
-// 2000-APR-17 - Thanks to Joe Vitaterna for pointing out that ReverseFind
-// is supposed to be a const function.
-//
-// 2000-MAR-07 - Thanks to Ullrich Poll�hne for catching a range bug in one
-// of the overloads of assign.
-//
-// 2000-FEB-01 - You can now use CStdString on the Mac with CodeWarrior!
-// Thanks to Todd Heckel for helping out with this.
-//
-// 2000-JAN-23 - Thanks to Jim Cline for pointing out how I could make the
-// Trim() function more efficient.
-// - Thanks to Jeff Kohn for prompting me to find and fix a typo
-// in one of the addition operators that takes _bstr_t.
-// - Got rid of the .CPP file - you only need StdString.h now!
-//
-// 1999-DEC-22 - Thanks to Greg Pickles for helping me identify a problem
-// with my implementation of CStdString::FormatV in which
-// resulting string might not be properly NULL terminated.
-//
-// 1999-DEC-06 - Chris Conti pointed yet another basic_string<> assignment
-// bug that MS has not fixed. CStdString did nothing to fix
-// it either but it does now! The bug was: create a string
-// longer than 31 characters, get a pointer to it (via c_str())
-// and then assign that pointer to the original string object.
-// The resulting string would be empty. Not with CStdString!
-//
-// 1999-OCT-06 - BufferSet was erasing the string even when it was merely
-// supposed to shrink it. Fixed. Thanks to Chris Conti.
-// - Some of the Q172398 fixes were not checking for assignment-
-// to-self. Fixed. Thanks to Baptiste Lepilleur.
-//
-// 1999-AUG-20 - Improved Load() function to be more efficient by using
-// SizeOfResource(). Thanks to Rich Zuris for this.
-// - Corrected resource ID constructor, again thanks to Rich.
-// - Fixed a bug that occurred with UNICODE characters above
-// the first 255 ANSI ones. Thanks to Craig Watson.
-// - Added missing overloads of TrimLeft() and TrimRight().
-// Thanks to Karim Ratib for pointing them out
-//
-// 1999-JUL-21 - Made all calls to GetBuf() with no args check length first.
-//
-// 1999-JUL-10 - Improved MFC/ATL independence of conversion macros
-// - Added SS_NO_REFCOUNT macro to allow you to disable any
-// reference-counting your basic_string<> impl. may do.
-// - Improved ReleaseBuffer() to be as forgiving as CString.
-// Thanks for Fan Xia for helping me find this and to
-// Matthew Williams for pointing it out directly.
-//
-// 1999-JUL-06 - Thanks to Nigel Nunn for catching a very sneaky bug in
-// ToLower/ToUpper. They should call GetBuf() instead of
-// data() in order to ensure the changed string buffer is not
-// reference-counted (in those implementations that refcount).
-//
-// 1999-JUL-01 - Added a true CString facade. Now you can use CStdString as
-// a drop-in replacement for CString. If you find this useful,
-// you can thank Chris Sells for finally convincing me to give
-// in and implement it.
-// - Changed operators << and >> (for MFC CArchive) to serialize
-// EXACTLY as CString's do. So now you can send a CString out
-// to a CArchive and later read it in as a CStdString. I have
-// no idea why you would want to do this but you can.
-//
-// 1999-JUN-21 - Changed the CStdString class into the CStdStr template.
-// - Fixed FormatV() to correctly decrement the loop counter.
-// This was harmless bug but a bug nevertheless. Thanks to
-// Chris (of Melbsys) for pointing it out
-// - Changed Format() to try a normal stack-based array before
-// using to _alloca().
-// - Updated the text conversion macros to properly use code
-// pages and to fit in better in MFC/ATL builds. In other
-// words, I copied Microsoft's conversion stuff again.
-// - Added equivalents of CString::GetBuffer, GetBufferSetLength
-// - new sscpy() replacement of CStdString::CopyString()
-// - a Trim() function that combines TrimRight() and TrimLeft().
-//
-// 1999-MAR-13 - Corrected the "NotSpace" functional object to use _istpace()
-// instead of _isspace() Thanks to Dave Plummer for this.
-//
-// 1999-FEB-26 - Removed errant line (left over from testing) that #defined
-// _MFC_VER. Thanks to John C Sipos for noticing this.
-//
-// 1999-FEB-03 - Fixed a bug in a rarely-used overload of operator+() that
-// caused infinite recursion and stack overflow
-// - Added member functions to simplify the process of
-// persisting CStdStrings to/from DCOM IStream interfaces
-// - Added functional objects (e.g. StdStringLessNoCase) that
-// allow CStdStrings to be used as keys STL map objects with
-// case-insensitive comparison
-// - Added array indexing operators (i.e. operator[]). I
-// originally assumed that these were unnecessary and would be
-// inherited from basic_string. However, without them, Visual
-// C++ complains about ambiguous overloads when you try to use
-// them. Thanks to Julian Selman to pointing this out.
-//
-// 1998-FEB-?? - Added overloads of assign() function to completely account
-// for Q172398 bug. Thanks to "Pete the Plumber" for this
-//
-// 1998-FEB-?? - Initial submission
-//
-// COPYRIGHT:
-// 2002 Joseph M. O'Leary. This code is 100% free. Use it anywhere you
-// want. Rewrite it, restructure it, whatever. If you can write software
-// that makes money off of it, good for you. I kinda like capitalism.
-// Please don't blame me if it causes your $30 billion dollar satellite
-// explode in orbit. If you redistribute it in any form, I'd appreciate it
-// if you would leave this notice here.
-// =============================================================================
-
-// Avoid multiple inclusion
-
-#ifndef STDSTRING_H
-#define STDSTRING_H
-
-// When using VC, turn off browser references
-// Turn off unavoidable compiler warnings
-
-#if defined(_MSC_VER) && (_MSC_VER > 1100)
- #pragma component(browser, off, references, "CStdString")
- #pragma warning (disable : 4290) // C++ Exception Specification ignored
- #pragma warning (disable : 4127) // Conditional expression is constant
- #pragma warning (disable : 4097) // typedef name used as synonym for class name
-#endif
-
-// Borland warnings to turn off
-
-#ifdef __BORLANDC__
- #pragma option push -w-inl
-// #pragma warn -inl // Turn off inline function warnings
-#endif
-
-// SS_IS_INTRESOURCE
-// -----------------
-// A copy of IS_INTRESOURCE from VC7. Because old VC6 version of winuser.h
-// doesn't have this.
-
-#define SS_IS_INTRESOURCE(_r) (false)
-
-#if !defined (SS_ANSI) && defined(_MSC_VER)
- #undef SS_IS_INTRESOURCE
- #if defined(_WIN64)
- #define SS_IS_INTRESOURCE(_r) (((unsigned __int64)(_r) >> 16) == 0)
- #else
- #define SS_IS_INTRESOURCE(_r) (((unsigned long)(_r) >> 16) == 0)
- #endif
-#endif
-
-
-// MACRO: SS_UNSIGNED
-// ------------------
-// This macro causes the addition of a constructor and assignment operator
-// which take unsigned characters. CString has such functions and in order
-// to provide maximum CString-compatability, this code needs them as well.
-// In practice you will likely never need these functions...
-
-//#define SS_UNSIGNED
-
-#ifdef SS_ALLOW_UNSIGNED_CHARS
- #define SS_UNSIGNED
-#endif
-
-// MACRO: SS_SAFE_FORMAT
-// ---------------------
-// This macro provides limited compatability with a questionable CString
-// "feature". You can define it in order to avoid a common problem that
-// people encounter when switching from CString to CStdString.
-//
-// To illustrate the problem -- With CString, you can do this:
-//
-// CString sName("Joe");
-// CString sTmp;
-// sTmp.Format("My name is %s", sName); // WORKS!
-//
-// However if you were to try this with CStdString, your program would
-// crash.
-//
-// CStdString sName("Joe");
-// CStdString sTmp;
-// sTmp.Format("My name is %s", sName); // CRASHES!
-//
-// You must explicitly call c_str() or cast the object to the proper type
-//
-// sTmp.Format("My name is %s", sName.c_str()); // WORKS!
-// sTmp.Format("My name is %s", static_cast<PCSTR>(sName));// WORKS!
-// sTmp.Format("My name is %s", (PCSTR)sName); // WORKS!
-//
-// This is because it is illegal to pass anything but a POD type as a
-// variadic argument to a variadic function (i.e. as one of the "..."
-// arguments). The type const char* is a POD type. The type CStdString
-// is not. Of course, neither is the type CString, but CString lets you do
-// it anyway due to the way they laid out the class in binary. I have no
-// control over this in CStdString since I derive from whatever
-// implementation of basic_string is available.
-//
-// However if you have legacy code (which does this) that you want to take
-// out of the MFC world and you don't want to rewrite all your calls to
-// Format(), then you can define this flag and it will no longer crash.
-//
-// Note however that this ONLY works for Format(), not sprintf, fprintf,
-// etc. If you pass a CStdString object to one of those functions, your
-// program will crash. Not much I can do to get around this, short of
-// writing substitutes for those functions as well.
-
-#define SS_SAFE_FORMAT // use new template style Format() function
-
-
-// MACRO: SS_NO_IMPLICIT_CAST
-// --------------------------
-// Some people don't like the implicit cast to const char* (or rather to
-// const CT*) that CStdString (and MFC's CString) provide. That was the
-// whole reason I created this class in the first place, but hey, whatever
-// bakes your cake. Just #define this macro to get rid of the the implicit
-// cast.
-
-//#define SS_NO_IMPLICIT_CAST // gets rid of operator const CT*()
-
-
-// MACRO: SS_NO_REFCOUNT
-// ---------------------
-// turns off reference counting at the assignment level. Only needed
-// for the version of basic_string<> that comes with Visual C++ versions
-// 6.0 or earlier, and only then in some heavily multithreaded scenarios.
-// Uncomment it if you feel you need it.
-
-//#define SS_NO_REFCOUNT
-
-// MACRO: SS_WIN32
-// ---------------
-// When this flag is set, we are building code for the Win32 platform and
-// may use Win32 specific functions (such as LoadString). This gives us
-// a couple of nice extras for the code.
-//
-// Obviously, Microsoft's is not the only compiler available for Win32 out
-// there. So I can't just check to see if _MSC_VER is defined to detect
-// if I'm building on Win32. So for now, if you use MS Visual C++ or
-// Borland's compiler, I turn this on. Otherwise you may turn it on
-// yourself, if you prefer
-
-#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WIN32)
- #define SS_WIN32
-#endif
-
-// MACRO: SS_ANSI
-// --------------
-// When this macro is defined, the code attempts only to use ANSI/ISO
-// standard library functions to do it's work. It will NOT attempt to use
-// any Win32 of Visual C++ specific functions -- even if they are
-// available. You may define this flag yourself to prevent any Win32
-// of VC++ specific functions from being called.
-
-// If we're not on Win32, we MUST use an ANSI build
-
-#ifndef SS_WIN32
- #if !defined(SS_NO_ANSI)
- #define SS_ANSI
- #endif
-#endif
-
-// MACRO: SS_ALLOCA
-// ----------------
-// Some implementations of the Standard C Library have a non-standard
-// function known as alloca(). This functions allows one to allocate a
-// variable amount of memory on the stack. It is needed to implement
-// the ASCII/MBCS conversion macros.
-//
-// I wanted to find some way to determine automatically if alloca() is
-// available on this platform via compiler flags but that is asking for
-// trouble. The crude test presented here will likely need fixing on
-// other platforms. Therefore I'll leave it up to you to fiddle with
-// this test to determine if it exists. Just make sure SS_ALLOCA is or
-// is not defined as appropriate and you control this feature.
-
-#if defined(_MSC_VER) && !defined(SS_ANSI)
- #define SS_ALLOCA
-#endif
-
-
-// MACRO: SS_MBCS
-// --------------
-// Setting this macro means you are using MBCS characters. In MSVC builds,
-// this macro gets set automatically by detection of the preprocessor flag
-// _MBCS. For other platforms you may set it manually if you wish. The
-// only effect it currently has is to cause the allocation of more space
-// for wchar_t --> char conversions.
-// Note that MBCS does not mean UNICODE.
-//
-// #define SS_MBCS
-//
-
-#ifdef _MBCS
- #define SS_MBCS
-#endif
-
-
-// MACRO SS_NO_LOCALE
-// ------------------
-// If your implementation of the Standard C++ Library lacks the <locale> header,
-// you can #define this macro to make your code build properly. Note that this
-// is some of my newest code and frankly I'm not very sure of it, though it does
-// pass my unit tests.
-
-// #define SS_NO_LOCALE
-
-
-// Compiler Error regarding _UNICODE and UNICODE
-// -----------------------------------------------
-// Microsoft header files are screwy. Sometimes they depend on a preprocessor
-// flag named "_UNICODE". Other times they check "UNICODE" (note the lack of
-// leading underscore in the second version". In several places, they silently
-// "synchronize" these two flags this by defining one of the other was defined.
-// In older version of this header, I used to try to do the same thing.
-//
-// However experience has taught me that this is a bad idea. You get weird
-// compiler errors that seem to indicate things like LPWSTR and LPTSTR not being
-// equivalent in UNICODE builds, stuff like that (when they MUST be in a proper
-// UNICODE build). You end up scratching your head and saying, "But that HAS
-// to compile!".
-//
-// So what should you do if you get this error?
-//
-// Make sure that both macros (_UNICODE and UNICODE) are defined before this
-// file is included. You can do that by either
-//
-// a) defining both yourself before any files get included
-// b) including the proper MS headers in the proper order
-// c) including this file before any other file, uncommenting
-// the #defines below, and commenting out the #errors
-//
-// Personally I recommend solution a) but it's your call.
-
-#ifdef _MSC_VER
- #if defined (_UNICODE) && !defined (UNICODE)
- #error UNICODE defined but not UNICODE
- // #define UNICODE // no longer silently fix this
- #endif
- #if defined (UNICODE) && !defined (_UNICODE)
- #error Warning, UNICODE defined but not _UNICODE
- // #define _UNICODE // no longer silently fix this
- #endif
-#endif
-
-
-// -----------------------------------------------------------------------------
-// MIN and MAX. The Standard C++ template versions go by so many names (at
-// at least in the MS implementation) that you never know what's available
-// -----------------------------------------------------------------------------
-template<class Type>
-inline const Type& SSMIN(const Type& arg1, const Type& arg2)
-{
- return arg2 < arg1 ? arg2 : arg1;
-}
-template<class Type>
-inline const Type& SSMAX(const Type& arg1, const Type& arg2)
-{
- return arg2 > arg1 ? arg2 : arg1;
-}
-
-// If they have not #included W32Base.h (part of my W32 utility library) then
-// we need to define some stuff. Otherwise, this is all defined there.
-
-#if !defined(W32BASE_H)
-
- // If they want us to use only standard C++ stuff (no Win32 stuff)
-
- #ifdef SS_ANSI
-
- // On Win32 we have TCHAR.H so just include it. This is NOT violating
- // the spirit of SS_ANSI as we are not calling any Win32 functions here.
-
- #ifdef SS_WIN32
-
- #include <TCHAR.H>
- #include <WTYPES.H>
- #ifndef STRICT
- #define STRICT
- #endif
-
- // ... but on non-Win32 platforms, we must #define the types we need.
-
- #else
-
- typedef const char* PCSTR;
- typedef char* PSTR;
- typedef const wchar_t* PCWSTR;
- typedef wchar_t* PWSTR;
- #ifdef UNICODE
- typedef wchar_t TCHAR;
- #else
- typedef char TCHAR;
- #endif
- typedef wchar_t OLECHAR;
-
- #endif // #ifndef _WIN32
-
-
- // Make sure ASSERT and verify are defined using only ANSI stuff
-
- #ifndef ASSERT
- #include <assert.h>
- #define ASSERT(f) assert((f))
- #endif
- #ifndef VERIFY
- #ifdef _DEBUG
- #define VERIFY(x) ASSERT((x))
- #else
- #define VERIFY(x) x
- #endif
- #endif
-
- #else // ...else SS_ANSI is NOT defined
-
- #include <TCHAR.H>
- #include <WTYPES.H>
- #ifndef STRICT
- #define STRICT
- #endif
-
- // Make sure ASSERT and verify are defined
-
- #ifndef ASSERT
- #include <crtdbg.h>
- #define ASSERT(f) _ASSERTE((f))
- #endif
- #ifndef VERIFY
- #ifdef _DEBUG
- #define VERIFY(x) ASSERT((x))
- #else
- #define VERIFY(x) x
- #endif
- #endif
-
- #endif // #ifdef SS_ANSI
-
- #ifndef UNUSED
- #define UNUSED(x) x
- #endif
-
-#endif // #ifndef W32BASE_H
-
-// Standard headers needed
-
-#include <string> // basic_string
-#include <algorithm> // for_each, etc.
-#include <functional> // for StdStringLessNoCase, et al
-#ifndef SS_NO_LOCALE
- #include <locale> // for various facets
-#endif
-
-// If this is a recent enough version of VC include comdef.h, so we can write
-// member functions to deal with COM types & compiler support classes e.g.
-// _bstr_t
-
-#if defined (_MSC_VER) && (_MSC_VER >= 1100)
- #include <comdef.h>
- #define SS_INC_COMDEF // signal that we #included MS comdef.h file
- #define STDSTRING_INC_COMDEF
- #define SS_NOTHROW __declspec(nothrow)
-#else
- #define SS_NOTHROW
-#endif
-
-#ifndef TRACE
- #define TRACE_DEFINED_HERE
- #define TRACE
-#endif
-
-// Microsoft defines PCSTR, PCWSTR, etc, but no PCTSTR. I hate to use the
-// versions with the "L" in front of them because that's a leftover from Win 16
-// days, even though it evaluates to the same thing. Therefore, Define a PCSTR
-// as an LPCTSTR.
-
-#if !defined(PCTSTR) && !defined(PCTSTR_DEFINED)
- typedef const TCHAR* PCTSTR;
- #define PCTSTR_DEFINED
-#endif
-
-#if !defined(PCOLESTR) && !defined(PCOLESTR_DEFINED)
- typedef const OLECHAR* PCOLESTR;
- #define PCOLESTR_DEFINED
-#endif
-
-#if !defined(POLESTR) && !defined(POLESTR_DEFINED)
- typedef OLECHAR* POLESTR;
- #define POLESTR_DEFINED
-#endif
-
-#if !defined(PCUSTR) && !defined(PCUSTR_DEFINED)
- typedef const unsigned char* PCUSTR;
- typedef unsigned char* PUSTR;
- #define PCUSTR_DEFINED
-#endif
-
-
-// SGI compiler 7.3 doesnt know these types - oh and btw, remember to use
-// -LANG:std in the CXX Flags
-#if defined(__sgi)
- typedef unsigned long DWORD;
- typedef void * LPCVOID;
-#endif
-
-
-// SS_USE_FACET macro and why we need it:
-//
-// Since I'm a good little Standard C++ programmer, I use locales. Thus, I
-// need to make use of the use_facet<> template function here. Unfortunately,
-// this need is complicated by the fact the MS' implementation of the Standard
-// C++ Library has a non-standard version of use_facet that takes more
-// arguments than the standard dictates. Since I'm trying to write CStdString
-// to work with any version of the Standard library, this presents a problem.
-//
-// The upshot of this is that I can't do 'use_facet' directly. The MS' docs
-// tell me that I have to use a macro, _USE() instead. Since _USE obviously
-// won't be available in other implementations, this means that I have to write
-// my OWN macro -- SS_USE_FACET -- that evaluates either to _USE or to the
-// standard, use_facet.
-//
-// If you are having trouble with the SS_USE_FACET macro, in your implementation
-// of the Standard C++ Library, you can define your own version of SS_USE_FACET.
-
-#ifndef schMSG
- #define schSTR(x) #x
- #define schSTR2(x) schSTR(x)
- #define schMSG(desc) message(__FILE__ "(" schSTR2(__LINE__) "):" #desc)
-#endif
-
-#ifndef SS_USE_FACET
-
- // STLPort #defines a macro (__STL_NO_EXPLICIT_FUNCTION_TMPL_ARGS) for
- // all MSVC builds, erroneously in my opinion. It causes problems for
- // my SS_ANSI builds. In my code, I always comment out that line. You'll
- // find it in \stlport\config\stl_msvc.h
-
- #if defined(__SGI_STL_PORT) && (__SGI_STL_PORT >= 0x400 )
-
- #if defined(__STL_NO_EXPLICIT_FUNCTION_TMPL_ARGS) && defined(_MSC_VER)
- #ifdef SS_ANSI
- #pragma schMSG(__STL_NO_EXPLICIT_FUNCTION_TMPL_ARGS defined!!)
- #endif
- #endif
- #define SS_USE_FACET(loc, fac) std::use_facet<fac >(loc)
-
- #elif defined(_MSC_VER )
-
- #define SS_USE_FACET(loc, fac) std::_USE(loc, fac)
-
- // ...and
- #elif defined(_RWSTD_NO_TEMPLATE_ON_RETURN_TYPE)
-
- #define SS_USE_FACET(loc, fac) std::use_facet(loc, (fac*)0)
-
- #else
-
- #define SS_USE_FACET(loc, fac) std::use_facet<fac >(loc)
-
- #endif
-
-#endif
-
-// =============================================================================
-// UNICODE/MBCS conversion macros. Made to work just like the MFC/ATL ones.
-// =============================================================================
-
-#include <wchar.h> // Added to Std Library with Amendment #1.
-
-// First define the conversion helper functions. We define these regardless of
-// any preprocessor macro settings since their names won't collide.
-
-// Not sure if we need all these headers. I believe ANSI says we do.
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <wctype.h>
-#include <ctype.h>
-#include <stdlib.h>
-#ifndef va_start
- #include <varargs.h>
-#endif
-
-
-#ifdef SS_NO_LOCALE
-
- #if defined(_WIN32) || defined (_WIN32_WCE)
-
- inline PWSTR StdCodeCvt(PWSTR pDstW, int nDst, PCSTR pSrcA, int nSrc,
- UINT acp=CP_ACP)
- {
- ASSERT(0 != pSrcA);
- ASSERT(0 != pDstW);
- pDstW[0] = '\0';
- MultiByteToWideChar(acp, 0, pSrcA, nSrc, pDstW, nDst);
- return pDstW;
- }
- inline PWSTR StdCodeCvt(PWSTR pDstW, int nDst, PCUSTR pSrcA, int nSrc,
- UINT acp=CP_ACP)
- {
- return StdCodeCvt(pDstW, nDst, (PCSTR)pSrcA, nSrc, acp);
- }
-
- inline PSTR StdCodeCvt(PSTR pDstA, int nDst, PCWSTR pSrcW, int nSrc,
- UINT acp=CP_ACP)
- {
- ASSERT(0 != pDstA);
- ASSERT(0 != pSrcW);
- pDstA[0] = '\0';
- WideCharToMultiByte(acp, 0, pSrcW, nSrc, pDstA, nDst, 0, 0);
- return pDstA;
- }
- inline PUSTR StdCodeCvt(PUSTR pDstA, int nDst, PCWSTR pSrcW, int nSrc,
- UINT acp=CP_ACP)
- {
- return (PUSTR)StdCodeCvt((PSTR)pDstA, nDst, pSrcW, nSrc, acp);
- }
- #else
- #endif
-
-#else
-
- // StdCodeCvt - made to look like Win32 functions WideCharToMultiByte
- // and MultiByteToWideChar but uses locales in SS_ANSI
- // builds. There are a number of overloads.
- // First argument is the destination buffer.
- // Second argument is the source buffer
- //#if defined (SS_ANSI) || !defined (SS_WIN32)
-
- // 'SSCodeCvt' - shorthand name for the codecvt facet we use
-
- typedef std::codecvt<wchar_t, char, mbstate_t> SSCodeCvt;
-
- inline PWSTR StdCodeCvt(PWSTR pDstW, int nDst, PCSTR pSrcA, int nSrc,
- const std::locale& loc=std::locale())
- {
- ASSERT(0 != pSrcA);
- ASSERT(0 != pDstW);
-
- pDstW[0] = '\0';
-
- if ( nSrc > 0 )
- {
- PCSTR pNextSrcA = pSrcA;
- PWSTR pNextDstW = pDstW;
- SSCodeCvt::result res = SSCodeCvt::ok;
- const SSCodeCvt& conv = SS_USE_FACET(loc, SSCodeCvt);
- SSCodeCvt::state_type st= { 0 };
- res = conv.in(st,
- pSrcA, pSrcA + nSrc, pNextSrcA,
- pDstW, pDstW + nDst, pNextDstW);
-#ifdef _LINUX
-#define ASSERT2(a) if (!(a)) {fprintf(stderr, "StdString: Assertion Failed on line %d\n", __LINE__);}
-#else
-#define ASSERT2 ASSERT
-#endif
- ASSERT2(SSCodeCvt::ok == res);
- ASSERT2(SSCodeCvt::error != res);
- ASSERT2(pNextDstW >= pDstW);
- ASSERT2(pNextSrcA >= pSrcA);
-#undef ASSERT2
- // Null terminate the converted string
-
- if ( pNextDstW - pDstW > nDst )
- *(pDstW + nDst) = '\0';
- else
- *pNextDstW = '\0';
- }
- return pDstW;
- }
- inline PWSTR StdCodeCvt(PWSTR pDstW, int nDst, PCUSTR pSrcA, int nSrc,
- const std::locale& loc=std::locale())
- {
- return StdCodeCvt(pDstW, nDst, (PCSTR)pSrcA, nSrc, loc);
- }
-
- inline PSTR StdCodeCvt(PSTR pDstA, int nDst, PCWSTR pSrcW, int nSrc,
- const std::locale& loc=std::locale())
- {
- ASSERT(0 != pDstA);
- ASSERT(0 != pSrcW);
-
- pDstA[0] = '\0';
-
- if ( nSrc > 0 )
- {
- PSTR pNextDstA = pDstA;
- PCWSTR pNextSrcW = pSrcW;
- SSCodeCvt::result res = SSCodeCvt::ok;
- const SSCodeCvt& conv = SS_USE_FACET(loc, SSCodeCvt);
- SSCodeCvt::state_type st= { 0 };
- res = conv.out(st,
- pSrcW, pSrcW + nSrc, pNextSrcW,
- pDstA, pDstA + nDst, pNextDstA);
-#ifdef _LINUX
-#define ASSERT2(a) if (!(a)) {fprintf(stderr, "StdString: Assertion Failed on line %d\n", __LINE__);}
-#else
-#define ASSERT2 ASSERT
-#endif
- ASSERT2(SSCodeCvt::error != res);
- ASSERT2(SSCodeCvt::ok == res); // strict, comment out for sanity
- ASSERT2(pNextDstA >= pDstA);
- ASSERT2(pNextSrcW >= pSrcW);
-#undef ASSERT2
-
- // Null terminate the converted string
-
- if ( pNextDstA - pDstA > nDst )
- *(pDstA + nDst) = '\0';
- else
- *pNextDstA = '\0';
- }
- return pDstA;
- }
-
- inline PUSTR StdCodeCvt(PUSTR pDstA, int nDst, PCWSTR pSrcW, int nSrc,
- const std::locale& loc=std::locale())
- {
- return (PUSTR)StdCodeCvt((PSTR)pDstA, nDst, pSrcW, nSrc, loc);
- }
-
-#endif
-
-
-
-// Unicode/MBCS conversion macros are only available on implementations of
-// the "C" library that have the non-standard _alloca function. As far as I
-// know that's only Microsoft's though I've heard that the function exists
-// elsewhere.
-
-#if defined(SS_ALLOCA) && !defined SS_NO_CONVERSION
-
- #include <malloc.h> // needed for _alloca
-
- // Define our conversion macros to look exactly like Microsoft's to
- // facilitate using this stuff both with and without MFC/ATL
-
- #ifdef _CONVERSION_USES_THREAD_LOCALE
-
- #ifndef _DEBUG
- #define SSCVT int _cvt; _cvt; UINT _acp=GetACP(); \
- _acp; PCWSTR _pw; _pw; PCSTR _pa; _pa
- #else
- #define SSCVT int _cvt = 0; _cvt; UINT _acp=GetACP();\
- _acp; PCWSTR _pw=0; _pw; PCSTR _pa=0; _pa
- #endif
- #define SSA2W(pa) (\
- ((_pa = pa) == 0) ? 0 : (\
- _cvt = (sslen(_pa)),\
- StdCodeCvt((PWSTR) _alloca((_cvt+1)*2), (_cvt+1)*2, \
- _pa, _cvt, _acp)))
- #define SSW2A(pw) (\
- ((_pw = pw) == 0) ? 0 : (\
- _cvt = sslen(_pw), \
- StdCodeCvt((LPSTR) _alloca((_cvt+1)*2), (_cvt+1)*2, \
- _pw, _cvt, _acp)))
- #else
-
- #ifndef _DEBUG
- #define SSCVT int _cvt; _cvt; UINT _acp=CP_ACP; _acp;\
- PCWSTR _pw; _pw; PCSTR _pa; _pa
- #else
- #define SSCVT int _cvt = 0; _cvt; UINT _acp=CP_ACP; \
- _acp; PCWSTR _pw=0; _pw; PCSTR _pa=0; _pa
- #endif
- #define SSA2W(pa) (\
- ((_pa = pa) == 0) ? 0 : (\
- _cvt = (sslen(_pa)),\
- StdCodeCvt((PWSTR) _alloca((_cvt+1)*2), (_cvt+1)*2, \
- _pa, _cvt)))
- #define SSW2A(pw) (\
- ((_pw = pw) == 0) ? 0 : (\
- _cvt = (sslen(_pw)),\
- StdCodeCvt((LPSTR) _alloca((_cvt+1)*2), (_cvt+1)*2, \
- _pw, _cvt)))
- #endif
-
- #define SSA2CW(pa) ((PCWSTR)SSA2W((pa)))
- #define SSW2CA(pw) ((PCSTR)SSW2A((pw)))
-
- #ifdef UNICODE
- #define SST2A SSW2A
- #define SSA2T SSA2W
- #define SST2CA SSW2CA
- #define SSA2CT SSA2CW
- // (Did you get a compiler error here about not being able to convert
- // PTSTR into PWSTR? Then your _UNICODE and UNICODE flags are messed
- // up. Best bet: #define BOTH macros before including any MS headers.)
- inline PWSTR SST2W(PTSTR p) { return p; }
- inline PTSTR SSW2T(PWSTR p) { return p; }
- inline PCWSTR SST2CW(PCTSTR p) { return p; }
- inline PCTSTR SSW2CT(PCWSTR p) { return p; }
- #else
- #define SST2W SSA2W
- #define SSW2T SSW2A
- #define SST2CW SSA2CW
- #define SSW2CT SSW2CA
- inline PSTR SST2A(PTSTR p) { return p; }
- inline PTSTR SSA2T(PSTR p) { return p; }
- inline PCSTR SST2CA(PCTSTR p) { return p; }
- inline PCTSTR SSA2CT(PCSTR p) { return p; }
- #endif // #ifdef UNICODE
-
- #if defined(UNICODE)
- // in these cases the default (TCHAR) is the same as OLECHAR
- inline PCOLESTR SST2COLE(PCTSTR p) { return p; }
- inline PCTSTR SSOLE2CT(PCOLESTR p) { return p; }
- inline POLESTR SST2OLE(PTSTR p) { return p; }
- inline PTSTR SSOLE2T(POLESTR p) { return p; }
- #elif defined(OLE2ANSI)
- // in these cases the default (TCHAR) is the same as OLECHAR
- inline PCOLESTR SST2COLE(PCTSTR p) { return p; }
- inline PCTSTR SSOLE2CT(PCOLESTR p) { return p; }
- inline POLESTR SST2OLE(PTSTR p) { return p; }
- inline PTSTR SSOLE2T(POLESTR p) { return p; }
- #else
- //CharNextW doesn't work on Win95 so we use this
- #define SST2COLE(pa) SSA2CW((pa))
- #define SST2OLE(pa) SSA2W((pa))
- #define SSOLE2CT(po) SSW2CA((po))
- #define SSOLE2T(po) SSW2A((po))
- #endif
-
- #ifdef OLE2ANSI
- #define SSW2OLE SSW2A
- #define SSOLE2W SSA2W
- #define SSW2COLE SSW2CA
- #define SSOLE2CW SSA2CW
- inline POLESTR SSA2OLE(PSTR p) { return p; }
- inline PSTR SSOLE2A(POLESTR p) { return p; }
- inline PCOLESTR SSA2COLE(PCSTR p) { return p; }
- inline PCSTR SSOLE2CA(PCOLESTR p){ return p; }
- #else
- #define SSA2OLE SSA2W
- #define SSOLE2A SSW2A
- #define SSA2COLE SSA2CW
- #define SSOLE2CA SSW2CA
- inline POLESTR SSW2OLE(PWSTR p) { return p; }
- inline PWSTR SSOLE2W(POLESTR p) { return p; }
- inline PCOLESTR SSW2COLE(PCWSTR p) { return p; }
- inline PCWSTR SSOLE2CW(PCOLESTR p){ return p; }
- #endif
-
- // Above we've defined macros that look like MS' but all have
- // an 'SS' prefix. Now we need the real macros. We'll either
- // get them from the macros above or from MFC/ATL.
-
- #if defined (USES_CONVERSION)
-
- #define _NO_STDCONVERSION // just to be consistent
-
- #else
-
- #ifdef _MFC_VER
-
- #include <afxconv.h>
- #define _NO_STDCONVERSION // just to be consistent
-
- #else
-
- #define USES_CONVERSION SSCVT
- #define A2CW SSA2CW
- #define W2CA SSW2CA
- #define T2A SST2A
- #define A2T SSA2T
- #define T2W SST2W
- #define W2T SSW2T
- #define T2CA SST2CA
- #define A2CT SSA2CT
- #define T2CW SST2CW
- #define W2CT SSW2CT
- #define ocslen sslen
- #define ocscpy sscpy
- #define T2COLE SST2COLE
- #define OLE2CT SSOLE2CT
- #define T2OLE SST2COLE
- #define OLE2T SSOLE2CT
- #define A2OLE SSA2OLE
- #define OLE2A SSOLE2A
- #define W2OLE SSW2OLE
- #define OLE2W SSOLE2W
- #define A2COLE SSA2COLE
- #define OLE2CA SSOLE2CA
- #define W2COLE SSW2COLE
- #define OLE2CW SSOLE2CW
-
- #endif // #ifdef _MFC_VER
- #endif // #ifndef USES_CONVERSION
-#endif // #ifndef SS_NO_CONVERSION
-
-// Define ostring - generic name for std::basic_string<OLECHAR>
-
-#if !defined(ostring) && !defined(OSTRING_DEFINED)
- typedef std::basic_string<OLECHAR> ostring;
- #define OSTRING_DEFINED
-#endif
-
-// StdCodeCvt when there's no conversion to be done
-template <typename T>
-inline T* StdCodeCvt(T* pDst, int nDst, const T* pSrc, int nSrc)
-{
- int nChars = SSMIN(nSrc, nDst);
-
- if ( nChars > 0 )
- {
- pDst[0] = '\0';
- std::basic_string<T>::traits_type::copy(pDst, pSrc, nChars);
-// std::char_traits<T>::copy(pDst, pSrc, nChars);
- pDst[nChars] = '\0';
- }
-
- return pDst;
-}
-inline PSTR StdCodeCvt(PSTR pDst, int nDst, PCUSTR pSrc, int nSrc)
-{
- return StdCodeCvt(pDst, nDst, (PCSTR)pSrc, nSrc);
-}
-inline PUSTR StdCodeCvt(PUSTR pDst, int nDst, PCSTR pSrc, int nSrc)
-{
- return (PUSTR)StdCodeCvt((PSTR)pDst, nDst, pSrc, nSrc);
-}
-
-// Define tstring -- generic name for std::basic_string<TCHAR>
-
-#if !defined(tstring) && !defined(TSTRING_DEFINED)
- typedef std::basic_string<TCHAR> tstring;
- #define TSTRING_DEFINED
-#endif
-
-// a very shorthand way of applying the fix for KB problem Q172398
-// (basic_string assignment bug)
-
-#if defined ( _MSC_VER ) && ( _MSC_VER < 1200 )
- #define Q172398(x) (x).erase()
-#else
- #define Q172398(x)
-#endif
-
-// =============================================================================
-// INLINE FUNCTIONS ON WHICH CSTDSTRING RELIES
-//
-// Usually for generic text mapping, we rely on preprocessor macro definitions
-// to map to string functions. However the CStdStr<> template cannot use
-// macro-based generic text mappings because its character types do not get
-// resolved until template processing which comes AFTER macro processing. In
-// other words, the preprocessor macro UNICODE is of little help to us in the
-// CStdStr template
-//
-// Therefore, to keep the CStdStr declaration simple, we have these inline
-// functions. The template calls them often. Since they are inline (and NOT
-// exported when this is built as a DLL), they will probably be resolved away
-// to nothing.
-//
-// Without these functions, the CStdStr<> template would probably have to broken
-// out into two, almost identical classes. Either that or it would be a huge,
-// convoluted mess, with tons of "if" statements all over the place checking the
-// size of template parameter CT.
-// =============================================================================
-
-#ifdef SS_NO_LOCALE
-
- // --------------------------------------------------------------------------
- // Win32 GetStringTypeEx wrappers
- // --------------------------------------------------------------------------
- inline bool wsGetStringType(LCID lc, DWORD dwT, PCSTR pS, int nSize,
- WORD* pWd)
- {
- return FALSE != GetStringTypeExA(lc, dwT, pS, nSize, pWd);
- }
- inline bool wsGetStringType(LCID lc, DWORD dwT, PCWSTR pS, int nSize,
- WORD* pWd)
- {
- return FALSE != GetStringTypeExW(lc, dwT, pS, nSize, pWd);
- }
-
-
- template<typename CT>
- inline bool ssisspace (CT t)
- {
- WORD toYourMother;
- return wsGetStringType(GetThreadLocale(), CT_CTYPE1, &t, 1, &toYourMother)
- && 0 != (C1_BLANK & toYourMother);
- }
-
-#endif
-
-// If they defined SS_NO_REFCOUNT, then we must convert all assignments
-
-#if defined (_MSC_VER) && (_MSC_VER < 1300)
- #ifdef SS_NO_REFCOUNT
- #define SSREF(x) (x).c_str()
- #else
- #define SSREF(x) (x)
- #endif
-#else
- #define SSREF(x) (x)
-#endif
-
-// -----------------------------------------------------------------------------
-// sslen: strlen/wcslen wrappers
-// -----------------------------------------------------------------------------
-template<typename CT> inline int sslen(const CT* pT)
-{
- return 0 == pT ? 0 : (int)std::basic_string<CT>::traits_type::length(pT);
-// return 0 == pT ? 0 : std::char_traits<CT>::length(pT);
-}
-inline SS_NOTHROW int sslen(const std::string& s)
-{
- return static_cast<int>(s.length());
-}
-inline SS_NOTHROW int sslen(const std::wstring& s)
-{
- return static_cast<int>(s.length());
-}
-
-// -----------------------------------------------------------------------------
-// sstolower/sstoupper -- convert characters to upper/lower case
-// -----------------------------------------------------------------------------
-
-#ifdef SS_NO_LOCALE
- inline char sstoupper(char ch) { return (char)::toupper(ch); }
- inline wchar_t sstoupper(wchar_t ch){ return (wchar_t)::towupper(ch); }
- inline char sstolower(char ch) { return (char)::tolower(ch); }
- inline wchar_t sstolower(wchar_t ch){ return (wchar_t)::tolower(ch); }
-#else
- template<typename CT>
- inline CT sstolower(const CT& t, const std::locale& loc = std::locale())
- {
- return std::tolower<CT>(t, loc);
- }
- template<typename CT>
- inline CT sstoupper(const CT& t, const std::locale& loc = std::locale())
- {
- return std::toupper<CT>(t, loc);
- }
-#endif
-
-// -----------------------------------------------------------------------------
-// ssasn: assignment functions -- assign "sSrc" to "sDst"
-// -----------------------------------------------------------------------------
-typedef std::string::size_type SS_SIZETYPE; // just for shorthand, really
-typedef std::string::pointer SS_PTRTYPE;
-typedef std::wstring::size_type SW_SIZETYPE;
-typedef std::wstring::pointer SW_PTRTYPE;
-
-
-template <typename T>
-inline void ssasn(std::basic_string<T>& sDst, const std::basic_string<T>& sSrc)
-{
- if ( sDst.c_str() != sSrc.c_str() )
- {
- sDst.erase();
- sDst.assign(SSREF(sSrc));
- }
-}
-template <typename T>
-inline void ssasn(std::basic_string<T>& sDst, const T *pA)
-{
- // Watch out for NULLs, as always.
-
- if ( 0 == pA )
- {
- sDst.erase();
- }
-
- // If pA actually points to part of sDst, we must NOT erase(), but
- // rather take a substring
-
- else if ( pA >= sDst.c_str() && pA <= sDst.c_str() + sDst.size() )
- {
- sDst =sDst.substr(static_cast<typename std::basic_string<T>::size_type>(pA-sDst.c_str()));
- }
-
- // Otherwise (most cases) apply the assignment bug fix, if applicable
- // and do the assignment
-
- else
- {
- Q172398(sDst);
- sDst.assign(pA);
- }
-}
-inline void ssasn(std::string& sDst, const std::wstring& sSrc)
-{
- if ( sSrc.empty() )
- {
- sDst.erase();
- }
- else
- {
- int nDst = static_cast<int>(sSrc.size());
-
- // In MBCS builds, pad the buffer to account for the possibility of
- // some 3 byte characters. Not perfect but should get most cases.
-
-#ifdef SS_MBCS
- // In MBCS builds, we don't know how long the destination string will be.
- nDst = static_cast<int>(static_cast<double>(nDst) * 1.3);
- sDst.resize(nDst+1);
- PCSTR szCvt = StdCodeCvt(const_cast<SS_PTRTYPE>(sDst.data()), nDst,
- sSrc.c_str(), static_cast<int>(sSrc.size()));
- sDst.resize(sslen(szCvt));
-#else
- sDst.resize(nDst+1);
- StdCodeCvt(const_cast<SS_PTRTYPE>(sDst.data()), nDst,
- sSrc.c_str(), static_cast<int>(sSrc.size()));
- sDst.resize(sSrc.size());
-#endif
- }
-}
-inline void ssasn(std::string& sDst, PCWSTR pW)
-{
- int nSrc = sslen(pW);
- if ( nSrc > 0 )
- {
- int nSrc = sslen(pW);
- int nDst = nSrc;
-
- // In MBCS builds, pad the buffer to account for the possibility of
- // some 3 byte characters. Not perfect but should get most cases.
-
-#ifdef SS_MBCS
- nDst = static_cast<int>(static_cast<double>(nDst) * 1.3);
- // In MBCS builds, we don't know how long the destination string will be.
- sDst.resize(nDst + 1);
- PCSTR szCvt = StdCodeCvt(const_cast<SS_PTRTYPE>(sDst.data()), nDst,
- pW, nSrc);
- sDst.resize(sslen(szCvt));
-#else
- sDst.resize(nDst + 1);
- StdCodeCvt(const_cast<SS_PTRTYPE>(sDst.data()), nDst, pW, nSrc);
- sDst.resize(nDst);
-#endif
- }
- else
- {
- sDst.erase();
- }
-}
-inline void ssasn(std::string& sDst, const int nNull)
-{
- //UNUSED(nNull);
- ASSERT(nNull==0);
- sDst.assign("");
-}
-#undef StrSizeType
-inline void ssasn(std::wstring& sDst, const std::string& sSrc)
-{
- if ( sSrc.empty() )
- {
- sDst.erase();
- }
- else
- {
- int nSrc = static_cast<int>(sSrc.size());
- int nDst = nSrc;
-
- sDst.resize(nSrc+1);
- PCWSTR szCvt = StdCodeCvt(const_cast<SW_PTRTYPE>(sDst.data()), nDst,
- sSrc.c_str(), nSrc);
-
- sDst.resize(sslen(szCvt));
- }
-}
-inline void ssasn(std::wstring& sDst, PCSTR pA)
-{
- int nSrc = sslen(pA);
-
- if ( 0 == nSrc )
- {
- sDst.erase();
- }
- else
- {
- int nDst = nSrc;
- sDst.resize(nDst+1);
- PCWSTR szCvt = StdCodeCvt(const_cast<SW_PTRTYPE>(sDst.data()), nDst, pA,
- nSrc);
-
- sDst.resize(sslen(szCvt));
- }
-}
-inline void ssasn(std::wstring& sDst, const int nNull)
-{
- //UNUSED(nNull);
- ASSERT(nNull==0);
- sDst.assign(L"");
-}
-
-// -----------------------------------------------------------------------------
-// ssadd: string object concatenation -- add second argument to first
-// -----------------------------------------------------------------------------
-inline void ssadd(std::string& sDst, const std::wstring& sSrc)
-{
- int nSrc = static_cast<int>(sSrc.size());
-
- if ( nSrc > 0 )
- {
- int nDst = static_cast<int>(sDst.size());
- int nAdd = nSrc;
-
- // In MBCS builds, pad the buffer to account for the possibility of
- // some 3 byte characters. Not perfect but should get most cases.
-
-#ifdef SS_MBCS
- nAdd = static_cast<int>(static_cast<double>(nAdd) * 1.3);
- sDst.resize(nDst+nAdd+1);
- PCSTR szCvt = StdCodeCvt(const_cast<SS_PTRTYPE>(sDst.data()+nDst),
- nAdd, sSrc.c_str(), nSrc);
- sDst.resize(nDst + sslen(szCvt));
-#else
- sDst.resize(nDst+nAdd+1);
- StdCodeCvt(const_cast<SS_PTRTYPE>(sDst.data()+nDst), nAdd, sSrc.c_str(), nSrc);
- sDst.resize(nDst + nAdd);
-#endif
- }
-}
-template <typename T>
-inline void ssadd(typename std::basic_string<T>& sDst, const typename std::basic_string<T>& sSrc)
-{
- sDst += sSrc;
-}
-inline void ssadd(std::string& sDst, PCWSTR pW)
-{
- int nSrc = sslen(pW);
- if ( nSrc > 0 )
- {
- int nDst = static_cast<int>(sDst.size());
- int nAdd = nSrc;
-
-#ifdef SS_MBCS
- nAdd = static_cast<int>(static_cast<double>(nAdd) * 1.3);
- sDst.resize(nDst + nAdd + 1);
- PCSTR szCvt = StdCodeCvt(const_cast<SS_PTRTYPE>(sDst.data()+nDst),
- nAdd, pW, nSrc);
- sDst.resize(nDst + sslen(szCvt));
-#else
- sDst.resize(nDst + nAdd + 1);
- StdCodeCvt(const_cast<SS_PTRTYPE>(sDst.data()+nDst), nAdd, pW, nSrc);
- sDst.resize(nDst + nSrc);
-#endif
- }
-}
-template <typename T>
-inline void ssadd(typename std::basic_string<T>& sDst, const T *pA)
-{
- if ( pA )
- {
- // If the string being added is our internal string or a part of our
- // internal string, then we must NOT do any reallocation without
- // first copying that string to another object (since we're using a
- // direct pointer)
-
- if ( pA >= sDst.c_str() && pA <= sDst.c_str()+sDst.length())
- {
- if ( sDst.capacity() <= sDst.size()+sslen(pA) )
- sDst.append(std::basic_string<T>(pA));
- else
- sDst.append(pA);
- }
- else
- {
- sDst.append(pA);
- }
- }
-}
-inline void ssadd(std::wstring& sDst, const std::string& sSrc)
-{
- if ( !sSrc.empty() )
- {
- int nSrc = static_cast<int>(sSrc.size());
- int nDst = static_cast<int>(sDst.size());
-
- sDst.resize(nDst + nSrc + 1);
-#ifdef SS_MBCS
- PCWSTR szCvt = StdCodeCvt(const_cast<SW_PTRTYPE>(sDst.data()+nDst),
- nSrc, sSrc.c_str(), nSrc+1);
- sDst.resize(nDst + sslen(szCvt));
-#else
- StdCodeCvt(const_cast<SW_PTRTYPE>(sDst.data()+nDst), nSrc, sSrc.c_str(), nSrc+1);
- sDst.resize(nDst + nSrc);
-#endif
- }
-}
-inline void ssadd(std::wstring& sDst, PCSTR pA)
-{
- int nSrc = sslen(pA);
-
- if ( nSrc > 0 )
- {
- int nDst = static_cast<int>(sDst.size());
-
- sDst.resize(nDst + nSrc + 1);
-#ifdef SS_MBCS
- PCWSTR szCvt = StdCodeCvt(const_cast<SW_PTRTYPE>(sDst.data()+nDst),
- nSrc, pA, nSrc+1);
- sDst.resize(nDst + sslen(szCvt));
-#else
- StdCodeCvt(const_cast<SW_PTRTYPE>(sDst.data()+nDst), nSrc, pA, nSrc+1);
- sDst.resize(nDst + nSrc);
-#endif
- }
-}
-
-// -----------------------------------------------------------------------------
-// sscmp: comparison (case sensitive, not affected by locale)
-// -----------------------------------------------------------------------------
-template<typename CT>
-inline int sscmp(const CT* pA1, const CT* pA2)
-{
- CT f;
- CT l;
-
- do
- {
- f = *(pA1++);
- l = *(pA2++);
- } while ( (f) && (f == l) );
-
- return (int)(f - l);
-}
-
-// -----------------------------------------------------------------------------
-// ssicmp: comparison (case INsensitive, not affected by locale)
-// -----------------------------------------------------------------------------
-template<typename CT>
-inline int ssicmp(const CT* pA1, const CT* pA2)
-{
- // Using the "C" locale = "not affected by locale"
-
- std::locale loc = std::locale::classic();
- const std::ctype<CT>& ct = SS_USE_FACET(loc, std::ctype<CT>);
- CT f;
- CT l;
-
- do
- {
- f = ct.tolower(*(pA1++));
- l = ct.tolower(*(pA2++));
- } while ( (f) && (f == l) );
-
- return (int)(f - l);
-}
-
-// -----------------------------------------------------------------------------
-// ssupr/sslwr: Uppercase/Lowercase conversion functions
-// -----------------------------------------------------------------------------
-
-template<typename CT>
-inline void sslwr(CT* pT, size_t nLen, const std::locale& loc=std::locale())
-{
- SS_USE_FACET(loc, std::ctype<CT>).tolower(pT, pT+nLen);
-}
-template<typename CT>
-inline void ssupr(CT* pT, size_t nLen, const std::locale& loc=std::locale())
-{
- SS_USE_FACET(loc, std::ctype<CT>).toupper(pT, pT+nLen);
-}
-
-// -----------------------------------------------------------------------------
-// vsprintf/vswprintf or _vsnprintf/_vsnwprintf equivalents. In standard
-// builds we can't use _vsnprintf/_vsnwsprintf because they're MS extensions.
-//
-// -----------------------------------------------------------------------------
-// Borland's headers put some ANSI "C" functions in the 'std' namespace.
-// Promote them to the global namespace so we can use them here.
-
-#if defined(__BORLANDC__)
- using std::vsprintf;
- using std::vswprintf;
-#endif
-
- // GNU is supposed to have vsnprintf and vsnwprintf. But only the newer
- // distributions do.
-
-#if defined(__GNUC__)
-
- inline int ssvsprintf(PSTR pA, size_t nCount, PCSTR pFmtA, va_list vl)
- {
- return vsnprintf(pA, nCount, pFmtA, vl);
- }
- inline int ssvsprintf(PWSTR pW, size_t nCount, PCWSTR pFmtW, va_list vl)
- {
- return vswprintf(pW, nCount, pFmtW, vl);
- }
-
- // Microsofties can use
-#elif defined(_MSC_VER) && !defined(SS_ANSI)
-
- inline int ssvsprintf(PSTR pA, size_t nCount, PCSTR pFmtA, va_list vl)
- {
- return _vsnprintf(pA, nCount, pFmtA, vl);
- }
- inline int ssvsprintf(PWSTR pW, size_t nCount, PCWSTR pFmtW, va_list vl)
- {
- return _vsnwprintf(pW, nCount, pFmtW, vl);
- }
-
-#elif defined (SS_DANGEROUS_FORMAT) // ignore buffer size parameter if needed?
-
- inline int ssvsprintf(PSTR pA, size_t /*nCount*/, PCSTR pFmtA, va_list vl)
- {
- return vsprintf(pA, pFmtA, vl);
- }
-
- inline int ssvsprintf(PWSTR pW, size_t nCount, PCWSTR pFmtW, va_list vl)
- {
- // JMO: Some distributions of the "C" have a version of vswprintf that
- // takes 3 arguments (e.g. Microsoft, Borland, GNU). Others have a
- // version which takes 4 arguments (an extra "count" argument in the
- // second position. The best stab I can take at this so far is that if
- // you are NOT running with MS, Borland, or GNU, then I'll assume you
- // have the version that takes 4 arguments.
- //
- // I'm sure that these checks don't catch every platform correctly so if
- // you get compiler errors on one of the lines immediately below, it's
- // probably because your implemntation takes a different number of
- // arguments. You can comment out the offending line (and use the
- // alternate version) or you can figure out what compiler flag to check
- // and add that preprocessor check in. Regardless, if you get an error
- // on these lines, I'd sure like to hear from you about it.
- //
- // Thanks to Ronny Schulz for the SGI-specific checks here.
-
-// #if !defined(__MWERKS__) && !defined(__SUNPRO_CC_COMPAT) && !defined(__SUNPRO_CC)
- #if !defined(_MSC_VER) \
- && !defined (__BORLANDC__) \
- && !defined(__GNUC__) \
- && !defined(__sgi)
-
- return vswprintf(pW, nCount, pFmtW, vl);
-
- // suddenly with the current SGI 7.3 compiler there is no such function as
- // vswprintf and the substitute needs explicit casts to compile
-
- #elif defined(__sgi)
-
- nCount;
- return vsprintf( (char *)pW, (char *)pFmtW, vl);
-
- #else
-
- nCount;
- return vswprintf(pW, pFmtW, vl);
-
- #endif
-
- }
-
-#endif
-
- // GOT COMPILER PROBLEMS HERE?
- // ---------------------------
- // Does your compiler choke on one or more of the following 2 functions? It
- // probably means that you don't have have either vsnprintf or vsnwprintf in
- // your version of the CRT. This is understandable since neither is an ANSI
- // "C" function. However it still leaves you in a dilemma. In order to make
- // this code build, you're going to have to to use some non-length-checked
- // formatting functions that every CRT has: vsprintf and vswprintf.
- //
- // This is very dangerous. With the proper erroneous (or malicious) code, it
- // can lead to buffer overlows and crashing your PC. Use at your own risk
- // In order to use them, just #define SS_DANGEROUS_FORMAT at the top of
- // this file.
- //
- // Even THEN you might not be all the way home due to some non-conforming
- // distributions. More on this in the comments below.
-
- inline int ssnprintf(PSTR pA, size_t nCount, PCSTR pFmtA, va_list vl)
- {
- #ifdef _MSC_VER
- return _vsnprintf(pA, nCount, pFmtA, vl);
- #else
- return vsnprintf(pA, nCount, pFmtA, vl);
- #endif
- }
- inline int ssnprintf(PWSTR pW, size_t nCount, PCWSTR pFmtW, va_list vl)
- {
- #ifdef _MSC_VER
- return _vsnwprintf(pW, nCount, pFmtW, vl);
- #else
- return vswprintf(pW, nCount, pFmtW, vl);
- #endif
- }
-
-
-
-
-// -----------------------------------------------------------------------------
-// ssload: Type safe, overloaded ::LoadString wrappers
-// There is no equivalent of these in non-Win32-specific builds. However, I'm
-// thinking that with the message facet, there might eventually be one
-// -----------------------------------------------------------------------------
-#if defined (SS_WIN32) && !defined(SS_ANSI)
- inline int ssload(HMODULE hInst, UINT uId, PSTR pBuf, int nMax)
- {
- return ::LoadStringA(hInst, uId, pBuf, nMax);
- }
- inline int ssload(HMODULE hInst, UINT uId, PWSTR pBuf, int nMax)
- {
- return ::LoadStringW(hInst, uId, pBuf, nMax);
- }
-#if defined ( _MSC_VER ) && ( _MSC_VER >= 1500 )
- inline int ssload(HMODULE hInst, UINT uId, uint16_t *pBuf, int nMax)
- {
- return 0;
- }
- inline int ssload(HMODULE hInst, UINT uId, uint32_t *pBuf, int nMax)
- {
- return 0;
- }
-#endif
-#endif
-
-
-// -----------------------------------------------------------------------------
-// sscoll/ssicoll: Collation wrappers
-// Note -- with MSVC I have reversed the arguments order here because the
-// functions appear to return the opposite of what they should
-// -----------------------------------------------------------------------------
-#ifndef SS_NO_LOCALE
-template <typename CT>
-inline int sscoll(const CT* sz1, int nLen1, const CT* sz2, int nLen2)
-{
- const std::collate<CT>& coll =
- SS_USE_FACET(std::locale(), std::collate<CT>);
-
- return coll.compare(sz2, sz2+nLen2, sz1, sz1+nLen1);
-}
-template <typename CT>
-inline int ssicoll(const CT* sz1, int nLen1, const CT* sz2, int nLen2)
-{
- const std::locale loc;
- const std::collate<CT>& coll = SS_USE_FACET(loc, std::collate<CT>);
-
- // Some implementations seem to have trouble using the collate<>
- // facet typedefs so we'll just default to basic_string and hope
- // that's what the collate facet uses (which it generally should)
-
-// std::collate<CT>::string_type s1(sz1);
-// std::collate<CT>::string_type s2(sz2);
- const std::basic_string<CT> sEmpty;
- std::basic_string<CT> s1(sz1 ? sz1 : sEmpty.c_str());
- std::basic_string<CT> s2(sz2 ? sz2 : sEmpty.c_str());
-
- sslwr(const_cast<CT*>(s1.c_str()), nLen1, loc);
- sslwr(const_cast<CT*>(s2.c_str()), nLen2, loc);
- return coll.compare(s2.c_str(), s2.c_str()+nLen2,
- s1.c_str(), s1.c_str()+nLen1);
-}
-#endif
-
-
-// -----------------------------------------------------------------------------
-// ssfmtmsg: FormatMessage equivalents. Needed because I added a CString facade
-// Again -- no equivalent of these on non-Win32 builds but their might one day
-// be one if the message facet gets implemented
-// -----------------------------------------------------------------------------
-#if defined (SS_WIN32) && !defined(SS_ANSI)
- inline DWORD ssfmtmsg(DWORD dwFlags, LPCVOID pSrc, DWORD dwMsgId,
- DWORD dwLangId, PSTR pBuf, DWORD nSize,
- va_list* vlArgs)
- {
- return FormatMessageA(dwFlags, pSrc, dwMsgId, dwLangId,
- pBuf, nSize,vlArgs);
- }
- inline DWORD ssfmtmsg(DWORD dwFlags, LPCVOID pSrc, DWORD dwMsgId,
- DWORD dwLangId, PWSTR pBuf, DWORD nSize,
- va_list* vlArgs)
- {
- return FormatMessageW(dwFlags, pSrc, dwMsgId, dwLangId,
- pBuf, nSize,vlArgs);
- }
-#else
-#endif
-
-
-
-// FUNCTION: sscpy. Copies up to 'nMax' characters from pSrc to pDst.
-// -----------------------------------------------------------------------------
-// FUNCTION: sscpy
-// inline int sscpy(PSTR pDst, PCSTR pSrc, int nMax=-1);
-// inline int sscpy(PUSTR pDst, PCSTR pSrc, int nMax=-1)
-// inline int sscpy(PSTR pDst, PCWSTR pSrc, int nMax=-1);
-// inline int sscpy(PWSTR pDst, PCWSTR pSrc, int nMax=-1);
-// inline int sscpy(PWSTR pDst, PCSTR pSrc, int nMax=-1);
-//
-// DESCRIPTION:
-// This function is very much (but not exactly) like strcpy. These
-// overloads simplify copying one C-style string into another by allowing
-// the caller to specify two different types of strings if necessary.
-//
-// The strings must NOT overlap
-//
-// "Character" is expressed in terms of the destination string, not
-// the source. If no 'nMax' argument is supplied, then the number of
-// characters copied will be sslen(pSrc). A NULL terminator will
-// also be added so pDst must actually be big enough to hold nMax+1
-// characters. The return value is the number of characters copied,
-// not including the NULL terminator.
-//
-// PARAMETERS:
-// pSrc - the string to be copied FROM. May be a char based string, an
-// MBCS string (in Win32 builds) or a wide string (wchar_t).
-// pSrc - the string to be copied TO. Also may be either MBCS or wide
-// nMax - the maximum number of characters to be copied into szDest. Note
-// that this is expressed in whatever a "character" means to pDst.
-// If pDst is a wchar_t type string than this will be the maximum
-// number of wchar_ts that my be copied. The pDst string must be
-// large enough to hold least nMaxChars+1 characters.
-// If the caller supplies no argument for nMax this is a signal to
-// the routine to copy all the characters in pSrc, regardless of
-// how long it is.
-//
-// RETURN VALUE: none
-// -----------------------------------------------------------------------------
-
-template<typename CT1, typename CT2>
-inline int sscpycvt(CT1* pDst, const CT2* pSrc, int nMax)
-{
- // Note -- we assume pDst is big enough to hold pSrc. If not, we're in
- // big trouble. No bounds checking. Caveat emptor.
-
- int nSrc = sslen(pSrc);
-
- const CT1* szCvt = StdCodeCvt(pDst, nMax, pSrc, nSrc);
-
- // If we're copying the same size characters, then all the "code convert"
- // just did was basically memcpy so the #of characters copied is the same
- // as the number requested. I should probably specialize this function
- // template to achieve this purpose as it is silly to do a runtime check
- // of a fact known at compile time. I'll get around to it.
-
- return sslen(szCvt);
-}
-
-template<typename T>
-inline int sscpycvt(T* pDst, const T* pSrc, int nMax)
-{
- int nCount = nMax;
- for (; nCount > 0 && *pSrc; ++pSrc, ++pDst, --nCount)
- std::basic_string<T>::traits_type::assign(*pDst, *pSrc);
-
- *pDst = 0;
- return nMax - nCount;
-}
-
-inline int sscpycvt(PWSTR pDst, PCSTR pSrc, int nMax)
-{
- // Note -- we assume pDst is big enough to hold pSrc. If not, we're in
- // big trouble. No bounds checking. Caveat emptor.
-
- const PWSTR szCvt = StdCodeCvt(pDst, nMax, pSrc, nMax);
- return sslen(szCvt);
-}
-
-template<typename CT1, typename CT2>
-inline int sscpy(CT1* pDst, const CT2* pSrc, int nMax, int nLen)
-{
- return sscpycvt(pDst, pSrc, SSMIN(nMax, nLen));
-}
-template<typename CT1, typename CT2>
-inline int sscpy(CT1* pDst, const CT2* pSrc, int nMax)
-{
- return sscpycvt(pDst, pSrc, SSMIN(nMax, sslen(pSrc)));
-}
-template<typename CT1, typename CT2>
-inline int sscpy(CT1* pDst, const CT2* pSrc)
-{
- return sscpycvt(pDst, pSrc, sslen(pSrc));
-}
-template<typename CT1, typename CT2>
-inline int sscpy(CT1* pDst, const std::basic_string<CT2>& sSrc, int nMax)
-{
- return sscpycvt(pDst, sSrc.c_str(), SSMIN(nMax, (int)sSrc.length()));
-}
-template<typename CT1, typename CT2>
-inline int sscpy(CT1* pDst, const std::basic_string<CT2>& sSrc)
-{
- return sscpycvt(pDst, sSrc.c_str(), (int)sSrc.length());
-}
-
-#ifdef SS_INC_COMDEF
- template<typename CT1>
- inline int sscpy(CT1* pDst, const _bstr_t& bs, int nMax)
- {
- return sscpycvt(pDst, static_cast<PCOLESTR>(bs),
- SSMIN(nMax, static_cast<int>(bs.length())));
- }
- template<typename CT1>
- inline int sscpy(CT1* pDst, const _bstr_t& bs)
- {
- return sscpy(pDst, bs, static_cast<int>(bs.length()));
- }
-#endif
-
-
-// -----------------------------------------------------------------------------
-// Functional objects for changing case. They also let you pass locales
-// -----------------------------------------------------------------------------
-
-#ifdef SS_NO_LOCALE
- template<typename CT>
- struct SSToUpper : public std::unary_function<CT, CT>
- {
- inline CT operator()(const CT& t) const
- {
- return sstoupper(t);
- }
- };
- template<typename CT>
- struct SSToLower : public std::unary_function<CT, CT>
- {
- inline CT operator()(const CT& t) const
- {
- return sstolower(t);
- }
- };
-#else
- template<typename CT>
- struct SSToUpper : public std::binary_function<CT, std::locale, CT>
- {
- inline CT operator()(const CT& t, const std::locale& loc) const
- {
- return sstoupper<CT>(t, loc);
- }
- };
- template<typename CT>
- struct SSToLower : public std::binary_function<CT, std::locale, CT>
- {
- inline CT operator()(const CT& t, const std::locale& loc) const
- {
- return sstolower<CT>(t, loc);
- }
- };
-#endif
-
-// This struct is used for TrimRight() and TrimLeft() function implementations.
-//template<typename CT>
-//struct NotSpace : public std::unary_function<CT, bool>
-//{
-// const std::locale& loc;
-// inline NotSpace(const std::locale& locArg) : loc(locArg) {}
-// inline bool operator() (CT t) { return !std::isspace(t, loc); }
-//};
-template<typename CT>
-struct NotSpace : public std::unary_function<CT, bool>
-{
- // DINKUMWARE BUG:
- // Note -- using std::isspace in a COM DLL gives us access violations
- // because it causes the dynamic addition of a function to be called
- // when the library shuts down. Unfortunately the list is maintained
- // in DLL memory but the function is in static memory. So the COM DLL
- // goes away along with the function that was supposed to be called,
- // and then later when the DLL CRT shuts down it unloads the list and
- // tries to call the long-gone function.
- // This is DinkumWare's implementation problem. If you encounter this
- // problem, you may replace the calls here with good old isspace() and
- // iswspace() from the CRT unless they specify SS_ANSI
-
-#ifdef SS_NO_LOCALE
-
- bool operator() (CT t) const { return !ssisspace(t); }
-
-#else
- const std::locale loc;
- NotSpace(const std::locale& locArg=std::locale()) : loc(locArg) {}
- bool operator() (CT t) const { return !std::isspace(t, loc); }
-#endif
-};
-
-
-
-
-// Now we can define the template (finally!)
-// =============================================================================
-// TEMPLATE: CStdStr
-// template<typename CT> class CStdStr : public std::basic_string<CT>
-//
-// REMARKS:
-// This template derives from basic_string<CT> and adds some MFC CString-
-// like functionality
-//
-// Basically, this is my attempt to make Standard C++ library strings as
-// easy to use as the MFC CString class.
-//
-// Note that although this is a template, it makes the assumption that the
-// template argument (CT, the character type) is either char or wchar_t.
-// =============================================================================
-
-//#define CStdStr _SS // avoid compiler warning 4786
-
-// template<typename ARG> ARG& FmtArg(ARG& arg) { return arg; }
-// PCSTR FmtArg(const std::string& arg) { return arg.c_str(); }
-// PCWSTR FmtArg(const std::wstring& arg) { return arg.c_str(); }
-
-template<typename ARG>
-struct FmtArg
-{
- explicit FmtArg(const ARG& arg) : a_(arg) {}
- const ARG& operator()() const { return a_; }
- const ARG& a_;
-private:
- FmtArg& operator=(const FmtArg&) { return *this; }
-};
-
-template<typename CT>
-class CStdStr : public std::basic_string<CT>
-{
- // Typedefs for shorter names. Using these names also appears to help
- // us avoid some ambiguities that otherwise arise on some platforms
-
- #define MYBASE std::basic_string<CT> // my base class
- //typedef typename std::basic_string<CT> MYBASE; // my base class
- typedef CStdStr<CT> MYTYPE; // myself
- typedef typename MYBASE::const_pointer PCMYSTR; // PCSTR or PCWSTR
- typedef typename MYBASE::pointer PMYSTR; // PSTR or PWSTR
- typedef typename MYBASE::iterator MYITER; // my iterator type
- typedef typename MYBASE::const_iterator MYCITER; // you get the idea...
- typedef typename MYBASE::reverse_iterator MYRITER;
- typedef typename MYBASE::size_type MYSIZE;
- typedef typename MYBASE::value_type MYVAL;
- typedef typename MYBASE::allocator_type MYALLOC;
-
-public:
- // shorthand conversion from PCTSTR to string resource ID
- #define SSRES(pctstr) LOWORD(reinterpret_cast<unsigned long>(pctstr))
-
- bool TryLoad(const void* pT)
- {
- bool bLoaded = false;
-
-#if defined(SS_WIN32) && !defined(SS_ANSI)
- if ( ( pT != NULL ) && SS_IS_INTRESOURCE(pT) )
- {
- UINT nId = LOWORD(reinterpret_cast<unsigned long>(pT));
- if ( !LoadString(nId) )
- {
- TRACE(_T("Can't load string %u\n"), SSRES(pT));
- }
- bLoaded = true;
- }
-#endif
-
- return bLoaded;
- }
-
-
- // CStdStr inline constructors
- CStdStr()
- {
- }
-
- CStdStr(const MYTYPE& str) : MYBASE(SSREF(str))
- {
- }
-
- CStdStr(const std::string& str)
- {
- ssasn(*this, SSREF(str));
- }
-
- CStdStr(const std::wstring& str)
- {
- ssasn(*this, SSREF(str));
- }
-
- CStdStr(PCMYSTR pT, MYSIZE n) : MYBASE(pT, n)
- {
- }
-
-#ifdef SS_UNSIGNED
- CStdStr(PCUSTR pU)
- {
- *this = reinterpret_cast<PCSTR>(pU);
- }
-#endif
-
- CStdStr(PCSTR pA)
- {
- #ifdef SS_ANSI
- *this = pA;
- #else
- if ( !TryLoad(pA) )
- *this = pA;
- #endif
- }
-
- CStdStr(PCWSTR pW)
- {
- #ifdef SS_ANSI
- *this = pW;
- #else
- if ( !TryLoad(pW) )
- *this = pW;
- #endif
- }
-
- CStdStr(uint16_t* pW)
- {
- #ifdef SS_ANSI
- *this = pW;
- #else
- if ( !TryLoad(pW) )
- *this = pW;
- #endif
- }
-
- CStdStr(uint32_t* pW)
- {
- #ifdef SS_ANSI
- *this = pW;
- #else
- if ( !TryLoad(pW) )
- *this = pW;
- #endif
- }
-
- CStdStr(MYCITER first, MYCITER last)
- : MYBASE(first, last)
- {
- }
-
- CStdStr(MYSIZE nSize, MYVAL ch, const MYALLOC& al=MYALLOC())
- : MYBASE(nSize, ch, al)
- {
- }
-
- #ifdef SS_INC_COMDEF
- CStdStr(const _bstr_t& bstr)
- {
- if ( bstr.length() > 0 )
- this->append(static_cast<PCMYSTR>(bstr), bstr.length());
- }
- #endif
-
- // CStdStr inline assignment operators -- the ssasn function now takes care
- // of fixing the MSVC assignment bug (see knowledge base article Q172398).
- MYTYPE& operator=(const MYTYPE& str)
- {
- ssasn(*this, str);
- return *this;
- }
-
- MYTYPE& operator=(const std::string& str)
- {
- ssasn(*this, str);
- return *this;
- }
-
- MYTYPE& operator=(const std::wstring& str)
- {
- ssasn(*this, str);
- return *this;
- }
-
- MYTYPE& operator=(PCSTR pA)
- {
- ssasn(*this, pA);
- return *this;
- }
-
- MYTYPE& operator=(PCWSTR pW)
- {
- ssasn(*this, pW);
- return *this;
- }
-
-#ifdef SS_UNSIGNED
- MYTYPE& operator=(PCUSTR pU)
- {
- ssasn(*this, reinterpret_cast<PCSTR>(pU));
- return *this;
- }
-#endif
-
- MYTYPE& operator=(uint16_t* pA)
- {
- ssasn(*this, pA);
- return *this;
- }
-
- MYTYPE& operator=(uint32_t* pA)
- {
- ssasn(*this, pA);
- return *this;
- }
-
- MYTYPE& operator=(CT t)
- {
- Q172398(*this);
- this->assign(1, t);
- return *this;
- }
-
- #ifdef SS_INC_COMDEF
- MYTYPE& operator=(const _bstr_t& bstr)
- {
- if ( bstr.length() > 0 )
- {
- this->assign(static_cast<PCMYSTR>(bstr), bstr.length());
- return *this;
- }
- else
- {
- this->erase();
- return *this;
- }
- }
- #endif
-
-
- // Overloads also needed to fix the MSVC assignment bug (KB: Q172398)
- // *** Thanks to Pete The Plumber for catching this one ***
- // They also are compiled if you have explicitly turned off refcounting
- #if ( defined(_MSC_VER) && ( _MSC_VER < 1200 ) ) || defined(SS_NO_REFCOUNT)
-
- MYTYPE& assign(const MYTYPE& str)
- {
- Q172398(*this);
- sscpy(GetBuffer(str.size()+1), SSREF(str));
- this->ReleaseBuffer(str.size());
- return *this;
- }
-
- MYTYPE& assign(const MYTYPE& str, MYSIZE nStart, MYSIZE nChars)
- {
- // This overload of basic_string::assign is supposed to assign up to
- // <nChars> or the NULL terminator, whichever comes first. Since we
- // are about to call a less forgiving overload (in which <nChars>
- // must be a valid length), we must adjust the length here to a safe
- // value. Thanks to Ullrich Poll�hne for catching this bug
-
- nChars = SSMIN(nChars, str.length() - nStart);
- MYTYPE strTemp(str.c_str()+nStart, nChars);
- Q172398(*this);
- this->assign(strTemp);
- return *this;
- }
-
- MYTYPE& assign(const MYBASE& str)
- {
- ssasn(*this, str);
- return *this;
- }
-
- MYTYPE& assign(const MYBASE& str, MYSIZE nStart, MYSIZE nChars)
- {
- // This overload of basic_string::assign is supposed to assign up to
- // <nChars> or the NULL terminator, whichever comes first. Since we
- // are about to call a less forgiving overload (in which <nChars>
- // must be a valid length), we must adjust the length here to a safe
- // value. Thanks to Ullrich Poll�hne for catching this bug
-
- nChars = SSMIN(nChars, str.length() - nStart);
-
- // Watch out for assignment to self
-
- if ( this == &str )
- {
- MYTYPE strTemp(str.c_str() + nStart, nChars);
- static_cast<MYBASE*>(this)->assign(strTemp);
- }
- else
- {
- Q172398(*this);
- static_cast<MYBASE*>(this)->assign(str.c_str()+nStart, nChars);
- }
- return *this;
- }
-
- MYTYPE& assign(const CT* pC, MYSIZE nChars)
- {
- // Q172398 only fix -- erase before assigning, but not if we're
- // assigning from our own buffer
-
- #if defined ( _MSC_VER ) && ( _MSC_VER < 1200 )
- if ( !this->empty() &&
- ( pC < this->data() || pC > this->data() + this->capacity() ) )
- {
- this->erase();
- }
- #endif
- Q172398(*this);
- static_cast<MYBASE*>(this)->assign(pC, nChars);
- return *this;
- }
-
- MYTYPE& assign(MYSIZE nChars, MYVAL val)
- {
- Q172398(*this);
- static_cast<MYBASE*>(this)->assign(nChars, val);
- return *this;
- }
-
- MYTYPE& assign(const CT* pT)
- {
- return this->assign(pT, MYBASE::traits_type::length(pT));
- }
-
- MYTYPE& assign(MYCITER iterFirst, MYCITER iterLast)
- {
- #if defined ( _MSC_VER ) && ( _MSC_VER < 1200 )
- // Q172398 fix. don't call erase() if we're assigning from ourself
- if ( iterFirst < this->begin() ||
- iterFirst > this->begin() + this->size() )
- {
- this->erase()
- }
- #endif
- this->replace(this->begin(), this->end(), iterFirst, iterLast);
- return *this;
- }
- #endif
-
-
- // -------------------------------------------------------------------------
- // CStdStr inline concatenation.
- // -------------------------------------------------------------------------
- MYTYPE& operator+=(const MYTYPE& str)
- {
- ssadd(*this, str);
- return *this;
- }
-
- MYTYPE& operator+=(const std::string& str)
- {
- ssadd(*this, str);
- return *this;
- }
-
- MYTYPE& operator+=(const std::wstring& str)
- {
- ssadd(*this, str);
- return *this;
- }
-
- MYTYPE& operator+=(PCSTR pA)
- {
- ssadd(*this, pA);
- return *this;
- }
-
- MYTYPE& operator+=(PCWSTR pW)
- {
- ssadd(*this, pW);
- return *this;
- }
-
- MYTYPE& operator+=(uint16_t* pW)
- {
- ssadd(*this, pW);
- return *this;
- }
-
- MYTYPE& operator+=(uint32_t* pW)
- {
- ssadd(*this, pW);
- return *this;
- }
-
- MYTYPE& operator+=(CT t)
- {
- this->append(1, t);
- return *this;
- }
- #ifdef SS_INC_COMDEF // if we have _bstr_t, define a += for it too.
- MYTYPE& operator+=(const _bstr_t& bstr)
- {
- return this->operator+=(static_cast<PCMYSTR>(bstr));
- }
- #endif
-
-
- // -------------------------------------------------------------------------
- // Case changing functions
- // -------------------------------------------------------------------------
-
- MYTYPE& ToUpper(const std::locale& loc=std::locale())
- {
- // Note -- if there are any MBCS character sets in which the lowercase
- // form a character takes up a different number of bytes than the
- // uppercase form, this would probably not work...
-
- std::transform(this->begin(),
- this->end(),
- this->begin(),
-#ifdef SS_NO_LOCALE
- SSToUpper<CT>());
-#else
- std::bind2nd(SSToUpper<CT>(), loc));
-#endif
-
- // ...but if it were, this would probably work better. Also, this way
- // seems to be a bit faster when anything other then the "C" locale is
- // used...
-
-// if ( !empty() )
-// {
-// ssupr(this->GetBuf(), this->size(), loc);
-// this->RelBuf();
-// }
-
- return *this;
- }
-
- MYTYPE& ToLower(const std::locale& loc=std::locale())
- {
- // Note -- if there are any MBCS character sets in which the lowercase
- // form a character takes up a different number of bytes than the
- // uppercase form, this would probably not work...
-
- std::transform(this->begin(),
- this->end(),
- this->begin(),
-#ifdef SS_NO_LOCALE
- SSToLower<CT>());
-#else
- std::bind2nd(SSToLower<CT>(), loc));
-#endif
-
- // ...but if it were, this would probably work better. Also, this way
- // seems to be a bit faster when anything other then the "C" locale is
- // used...
-
-// if ( !empty() )
-// {
-// sslwr(this->GetBuf(), this->size(), loc);
-// this->RelBuf();
-// }
- return *this;
- }
-
-
- MYTYPE& Normalize()
- {
- return Trim().ToLower();
- }
-
-
- // -------------------------------------------------------------------------
- // CStdStr -- Direct access to character buffer. In the MS' implementation,
- // the at() function that we use here also calls _Freeze() providing us some
- // protection from multithreading problems associated with ref-counting.
- // In VC 7 and later, of course, the ref-counting stuff is gone.
- // -------------------------------------------------------------------------
-
- CT* GetBuf(int nMinLen=-1)
- {
- if ( static_cast<int>(this->size()) < nMinLen )
- this->resize(static_cast<MYSIZE>(nMinLen));
-
- return this->empty() ? const_cast<CT*>(this->data()) : &(this->at(0));
- }
-
- CT* SetBuf(int nLen)
- {
- nLen = ( nLen > 0 ? nLen : 0 );
- if ( this->capacity() < 1 && nLen == 0 )
- this->resize(1);
-
- this->resize(static_cast<MYSIZE>(nLen));
- return const_cast<CT*>(this->data());
- }
- void RelBuf(int nNewLen=-1)
- {
- this->resize(static_cast<MYSIZE>(nNewLen > -1 ? nNewLen :
- sslen(this->c_str())));
- }
-
- void BufferRel() { RelBuf(); } // backwards compatability
- CT* Buffer() { return GetBuf(); } // backwards compatability
- CT* BufferSet(int nLen) { return SetBuf(nLen);}// backwards compatability
-
- bool Equals(const CT* pT, bool bUseCase=false) const
- {
- return 0 == (bUseCase ? this->compare(pT) : ssicmp(this->c_str(), pT));
- }
-
- // -------------------------------------------------------------------------
- // FUNCTION: CStdStr::Load
- // REMARKS:
- // Loads string from resource specified by nID
- //
- // PARAMETERS:
- // nID - resource Identifier. Purely a Win32 thing in this case
- //
- // RETURN VALUE:
- // true if successful, false otherwise
- // -------------------------------------------------------------------------
-
-#ifndef SS_ANSI
-
- bool Load(UINT nId, HMODULE hModule=NULL)
- {
- bool bLoaded = false; // set to true of we succeed.
-
- #ifdef _MFC_VER // When in Rome (or MFC land)...
-
- // If they gave a resource handle, use it. Note - this is archaic
- // and not really what I would recommend. But then again, in MFC
- // land, you ought to be using CString for resources anyway since
- // it walks the resource chain for you.
-
- HMODULE hModuleOld = NULL;
-
- if ( NULL != hModule )
- {
- hModuleOld = AfxGetResourceHandle();
- AfxSetResourceHandle(hModule);
- }
-
- // ...load the string
-
- CString strRes;
- bLoaded = FALSE != strRes.LoadString(nId);
-
- // ...and if we set the resource handle, restore it.
-
- if ( NULL != hModuleOld )
- AfxSetResourceHandle(hModule);
-
- if ( bLoaded )
- *this = strRes;
-
- #else // otherwise make our own hackneyed version of CString's Load
-
- // Get the resource name and module handle
-
- if ( NULL == hModule )
- hModule = GetResourceHandle();
-
- PCTSTR szName = MAKEINTRESOURCE((nId>>4)+1); // lifted
- DWORD dwSize = 0;
-
- // No sense continuing if we can't find the resource
-
- HRSRC hrsrc = ::FindResource(hModule, szName, RT_STRING);
-
- if ( NULL == hrsrc )
- {
- TRACE(_T("Cannot find resource %d: 0x%X"), nId, ::GetLastError());
- }
- else if ( 0 == (dwSize = ::SizeofResource(hModule, hrsrc) / sizeof(CT)))
- {
- TRACE(_T("Cant get size of resource %d 0x%X\n"),nId,GetLastError());
- }
- else
- {
- bLoaded = 0 != ssload(hModule, nId, GetBuf(dwSize), dwSize);
- ReleaseBuffer();
- }
-
- #endif // #ifdef _MFC_VER
-
- if ( !bLoaded )
- TRACE(_T("String not loaded 0x%X\n"), ::GetLastError());
-
- return bLoaded;
- }
-
-#endif // #ifdef SS_ANSI
-
- // -------------------------------------------------------------------------
- // FUNCTION: CStdStr::Format
- // void _cdecl Formst(CStdStringA& PCSTR szFormat, ...)
- // void _cdecl Format(PCSTR szFormat);
- //
- // DESCRIPTION:
- // This function does sprintf/wsprintf style formatting on CStdStringA
- // objects. It looks a lot like MFC's CString::Format. Some people
- // might even call this identical. Fortunately, these people are now
- // dead... heh heh.
- //
- // PARAMETERS:
- // nId - ID of string resource holding the format string
- // szFormat - a PCSTR holding the format specifiers
- // argList - a va_list holding the arguments for the format specifiers.
- //
- // RETURN VALUE: None.
- // -------------------------------------------------------------------------
- // formatting (using wsprintf style formatting)
-
- // If they want a Format() function that safely handles string objects
- // without casting
-
-#ifdef SS_SAFE_FORMAT
-
- // Question: Joe, you wacky coder you, why do you have so many overloads
- // of the Format() function
- // Answer: One reason only - CString compatability. In short, by making
- // the Format() function a template this way, I can do strong typing
- // and allow people to pass CStdString arguments as fillers for
- // "%s" format specifiers without crashing their program! The downside
- // is that I need to overload on the number of arguments. If you are
- // passing more arguments than I have listed below in any of my
- // overloads, just add another one.
- //
- // Yes, yes, this is really ugly. In essence what I am doing here is
- // protecting people from a bad (and incorrect) programming practice
- // that they should not be doing anyway. I am protecting them from
- // themselves. Why am I doing this? Well, if you had any idea the
- // number of times I've been emailed by people about this
- // "incompatability" in my code, you wouldn't ask.
-
- void Fmt(const CT* szFmt, ...)
- {
- va_list argList;
- va_start(argList, szFmt);
- FormatV(szFmt, argList);
- va_end(argList);
- }
-
-#ifndef SS_ANSI
-
- void Format(UINT nId)
- {
- MYTYPE strFmt;
- if ( strFmt.Load(nId) )
- this->swap(strFmt);
- }
- template<class A1>
- void Format(UINT nId, const A1& v)
- {
- MYTYPE strFmt;
- if ( strFmt.Load(nId) )
- Fmt(strFmt, FmtArg<A1>(v)());
- }
- template<class A1, class A2>
- void Format(UINT nId, const A1& v1, const A2& v2)
- {
- MYTYPE strFmt;
- if ( strFmt.Load(nId) )
- Fmt(strFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)());
- }
- template<class A1, class A2, class A3>
- void Format(UINT nId, const A1& v1, const A2& v2, const A3& v3)
- {
- MYTYPE strFmt;
- if ( strFmt.Load(nId) )
- {
- Fmt(strFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)());
- }
- }
- template<class A1, class A2, class A3, class A4>
- void Format(UINT nId, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4)
- {
- MYTYPE strFmt;
- if ( strFmt.Load(nId) )
- {
- Fmt(strFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)());
- }
- }
- template<class A1, class A2, class A3, class A4, class A5>
- void Format(UINT nId, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5)
- {
- MYTYPE strFmt;
- if ( strFmt.Load(nId) )
- {
- Fmt(strFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(), FmtArg<A5>(v5)());
- }
- }
- template<class A1, class A2, class A3, class A4, class A5, class A6>
- void Format(UINT nId, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5, const A6& v6)
- {
- MYTYPE strFmt;
- if ( strFmt.Load(nId) )
- {
- Fmt(strFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(),FmtArg<A5>(v5)(),
- FmtArg<A6>(v6)());
- }
- }
- template<class A1, class A2, class A3, class A4, class A5, class A6,
- class A7>
- void Format(UINT nId, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5, const A6& v6, const A7& v7)
- {
- MYTYPE strFmt;
- if ( strFmt.Load(nId) )
- {
- Fmt(strFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(),FmtArg<A5>(v5)(),
- FmtArg<A6>(v6)(), FmtArg<A7>(v7)());
- }
- }
- template<class A1, class A2, class A3, class A4, class A5, class A6,
- class A7, class A8>
- void Format(UINT nId, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5, const A6& v6, const A7& v7,
- const A8& v8)
- {
- MYTYPE strFmt;
- if ( strFmt.Load(nId) )
- {
- Fmt(strFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(), FmtArg<A5>(v5)(),
- FmtArg<A6>(v6)(), FmtArg<A7>(v7)(), FmtArg<A8>(v8)());
- }
- }
- template<class A1, class A2, class A3, class A4, class A5, class A6,
- class A7, class A8, class A9>
- void Format(UINT nId, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5, const A6& v6, const A7& v7,
- const A8& v8, const A9& v9)
- {
- MYTYPE strFmt;
- if ( strFmt.Load(nId) )
- {
- Fmt(strFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(), FmtArg<A5>(v5)(),
- FmtArg<A6>(v6)(), FmtArg<A7>(v7)(), FmtArg<A8>(v8)(),
- FmtArg<A9>(v9)());
- }
- }
- template<class A1, class A2, class A3, class A4, class A5, class A6,
- class A7, class A8, class A9, class A10>
- void Format(UINT nId, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5, const A6& v6, const A7& v7,
- const A8& v8, const A9& v9, const A10& v10)
- {
- MYTYPE strFmt;
- if ( strFmt.Load(nId) )
- {
- Fmt(strFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(), FmtArg<A5>(v5)(),
- FmtArg<A6>(v6)(), FmtArg<A7>(v7)(), FmtArg<A8>(v8)(),
- FmtArg<A9>(v9)(), FmtArg<A10>(v10)());
- }
- }
- template<class A1, class A2, class A3, class A4, class A5, class A6,
- class A7, class A8, class A9, class A10, class A11>
- void Format(UINT nId, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5, const A6& v6, const A7& v7,
- const A8& v8, const A9& v9, const A10& v10, const A11& v11)
- {
- MYTYPE strFmt;
- if ( strFmt.Load(nId) )
- {
- Fmt(strFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(), FmtArg<A5>(v5)(),
- FmtArg<A6>(v6)(), FmtArg<A7>(v7)(), FmtArg<A8>(v8)(),
- FmtArg<A9>(v9)(),FmtArg<A10>(v10)(),FmtArg<A11>(v11)());
- }
- }
- template<class A1, class A2, class A3, class A4, class A5, class A6,
- class A7, class A8, class A9, class A10, class A11, class A12>
- void Format(UINT nId, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5, const A6& v6, const A7& v7,
- const A8& v8, const A9& v9, const A10& v10, const A11& v11,
- const A12& v12)
- {
- MYTYPE strFmt;
- if ( strFmt.Load(nId) )
- {
- Fmt(strFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(), FmtArg<A5>(v5)(),
- FmtArg<A6>(v6)(), FmtArg<A7>(v7)(), FmtArg<A8>(v8)(),
- FmtArg<A9>(v9)(), FmtArg<A10>(v10)(),FmtArg<A11>(v11)(),
- FmtArg<A12>(v12)());
- }
- }
- template<class A1, class A2, class A3, class A4, class A5, class A6,
- class A7, class A8, class A9, class A10, class A11, class A12,
- class A13>
- void Format(UINT nId, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5, const A6& v6, const A7& v7,
- const A8& v8, const A9& v9, const A10& v10, const A11& v11,
- const A12& v12, const A13& v13)
- {
- MYTYPE strFmt;
- if ( strFmt.Load(nId) )
- {
- Fmt(strFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(), FmtArg<A5>(v5)(),
- FmtArg<A6>(v6)(), FmtArg<A7>(v7)(), FmtArg<A8>(v8)(),
- FmtArg<A9>(v9)(), FmtArg<A10>(v10)(),FmtArg<A11>(v11)(),
- FmtArg<A12>(v12)(), FmtArg<A13>(v13)());
- }
- }
- template<class A1, class A2, class A3, class A4, class A5, class A6,
- class A7, class A8, class A9, class A10, class A11, class A12,
- class A13, class A14>
- void Format(UINT nId, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5, const A6& v6, const A7& v7,
- const A8& v8, const A9& v9, const A10& v10, const A11& v11,
- const A12& v12, const A13& v13, const A14& v14)
- {
- MYTYPE strFmt;
- if ( strFmt.Load(nId) )
- {
- Fmt(strFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(), FmtArg<A5>(v5)(),
- FmtArg<A6>(v6)(), FmtArg<A7>(v7)(), FmtArg<A8>(v8)(),
- FmtArg<A9>(v9)(), FmtArg<A10>(v10)(),FmtArg<A11>(v11)(),
- FmtArg<A12>(v12)(), FmtArg<A13>(v13)(),FmtArg<A14>(v14)());
- }
- }
- template<class A1, class A2, class A3, class A4, class A5, class A6,
- class A7, class A8, class A9, class A10, class A11, class A12,
- class A13, class A14, class A15>
- void Format(UINT nId, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5, const A6& v6, const A7& v7,
- const A8& v8, const A9& v9, const A10& v10, const A11& v11,
- const A12& v12, const A13& v13, const A14& v14, const A15& v15)
- {
- MYTYPE strFmt;
- if ( strFmt.Load(nId) )
- {
- Fmt(strFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(), FmtArg<A5>(v5)(),
- FmtArg<A6>(v6)(), FmtArg<A7>(v7)(), FmtArg<A8>(v8)(),
- FmtArg<A9>(v9)(), FmtArg<A10>(v10)(),FmtArg<A11>(v11)(),
- FmtArg<A12>(v12)(),FmtArg<A13>(v13)(),FmtArg<A14>(v14)(),
- FmtArg<A15>(v15)());
- }
- }
- template<class A1, class A2, class A3, class A4, class A5, class A6,
- class A7, class A8, class A9, class A10, class A11, class A12,
- class A13, class A14, class A15, class A16>
- void Format(UINT nId, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5, const A6& v6, const A7& v7,
- const A8& v8, const A9& v9, const A10& v10, const A11& v11,
- const A12& v12, const A13& v13, const A14& v14, const A15& v15,
- const A16& v16)
- {
- MYTYPE strFmt;
- if ( strFmt.Load(nId) )
- {
- Fmt(strFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(), FmtArg<A5>(v5)(),
- FmtArg<A6>(v6)(), FmtArg<A7>(v7)(), FmtArg<A8>(v8)(),
- FmtArg<A9>(v9)(), FmtArg<A10>(v10)(),FmtArg<A11>(v11)(),
- FmtArg<A12>(v12)(),FmtArg<A13>(v13)(),FmtArg<A14>(v14)(),
- FmtArg<A15>(v15)(), FmtArg<A16>(v16)());
- }
- }
- template<class A1, class A2, class A3, class A4, class A5, class A6,
- class A7, class A8, class A9, class A10, class A11, class A12,
- class A13, class A14, class A15, class A16, class A17>
- void Format(UINT nId, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5, const A6& v6, const A7& v7,
- const A8& v8, const A9& v9, const A10& v10, const A11& v11,
- const A12& v12, const A13& v13, const A14& v14, const A15& v15,
- const A16& v16, const A17& v17)
- {
- MYTYPE strFmt;
- if ( strFmt.Load(nId) )
- {
- Fmt(strFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(), FmtArg<A5>(v5)(),
- FmtArg<A6>(v6)(), FmtArg<A7>(v7)(), FmtArg<A8>(v8)(),
- FmtArg<A9>(v9)(), FmtArg<A10>(v10)(),FmtArg<A11>(v11)(),
- FmtArg<A12>(v12)(),FmtArg<A13>(v13)(),FmtArg<A14>(v14)(),
- FmtArg<A15>(v15)(),FmtArg<A16>(v16)(),FmtArg<A17>(v17)());
- }
- }
-
-#endif // #ifndef SS_ANSI
-
- // ...now the other overload of Format: the one that takes a string literal
-
- void Format(const CT* szFmt)
- {
- *this = szFmt;
- }
- template<class A1>
- void Format(const CT* szFmt, const A1& v)
- {
- Fmt(szFmt, FmtArg<A1>(v)());
- }
- template<class A1, class A2>
- void Format(const CT* szFmt, const A1& v1, const A2& v2)
- {
- Fmt(szFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)());
- }
- template<class A1, class A2, class A3>
- void Format(const CT* szFmt, const A1& v1, const A2& v2, const A3& v3)
- {
- Fmt(szFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)());
- }
- template<class A1, class A2, class A3, class A4>
- void Format(const CT* szFmt, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4)
- {
- Fmt(szFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)());
- }
- template<class A1, class A2, class A3, class A4, class A5>
- void Format(const CT* szFmt, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5)
- {
- Fmt(szFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(), FmtArg<A5>(v5)());
- }
- template<class A1, class A2, class A3, class A4, class A5, class A6>
- void Format(const CT* szFmt, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5, const A6& v6)
- {
- Fmt(szFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(), FmtArg<A5>(v5)(),
- FmtArg<A6>(v6)());
- }
- template<class A1, class A2, class A3, class A4, class A5, class A6,
- class A7>
- void Format(const CT* szFmt, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5, const A6& v6, const A7& v7)
- {
- Fmt(szFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(), FmtArg<A5>(v5)(),
- FmtArg<A6>(v6)(), FmtArg<A7>(v7)());
- }
- template<class A1, class A2, class A3, class A4, class A5, class A6,
- class A7, class A8>
- void Format(const CT* szFmt, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5, const A6& v6, const A7& v7,
- const A8& v8)
- {
- Fmt(szFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(), FmtArg<A5>(v5)(),
- FmtArg<A6>(v6)(), FmtArg<A7>(v7)(), FmtArg<A8>(v8)());
- }
- template<class A1, class A2, class A3, class A4, class A5, class A6,
- class A7, class A8, class A9>
- void Format(const CT* szFmt, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5, const A6& v6, const A7& v7,
- const A8& v8, const A9& v9)
- {
- Fmt(szFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(), FmtArg<A5>(v5)(),
- FmtArg<A6>(v6)(), FmtArg<A7>(v7)(), FmtArg<A8>(v8)(),
- FmtArg<A9>(v9)());
- }
- template<class A1, class A2, class A3, class A4, class A5, class A6,
- class A7, class A8, class A9, class A10>
- void Format(const CT* szFmt, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5, const A6& v6, const A7& v7,
- const A8& v8, const A9& v9, const A10& v10)
- {
- Fmt(szFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(), FmtArg<A5>(v5)(),
- FmtArg<A6>(v6)(), FmtArg<A7>(v7)(), FmtArg<A8>(v8)(),
- FmtArg<A9>(v9)(), FmtArg<A10>(v10)());
- }
- template<class A1, class A2, class A3, class A4, class A5, class A6,
- class A7, class A8, class A9, class A10, class A11>
- void Format(const CT* szFmt, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5, const A6& v6, const A7& v7,
- const A8& v8, const A9& v9, const A10& v10, const A11& v11)
- {
- Fmt(szFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(), FmtArg<A5>(v5)(),
- FmtArg<A6>(v6)(), FmtArg<A7>(v7)(), FmtArg<A8>(v8)(),
- FmtArg<A9>(v9)(),FmtArg<A10>(v10)(),FmtArg<A11>(v11)());
- }
- template<class A1, class A2, class A3, class A4, class A5, class A6,
- class A7, class A8, class A9, class A10, class A11, class A12>
- void Format(const CT* szFmt, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5, const A6& v6, const A7& v7,
- const A8& v8, const A9& v9, const A10& v10, const A11& v11,
- const A12& v12)
- {
- Fmt(szFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(), FmtArg<A5>(v5)(),
- FmtArg<A6>(v6)(), FmtArg<A7>(v7)(), FmtArg<A8>(v8)(),
- FmtArg<A9>(v9)(), FmtArg<A10>(v10)(),FmtArg<A11>(v11)(),
- FmtArg<A12>(v12)());
- }
- template<class A1, class A2, class A3, class A4, class A5, class A6,
- class A7, class A8, class A9, class A10, class A11, class A12,
- class A13>
- void Format(const CT* szFmt, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5, const A6& v6, const A7& v7,
- const A8& v8, const A9& v9, const A10& v10, const A11& v11,
- const A12& v12, const A13& v13)
- {
- Fmt(szFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(), FmtArg<A5>(v5)(),
- FmtArg<A6>(v6)(), FmtArg<A7>(v7)(), FmtArg<A8>(v8)(),
- FmtArg<A9>(v9)(), FmtArg<A10>(v10)(),FmtArg<A11>(v11)(),
- FmtArg<A12>(v12)(), FmtArg<A13>(v13)());
- }
- template<class A1, class A2, class A3, class A4, class A5, class A6,
- class A7, class A8, class A9, class A10, class A11, class A12,
- class A13, class A14>
- void Format(const CT* szFmt, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5, const A6& v6, const A7& v7,
- const A8& v8, const A9& v9, const A10& v10, const A11& v11,
- const A12& v12, const A13& v13, const A14& v14)
- {
- Fmt(szFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(), FmtArg<A5>(v5)(),
- FmtArg<A6>(v6)(), FmtArg<A7>(v7)(), FmtArg<A8>(v8)(),
- FmtArg<A9>(v9)(), FmtArg<A10>(v10)(),FmtArg<A11>(v11)(),
- FmtArg<A12>(v12)(), FmtArg<A13>(v13)(),FmtArg<A14>(v14)());
- }
- template<class A1, class A2, class A3, class A4, class A5, class A6,
- class A7, class A8, class A9, class A10, class A11, class A12,
- class A13, class A14, class A15>
- void Format(const CT* szFmt, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5, const A6& v6, const A7& v7,
- const A8& v8, const A9& v9, const A10& v10, const A11& v11,
- const A12& v12, const A13& v13, const A14& v14, const A15& v15)
- {
- Fmt(szFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(), FmtArg<A5>(v5)(),
- FmtArg<A6>(v6)(), FmtArg<A7>(v7)(), FmtArg<A8>(v8)(),
- FmtArg<A9>(v9)(), FmtArg<A10>(v10)(),FmtArg<A11>(v11)(),
- FmtArg<A12>(v12)(),FmtArg<A13>(v13)(),FmtArg<A14>(v14)(),
- FmtArg<A15>(v15)());
- }
- template<class A1, class A2, class A3, class A4, class A5, class A6,
- class A7, class A8, class A9, class A10, class A11, class A12,
- class A13, class A14, class A15, class A16>
- void Format(const CT* szFmt, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5, const A6& v6, const A7& v7,
- const A8& v8, const A9& v9, const A10& v10, const A11& v11,
- const A12& v12, const A13& v13, const A14& v14, const A15& v15,
- const A16& v16)
- {
- Fmt(szFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(), FmtArg<A5>(v5)(),
- FmtArg<A6>(v6)(), FmtArg<A7>(v7)(), FmtArg<A8>(v8)(),
- FmtArg<A9>(v9)(), FmtArg<A10>(v10)(),FmtArg<A11>(v11)(),
- FmtArg<A12>(v12)(),FmtArg<A13>(v13)(),FmtArg<A14>(v14)(),
- FmtArg<A15>(v15)(), FmtArg<A16>(v16)());
- }
- template<class A1, class A2, class A3, class A4, class A5, class A6,
- class A7, class A8, class A9, class A10, class A11, class A12,
- class A13, class A14, class A15, class A16, class A17>
- void Format(const CT* szFmt, const A1& v1, const A2& v2, const A3& v3,
- const A4& v4, const A5& v5, const A6& v6, const A7& v7,
- const A8& v8, const A9& v9, const A10& v10, const A11& v11,
- const A12& v12, const A13& v13, const A14& v14, const A15& v15,
- const A16& v16, const A17& v17)
- {
- Fmt(szFmt, FmtArg<A1>(v1)(), FmtArg<A2>(v2)(),
- FmtArg<A3>(v3)(), FmtArg<A4>(v4)(), FmtArg<A5>(v5)(),
- FmtArg<A6>(v6)(), FmtArg<A7>(v7)(), FmtArg<A8>(v8)(),
- FmtArg<A9>(v9)(), FmtArg<A10>(v10)(),FmtArg<A11>(v11)(),
- FmtArg<A12>(v12)(),FmtArg<A13>(v13)(),FmtArg<A14>(v14)(),
- FmtArg<A15>(v15)(),FmtArg<A16>(v16)(),FmtArg<A17>(v17)());
- }
-
-#else // #ifdef SS_SAFE_FORMAT
-
-
-#ifndef SS_ANSI
-
- void Format(UINT nId, ...)
- {
- va_list argList;
- va_start(argList, nId);
-
- MYTYPE strFmt;
- if ( strFmt.Load(nId) )
- FormatV(strFmt, argList);
-
- va_end(argList);
- }
-
-#endif // #ifdef SS_ANSI
-
- void Format(const CT* szFmt, ...)
- {
- va_list argList;
- va_start(argList, szFmt);
- FormatV(szFmt, argList);
- va_end(argList);
- }
-
-#endif // #ifdef SS_SAFE_FORMAT
-
- void AppendFormat(const CT* szFmt, ...)
- {
- va_list argList;
- va_start(argList, szFmt);
- AppendFormatV(szFmt, argList);
- va_end(argList);
- }
-
- #define MAX_FMT_TRIES 5 // #of times we try
- #define FMT_BLOCK_SIZE 2048 // # of bytes to increment per try
- #define BUFSIZE_1ST 256
- #define BUFSIZE_2ND 512
- #define STD_BUF_SIZE 1024
-
- // an efficient way to add formatted characters to the string. You may only
- // add up to STD_BUF_SIZE characters at a time, though
- void AppendFormatV(const CT* szFmt, va_list argList)
- {
- CT szBuf[STD_BUF_SIZE];
- int nLen = ssnprintf(szBuf, STD_BUF_SIZE-1, szFmt, argList);
-
- if ( 0 < nLen )
- this->append(szBuf, nLen);
- }
-
- // -------------------------------------------------------------------------
- // FUNCTION: FormatV
- // void FormatV(PCSTR szFormat, va_list, argList);
- //
- // DESCRIPTION:
- // This function formats the string with sprintf style format-specs.
- // It makes a general guess at required buffer size and then tries
- // successively larger buffers until it finds one big enough or a
- // threshold (MAX_FMT_TRIES) is exceeded.
- //
- // PARAMETERS:
- // szFormat - a PCSTR holding the format of the output
- // argList - a Microsoft specific va_list for variable argument lists
- //
- // RETURN VALUE:
- // -------------------------------------------------------------------------
-
- // NOTE: Changed by JM to actually function under non-win32,
- // and to remove the upper limit on size.
- void FormatV(const CT* szFormat, va_list argList)
- {
- // try and grab a sufficient buffersize
- int nChars = FMT_BLOCK_SIZE;
- va_list argCopy;
-
- CT *p = reinterpret_cast<CT*>(malloc(sizeof(CT)*nChars));
- if (!p) return;
-
- while (1)
- {
- va_copy(argCopy, argList);
-
- int nActual = ssvsprintf(p, nChars, szFormat, argCopy);
- /* If that worked, return the string. */
- if (nActual > -1 && nActual < nChars)
- { /* make sure it's NULL terminated */
- p[nActual] = '\0';
- this->assign(p, nActual);
- free(p);
- va_end(argCopy);
- return;
- }
- /* Else try again with more space. */
- if (nActual > -1) /* glibc 2.1 */
- nChars = nActual + 1; /* precisely what is needed */
- else /* glibc 2.0 */
- nChars *= 2; /* twice the old size */
-
- CT *np = reinterpret_cast<CT*>(realloc(p, sizeof(CT)*nChars));
- if (np == NULL)
- {
- free(p);
- va_end(argCopy);
- return; // failed :(
- }
- p = np;
- va_end(argCopy);
- }
- }
-
- // -------------------------------------------------------------------------
- // CString Facade Functions:
- //
- // The following methods are intended to allow you to use this class as a
- // near drop-in replacement for CString.
- // -------------------------------------------------------------------------
- #ifdef SS_WIN32
- BSTR AllocSysString() const
- {
- ostring os;
- ssasn(os, *this);
- return ::SysAllocString(os.c_str());
- }
- #endif
-
-#ifndef SS_NO_LOCALE
- int Collate(PCMYSTR szThat) const
- {
- return sscoll(this->c_str(), this->length(), szThat, sslen(szThat));
- }
-
- int CollateNoCase(PCMYSTR szThat) const
- {
- return ssicoll(this->c_str(), this->length(), szThat, sslen(szThat));
- }
-#endif
- int Compare(PCMYSTR szThat) const
- {
- return this->compare(szThat);
- }
-
- int CompareNoCase(PCMYSTR szThat) const
- {
- return ssicmp(this->c_str(), szThat);
- }
-
- int Delete(int nIdx, int nCount=1)
- {
- if ( nIdx < 0 )
- nIdx = 0;
-
- if ( nIdx < this->GetLength() )
- this->erase(static_cast<MYSIZE>(nIdx), static_cast<MYSIZE>(nCount));
-
- return GetLength();
- }
-
- void Empty()
- {
- this->erase();
- }
-
- int Find(CT ch) const
- {
- MYSIZE nIdx = this->find_first_of(ch);
- return static_cast<int>(MYBASE::npos == nIdx ? -1 : nIdx);
- }
-
- int Find(PCMYSTR szSub) const
- {
- MYSIZE nIdx = this->find(szSub);
- return static_cast<int>(MYBASE::npos == nIdx ? -1 : nIdx);
- }
-
- int Find(CT ch, int nStart) const
- {
- // CString::Find docs say add 1 to nStart when it's not zero
- // CString::Find code doesn't do that however. We'll stick
- // with what the code does
-
- MYSIZE nIdx = this->find_first_of(ch, static_cast<MYSIZE>(nStart));
- return static_cast<int>(MYBASE::npos == nIdx ? -1 : nIdx);
- }
-
- int Find(PCMYSTR szSub, int nStart) const
- {
- // CString::Find docs say add 1 to nStart when it's not zero
- // CString::Find code doesn't do that however. We'll stick
- // with what the code does
-
- MYSIZE nIdx = this->find(szSub, static_cast<MYSIZE>(nStart));
- return static_cast<int>(MYBASE::npos == nIdx ? -1 : nIdx);
- }
-
- int FindOneOf(PCMYSTR szCharSet) const
- {
- MYSIZE nIdx = this->find_first_of(szCharSet);
- return static_cast<int>(MYBASE::npos == nIdx ? -1 : nIdx);
- }
-
-#ifndef SS_ANSI
- void FormatMessage(PCMYSTR szFormat, ...) throw(std::exception)
- {
- va_list argList;
- va_start(argList, szFormat);
- PMYSTR szTemp;
- if ( ssfmtmsg(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ALLOCATE_BUFFER,
- szFormat, 0, 0,
- reinterpret_cast<PMYSTR>(&szTemp), 0, &argList) == 0 ||
- szTemp == 0 )
- {
- throw std::runtime_error("out of memory");
- }
- *this = szTemp;
- LocalFree(szTemp);
- va_end(argList);
- }
-
- void FormatMessage(UINT nFormatId, ...) throw(std::exception)
- {
- MYTYPE sFormat;
- VERIFY(sFormat.LoadString(nFormatId));
- va_list argList;
- va_start(argList, nFormatId);
- PMYSTR szTemp;
- if ( ssfmtmsg(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ALLOCATE_BUFFER,
- sFormat, 0, 0,
- reinterpret_cast<PMYSTR>(&szTemp), 0, &argList) == 0 ||
- szTemp == 0)
- {
- throw std::runtime_error("out of memory");
- }
- *this = szTemp;
- LocalFree(szTemp);
- va_end(argList);
- }
-#endif
-
- // GetAllocLength -- an MSVC7 function but it costs us nothing to add it.
-
- int GetAllocLength()
- {
- return static_cast<int>(this->capacity());
- }
-
- // -------------------------------------------------------------------------
- // GetXXXX -- Direct access to character buffer
- // -------------------------------------------------------------------------
- CT GetAt(int nIdx) const
- {
- return this->at(static_cast<MYSIZE>(nIdx));
- }
-
- CT* GetBuffer(int nMinLen=-1)
- {
- return GetBuf(nMinLen);
- }
-
- CT* GetBufferSetLength(int nLen)
- {
- return BufferSet(nLen);
- }
-
- // GetLength() -- MFC docs say this is the # of BYTES but
- // in truth it is the number of CHARACTERs (chars or wchar_ts)
- int GetLength() const
- {
- return static_cast<int>(this->length());
- }
-
- int Insert(int nIdx, CT ch)
- {
- if ( static_cast<MYSIZE>(nIdx) > this->size()-1 )
- this->append(1, ch);
- else
- this->insert(static_cast<MYSIZE>(nIdx), 1, ch);
-
- return GetLength();
- }
- int Insert(int nIdx, PCMYSTR sz)
- {
- if ( static_cast<MYSIZE>(nIdx) >= this->size() )
- this->append(sz, static_cast<MYSIZE>(sslen(sz)));
- else
- this->insert(static_cast<MYSIZE>(nIdx), sz);
-
- return GetLength();
- }
-
- bool IsEmpty() const
- {
- return this->empty();
- }
-
- MYTYPE Left(int nCount) const
- {
- // Range check the count.
-
- nCount = SSMAX(0, SSMIN(nCount, static_cast<int>(this->size())));
- return this->substr(0, static_cast<MYSIZE>(nCount));
- }
-
-#ifndef SS_ANSI
- bool LoadString(UINT nId)
- {
- return this->Load(nId);
- }
-#endif
-
- void MakeLower()
- {
- ToLower();
- }
-
- void MakeReverse()
- {
- std::reverse(this->begin(), this->end());
- }
-
- void MakeUpper()
- {
- ToUpper();
- }
-
- MYTYPE Mid(int nFirst) const
- {
- return Mid(nFirst, this->GetLength()-nFirst);
- }
-
- MYTYPE Mid(int nFirst, int nCount) const
- {
- // CString does range checking here. Since we're trying to emulate it,
- // we must check too.
-
- if ( nFirst < 0 )
- nFirst = 0;
- if ( nCount < 0 )
- nCount = 0;
-
- int nSize = static_cast<int>(this->size());
-
- if ( nFirst + nCount > nSize )
- nCount = nSize - nFirst;
-
- if ( nFirst > nSize )
- return MYTYPE();
-
- ASSERT(nFirst >= 0);
- ASSERT(nFirst + nCount <= nSize);
-
- return this->substr(static_cast<MYSIZE>(nFirst),
- static_cast<MYSIZE>(nCount));
- }
-
- void ReleaseBuffer(int nNewLen=-1)
- {
- RelBuf(nNewLen);
- }
-
- int Remove(CT ch)
- {
- MYSIZE nIdx = 0;
- int nRemoved = 0;
- while ( (nIdx=this->find_first_of(ch)) != MYBASE::npos )
- {
- this->erase(nIdx, 1);
- nRemoved++;
- }
- return nRemoved;
- }
-
- int Replace(CT chOld, CT chNew)
- {
- int nReplaced = 0;
-
- for ( MYITER iter=this->begin(); iter != this->end(); iter++ )
- {
- if ( *iter == chOld )
- {
- *iter = chNew;
- nReplaced++;
- }
- }
-
- return nReplaced;
- }
-
- int Replace(PCMYSTR szOld, PCMYSTR szNew)
- {
- int nReplaced = 0;
- MYSIZE nIdx = 0;
- MYSIZE nOldLen = sslen(szOld);
-
- if ( 0 != nOldLen )
- {
- // If the replacement string is longer than the one it replaces, this
- // string is going to have to grow in size, Figure out how much
- // and grow it all the way now, rather than incrementally
-
- MYSIZE nNewLen = sslen(szNew);
- if ( nNewLen > nOldLen )
- {
- int nFound = 0;
- while ( nIdx < this->length() &&
- (nIdx=this->find(szOld, nIdx)) != MYBASE::npos )
- {
- nFound++;
- nIdx += nOldLen;
- }
- this->reserve(this->size() + nFound * (nNewLen - nOldLen));
- }
-
-
- static const CT ch = CT(0);
- PCMYSTR szRealNew = szNew == 0 ? &ch : szNew;
- nIdx = 0;
-
- while ( nIdx < this->length() &&
- (nIdx=this->find(szOld, nIdx)) != MYBASE::npos )
- {
- this->replace(this->begin()+nIdx, this->begin()+nIdx+nOldLen,
- szRealNew);
-
- nReplaced++;
- nIdx += nNewLen;
- }
- }
-
- return nReplaced;
- }
-
- int ReverseFind(CT ch) const
- {
- MYSIZE nIdx = this->find_last_of(ch);
- return static_cast<int>(MYBASE::npos == nIdx ? -1 : nIdx);
- }
-
- // ReverseFind overload that's not in CString but might be useful
- int ReverseFind(PCMYSTR szFind, MYSIZE pos=MYBASE::npos) const
- {
- //yuvalt - this does not compile with g++ since MYTTYPE() is different type
- //MYSIZE nIdx = this->rfind(0 == szFind ? MYTYPE() : szFind, pos);
- MYSIZE nIdx = this->rfind(0 == szFind ? "" : szFind, pos);
- return static_cast<int>(MYBASE::npos == nIdx ? -1 : nIdx);
- }
-
- MYTYPE Right(int nCount) const
- {
- // Range check the count.
-
- nCount = SSMAX(0, SSMIN(nCount, static_cast<int>(this->size())));
- return this->substr(this->size()-static_cast<MYSIZE>(nCount));
- }
-
- void SetAt(int nIndex, CT ch)
- {
- ASSERT(this->size() > static_cast<MYSIZE>(nIndex));
- this->at(static_cast<MYSIZE>(nIndex)) = ch;
- }
-
-#ifndef SS_ANSI
- BSTR SetSysString(BSTR* pbstr) const
- {
- ostring os;
- ssasn(os, *this);
- if ( !::SysReAllocStringLen(pbstr, os.c_str(), os.length()) )
- throw std::runtime_error("out of memory");
-
- ASSERT(*pbstr != 0);
- return *pbstr;
- }
-#endif
-
- MYTYPE SpanExcluding(PCMYSTR szCharSet) const
- {
- MYSIZE pos = this->find_first_of(szCharSet);
- return pos == MYBASE::npos ? *this : Left(pos);
- }
-
- MYTYPE SpanIncluding(PCMYSTR szCharSet) const
- {
- MYSIZE pos = this->find_first_not_of(szCharSet);
- return pos == MYBASE::npos ? *this : Left(pos);
- }
-
-#if defined SS_WIN32 && !defined(UNICODE) && !defined(SS_ANSI)
-
- // CString's OemToAnsi and AnsiToOem functions are available only in
- // Unicode builds. However since we're a template we also need a
- // runtime check of CT and a reinterpret_cast to account for the fact
- // that CStdStringW gets instantiated even in non-Unicode builds.
-
- void AnsiToOem()
- {
- if ( sizeof(CT) == sizeof(char) && !empty() )
- {
- ::CharToOem(reinterpret_cast<PCSTR>(this->c_str()),
- reinterpret_cast<PSTR>(GetBuf()));
- }
- else
- {
- ASSERT(false);
- }
- }
-
- void OemToAnsi()
- {
- if ( sizeof(CT) == sizeof(char) && !empty() )
- {
- ::OemToChar(reinterpret_cast<PCSTR>(this->c_str()),
- reinterpret_cast<PSTR>(GetBuf()));
- }
- else
- {
- ASSERT(false);
- }
- }
-
-#endif
-
-
- // -------------------------------------------------------------------------
- // Trim and its variants
- // -------------------------------------------------------------------------
- MYTYPE& Trim()
- {
- return TrimLeft().TrimRight();
- }
-
- MYTYPE& TrimLeft()
- {
- this->erase(this->begin(),
- std::find_if(this->begin(), this->end(), NotSpace<CT>()));
-
- return *this;
- }
-
- MYTYPE& TrimLeft(CT tTrim)
- {
- this->erase(0, this->find_first_not_of(tTrim));
- return *this;
- }
-
- MYTYPE& TrimLeft(PCMYSTR szTrimChars)
- {
- this->erase(0, this->find_first_not_of(szTrimChars));
- return *this;
- }
-
- MYTYPE& TrimRight()
- {
- // NOTE: When comparing reverse_iterators here (MYRITER), I avoid using
- // operator!=. This is because namespace rel_ops also has a template
- // operator!= which conflicts with the global operator!= already defined
- // for reverse_iterator in the header <utility>.
- // Thanks to John James for alerting me to this.
-
- MYRITER it = std::find_if(this->rbegin(), this->rend(), NotSpace<CT>());
- if ( !(this->rend() == it) )
- this->erase(this->rend() - it);
-
- this->erase(!(it == this->rend()) ? this->find_last_of(*it) + 1 : 0);
- return *this;
- }
-
- MYTYPE& TrimRight(CT tTrim)
- {
- MYSIZE nIdx = this->find_last_not_of(tTrim);
- this->erase(MYBASE::npos == nIdx ? 0 : ++nIdx);
- return *this;
- }
-
- MYTYPE& TrimRight(PCMYSTR szTrimChars)
- {
- MYSIZE nIdx = this->find_last_not_of(szTrimChars);
- this->erase(MYBASE::npos == nIdx ? 0 : ++nIdx);
- return *this;
- }
-
- void FreeExtra()
- {
- MYTYPE mt;
- this->swap(mt);
- if ( !mt.empty() )
- this->assign(mt.c_str(), mt.size());
- }
-
- // I have intentionally not implemented the following CString
- // functions. You cannot make them work without taking advantage
- // of implementation specific behavior. However if you absolutely
- // MUST have them, uncomment out these lines for "sort-of-like"
- // their behavior. You're on your own.
-
-// CT* LockBuffer() { return GetBuf(); }// won't really lock
-// void UnlockBuffer(); { } // why have UnlockBuffer w/o LockBuffer?
-
- // Array-indexing operators. Required because we defined an implicit cast
- // to operator const CT* (Thanks to Julian Selman for pointing this out)
-
- CT& operator[](int nIdx)
- {
- return static_cast<MYBASE*>(this)->operator[](static_cast<MYSIZE>(nIdx));
- }
-
- const CT& operator[](int nIdx) const
- {
- return static_cast<const MYBASE*>(this)->operator[](static_cast<MYSIZE>(nIdx));
- }
-
- CT& operator[](unsigned int nIdx)
- {
- return static_cast<MYBASE*>(this)->operator[](static_cast<MYSIZE>(nIdx));
- }
-
- const CT& operator[](unsigned int nIdx) const
- {
- return static_cast<const MYBASE*>(this)->operator[](static_cast<MYSIZE>(nIdx));
- }
-
- CT& operator[](unsigned long nIdx)
- {
- return static_cast<MYBASE*>(this)->operator[](static_cast<MYSIZE>(nIdx));
- }
-
- const CT& operator[](unsigned long nIdx) const
- {
- return static_cast<const MYBASE*>(this)->operator[](static_cast<MYSIZE>(nIdx));
- }
-
-#ifndef SS_NO_IMPLICIT_CAST
- operator const CT*() const
- {
- return this->c_str();
- }
-#endif
-
- // IStream related functions. Useful in IPersistStream implementations
-
-#ifdef SS_INC_COMDEF
-
- // struct SSSHDR - useful for non Std C++ persistence schemes.
- typedef struct SSSHDR
- {
- BYTE byCtrl;
- ULONG nChars;
- } SSSHDR; // as in "Standard String Stream Header"
-
- #define SSSO_UNICODE 0x01 // the string is a wide string
- #define SSSO_COMPRESS 0x02 // the string is compressed
-
- // -------------------------------------------------------------------------
- // FUNCTION: StreamSize
- // REMARKS:
- // Returns how many bytes it will take to StreamSave() this CStdString
- // object to an IStream.
- // -------------------------------------------------------------------------
- ULONG StreamSize() const
- {
- // Control header plus string
- ASSERT(this->size()*sizeof(CT) < 0xffffffffUL - sizeof(SSSHDR));
- return (this->size() * sizeof(CT)) + sizeof(SSSHDR);
- }
-
- // -------------------------------------------------------------------------
- // FUNCTION: StreamSave
- // REMARKS:
- // Saves this CStdString object to a COM IStream.
- // -------------------------------------------------------------------------
- HRESULT StreamSave(IStream* pStream) const
- {
- ASSERT(this->size()*sizeof(CT) < 0xffffffffUL - sizeof(SSSHDR));
- HRESULT hr = E_FAIL;
- ASSERT(pStream != 0);
- SSSHDR hdr;
- hdr.byCtrl = sizeof(CT) == 2 ? SSSO_UNICODE : 0;
- hdr.nChars = this->size();
-
-
- if ( FAILED(hr=pStream->Write(&hdr, sizeof(SSSHDR), 0)) )
- {
- TRACE(_T("StreamSave: Cannot write control header, ERR=0x%X\n"),hr);
- }
- else if ( empty() )
- {
- ; // nothing to write
- }
- else if ( FAILED(hr=pStream->Write(this->c_str(),
- this->size()*sizeof(CT), 0)) )
- {
- TRACE(_T("StreamSave: Cannot write string to stream 0x%X\n"), hr);
- }
-
- return hr;
- }
-
-
- // -------------------------------------------------------------------------
- // FUNCTION: StreamLoad
- // REMARKS:
- // This method loads the object from an IStream.
- // -------------------------------------------------------------------------
- HRESULT StreamLoad(IStream* pStream)
- {
- ASSERT(pStream != 0);
- SSSHDR hdr;
- HRESULT hr = E_FAIL;
-
- if ( FAILED(hr=pStream->Read(&hdr, sizeof(SSSHDR), 0)) )
- {
- TRACE(_T("StreamLoad: Cant read control header, ERR=0x%X\n"), hr);
- }
- else if ( hdr.nChars > 0 )
- {
- ULONG nRead = 0;
- PMYSTR pMyBuf = BufferSet(hdr.nChars);
-
- // If our character size matches the character size of the string
- // we're trying to read, then we can read it directly into our
- // buffer. Otherwise, we have to read into an intermediate buffer
- // and convert.
-
- if ( (hdr.byCtrl & SSSO_UNICODE) != 0 )
- {
- ULONG nBytes = hdr.nChars * sizeof(wchar_t);
- if ( sizeof(CT) == sizeof(wchar_t) )
- {
- if ( FAILED(hr=pStream->Read(pMyBuf, nBytes, &nRead)) )
- TRACE(_T("StreamLoad: Cannot read string: 0x%X\n"), hr);
- }
- else
- {
- PWSTR pBufW = reinterpret_cast<PWSTR>(_alloca((nBytes)+1));
- if ( FAILED(hr=pStream->Read(pBufW, nBytes, &nRead)) )
- TRACE(_T("StreamLoad: Cannot read string: 0x%X\n"), hr);
- else
- sscpy(pMyBuf, pBufW, hdr.nChars);
- }
- }
- else
- {
- ULONG nBytes = hdr.nChars * sizeof(char);
- if ( sizeof(CT) == sizeof(char) )
- {
- if ( FAILED(hr=pStream->Read(pMyBuf, nBytes, &nRead)) )
- TRACE(_T("StreamLoad: Cannot read string: 0x%X\n"), hr);
- }
- else
- {
- PSTR pBufA = reinterpret_cast<PSTR>(_alloca(nBytes));
- if ( FAILED(hr=pStream->Read(pBufA, hdr.nChars, &nRead)) )
- TRACE(_T("StreamLoad: Cannot read string: 0x%X\n"), hr);
- else
- sscpy(pMyBuf, pBufA, hdr.nChars);
- }
- }
- }
- else
- {
- this->erase();
- }
- return hr;
- }
-#endif // #ifdef SS_INC_COMDEF
-
-#ifndef SS_ANSI
-
- // SetResourceHandle/GetResourceHandle. In MFC builds, these map directly
- // to AfxSetResourceHandle and AfxGetResourceHandle. In non-MFC builds they
- // point to a single static HINST so that those who call the member
- // functions that take resource IDs can provide an alternate HINST of a DLL
- // to search. This is not exactly the list of HMODULES that MFC provides
- // but it's better than nothing.
-
- #ifdef _MFC_VER
- static void SetResourceHandle(HMODULE hNew)
- {
- AfxSetResourceHandle(hNew);
- }
- static HMODULE GetResourceHandle()
- {
- return AfxGetResourceHandle();
- }
- #else
- static void SetResourceHandle(HMODULE hNew)
- {
- SSResourceHandle() = hNew;
- }
- static HMODULE GetResourceHandle()
- {
- return SSResourceHandle();
- }
- #endif
-
-#endif
-};
-
-// -----------------------------------------------------------------------------
-// MSVC USERS: HOW TO EXPORT CSTDSTRING FROM A DLL
-//
-// If you are using MS Visual C++ and you want to export CStdStringA and
-// CStdStringW from a DLL, then all you need to
-//
-// 1. make sure that all components link to the same DLL version
-// of the CRT (not the static one).
-// 2. Uncomment the 3 lines of code below
-// 3. #define 2 macros per the instructions in MS KnowledgeBase
-// article Q168958. The macros are:
-//
-// MACRO DEFINTION WHEN EXPORTING DEFINITION WHEN IMPORTING
-// ----- ------------------------ -------------------------
-// SSDLLEXP (nothing, just #define it) extern
-// SSDLLSPEC __declspec(dllexport) __declspec(dllimport)
-//
-// Note that these macros must be available to ALL clients who want to
-// link to the DLL and use the class. If they
-//
-// A word of advice: Don't bother.
-//
-// Really, it is not necessary to export CStdString functions from a DLL. I
-// never do. In my projects, I do generally link to the DLL version of the
-// Standard C++ Library, but I do NOT attempt to export CStdString functions.
-// I simply include the header where it is needed and allow for the code
-// redundancy.
-//
-// That redundancy is a lot less than you think. This class does most of its
-// work via the Standard C++ Library, particularly the base_class basic_string<>
-// member functions. Most of the functions here are small enough to be inlined
-// anyway. Besides, you'll find that in actual practice you use less than 1/2
-// of the code here, even in big projects and different modules will use as
-// little as 10% of it. That means a lot less functions actually get linked
-// your binaries. If you export this code from a DLL, it ALL gets linked in.
-//
-// I've compared the size of the binaries from exporting vs NOT exporting. Take
-// my word for it -- exporting this code is not worth the hassle.
-//
-// -----------------------------------------------------------------------------
-//#pragma warning(disable:4231) // non-standard extension ("extern template")
-// SSDLLEXP template class SSDLLSPEC CStdStr<char>;
-// SSDLLEXP template class SSDLLSPEC CStdStr<wchar_t>;
-
-
-// =============================================================================
-// END OF CStdStr INLINE FUNCTION DEFINITIONS
-// =============================================================================
-
-// Now typedef our class names based upon this humongous template
-
-typedef CStdStr<char> CStdStringA; // a better std::string
-typedef CStdStr<wchar_t> CStdStringW; // a better std::wstring
-typedef CStdStr<uint16_t> CStdString16; // a 16bit char string
-typedef CStdStr<uint32_t> CStdString32; // a 32bit char string
-typedef CStdStr<OLECHAR> CStdStringO; // almost always CStdStringW
-
-// -----------------------------------------------------------------------------
-// CStdStr addition functions defined as inline
-// -----------------------------------------------------------------------------
-
-
-inline CStdStringA operator+(const CStdStringA& s1, const CStdStringA& s2)
-{
- CStdStringA sRet(SSREF(s1));
- sRet.append(s2);
- return sRet;
-}
-inline CStdStringA operator+(const CStdStringA& s1, CStdStringA::value_type t)
-{
- CStdStringA sRet(SSREF(s1));
- sRet.append(1, t);
- return sRet;
-}
-inline CStdStringA operator+(const CStdStringA& s1, PCSTR pA)
-{
- CStdStringA sRet(SSREF(s1));
- sRet.append(pA);
- return sRet;
-}
-inline CStdStringA operator+(PCSTR pA, const CStdStringA& sA)
-{
- CStdStringA sRet;
- CStdStringA::size_type nObjSize = sA.size();
- CStdStringA::size_type nLitSize =
- static_cast<CStdStringA::size_type>(sslen(pA));
-
- sRet.reserve(nLitSize + nObjSize);
- sRet.assign(pA);
- sRet.append(sA);
- return sRet;
-}
-
-
-inline CStdStringA operator+(const CStdStringA& s1, const CStdStringW& s2)
-{
- return s1 + CStdStringA(s2);
-}
-inline CStdStringW operator+(const CStdStringW& s1, const CStdStringW& s2)
-{
- CStdStringW sRet(SSREF(s1));
- sRet.append(s2);
- return sRet;
-}
-inline CStdStringA operator+(const CStdStringA& s1, PCWSTR pW)
-{
- return s1 + CStdStringA(pW);
-}
-
-#ifdef UNICODE
- inline CStdStringW operator+(PCWSTR pW, const CStdStringA& sA)
- {
- return CStdStringW(pW) + CStdStringW(SSREF(sA));
- }
- inline CStdStringW operator+(PCSTR pA, const CStdStringW& sW)
- {
- return CStdStringW(pA) + sW;
- }
-#else
- inline CStdStringA operator+(PCWSTR pW, const CStdStringA& sA)
- {
- return CStdStringA(pW) + sA;
- }
- inline CStdStringA operator+(PCSTR pA, const CStdStringW& sW)
- {
- return pA + CStdStringA(sW);
- }
-#endif
-
-// ...Now the wide string versions.
-inline CStdStringW operator+(const CStdStringW& s1, CStdStringW::value_type t)
-{
- CStdStringW sRet(SSREF(s1));
- sRet.append(1, t);
- return sRet;
-}
-inline CStdStringW operator+(const CStdStringW& s1, PCWSTR pW)
-{
- CStdStringW sRet(SSREF(s1));
- sRet.append(pW);
- return sRet;
-}
-inline CStdStringW operator+(PCWSTR pW, const CStdStringW& sW)
-{
- CStdStringW sRet;
- CStdStringW::size_type nObjSize = sW.size();
- CStdStringA::size_type nLitSize =
- static_cast<CStdStringW::size_type>(sslen(pW));
-
- sRet.reserve(nLitSize + nObjSize);
- sRet.assign(pW);
- sRet.append(sW);
- return sRet;
-}
-
-inline CStdStringW operator+(const CStdStringW& s1, const CStdStringA& s2)
-{
- return s1 + CStdStringW(s2);
-}
-inline CStdStringW operator+(const CStdStringW& s1, PCSTR pA)
-{
- return s1 + CStdStringW(pA);
-}
-
-
-// New-style format function is a template
-
-#ifdef SS_SAFE_FORMAT
-
-template<>
-struct FmtArg<CStdStringA>
-{
- explicit FmtArg(const CStdStringA& arg) : a_(arg) {}
- PCSTR operator()() const { return a_.c_str(); }
- const CStdStringA& a_;
-private:
- FmtArg<CStdStringA>& operator=(const FmtArg<CStdStringA>&) { return *this; }
-};
-template<>
-struct FmtArg<CStdStringW>
-{
- explicit FmtArg(const CStdStringW& arg) : a_(arg) {}
- PCWSTR operator()() const { return a_.c_str(); }
- const CStdStringW& a_;
-private:
- FmtArg<CStdStringW>& operator=(const FmtArg<CStdStringW>&) { return *this; }
-};
-
-template<>
-struct FmtArg<std::string>
-{
- explicit FmtArg(const std::string& arg) : a_(arg) {}
- PCSTR operator()() const { return a_.c_str(); }
- const std::string& a_;
-private:
- FmtArg<std::string>& operator=(const FmtArg<std::string>&) { return *this; }
-};
-template<>
-struct FmtArg<std::wstring>
-{
- explicit FmtArg(const std::wstring& arg) : a_(arg) {}
- PCWSTR operator()() const { return a_.c_str(); }
- const std::wstring& a_;
-private:
- FmtArg<std::wstring>& operator=(const FmtArg<std::wstring>&) {return *this;}
-};
-#endif // #ifdef SS_SAFEFORMAT
-
-#ifndef SS_ANSI
- // SSResourceHandle: our MFC-like resource handle
- inline HMODULE& SSResourceHandle()
- {
- static HMODULE hModuleSS = GetModuleHandle(0);
- return hModuleSS;
- }
-#endif
-
-
-// In MFC builds, define some global serialization operators
-// Special operators that allow us to serialize CStdStrings to CArchives.
-// Note that we use an intermediate CString object in order to ensure that
-// we use the exact same format.
-
-#ifdef _MFC_VER
- inline CArchive& AFXAPI operator<<(CArchive& ar, const CStdStringA& strA)
- {
- CString strTemp = strA;
- return ar << strTemp;
- }
- inline CArchive& AFXAPI operator<<(CArchive& ar, const CStdStringW& strW)
- {
- CString strTemp = strW;
- return ar << strTemp;
- }
-
- inline CArchive& AFXAPI operator>>(CArchive& ar, CStdStringA& strA)
- {
- CString strTemp;
- ar >> strTemp;
- strA = strTemp;
- return ar;
- }
- inline CArchive& AFXAPI operator>>(CArchive& ar, CStdStringW& strW)
- {
- CString strTemp;
- ar >> strTemp;
- strW = strTemp;
- return ar;
- }
-#endif // #ifdef _MFC_VER -- (i.e. is this MFC?)
-
-
-
-// -----------------------------------------------------------------------------
-// GLOBAL FUNCTION: WUFormat
-// CStdStringA WUFormat(UINT nId, ...);
-// CStdStringA WUFormat(PCSTR szFormat, ...);
-//
-// REMARKS:
-// This function allows the caller for format and return a CStdStringA
-// object with a single line of code.
-// -----------------------------------------------------------------------------
-#ifdef SS_ANSI
-#else
- inline CStdStringA WUFormatA(UINT nId, ...)
- {
- va_list argList;
- va_start(argList, nId);
-
- CStdStringA strFmt;
- CStdStringA strOut;
- if ( strFmt.Load(nId) )
- strOut.FormatV(strFmt, argList);
-
- va_end(argList);
- return strOut;
- }
- inline CStdStringA WUFormatA(PCSTR szFormat, ...)
- {
- va_list argList;
- va_start(argList, szFormat);
- CStdStringA strOut;
- strOut.FormatV(szFormat, argList);
- va_end(argList);
- return strOut;
- }
- inline CStdStringW WUFormatW(UINT nId, ...)
- {
- va_list argList;
- va_start(argList, nId);
-
- CStdStringW strFmt;
- CStdStringW strOut;
- if ( strFmt.Load(nId) )
- strOut.FormatV(strFmt, argList);
-
- va_end(argList);
- return strOut;
- }
- inline CStdStringW WUFormatW(PCWSTR szwFormat, ...)
- {
- va_list argList;
- va_start(argList, szwFormat);
- CStdStringW strOut;
- strOut.FormatV(szwFormat, argList);
- va_end(argList);
- return strOut;
- }
-#endif // #ifdef SS_ANSI
-
-
-
-#if defined(SS_WIN32) && !defined (SS_ANSI)
- // -------------------------------------------------------------------------
- // FUNCTION: WUSysMessage
- // CStdStringA WUSysMessageA(DWORD dwError, DWORD dwLangId=SS_DEFLANGID);
- // CStdStringW WUSysMessageW(DWORD dwError, DWORD dwLangId=SS_DEFLANGID);
- //
- // DESCRIPTION:
- // This function simplifies the process of obtaining a string equivalent
- // of a system error code returned from GetLastError(). You simply
- // supply the value returned by GetLastError() to this function and the
- // corresponding system string is returned in the form of a CStdStringA.
- //
- // PARAMETERS:
- // dwError - a DWORD value representing the error code to be translated
- // dwLangId - the language id to use. defaults to english.
- //
- // RETURN VALUE:
- // a CStdStringA equivalent of the error code. Currently, this function
- // only returns either English of the system default language strings.
- // -------------------------------------------------------------------------
- #define SS_DEFLANGID MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT)
- inline CStdStringA WUSysMessageA(DWORD dwError, DWORD dwLangId=SS_DEFLANGID)
- {
- CHAR szBuf[512];
-
- if ( 0 != ::FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError,
- dwLangId, szBuf, 511, NULL) )
- return WUFormatA("%s (0x%X)", szBuf, dwError);
- else
- return WUFormatA("Unknown error (0x%X)", dwError);
- }
- inline CStdStringW WUSysMessageW(DWORD dwError, DWORD dwLangId=SS_DEFLANGID)
- {
- WCHAR szBuf[512];
-
- if ( 0 != ::FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError,
- dwLangId, szBuf, 511, NULL) )
- return WUFormatW(L"%s (0x%X)", szBuf, dwError);
- else
- return WUFormatW(L"Unknown error (0x%X)", dwError);
- }
-#endif
-
-// Define TCHAR based friendly names for some of these functions
-
-#ifdef UNICODE
- //#define CStdString CStdStringW
- typedef CStdStringW CStdString;
- #define WUSysMessage WUSysMessageW
- #define WUFormat WUFormatW
-#else
- //#define CStdString CStdStringA
- typedef CStdStringA CStdString;
- #define WUSysMessage WUSysMessageA
- #define WUFormat WUFormatA
-#endif
-
-// ...and some shorter names for the space-efficient
-
-#define WUSysMsg WUSysMessage
-#define WUSysMsgA WUSysMessageA
-#define WUSysMsgW WUSysMessageW
-#define WUFmtA WUFormatA
-#define WUFmtW WUFormatW
-#define WUFmt WUFormat
-#define WULastErrMsg() WUSysMessage(::GetLastError())
-#define WULastErrMsgA() WUSysMessageA(::GetLastError())
-#define WULastErrMsgW() WUSysMessageW(::GetLastError())
-
-
-// -----------------------------------------------------------------------------
-// FUNCTIONAL COMPARATORS:
-// REMARKS:
-// These structs are derived from the std::binary_function template. They
-// give us functional classes (which may be used in Standard C++ Library
-// collections and algorithms) that perform case-insensitive comparisons of
-// CStdString objects. This is useful for maps in which the key may be the
-// proper string but in the wrong case.
-// -----------------------------------------------------------------------------
-#define StdStringLessNoCaseW SSLNCW // avoid VC compiler warning 4786
-#define StdStringEqualsNoCaseW SSENCW
-#define StdStringLessNoCaseA SSLNCA
-#define StdStringEqualsNoCaseA SSENCA
-
-#ifdef UNICODE
- #define StdStringLessNoCase SSLNCW
- #define StdStringEqualsNoCase SSENCW
-#else
- #define StdStringLessNoCase SSLNCA
- #define StdStringEqualsNoCase SSENCA
-#endif
-
-struct StdStringLessNoCaseW
- : std::binary_function<CStdStringW, CStdStringW, bool>
-{
- inline
- bool operator()(const CStdStringW& sLeft, const CStdStringW& sRight) const
- { return ssicmp(sLeft.c_str(), sRight.c_str()) < 0; }
-};
-struct StdStringEqualsNoCaseW
- : std::binary_function<CStdStringW, CStdStringW, bool>
-{
- inline
- bool operator()(const CStdStringW& sLeft, const CStdStringW& sRight) const
- { return ssicmp(sLeft.c_str(), sRight.c_str()) == 0; }
-};
-struct StdStringLessNoCaseA
- : std::binary_function<CStdStringA, CStdStringA, bool>
-{
- inline
- bool operator()(const CStdStringA& sLeft, const CStdStringA& sRight) const
- { return ssicmp(sLeft.c_str(), sRight.c_str()) < 0; }
-};
-struct StdStringEqualsNoCaseA
- : std::binary_function<CStdStringA, CStdStringA, bool>
-{
- inline
- bool operator()(const CStdStringA& sLeft, const CStdStringA& sRight) const
- { return ssicmp(sLeft.c_str(), sRight.c_str()) == 0; }
-};
-
-// If we had to define our own version of TRACE above, get rid of it now
-
-#ifdef TRACE_DEFINED_HERE
- #undef TRACE
- #undef TRACE_DEFINED_HERE
-#endif
-
-
-// These std::swap specializations come courtesy of Mike Crusader.
-
-//namespace std
-//{
-// inline void swap(CStdStringA& s1, CStdStringA& s2) throw()
-// {
-// s1.swap(s2);
-// }
-// template<>
-// inline void swap(CStdStringW& s1, CStdStringW& s2) throw()
-// {
-// s1.swap(s2);
-// }
-//}
-
-// Turn back on any Borland warnings we turned off.
-
-#ifdef __BORLANDC__
- #pragma option pop // Turn back on inline function warnings
-// #pragma warn +inl // Turn back on inline function warnings
-#endif
-
-typedef std::vector<CStdString> CStdStringArray;
-
-#endif // #ifndef STDSTRING_H
diff --git a/guilib/Texture.cpp b/guilib/Texture.cpp
deleted file mode 100644
index 8c53b29e2f..0000000000
--- a/guilib/Texture.cpp
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
-* Copyright (C) 2005-2008 Team XBMC
-* http://www.xbmc.org
-*
-* This Program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, 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 General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with XBMC; see the file COPYING. If not, write to
-* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-* http://www.gnu.org/copyleft/gpl.html
-*
-*/
-
-#include "Texture.h"
-#include "Picture.h"
-#include "WindowingFactory.h"
-#include "utils/log.h"
-#include "DllImageLib.h"
-#include "DDSImage.h"
-#include "Util.h"
-
-/************************************************************************/
-/* */
-/************************************************************************/
-CBaseTexture::CBaseTexture(unsigned int width, unsigned int height, unsigned int format)
- : m_hasAlpha( true )
-{
-#ifndef HAS_DX
- m_texture = NULL;
-#endif
- m_pixels = NULL;
- m_loadedToGPU = false;
- Allocate(width, height, format);
-}
-
-CBaseTexture::~CBaseTexture()
-{
- delete[] m_pixels;
-}
-
-void CBaseTexture::Allocate(unsigned int width, unsigned int height, unsigned int format)
-{
- m_imageWidth = width;
- m_imageHeight = height;
- m_format = format;
- m_orientation = 0;
-
- m_textureWidth = m_imageWidth;
- m_textureHeight = m_imageHeight;
-
- if (m_format & XB_FMT_DXT_MASK)
- while (GetPitch() < g_Windowing.GetMinDXTPitch())
- m_textureWidth += GetBlockSize();
-
- if (!g_Windowing.SupportsNPOT((m_format & XB_FMT_DXT_MASK) != 0))
- {
- m_textureWidth = PadPow2(m_textureWidth);
- m_textureHeight = PadPow2(m_textureHeight);
- }
- if (m_format & XB_FMT_DXT_MASK)
- { // DXT textures must be a multiple of 4 in width and height
- m_textureWidth = ((m_textureWidth + 3) / 4) * 4;
- m_textureHeight = ((m_textureHeight + 3) / 4) * 4;
- }
-
- // check for max texture size
- #define CLAMP(x, y) { if (x > y) x = y; }
- CLAMP(m_textureWidth, g_Windowing.GetMaxTextureSize());
- CLAMP(m_textureHeight, g_Windowing.GetMaxTextureSize());
- CLAMP(m_imageWidth, m_textureWidth);
- CLAMP(m_imageHeight, m_textureHeight);
-
- delete[] m_pixels;
- m_pixels = new unsigned char[GetPitch() * GetRows()];
-}
-
-void CBaseTexture::Update(unsigned int width, unsigned int height, unsigned int pitch, unsigned int format, const unsigned char *pixels, bool loadToGPU)
-{
- if (pixels == NULL)
- return;
-
- if (format & XB_FMT_DXT_MASK && !g_Windowing.SupportsDXT())
- { // compressed format that we don't support
- Allocate(width, height, XB_FMT_A8R8G8B8);
- CDDSImage::Decompress(m_pixels, std::min(width, m_textureWidth), std::min(height, m_textureHeight), GetPitch(m_textureWidth), pixels, format);
- }
- else
- {
- Allocate(width, height, format);
-
- unsigned int srcPitch = pitch ? pitch : GetPitch(width);
- unsigned int srcRows = GetRows(height);
- unsigned int dstPitch = GetPitch(m_textureWidth);
- unsigned int dstRows = GetRows(m_textureHeight);
-
- if (srcPitch == dstPitch)
- memcpy(m_pixels, pixels, srcPitch * std::min(srcRows, dstRows));
- else
- {
- const unsigned char *src = pixels;
- unsigned char* dst = m_pixels;
- for (unsigned int y = 0; y < srcRows && y < dstRows; y++)
- {
- memcpy(dst, src, std::min(srcPitch, dstPitch));
- src += srcPitch;
- dst += dstPitch;
- }
- }
- }
- ClampToEdge();
-
- if (loadToGPU)
- LoadToGPU();
-}
-
-void CBaseTexture::ClampToEdge()
-{
- unsigned int imagePitch = GetPitch(m_imageWidth);
- unsigned int imageRows = GetRows(m_imageHeight);
- unsigned int texturePitch = GetPitch(m_textureWidth);
- unsigned int textureRows = GetRows(m_textureHeight);
- if (imagePitch < texturePitch)
- {
- unsigned int blockSize = GetBlockSize();
- unsigned char *src = m_pixels + imagePitch - blockSize;
- unsigned char *dst = m_pixels;
- for (unsigned int y = 0; y < imageRows; y++)
- {
- for (unsigned int x = imagePitch; x < texturePitch; x += blockSize)
- memcpy(dst + x, src, blockSize);
- dst += texturePitch;
- }
- }
-
- if (imageRows < textureRows)
- {
- unsigned char *dst = m_pixels + imageRows * texturePitch;
- for (unsigned int y = imageRows; y < textureRows; y++)
- {
- memcpy(dst, dst - texturePitch, texturePitch);
- dst += texturePitch;
- }
- }
-}
-
-bool CBaseTexture::LoadFromFile(const CStdString& texturePath, unsigned int maxWidth, unsigned int maxHeight,
- bool autoRotate, unsigned int *originalWidth, unsigned int *originalHeight)
-{
- if (CUtil::GetExtension(texturePath).Equals(".dds"))
- { // special case for DDS images
- CDDSImage image;
- if (image.ReadFile(texturePath))
- {
- Update(image.GetWidth(), image.GetHeight(), 0, image.GetFormat(), image.GetData(), false);
- return true;
- }
- return false;
- }
-
- DllImageLib dll;
- if (!dll.Load())
- return false;
-
- ImageInfo image;
- memset(&image, 0, sizeof(image));
-
- unsigned int width = maxWidth ? std::min(maxWidth, g_Windowing.GetMaxTextureSize()) : g_Windowing.GetMaxTextureSize();
- unsigned int height = maxHeight ? std::min(maxHeight, g_Windowing.GetMaxTextureSize()) : g_Windowing.GetMaxTextureSize();
-
- if(!dll.LoadImage(texturePath.c_str(), width, height, &image))
- {
- CLog::Log(LOGERROR, "Texture manager unable to load file: %s", texturePath.c_str());
- return false;
- }
-
- m_hasAlpha = NULL != image.alpha;
-
- Allocate(image.width, image.height, XB_FMT_A8R8G8B8);
- if (autoRotate && image.exifInfo.Orientation)
- m_orientation = image.exifInfo.Orientation - 1;
- if (originalWidth)
- *originalWidth = image.originalwidth;
- if (originalHeight)
- *originalHeight = image.originalheight;
-
- unsigned int destPitch = GetPitch();
- unsigned int srcPitch = ((image.width + 1)* 3 / 4) * 4; // bitmap row length is aligned to 4 bytes
-
- for (unsigned int y = 0; y < m_imageHeight; y++)
- {
- unsigned char *dst = m_pixels + y * destPitch;
- unsigned char *src = image.texture + (m_imageHeight - 1 - y) * srcPitch;
- unsigned char *alpha = image.alpha + (m_imageHeight - 1 - y) * m_imageWidth;
- for (unsigned int x = 0; x < m_imageWidth; x++)
- {
- *dst++ = *src++;
- *dst++ = *src++;
- *dst++ = *src++;
- *dst++ = (image.alpha) ? *alpha++ : 0xff;
- }
- }
-
- dll.ReleaseImage(&image);
-
- ClampToEdge();
-
- return true;
-}
-
-bool CBaseTexture::LoadFromMemory(unsigned int width, unsigned int height, unsigned int pitch, unsigned int format, unsigned char* pixels)
-{
- m_imageWidth = width;
- m_imageHeight = height;
- m_format = format;
- Update(width, height, pitch, format, pixels, false);
- return true;
-}
-
-bool CBaseTexture::LoadPaletted(unsigned int width, unsigned int height, unsigned int pitch, unsigned int format, const unsigned char *pixels, const COLOR *palette)
-{
- if (pixels == NULL || palette == NULL)
- return false;
-
- Allocate(width, height, format);
-
- for (unsigned int y = 0; y < m_imageHeight; y++)
- {
- unsigned char *dest = m_pixels + y * GetPitch();
- const unsigned char *src = pixels + y * pitch;
- for (unsigned int x = 0; x < m_imageWidth; x++)
- {
- COLOR col = palette[*src++];
- *dest++ = col.b;
- *dest++ = col.g;
- *dest++ = col.r;
- *dest++ = col.x;
- }
- }
- ClampToEdge();
- return true;
-}
-
-unsigned int CBaseTexture::PadPow2(unsigned int x)
-{
- --x;
- x |= x >> 1;
- x |= x >> 2;
- x |= x >> 4;
- x |= x >> 8;
- x |= x >> 16;
- return ++x;
-}
-
-unsigned int CBaseTexture::GetPitch(unsigned int width) const
-{
- switch (m_format)
- {
- case XB_FMT_DXT1:
- return ((width + 3) / 4) * 8;
- case XB_FMT_DXT3:
- case XB_FMT_DXT5:
- case XB_FMT_DXT5_YCoCg:
- return ((width + 3) / 4) * 16;
- case XB_FMT_A8:
- return width;
- case XB_FMT_A8R8G8B8:
- default:
- return width*4;
- }
-}
-
-unsigned int CBaseTexture::GetRows(unsigned int height) const
-{
- switch (m_format)
- {
- case XB_FMT_DXT1:
- return (height + 3) / 4;
- case XB_FMT_DXT3:
- case XB_FMT_DXT5:
- case XB_FMT_DXT5_YCoCg:
- return (height + 3) / 4;
- default:
- return height;
- }
-}
-
-unsigned int CBaseTexture::GetBlockSize() const
-{
- switch (m_format)
- {
- case XB_FMT_DXT1:
- return 8;
- case XB_FMT_DXT3:
- case XB_FMT_DXT5:
- case XB_FMT_DXT5_YCoCg:
- return 16;
- case XB_FMT_A8:
- return 1;
- default:
- return 4;
- }
-}
-
-bool CBaseTexture::HasAlpha() const
-{
- return m_hasAlpha;
-}
diff --git a/guilib/Texture.h b/guilib/Texture.h
deleted file mode 100644
index f54df0e73c..0000000000
--- a/guilib/Texture.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-/*!
-\file Texture.h
-\brief
-*/
-
-#ifndef GUILIB_TEXTURE_H
-#define GUILIB_TEXTURE_H
-
-#include "gui3d.h"
-#include "StdString.h"
-#include "XBTF.h"
-
-#pragma pack(1)
-struct COLOR {unsigned char b,g,r,x;}; // Windows GDI expects 4bytes per color
-#pragma pack()
-
-#ifdef HAS_DX
-#include "D3DResource.h"
-#endif
-
-class CTexture;
-class CGLTexture;
-class CDXTexture;
-
-#pragma once
-
-/*!
-\ingroup textures
-\brief Base texture class, subclasses of which depend on the render spec (DX, GL etc.)
-*/
-class CBaseTexture
-{
-
-public:
- CBaseTexture(unsigned int width = 0, unsigned int height = 0, unsigned int format = XB_FMT_A8R8G8B8);
- virtual ~CBaseTexture();
-
- bool LoadFromFile(const CStdString& texturePath, unsigned int maxHeight = 0, unsigned int maxWidth = 0,
- bool autoRotate = false, unsigned int *originalWidth = NULL, unsigned int *originalHeight = NULL);
- bool LoadFromMemory(unsigned int width, unsigned int height, unsigned int pitch, unsigned int format, unsigned char* pixels);
- bool LoadPaletted(unsigned int width, unsigned int height, unsigned int pitch, unsigned int format, const unsigned char *pixels, const COLOR *palette);
-
- bool HasAlpha() const;
-
- virtual void CreateTextureObject() = 0;
- virtual void DestroyTextureObject() = 0;
- virtual void LoadToGPU() = 0;
-
- XBMC::TexturePtr GetTextureObject() const
- {
-#ifdef HAS_DX
- return m_texture.Get();
-#else
- return m_texture;
-#endif
- }
- unsigned char* GetPixels() const { return m_pixels; }
- unsigned int GetPitch() const { return GetPitch(m_textureWidth); }
- unsigned int GetRows() const { return GetRows(m_textureHeight); }
- unsigned int GetTextureWidth() const { return m_textureWidth; }
- unsigned int GetTextureHeight() const { return m_textureHeight; }
- unsigned int GetWidth() const { return m_imageWidth; }
- unsigned int GetHeight() const { return m_imageHeight; }
- int GetOrientation() const { return m_orientation; }
-
- void Update(unsigned int width, unsigned int height, unsigned int pitch, unsigned int format, const unsigned char *pixels, bool loadToGPU);
- void Allocate(unsigned int width, unsigned int height, unsigned int format);
- void ClampToEdge();
-
- static unsigned int PadPow2(unsigned int x);
-
-protected:
- // helpers for computation of texture parameters for compressed textures
- unsigned int GetPitch(unsigned int width) const;
- unsigned int GetRows(unsigned int height) const;
- unsigned int GetBlockSize() const;
-
- unsigned int m_imageWidth;
- unsigned int m_imageHeight;
- unsigned int m_textureWidth;
- unsigned int m_textureHeight;
-#ifdef HAS_DX
- CD3DTexture m_texture;
-#else
- XBMC::TexturePtr m_texture;
-#endif
- unsigned char* m_pixels;
- bool m_loadedToGPU;
- unsigned int m_format;
- int m_orientation;
- bool m_hasAlpha;
-};
-
-#if defined(HAS_GL) || defined(HAS_GLES)
-#include "TextureGL.h"
-#define CTexture CGLTexture
-#elif defined(HAS_DX)
-#include "TextureDX.h"
-#define CTexture CDXTexture
-#endif
-
-#endif
diff --git a/guilib/TextureBundle.cpp b/guilib/TextureBundle.cpp
deleted file mode 100644
index 006660fea4..0000000000
--- a/guilib/TextureBundle.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2005-2009 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "system.h"
-#include "TextureBundle.h"
-
-CTextureBundle::CTextureBundle(void)
-{
- m_useXPR = false;
- m_useXBT = false;
-}
-
-CTextureBundle::~CTextureBundle(void)
-{
-}
-
-bool CTextureBundle::HasFile(const CStdString& Filename)
-{
- if (m_useXBT)
- {
- return m_tbXBT.HasFile(Filename);
- }
- else if (m_useXPR)
- {
- return m_tbXPR.HasFile(Filename);
- }
- else if (m_tbXBT.HasFile(Filename))
- {
- m_useXBT = true;
- return true;
- }
- else if (m_tbXPR.HasFile(Filename))
- {
- m_useXPR = true;
- return true;
- }
- else
- {
- return false;
- }
-}
-
-void CTextureBundle::GetTexturesFromPath(const CStdString &path, std::vector<CStdString> &textures)
-{
- if (m_useXBT)
- {
- m_tbXBT.GetTexturesFromPath(path, textures);
- }
- else if (m_useXPR)
- {
- m_tbXPR.GetTexturesFromPath(path, textures);
- }
-}
-
-bool CTextureBundle::LoadTexture(const CStdString& Filename, CBaseTexture** ppTexture,
- int &width, int &height)
-{
- if (m_useXBT)
- {
- return m_tbXBT.LoadTexture(Filename, ppTexture, width, height);
- }
- else if (m_useXPR)
- {
- return m_tbXPR.LoadTexture(Filename, ppTexture, width, height);
- }
- else
- {
- return false;
- }
-}
-
-int CTextureBundle::LoadAnim(const CStdString& Filename, CBaseTexture*** ppTextures,
- int &width, int &height, int& nLoops, int** ppDelays)
-{
- if (m_useXBT)
- {
- return m_tbXBT.LoadAnim(Filename, ppTextures, width, height, nLoops, ppDelays);
- }
- else if (m_useXPR)
- {
- return m_tbXPR.LoadAnim(Filename, ppTextures, width, height, nLoops, ppDelays);
- }
- else
- {
- return 0;
- }
-}
-
-void CTextureBundle::Cleanup()
-{
- if (m_useXBT)
- {
- m_tbXBT.Cleanup();
- }
- else if (m_useXPR)
- {
- m_tbXPR.Cleanup();
- }
-
- m_useXPR = m_useXBT = false;
-}
-
-void CTextureBundle::SetThemeBundle(bool themeBundle)
-{
- m_tbXPR.SetThemeBundle(themeBundle);
- m_tbXBT.SetThemeBundle(themeBundle);
-}
-
-CStdString CTextureBundle::Normalize(const CStdString &name)
-{
- return CTextureBundleXBT::Normalize(name);
-}
diff --git a/guilib/TextureBundle.h b/guilib/TextureBundle.h
deleted file mode 100644
index 9867a5688f..0000000000
--- a/guilib/TextureBundle.h
+++ /dev/null
@@ -1,53 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "StdString.h"
-#include "TextureBundleXPR.h"
-#include "TextureBundleXBT.h"
-
-class CTextureBundle
-{
-public:
- CTextureBundle(void);
- ~CTextureBundle(void);
-
- void Cleanup();
-
- void SetThemeBundle(bool themeBundle);
- bool HasFile(const CStdString& Filename);
- void GetTexturesFromPath(const CStdString &path, std::vector<CStdString> &textures);
- static CStdString Normalize(const CStdString &name);
-
- bool LoadTexture(const CStdString& Filename, CBaseTexture** ppTexture, int &width, int &height);
-
- int LoadAnim(const CStdString& Filename, CBaseTexture*** ppTextures, int &width, int &height, int& nLoops, int** ppDelays);
-
-private:
- CTextureBundleXPR m_tbXPR;
- CTextureBundleXBT m_tbXBT;
-
- bool m_useXPR;
- bool m_useXBT;
-};
-
-
diff --git a/guilib/TextureBundleXBT.cpp b/guilib/TextureBundleXBT.cpp
deleted file mode 100644
index a3482a5d85..0000000000
--- a/guilib/TextureBundleXBT.cpp
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Copyright (C) 2005-2009 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "lib/libsquish/squish.h"
-#include "system.h"
-#include "TextureBundleXBT.h"
-#include "Texture.h"
-#include "GraphicContext.h"
-#include "utils/log.h"
-#include "addons/Skin.h"
-#include "GUISettings.h"
-#include "Util.h"
-#include "FileSystem/SpecialProtocol.h"
-#include "utils/EndianSwap.h"
-#include "XBTF.h"
-#include "WindowingFactory.h"
-#ifndef _LINUX
-#include "lib/liblzo/LZO1X.H"
-#else
-#include <lzo/lzo1x.h>
-#endif
-
-#if !defined(__GNUC__)
-#pragma comment(lib,"../../xbmc/lib/liblzo/lzo.lib")
-#endif
-
-CTextureBundleXBT::CTextureBundleXBT(void)
-{
- m_themeBundle = false;
-}
-
-CTextureBundleXBT::~CTextureBundleXBT(void)
-{
- Cleanup();
-}
-
-bool CTextureBundleXBT::OpenBundle()
-{
- Cleanup();
-
- // Find the correct texture file (skin or theme)
- CStdString strPath;
-
- if (m_themeBundle)
- {
- // if we are the theme bundle, we only load if the user has chosen
- // a valid theme (or the skin has a default one)
- CStdString theme = g_guiSettings.GetString("lookandfeel.skintheme");
- if (!theme.IsEmpty() && theme.CompareNoCase("SKINDEFAULT"))
- {
- CStdString themeXBT(CUtil::ReplaceExtension(theme, ".xbt"));
- strPath = CUtil::AddFileToFolder(g_graphicsContext.GetMediaDir(), "media");
- strPath = CUtil::AddFileToFolder(strPath, themeXBT);
- }
- else
- {
- return false;
- }
- }
- else
- {
- strPath = CUtil::AddFileToFolder(g_graphicsContext.GetMediaDir(), "media/Textures.xbt");
- }
-
- strPath = PTH_IC(strPath);
-
- // Load the texture file
- if (!m_XBTFReader.Open(strPath))
- {
- return false;
- }
-
- m_TimeStamp = m_XBTFReader.GetLastModificationTimestamp();
-
- if (lzo_init() != LZO_E_OK)
- {
- return false;
- }
-
- return true;
-}
-
-bool CTextureBundleXBT::HasFile(const CStdString& Filename)
-{
- if (!m_XBTFReader.IsOpen() && !OpenBundle())
- return false;
-
- if (m_XBTFReader.GetLastModificationTimestamp() > m_TimeStamp)
- {
- CLog::Log(LOGINFO, "Texture bundle has changed, reloading");
- if (!OpenBundle())
- return false;
- }
-
- CStdString name = Normalize(Filename);
- return m_XBTFReader.Exists(name);
-}
-
-void CTextureBundleXBT::GetTexturesFromPath(const CStdString &path, std::vector<CStdString> &textures)
-{
- if (path.GetLength() > 1 && path[1] == ':')
- return;
-
- if (!m_XBTFReader.IsOpen() && !OpenBundle())
- return;
-
- CStdString testPath = Normalize(path);
- CUtil::AddSlashAtEnd(testPath);
- int testLength = testPath.GetLength();
-
- std::vector<CXBTFFile>& files = m_XBTFReader.GetFiles();
- for (size_t i = 0; i < files.size(); i++)
- {
- CStdString path = files[i].GetPath();
- if (path.Left(testLength).Equals(testPath))
- textures.push_back(path);
- }
-}
-
-bool CTextureBundleXBT::LoadTexture(const CStdString& Filename, CBaseTexture** ppTexture,
- int &width, int &height)
-{
- CStdString name = Normalize(Filename);
-
- CXBTFFile* file = m_XBTFReader.Find(name);
- if (!file)
- return false;
-
- if (file->GetFrames().size() == 0)
- return false;
-
- CXBTFFrame& frame = file->GetFrames().at(0);
- if (!ConvertFrameToTexture(Filename, frame, ppTexture))
- {
- return false;
- }
-
- width = frame.GetWidth();
- height = frame.GetHeight();
-
- return true;
-}
-
-int CTextureBundleXBT::LoadAnim(const CStdString& Filename, CBaseTexture*** ppTextures,
- int &width, int &height, int& nLoops, int** ppDelays)
-{
- CStdString name = Normalize(Filename);
-
- CXBTFFile* file = m_XBTFReader.Find(name);
- if (!file)
- return false;
-
- if (file->GetFrames().size() == 0)
- return false;
-
- size_t nTextures = file->GetFrames().size();
- *ppTextures = new CBaseTexture*[nTextures];
- *ppDelays = new int[nTextures];
-
- for (size_t i = 0; i < nTextures; i++)
- {
- CXBTFFrame& frame = file->GetFrames().at(i);
-
- if (!ConvertFrameToTexture(Filename, frame, &((*ppTextures)[i])))
- {
- return false;
- }
-
- (*ppDelays)[i] = frame.GetDuration();
- }
-
- width = file->GetFrames().at(0).GetWidth();
- height = file->GetFrames().at(0).GetHeight();
- nLoops = file->GetLoop();
-
- return nTextures;
-}
-
-bool CTextureBundleXBT::ConvertFrameToTexture(const CStdString& name, CXBTFFrame& frame, CBaseTexture** ppTexture)
-{
- // found texture - allocate the necessary buffers
- squish::u8 *buffer = new squish::u8[(size_t)frame.GetPackedSize()];
- if (buffer == NULL)
- {
- CLog::Log(LOGERROR, "Out of memory loading texture: %s (need %"PRIu64" bytes)", name.c_str(), frame.GetPackedSize());
- return false;
- }
-
- // load the compressed texture
- if (!m_XBTFReader.Load(frame, buffer))
- {
- CLog::Log(LOGERROR, "Error loading texture: %s", name.c_str());
- delete[] buffer;
- return false;
- }
-
- // check if it's packed with lzo
- if (frame.IsPacked())
- { // unpack
- squish::u8 *unpacked = new squish::u8[(size_t)frame.GetUnpackedSize()];
- if (unpacked == NULL)
- {
- CLog::Log(LOGERROR, "Out of memory unpacking texture: %s (need %"PRIu64" bytes)", name.c_str(), frame.GetUnpackedSize());
- delete[] buffer;
- return false;
- }
- lzo_uint s = (lzo_uint)frame.GetUnpackedSize();
- if (lzo1x_decompress(buffer, (lzo_uint)frame.GetPackedSize(), unpacked, &s, NULL) != LZO_E_OK ||
- s != frame.GetUnpackedSize())
- {
- CLog::Log(LOGERROR, "Error loading texture: %s: Decompression error", name.c_str());
- delete[] buffer;
- delete[] unpacked;
- return false;
- }
- delete[] buffer;
- buffer = unpacked;
- }
-
- // create an xbmc texture
- *ppTexture = new CTexture();
- (*ppTexture)->LoadFromMemory(frame.GetWidth(), frame.GetHeight(), 0, frame.GetFormat(), buffer);
-
- delete[] buffer;
-
- return true;
-}
-
-void CTextureBundleXBT::Cleanup()
-{
- if (m_XBTFReader.IsOpen())
- {
- m_XBTFReader.Close();
- }
-}
-
-void CTextureBundleXBT::SetThemeBundle(bool themeBundle)
-{
- m_themeBundle = themeBundle;
-}
-
-// normalize to how it's stored within the bundle
-// lower case + using forward slash rather than back slash
-CStdString CTextureBundleXBT::Normalize(const CStdString &name)
-{
- CStdString newName(name);
- newName.Normalize();
- newName.Replace('\\','/');
-
- return newName;
-}
diff --git a/guilib/TextureBundleXBT.h b/guilib/TextureBundleXBT.h
deleted file mode 100644
index a2e44f5489..0000000000
--- a/guilib/TextureBundleXBT.h
+++ /dev/null
@@ -1,58 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "StdString.h"
-#include <map>
-#include "XBTFReader.h"
-
-class CBaseTexture;
-
-class CTextureBundleXBT
-{
-public:
- CTextureBundleXBT(void);
- ~CTextureBundleXBT(void);
-
- void Cleanup();
- void SetThemeBundle(bool themeBundle);
- bool HasFile(const CStdString& Filename);
- void GetTexturesFromPath(const CStdString &path, std::vector<CStdString> &textures);
- static CStdString Normalize(const CStdString &name);
-
- bool LoadTexture(const CStdString& Filename, CBaseTexture** ppTexture,
- int &width, int &height);
-
- int LoadAnim(const CStdString& Filename, CBaseTexture*** ppTextures,
- int &width, int &height, int& nLoops, int** ppDelays);
-
-private:
- bool OpenBundle();
- bool ConvertFrameToTexture(const CStdString& name, CXBTFFrame& frame, CBaseTexture** ppTexture);
-
- time_t m_TimeStamp;
-
- bool m_themeBundle;
- CXBTFReader m_XBTFReader;
-};
-
-
diff --git a/guilib/TextureBundleXPR.cpp b/guilib/TextureBundleXPR.cpp
deleted file mode 100644
index cab3256d8b..0000000000
--- a/guilib/TextureBundleXPR.cpp
+++ /dev/null
@@ -1,507 +0,0 @@
-/*
- * Copyright (C) 2005-2010 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "system.h"
-#include "TextureBundleXPR.h"
-#include "Texture.h"
-#include "GraphicContext.h"
-#include "DirectXGraphics.h"
-#include "utils/log.h"
-#ifndef _LINUX
-#include <sys/stat.h>
-#include "utils/CharsetConverter.h"
-#include "lib/liblzo/LZO1X.H"
-#else
-#include <lzo/lzo1x.h>
-#endif
-#include "addons/Skin.h"
-#include "GUISettings.h"
-#include "Util.h"
-#include "FileSystem/SpecialProtocol.h"
-#include "utils/EndianSwap.h"
-
-#if !defined(__GNUC__)
-#pragma comment(lib,"../../xbmc/lib/liblzo/lzo.lib")
-#endif
-
-// alignment of file blocks - should be a multiple of the sector size of the disk and a power of 2
-// HDD sector = 512 bytes, DVD/CD sector = 2048 bytes
-#undef ALIGN
-#define ALIGN (512)
-
-
-enum XPR_FLAGS
-{
- XPRFLAG_PALETTE = 0x00000001,
- XPRFLAG_ANIM = 0x00000002
-};
-
-class CAutoBuffer
-{
- BYTE* p;
-public:
- CAutoBuffer() { p = 0; }
- explicit CAutoBuffer(size_t s) { p = (BYTE*)malloc(s); }
- ~CAutoBuffer() { free(p); }
-operator BYTE*() { return p; }
- void Set(BYTE* buf) { free(p); p = buf; }
- bool Resize(size_t s);
-void Release() { p = 0; }
-};
-
-bool CAutoBuffer::Resize(size_t s)
-{
- if (s == 0)
- {
- if (!p)
- return false;
- free(p);
- p = 0;
- return true;
- }
- void* q = realloc(p, s);
- if (q)
- {
- p = (BYTE*)q;
- return true;
- }
- return false;
-}
-
-// as above but for texture allocation (do not change from XPhysicalAlloc!)
-class CAutoTexBuffer
-{
- BYTE* p;
-public:
- CAutoTexBuffer() { p = 0; }
- explicit CAutoTexBuffer(size_t s) { p = (BYTE*)XPhysicalAlloc(s, MAXULONG_PTR, 128, PAGE_READWRITE); }
- ~CAutoTexBuffer() { if (p) XPhysicalFree(p); }
-operator BYTE*() { return p; }
- BYTE* Set(BYTE* buf) { if (p) XPhysicalFree(p); return p = buf; }
-void Release() { p = 0; }
-};
-
-CTextureBundleXPR::CTextureBundleXPR(void)
-{
- m_hFile = NULL;
- m_themeBundle = false;
-}
-
-CTextureBundleXPR::~CTextureBundleXPR(void)
-{
- if (m_hFile != NULL)
- fclose(m_hFile);
-}
-
-bool CTextureBundleXPR::OpenBundle()
-{
- DWORD AlignedSize;
- DWORD HeaderSize;
- int Version;
- XPR_HEADER* pXPRHeader;
-
- if (m_hFile != NULL)
- Cleanup();
-
- CStdString strPath;
-
- if (m_themeBundle)
- {
- // if we are the theme bundle, we only load if the user has chosen
- // a valid theme (or the skin has a default one)
- CStdString theme = g_guiSettings.GetString("lookandfeel.skintheme");
- if (!theme.IsEmpty() && theme.CompareNoCase("SKINDEFAULT"))
- {
- CStdString themeXPR(CUtil::ReplaceExtension(theme, ".xpr"));
- strPath = CUtil::AddFileToFolder(g_graphicsContext.GetMediaDir(), "media");
- strPath = CUtil::AddFileToFolder(strPath, themeXPR);
- }
- else
- return false;
- }
- else
- strPath = CUtil::AddFileToFolder(g_graphicsContext.GetMediaDir(), "media/Textures.xpr");
-
- strPath = PTH_IC(strPath);
-
-#ifndef _LINUX
- CStdStringW strPathW;
- g_charsetConverter.utf8ToW(_P(strPath), strPathW, false);
- m_hFile = _wfopen(strPathW.c_str(), L"rb");
-#else
- m_hFile = fopen(strPath.c_str(), "rb");
-#endif
- if (m_hFile == NULL)
- return false;
-
- struct stat fileStat;
- if (fstat(fileno(m_hFile), &fileStat) == -1)
- return false;
- m_TimeStamp = fileStat.st_mtime;
-
- CAutoBuffer HeaderBuf(ALIGN);
- DWORD n;
-
- n = fread(HeaderBuf, 1, ALIGN, m_hFile);
- if (n < ALIGN)
- goto LoadError;
-
- pXPRHeader = (XPR_HEADER*)(BYTE*)HeaderBuf;
- pXPRHeader->dwMagic = Endian_SwapLE32(pXPRHeader->dwMagic);
- Version = (pXPRHeader->dwMagic >> 24) - '0';
- pXPRHeader->dwMagic -= Version << 24;
- Version &= 0x0f;
-
- if (pXPRHeader->dwMagic != XPR_MAGIC_VALUE || Version < 2)
- goto LoadError;
-
- HeaderSize = Endian_SwapLE32(pXPRHeader->dwHeaderSize);
- AlignedSize = (HeaderSize - 1) & ~(ALIGN - 1); // align to sector, but remove the first sector
- HeaderBuf.Resize(AlignedSize + ALIGN);
-
- if (fseek(m_hFile, ALIGN, SEEK_SET) == -1)
- goto LoadError;
- n = fread(HeaderBuf + ALIGN, 1, AlignedSize, m_hFile);
- if (n < ALIGN)
- goto LoadError;
-
- struct DiskFileHeader_t
- {
- char Name[116];
- DWORD Offset;
- DWORD UnpackedSize;
- DWORD PackedSize;
- }
- *FileHeader;
- FileHeader = (DiskFileHeader_t*)(HeaderBuf + sizeof(XPR_HEADER));
-
- n = (HeaderSize - sizeof(XPR_HEADER)) / sizeof(DiskFileHeader_t);
- for (unsigned i = 0; i < n; ++i)
- {
- std::pair<CStdString, FileHeader_t> entry;
- entry.first = Normalize(FileHeader[i].Name);
- entry.second.Offset = Endian_SwapLE32(FileHeader[i].Offset);
- entry.second.UnpackedSize = Endian_SwapLE32(FileHeader[i].UnpackedSize);
- entry.second.PackedSize = Endian_SwapLE32(FileHeader[i].PackedSize);
- m_FileHeaders.insert(entry);
- }
-
- if (lzo_init() != LZO_E_OK)
- goto LoadError;
-
- return true;
-
-LoadError:
- CLog::Log(LOGERROR, "Unable to load file: %s: %s", strPath.c_str(), strerror(errno));
- fclose(m_hFile);
- m_hFile = NULL;
-
- return false;
-}
-
-void CTextureBundleXPR::Cleanup()
-{
- if (m_hFile != NULL)
- fclose(m_hFile);
- m_hFile = NULL;
-
- m_FileHeaders.clear();
-}
-
-bool CTextureBundleXPR::HasFile(const CStdString& Filename)
-{
- if (m_hFile == NULL && !OpenBundle())
- return false;
-
- struct stat fileStat;
- if (fstat(fileno(m_hFile), &fileStat) == -1)
- return false;
- if (fileStat.st_mtime > m_TimeStamp)
- {
- CLog::Log(LOGINFO, "Texture bundle has changed, reloading");
- Cleanup();
- if (!OpenBundle())
- return false;
- }
-
- CStdString name = Normalize(Filename);
- return m_FileHeaders.find(name) != m_FileHeaders.end();
-}
-
-void CTextureBundleXPR::GetTexturesFromPath(const CStdString &path, std::vector<CStdString> &textures)
-{
- if (path.GetLength() > 1 && path[1] == ':')
- return;
-
- if (m_hFile == NULL && !OpenBundle())
- return;
-
- CStdString testPath = Normalize(path);
- if (!CUtil::HasSlashAtEnd(testPath))
- testPath += "\\";
- int testLength = testPath.GetLength();
- std::map<CStdString, FileHeader_t>::iterator it;
- for (it = m_FileHeaders.begin(); it != m_FileHeaders.end(); it++)
- {
- if (it->first.Left(testLength).Equals(testPath))
- textures.push_back(it->first);
- }
-}
-
-bool CTextureBundleXPR::LoadFile(const CStdString& Filename, CAutoTexBuffer& UnpackedBuf)
-{
- CStdString name = Normalize(Filename);
-
- std::map<CStdString, FileHeader_t>::iterator file = m_FileHeaders.find(name);
- if (file == m_FileHeaders.end())
- return false;
-
- // found texture - allocate the necessary buffers
- DWORD ReadSize = (file->second.PackedSize + (ALIGN - 1)) & ~(ALIGN - 1);
- BYTE *buffer = (BYTE*)malloc(ReadSize);
-
- if (!buffer || !UnpackedBuf.Set((BYTE*)XPhysicalAlloc(file->second.UnpackedSize, MAXULONG_PTR, 128, PAGE_READWRITE)))
- { // failed due to lack of memory
-#ifndef _LINUX
- MEMORYSTATUS stat;
- GlobalMemoryStatus(&stat);
- CLog::Log(LOGERROR, "Out of memory loading texture: %s (need %lu bytes, have %lu bytes)", name.c_str(),
- file->second.UnpackedSize + file->second.PackedSize, stat.dwAvailPhys);
-#elif defined(__APPLE__)
- CLog::Log(LOGERROR, "Out of memory loading texture: %s (need %d bytes)", name.c_str(),
- file->second.UnpackedSize + file->second.PackedSize);
-#else
- struct sysinfo info;
- sysinfo(&info);
- CLog::Log(LOGERROR, "Out of memory loading texture: %s "
- "(need %u bytes, have %lu bytes)",
- name.c_str(), file->second.UnpackedSize + file->second.PackedSize,
- info.totalram);
-#endif
- free(buffer);
- return false;
- }
-
- // read the file into our buffer
- DWORD n;
- fseek(m_hFile, file->second.Offset, SEEK_SET);
- n = fread(buffer, 1, ReadSize, m_hFile);
- if (n < ReadSize && !feof(m_hFile))
- {
- CLog::Log(LOGERROR, "Error loading texture: %s: %s", Filename.c_str(), strerror(ferror(m_hFile)));
- free(buffer);
- return false;
- }
-
- // allocate a buffer for our unpacked texture
- lzo_uint s = file->second.UnpackedSize;
- bool success = true;
- if (lzo1x_decompress(buffer, file->second.PackedSize, UnpackedBuf, &s, NULL) != LZO_E_OK ||
- s != file->second.UnpackedSize)
- {
- CLog::Log(LOGERROR, "Error loading texture: %s: Decompression error", Filename.c_str());
- success = false;
- }
-
- try
- {
- free(buffer);
- }
- catch (...)
- {
- CLog::Log(LOGERROR, "Error freeing preload buffer.");
- }
-
- return success;
-}
-
-bool CTextureBundleXPR::LoadTexture(const CStdString& Filename, CBaseTexture** ppTexture,
- int &width, int &height)
-{
- DWORD ResDataOffset;
- *ppTexture = NULL;
-
- CAutoTexBuffer UnpackedBuf;
- if (!LoadFile(Filename, UnpackedBuf))
- return false;
-
- D3DTexture *pTex = (D3DTexture *)(new char[sizeof (D3DTexture)]);
- D3DPalette* pPal = 0;
- void* ResData = 0;
-
- WORD RealSize[2];
-
- enum XPR_FLAGS
- {
- XPRFLAG_PALETTE = 0x00000001,
- XPRFLAG_ANIM = 0x00000002
- };
-
- BYTE* Next = UnpackedBuf;
-
- DWORD flags = Endian_SwapLE32(*(DWORD*)Next);
- Next += sizeof(DWORD);
- if ((flags & XPRFLAG_ANIM) || (flags >> 16) > 1)
- goto PackedLoadError;
-
- if (flags & XPRFLAG_PALETTE)
- Next += sizeof(D3DPalette);
-
- memcpy(pTex, Next, sizeof(D3DTexture));
- pTex->Common = Endian_SwapLE32(pTex->Common);
- pTex->Data = Endian_SwapLE32(pTex->Data);
- pTex->Lock = Endian_SwapLE32(pTex->Lock);
- pTex->Format = Endian_SwapLE32(pTex->Format);
- pTex->Size = Endian_SwapLE32(pTex->Size);
- Next += sizeof(D3DTexture);
-
- memcpy(RealSize, Next, 4);
- Next += 4;
-
- ResDataOffset = ((Next - UnpackedBuf) + 127) & ~127;
- ResData = UnpackedBuf + ResDataOffset;
-
- if ((pTex->Common & D3DCOMMON_TYPE_MASK) != D3DCOMMON_TYPE_TEXTURE)
- goto PackedLoadError;
-
- GetTextureFromData(pTex, ResData, ppTexture);
- delete[] pTex;
-
- width = Endian_SwapLE16(RealSize[0]);
- height = Endian_SwapLE16(RealSize[1]);
-/* DXMERGE - this was previously used to specify the format of the image - probably only affects directx?
-#ifndef HAS_SDL
- D3DSURFACE_DESC desc;
- (*ppTexture)->GetLevelDesc(0, &desc);
- pInfo->Format = desc.Format;
-#endif
-*/
- return true;
-
-PackedLoadError:
- CLog::Log(LOGERROR, "Error loading texture: %s: Invalid data", Filename.c_str());
- delete[] pTex;
- delete pPal;
- return false;
-}
-
-int CTextureBundleXPR::LoadAnim(const CStdString& Filename, CBaseTexture*** ppTextures,
- int &width, int &height, int& nLoops, int** ppDelays)
-{
- DWORD ResDataOffset;
- int nTextures = 0;
-
- *ppTextures = NULL; *ppDelays = NULL;
-
- CAutoTexBuffer UnpackedBuf;
- if (!LoadFile(Filename, UnpackedBuf))
- return 0;
-
- struct AnimInfo_t
- {
- DWORD nLoops;
- WORD RealSize[2];
- }
- *pAnimInfo;
-
- D3DTexture** ppTex = 0;
- void* ResData = 0;
-
- BYTE* Next = UnpackedBuf;
-
- DWORD flags = Endian_SwapLE32(*(DWORD*)Next);
- Next += sizeof(DWORD);
- if (!(flags & XPRFLAG_ANIM))
- goto PackedAnimError;
-
- pAnimInfo = (AnimInfo_t*)Next;
- Next += sizeof(AnimInfo_t);
- nLoops = Endian_SwapLE32(pAnimInfo->nLoops);
-
- if (flags & XPRFLAG_PALETTE)
- Next += sizeof(D3DPalette);
-
- nTextures = flags >> 16;
- ppTex = new D3DTexture * [nTextures];
- *ppDelays = new int[nTextures];
- for (int i = 0; i < nTextures; ++i)
- {
- ppTex[i] = (D3DTexture *)(new char[sizeof (D3DTexture)+ sizeof (DWORD)]);
-
- memcpy(ppTex[i], Next, sizeof(D3DTexture));
- ppTex[i]->Common = Endian_SwapLE32(ppTex[i]->Common);
- ppTex[i]->Data = Endian_SwapLE32(ppTex[i]->Data);
- ppTex[i]->Lock = Endian_SwapLE32(ppTex[i]->Lock);
- ppTex[i]->Format = Endian_SwapLE32(ppTex[i]->Format);
- ppTex[i]->Size = Endian_SwapLE32(ppTex[i]->Size);
- Next += sizeof(D3DTexture);
-
- (*ppDelays)[i] = Endian_SwapLE32(*(int*)Next);
- Next += sizeof(int);
- }
-
- ResDataOffset = ((DWORD)(Next - UnpackedBuf) + 127) & ~127;
- ResData = UnpackedBuf + ResDataOffset;
-
- *ppTextures = new CBaseTexture*[nTextures];
- for (int i = 0; i < nTextures; ++i)
- {
- if ((ppTex[i]->Common & D3DCOMMON_TYPE_MASK) != D3DCOMMON_TYPE_TEXTURE)
- goto PackedAnimError;
-
- GetTextureFromData(ppTex[i], ResData, &(*ppTextures)[i]);
- delete[] ppTex[i];
- }
-
- delete[] ppTex;
- ppTex = 0;
-
- width = Endian_SwapLE16(pAnimInfo->RealSize[0]);
- height = Endian_SwapLE16(pAnimInfo->RealSize[1]);
-
- return nTextures;
-
-PackedAnimError:
- CLog::Log(LOGERROR, "Error loading texture: %s: Invalid data", Filename.c_str());
- if (ppTex)
- {
- for (int i = 0; i < nTextures; ++i)
- delete [] ppTex[i];
- delete [] ppTex;
- }
- delete [] *ppDelays;
- return 0;
-}
-
-void CTextureBundleXPR::SetThemeBundle(bool themeBundle)
-{
- m_themeBundle = themeBundle;
-}
-
-// normalize to how it's stored within the bundle
-// lower case + using \\ rather than /
-CStdString CTextureBundleXPR::Normalize(const CStdString &name)
-{
- CStdString newName(name);
- newName.Normalize();
- newName.Replace('/','\\');
- return newName;
-}
diff --git a/guilib/TextureBundleXPR.h b/guilib/TextureBundleXPR.h
deleted file mode 100644
index b68ac7c3b6..0000000000
--- a/guilib/TextureBundleXPR.h
+++ /dev/null
@@ -1,69 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "StdString.h"
-#include <stdint.h>
-#include <map>
-
-class CAutoTexBuffer;
-class CBaseTexture;
-
-class CTextureBundleXPR
-{
- struct FileHeader_t
- {
- uint32_t Offset;
- uint32_t UnpackedSize;
- uint32_t PackedSize;
- };
-
- FILE* m_hFile;
- time_t m_TimeStamp;
-
- std::map<CStdString, FileHeader_t> m_FileHeaders;
- typedef std::map<CStdString, FileHeader_t>::iterator iFiles;
-
- bool m_themeBundle;
-
- bool OpenBundle();
- bool LoadFile(const CStdString& Filename, CAutoTexBuffer& UnpackedBuf);
-
-public:
- CTextureBundleXPR(void);
- ~CTextureBundleXPR(void);
-
- void Cleanup();
-
- void SetThemeBundle(bool themeBundle);
- bool HasFile(const CStdString& Filename);
- void GetTexturesFromPath(const CStdString &path, std::vector<CStdString> &textures);
- static CStdString Normalize(const CStdString &name);
-
- bool LoadTexture(const CStdString& Filename, CBaseTexture** ppTexture,
- int &width, int &height);
-
- int LoadAnim(const CStdString& Filename, CBaseTexture*** ppTextures,
- int &width, int &height, int& nLoops, int** ppDelays);
-};
-
-
diff --git a/guilib/TextureDX.cpp b/guilib/TextureDX.cpp
deleted file mode 100644
index 23719dc2a0..0000000000
--- a/guilib/TextureDX.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
-* Copyright (C) 2005-2008 Team XBMC
-* http://www.xbmc.org
-*
-* This Program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, 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 General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with XBMC; see the file COPYING. If not, write to
-* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-* http://www.gnu.org/copyleft/gpl.html
-*
-*/
-
-#include "TextureDX.h"
-#include "WindowingFactory.h"
-#include "utils/log.h"
-
-#ifdef HAS_DX
-
-/************************************************************************/
-/* CDXTexture */
-/************************************************************************/
-CDXTexture::CDXTexture(unsigned int width, unsigned int height, unsigned int format)
-: CBaseTexture(width, height, format)
-{
-}
-
-CDXTexture::~CDXTexture()
-{
- DestroyTextureObject();
-}
-
-void CDXTexture::CreateTextureObject()
-{
- D3DFORMAT format = D3DFMT_UNKNOWN;
-
- switch (m_format)
- {
- case XB_FMT_DXT1:
- format = D3DFMT_DXT1;
- break;
- case XB_FMT_DXT3:
- format = D3DFMT_DXT3;
- break;
- case XB_FMT_DXT5:
- case XB_FMT_DXT5_YCoCg:
- format = D3DFMT_DXT5;
- break;
- case XB_FMT_A8R8G8B8:
- format = D3DFMT_A8R8G8B8;
- break;
- case XB_FMT_A8:
- format = D3DFMT_A8;
- break;
- default:
- return;
- }
-
- m_texture.Create(m_textureWidth, m_textureHeight, 1, g_Windowing.DefaultD3DUsage(), format, g_Windowing.DefaultD3DPool());
-}
-
-void CDXTexture::DestroyTextureObject()
-{
- m_texture.Release();
-}
-
-void CDXTexture::LoadToGPU()
-{
- if (!m_pixels)
- {
- // nothing to load - probably same image (no change)
- return;
- }
-
- if (m_texture.Get() == NULL)
- {
- CreateTextureObject();
- if (m_texture.Get() == NULL)
- {
- CLog::Log(LOGDEBUG, "CDXTexture::CDXTexture: Error creating new texture for size %d x %d", m_textureWidth, m_textureHeight);
- return;
- }
- }
-
- D3DLOCKED_RECT lr;
- if (m_texture.LockRect( 0, &lr, NULL, D3DLOCK_DISCARD ))
- {
- unsigned char *dst = (unsigned char *)lr.pBits;
- unsigned char *src = m_pixels;
- unsigned int dstPitch = lr.Pitch;
- unsigned int srcPitch = GetPitch();
- unsigned int minPitch = std::min(srcPitch, dstPitch);
-
- unsigned int rows = GetRows();
- if (srcPitch == dstPitch)
- {
- memcpy(dst, src, srcPitch * rows);
- }
- else
- {
- for (unsigned int y = 0; y < rows; y++)
- {
- memcpy(dst, src, minPitch);
- src += srcPitch;
- dst += dstPitch;
- }
- }
- }
- else
- {
- CLog::Log(LOGERROR, __FUNCTION__" - failed to lock texture");
- }
- m_texture.UnlockRect(0);
-
- delete [] m_pixels;
- m_pixels = NULL;
-
- m_loadedToGPU = true;
-}
-
-#endif
diff --git a/guilib/TextureDX.h b/guilib/TextureDX.h
deleted file mode 100644
index 6dabeaac35..0000000000
--- a/guilib/TextureDX.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
-* Copyright (C) 2005-2008 Team XBMC
-* http://www.xbmc.org
-*
-* This Program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, 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 General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with XBMC; see the file COPYING. If not, write to
-* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-* http://www.gnu.org/copyleft/gpl.html
-*
-*/
-
-/*!
-\file TextureDX.h
-\brief
-*/
-
-#ifndef GUILIB_TEXTUREDX_H
-#define GUILIB_TEXTUREDX_H
-
-#include "Texture.h"
-
-#pragma once
-
-#ifdef HAS_DX
-
-/************************************************************************/
-/* CDXTexture */
-/************************************************************************/
-class CDXTexture : public CBaseTexture
-{
-public:
- CDXTexture(unsigned int width = 0, unsigned int height = 0, unsigned int format = XB_FMT_UNKNOWN);
- virtual ~CDXTexture();
-
- void CreateTextureObject();
- void DestroyTextureObject();
- virtual void LoadToGPU();
-};
-
-#endif
-
-#endif
diff --git a/guilib/TextureGL.cpp b/guilib/TextureGL.cpp
deleted file mode 100644
index 040fb39177..0000000000
--- a/guilib/TextureGL.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
-* Copyright (C) 2005-2008 Team XBMC
-* http://www.xbmc.org
-*
-* This Program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, 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 General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with XBMC; see the file COPYING. If not, write to
-* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-* http://www.gnu.org/copyleft/gpl.html
-*
-*/
-
-#include "system.h"
-#include "TextureGL.h"
-#include "WindowingFactory.h"
-#include "utils/log.h"
-
-#if defined(HAS_GL) || defined(HAS_GLES)
-
-using namespace std;
-
-/************************************************************************/
-/* CGLTexture */
-/************************************************************************/
-CGLTexture::CGLTexture(unsigned int width, unsigned int height, unsigned int format)
-: CBaseTexture(width, height, format)
-{
-}
-
-CGLTexture::~CGLTexture()
-{
- DestroyTextureObject();
-}
-
-void CGLTexture::CreateTextureObject()
-{
- glGenTextures(1, (GLuint*) &m_texture);
-}
-
-void CGLTexture::DestroyTextureObject()
-{
- if (m_texture)
- glDeleteTextures(1, (GLuint*) &m_texture);
-}
-
-void CGLTexture::LoadToGPU()
-{
- if (!m_pixels)
- {
- // nothing to load - probably same image (no change)
- return;
- }
-
- if (m_texture == 0)
- {
- // Have OpenGL generate a texture object handle for us
- // this happens only one time - the first time the texture is loaded
- CreateTextureObject();
- }
-
- // Bind the texture object
- glBindTexture(GL_TEXTURE_2D, m_texture);
-
- // Set the texture's stretching properties
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
- unsigned int maxSize = g_Windowing.GetMaxTextureSize();
- if (m_textureHeight > maxSize)
- {
- CLog::Log(LOGERROR, "GL: Image height %d too big to fit into single texture unit, truncating to %u", m_textureHeight, maxSize);
- m_textureHeight = maxSize;
- }
- if (m_textureWidth > maxSize)
- {
- CLog::Log(LOGERROR, "GL: Image width %d too big to fit into single texture unit, truncating to %u", m_textureWidth, maxSize);
-#ifndef HAS_GLES
- glPixelStorei(GL_UNPACK_ROW_LENGTH, m_textureWidth);
- m_textureWidth = maxSize;
- }
-
- GLenum format;
-
- switch (m_format)
- {
- case XB_FMT_DXT1:
- format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
- break;
- case XB_FMT_DXT3:
- format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
- break;
- case XB_FMT_DXT5:
- case XB_FMT_DXT5_YCoCg:
- format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
- break;
- case XB_FMT_A8R8G8B8:
- default:
- format = GL_BGRA;
- break;
- }
-
- if ((m_format & XB_FMT_DXT_MASK) == 0)
- {
- glTexImage2D(GL_TEXTURE_2D, 0, 4, m_textureWidth, m_textureHeight, 0,
- format, GL_UNSIGNED_BYTE, m_pixels);
- }
- else
- {
- // changed from glCompressedTexImage2D to support GL < 1.3
- glCompressedTexImage2DARB(GL_TEXTURE_2D, 0, format,
- m_textureWidth, m_textureHeight, 0, GetPitch() * GetRows(), m_pixels);
- }
-
- glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
-#else // GLES version
- m_textureWidth = maxSize;
- }
-
-#if HAS_GLES == 1
- glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, m_textureWidth, m_textureHeight, 0,
- GL_BGRA_EXT, GL_UNSIGNED_BYTE, m_pixels);
-#elif HAS_GLES == 2
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_textureWidth, m_textureHeight, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, m_pixels);
-#endif
-
-#endif
- VerifyGLState();
-
- delete [] m_pixels;
- m_pixels = NULL;
-
- m_loadedToGPU = true;
-}
-#endif // HAS_GL
diff --git a/guilib/TextureGL.h b/guilib/TextureGL.h
deleted file mode 100644
index e208c725f3..0000000000
--- a/guilib/TextureGL.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
-* Copyright (C) 2005-2008 Team XBMC
-* http://www.xbmc.org
-*
-* This Program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, 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 General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with XBMC; see the file COPYING. If not, write to
-* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-* http://www.gnu.org/copyleft/gpl.html
-*
-*/
-
-/*!
-\file TextureManager.h
-\brief
-*/
-
-#ifndef GUILIB_TEXTUREGL_H
-#define GUILIB_TEXTUREGL_H
-
-#include "Texture.h"
-
-#pragma once
-
-#if defined(HAS_GL) || defined(HAS_GLES)
-
-/************************************************************************/
-/* CGLTexture */
-/************************************************************************/
-class CGLTexture : public CBaseTexture
-{
-public:
- CGLTexture(unsigned int width = 0, unsigned int height = 0, unsigned int format = XB_FMT_A8R8G8B8);
- virtual ~CGLTexture();
-
- void CreateTextureObject();
- virtual void DestroyTextureObject();
- void LoadToGPU();
-};
-
-#endif
-
-#endif
diff --git a/guilib/TextureManager.cpp b/guilib/TextureManager.cpp
deleted file mode 100644
index 5830a8446b..0000000000
--- a/guilib/TextureManager.cpp
+++ /dev/null
@@ -1,581 +0,0 @@
-/*
-* Copyright (C) 2005-2008 Team XBMC
-* http://www.xbmc.org
-*
-* This Program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, 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 General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with XBMC; see the file COPYING. If not, write to
-* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-* http://www.gnu.org/copyleft/gpl.html
-*
-*/
-
-#include "TextureManager.h"
-#include "Texture.h"
-#include "AnimatedGif.h"
-#include "GraphicContext.h"
-#include "utils/SingleLock.h"
-#include "utils/CharsetConverter.h"
-#include "utils/log.h"
-#include "utils/log.h"
-#include "addons/Skin.h"
-#ifdef _DEBUG
-#include "utils/TimeUtils.h"
-#endif
-#include "../xbmc/Util.h"
-#include "../xbmc/FileSystem/File.h"
-#include "../xbmc/FileSystem/Directory.h"
-#include <assert.h>
-
-using namespace std;
-
-
-/************************************************************************/
-/* */
-/************************************************************************/
-CTextureArray::CTextureArray(int width, int height, int loops, bool texCoordsArePixels)
-{
- m_width = width;
- m_height = height;
- m_loops = loops;
- m_orientation = 0;
- m_texWidth = 0;
- m_texHeight = 0;
- m_texCoordsArePixels = false;
-}
-
-CTextureArray::CTextureArray()
-{
- Reset();
-}
-
-CTextureArray::~CTextureArray()
-{
-
-}
-
-unsigned int CTextureArray::size() const
-{
- return m_textures.size();
-}
-
-
-void CTextureArray::Reset()
-{
- m_textures.clear();
- m_delays.clear();
- m_width = 0;
- m_height = 0;
- m_loops = 0;
- m_orientation = 0;
- m_texWidth = 0;
- m_texHeight = 0;
- m_texCoordsArePixels = false;
-}
-
-void CTextureArray::Add(CBaseTexture *texture, int delay)
-{
- if (!texture)
- return;
-
- m_textures.push_back(texture);
- m_delays.push_back(delay ? delay * 2 : 100);
-
- m_texWidth = texture->GetTextureWidth();
- m_texHeight = texture->GetTextureHeight();
- m_texCoordsArePixels = false;
-}
-
-void CTextureArray::Set(CBaseTexture *texture, int width, int height)
-{
- assert(!m_textures.size()); // don't try and set a texture if we already have one!
- m_width = width;
- m_height = height;
- m_orientation = texture ? texture->GetOrientation() : 0;
- Add(texture, 100);
-}
-
-void CTextureArray::Free()
-{
- CSingleLock lock(g_graphicsContext);
- for (unsigned int i = 0; i < m_textures.size(); i++)
- {
- delete m_textures[i];
- }
-
- m_textures.clear();
- m_delays.clear();
-
- Reset();
-}
-
-
-/************************************************************************/
-/* */
-/************************************************************************/
-
-CTextureMap::CTextureMap()
-{
- m_textureName = "";
- m_referenceCount = 0;
- m_memUsage = 0;
-}
-
-CTextureMap::CTextureMap(const CStdString& textureName, int width, int height, int loops)
-: m_texture(width, height, loops)
-{
- m_textureName = textureName;
- m_referenceCount = 0;
- m_memUsage = 0;
-}
-
-CTextureMap::~CTextureMap()
-{
- FreeTexture();
-}
-
-bool CTextureMap::Release()
-{
- if (!m_texture.m_textures.size())
- return true;
- if (!m_referenceCount)
- return true;
-
- m_referenceCount--;
- if (!m_referenceCount)
- {
- return true;
- }
- return false;
-}
-
-const CStdString& CTextureMap::GetName() const
-{
- return m_textureName;
-}
-
-const CTextureArray& CTextureMap::GetTexture()
-{
- m_referenceCount++;
- return m_texture;
-}
-
-void CTextureMap::Dump() const
-{
- if (!m_referenceCount)
- return; // nothing to see here
-
- CStdString strLog;
- strLog.Format(" texture:%s has %i frames %i refcount\n", m_textureName.c_str(), m_texture.m_textures.size(), m_referenceCount);
- OutputDebugString(strLog.c_str());
-}
-
-unsigned int CTextureMap::GetMemoryUsage() const
-{
- return m_memUsage;
-}
-
-void CTextureMap::Flush()
-{
- if (!m_referenceCount)
- FreeTexture();
-}
-
-
-void CTextureMap::FreeTexture()
-{
- m_texture.Free();
-}
-
-bool CTextureMap::IsEmpty() const
-{
- return m_texture.m_textures.size() == 0;
-}
-
-void CTextureMap::Add(CBaseTexture* texture, int delay)
-{
- m_texture.Add(texture, delay);
-
- if (texture)
- m_memUsage += sizeof(CTexture) + (texture->GetTextureWidth() * texture->GetTextureHeight() * 4);
-}
-
-/************************************************************************/
-/* */
-/************************************************************************/
-CGUITextureManager::CGUITextureManager(void)
-{
- // we set the theme bundle to be the first bundle (thus prioritizing it)
- m_TexBundle[0].SetThemeBundle(true);
-}
-
-CGUITextureManager::~CGUITextureManager(void)
-{
- Cleanup();
-}
-
-const CTextureArray& CGUITextureManager::GetTexture(const CStdString& strTextureName)
-{
- static CTextureArray emptyTexture;
- // CLog::Log(LOGINFO, " refcount++ for GetTexture(%s)\n", strTextureName.c_str());
- for (int i = 0; i < (int)m_vecTextures.size(); ++i)
- {
- CTextureMap *pMap = m_vecTextures[i];
- if (pMap->GetName() == strTextureName)
- {
- //CLog::Log(LOGDEBUG, "Total memusage %u", GetMemoryUsage());
- return pMap->GetTexture();
- }
- }
- return emptyTexture;
-}
-
-/************************************************************************/
-/* */
-/************************************************************************/
-bool CGUITextureManager::CanLoad(const CStdString &texturePath) const
-{
- if (texturePath == "-")
- return false;
-
- if (!CURL::IsFullPath(texturePath))
- return true; // assume we have it
-
- // we can't (or shouldn't) be loading from remote paths, so check these
- return CUtil::IsHD(texturePath);
-}
-
-bool CGUITextureManager::HasTexture(const CStdString &textureName, CStdString *path, int *bundle, int *size)
-{
- // default values
- if (bundle) *bundle = -1;
- if (size) *size = 0;
- if (path) *path = textureName;
-
- if (!CanLoad(textureName))
- return false;
-
- // Check our loaded and bundled textures - we store in bundles using \\.
- CStdString bundledName = CTextureBundle::Normalize(textureName);
- for (int i = 0; i < (int)m_vecTextures.size(); ++i)
- {
- CTextureMap *pMap = m_vecTextures[i];
- if (pMap->GetName() == textureName)
- {
- if (size) *size = 1;
- return true;
- }
- }
-
- for (int i = 0; i < 2; i++)
- {
- if (m_TexBundle[i].HasFile(bundledName))
- {
- if (bundle) *bundle = i;
- return true;
- }
- }
-
- CStdString fullPath = GetTexturePath(textureName);
- if (path)
- *path = fullPath;
-
- return !fullPath.IsEmpty();
-}
-
-int CGUITextureManager::Load(const CStdString& strTextureName, bool checkBundleOnly /*= false */)
-{
- CStdString strPath;
- int bundle = -1;
- int size = 0;
- if (!HasTexture(strTextureName, &strPath, &bundle, &size))
- return 0;
-
- if (size) // we found the texture
- return size;
-
- if (checkBundleOnly && bundle == -1)
- return 0;
-
- //Lock here, we will do stuff that could break rendering
- CSingleLock lock(g_graphicsContext);
-
-#ifdef _DEBUG
- int64_t start;
- start = CurrentHostCounter();
-#endif
-
- if (strPath.Right(4).ToLower() == ".gif")
- {
- CTextureMap* pMap;
-
- if (bundle >= 0)
- {
- CBaseTexture **pTextures;
- int nLoops = 0, width = 0, height = 0;
- int* Delay;
- int nImages = m_TexBundle[bundle].LoadAnim(strTextureName, &pTextures, width, height, nLoops, &Delay);
- if (!nImages)
- {
- CLog::Log(LOGERROR, "Texture manager unable to load bundled file: %s", strTextureName.c_str());
- return 0;
- }
-
- pMap = new CTextureMap(strTextureName, width, height, nLoops);
- for (int iImage = 0; iImage < nImages; ++iImage)
- {
- pMap->Add(pTextures[iImage], Delay[iImage]);
- }
-
- delete [] pTextures;
- delete [] Delay;
- }
- else
- {
- CAnimatedGifSet AnimatedGifSet;
- int iImages = AnimatedGifSet.LoadGIF(strPath.c_str());
- if (iImages == 0)
- {
- CStdString rootPath = strPath.Left(g_SkinInfo->Path().GetLength());
- if (0 == rootPath.CompareNoCase(g_SkinInfo->Path()))
- CLog::Log(LOGERROR, "Texture manager unable to load file: %s", strPath.c_str());
- return 0;
- }
- int iWidth = AnimatedGifSet.FrameWidth;
- int iHeight = AnimatedGifSet.FrameHeight;
-
- // fixup our palette
- COLOR *palette = AnimatedGifSet.m_vecimg[0]->Palette;
- // set the alpha values to fully opaque
- for (int i = 0; i < 256; i++)
- palette[i].x = 0xff;
- // and set the transparent colour
- if (AnimatedGifSet.m_vecimg[0]->Transparency && AnimatedGifSet.m_vecimg[0]->Transparent >= 0)
- palette[AnimatedGifSet.m_vecimg[0]->Transparent].x = 0;
-
- pMap = new CTextureMap(strTextureName, iWidth, iHeight, AnimatedGifSet.nLoops);
-
- for (int iImage = 0; iImage < iImages; iImage++)
- {
- CTexture *glTexture = new CTexture();
- if (glTexture)
- {
- CAnimatedGif* pImage = AnimatedGifSet.m_vecimg[iImage];
- glTexture->LoadPaletted(pImage->Width, pImage->Height, pImage->BytesPerRow, XB_FMT_A8R8G8B8, (unsigned char *)pImage->Raster, palette);
- pMap->Add(glTexture, pImage->Delay);
- }
- } // of for (int iImage=0; iImage < iImages; iImage++)
- }
-
-#ifdef _DEBUG
- int64_t end, freq;
- end = CurrentHostCounter();
- freq = CurrentHostFrequency();
- char temp[200];
- sprintf(temp, "Load %s: %.1fms%s\n", strPath.c_str(), 1000.f * (end - start) / freq, (bundle >= 0) ? " (bundled)" : "");
- OutputDebugString(temp);
-#endif
-
- m_vecTextures.push_back(pMap);
- return 1;
- } // of if (strPath.Right(4).ToLower()==".gif")
-
- CBaseTexture *pTexture = NULL;
- int width = 0, height = 0;
- if (bundle >= 0)
- {
- if (FAILED(m_TexBundle[bundle].LoadTexture(strTextureName, &pTexture, width, height)))
- {
- CLog::Log(LOGERROR, "Texture manager unable to load bundled file: %s", strTextureName.c_str());
- return 0;
- }
- }
- else
- {
- pTexture = new CTexture();
- if(!pTexture->LoadFromFile(strPath))
- return 0;
- width = pTexture->GetWidth();
- height = pTexture->GetHeight();
- }
-
- if (!pTexture) return 0;
-
- CTextureMap* pMap = new CTextureMap(strTextureName, width, height, 0);
- pMap->Add(pTexture, 100);
- m_vecTextures.push_back(pMap);
-
-#ifdef _DEBUG_TEXTURES
- int64_t end, freq;
- end = CurrentHostCounter();
- freq = CurrentHostFrequency();
- char temp[200];
- sprintf(temp, "Load %s: %.1fms%s\n", strPath.c_str(), 1000.f * (end - start) / freq, (bundle >= 0) ? " (bundled)" : "");
- OutputDebugString(temp);
-#endif
-
- return 1;
-}
-
-
-void CGUITextureManager::ReleaseTexture(const CStdString& strTextureName)
-{
- CSingleLock lock(g_graphicsContext);
-
- ivecTextures i;
- i = m_vecTextures.begin();
- while (i != m_vecTextures.end())
- {
- CTextureMap* pMap = *i;
- if (pMap->GetName() == strTextureName)
- {
- if (pMap->Release())
- {
- //CLog::Log(LOGINFO, " cleanup:%s", strTextureName.c_str());
- // add to our textures to free
- m_unusedTextures.push_back(pMap);
- i = m_vecTextures.erase(i);
- }
- return;
- }
- ++i;
- }
- CLog::Log(LOGWARNING, "%s: Unable to release texture %s", __FUNCTION__, strTextureName.c_str());
-}
-
-void CGUITextureManager::FreeUnusedTextures()
-{
- CSingleLock lock(g_graphicsContext);
- for (ivecTextures i = m_unusedTextures.begin(); i != m_unusedTextures.end(); ++i)
- delete *i;
- m_unusedTextures.clear();
-}
-
-void CGUITextureManager::Cleanup()
-{
- CSingleLock lock(g_graphicsContext);
-
- ivecTextures i;
- i = m_vecTextures.begin();
- while (i != m_vecTextures.end())
- {
- CTextureMap* pMap = *i;
- CLog::Log(LOGWARNING, "%s: Having to cleanup texture %s", __FUNCTION__, pMap->GetName().c_str());
- delete pMap;
- i = m_vecTextures.erase(i);
- }
- for (int i = 0; i < 2; i++)
- m_TexBundle[i].Cleanup();
- FreeUnusedTextures();
-}
-
-void CGUITextureManager::Dump() const
-{
- CStdString strLog;
- strLog.Format("total texturemaps size:%i\n", m_vecTextures.size());
- OutputDebugString(strLog.c_str());
-
- for (int i = 0; i < (int)m_vecTextures.size(); ++i)
- {
- const CTextureMap* pMap = m_vecTextures[i];
- if (!pMap->IsEmpty())
- pMap->Dump();
- }
-}
-
-void CGUITextureManager::Flush()
-{
- CSingleLock lock(g_graphicsContext);
-
- ivecTextures i;
- i = m_vecTextures.begin();
- while (i != m_vecTextures.end())
- {
- CTextureMap* pMap = *i;
- pMap->Flush();
- if (pMap->IsEmpty() )
- {
- delete pMap;
- i = m_vecTextures.erase(i);
- }
- else
- {
- ++i;
- }
- }
-}
-
-unsigned int CGUITextureManager::GetMemoryUsage() const
-{
- unsigned int memUsage = 0;
- for (int i = 0; i < (int)m_vecTextures.size(); ++i)
- {
- memUsage += m_vecTextures[i]->GetMemoryUsage();
- }
- return memUsage;
-}
-
-void CGUITextureManager::SetTexturePath(const CStdString &texturePath)
-{
- m_texturePaths.clear();
- AddTexturePath(texturePath);
-}
-
-void CGUITextureManager::AddTexturePath(const CStdString &texturePath)
-{
- if (!texturePath.IsEmpty())
- m_texturePaths.push_back(texturePath);
-}
-
-void CGUITextureManager::RemoveTexturePath(const CStdString &texturePath)
-{
- for (vector<CStdString>::iterator it = m_texturePaths.begin(); it != m_texturePaths.end(); ++it)
- {
- if (*it == texturePath)
- {
- m_texturePaths.erase(it);
- return;
- }
- }
-}
-
-CStdString CGUITextureManager::GetTexturePath(const CStdString &textureName, bool directory /* = false */)
-{
- if (CURL::IsFullPath(textureName))
- return textureName;
- else
- { // texture doesn't include the full path, so check all fallbacks
- for (vector<CStdString>::iterator it = m_texturePaths.begin(); it != m_texturePaths.end(); ++it)
- {
- CStdString path = CUtil::AddFileToFolder(it->c_str(), "media");
- path = CUtil::AddFileToFolder(path, textureName);
- if (directory)
- {
- if (XFILE::CDirectory::Exists(path))
- return path;
- }
- else
- {
- if (XFILE::CFile::Exists(path))
- return path;
- }
- }
- }
- return "";
-}
-
-void CGUITextureManager::GetBundledTexturesFromPath(const CStdString& texturePath, std::vector<CStdString> &items)
-{
- m_TexBundle[0].GetTexturesFromPath(texturePath, items);
- if (items.empty())
- m_TexBundle[1].GetTexturesFromPath(texturePath, items);
-}
diff --git a/guilib/TextureManager.h b/guilib/TextureManager.h
deleted file mode 100644
index c9dac5d146..0000000000
--- a/guilib/TextureManager.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-/*!
-\file TextureManager.h
-\brief
-*/
-
-#ifndef GUILIB_TEXTUREMANAGER_H
-#define GUILIB_TEXTUREMANAGER_H
-
-#include <vector>
-#include "TextureBundle.h"
-
-#pragma once
-
-/************************************************************************/
-/* */
-/************************************************************************/
-class CTextureArray
-{
-public:
- CTextureArray(int width, int height, int loops, bool texCoordsArePixels = false);
- CTextureArray();
-
- virtual ~CTextureArray();
-
- void Reset();
-
- void Add(CBaseTexture *texture, int delay);
- void Set(CBaseTexture *texture, int width, int height);
- void Free();
- unsigned int size() const;
-
- std::vector<CBaseTexture* > m_textures;
- std::vector<int> m_delays;
- int m_width;
- int m_height;
- int m_orientation;
- int m_loops;
- int m_texWidth;
- int m_texHeight;
- bool m_texCoordsArePixels;
-};
-
-/*!
- \ingroup textures
- \brief
- */
-/************************************************************************/
-/* */
-/************************************************************************/
-class CTextureMap
-{
-public:
- CTextureMap();
- CTextureMap(const CStdString& textureName, int width, int height, int loops);
- virtual ~CTextureMap();
-
- void Add(CBaseTexture* texture, int delay);
- bool Release();
-
- const CStdString& GetName() const;
- const CTextureArray& GetTexture();
- void Dump() const;
- uint32_t GetMemoryUsage() const;
- void Flush();
- bool IsEmpty() const;
-protected:
- void FreeTexture();
-
- CStdString m_textureName;
- CTextureArray m_texture;
- unsigned int m_referenceCount;
- uint32_t m_memUsage;
-};
-
-/*!
- \ingroup textures
- \brief
- */
-/************************************************************************/
-/* */
-/************************************************************************/
-class CGUITextureManager
-{
-public:
- CGUITextureManager(void);
- virtual ~CGUITextureManager(void);
-
- bool HasTexture(const CStdString &textureName, CStdString *path = NULL, int *bundle = NULL, int *size = NULL);
- bool CanLoad(const CStdString &texturePath) const; ///< Returns true if the texture manager can load this texture
- int Load(const CStdString& strTextureName, bool checkBundleOnly = false);
- const CTextureArray& GetTexture(const CStdString& strTextureName);
- void ReleaseTexture(const CStdString& strTextureName);
- void Cleanup();
- void Dump() const;
- uint32_t GetMemoryUsage() const;
- void Flush();
- CStdString GetTexturePath(const CStdString& textureName, bool directory = false);
- void GetBundledTexturesFromPath(const CStdString& texturePath, std::vector<CStdString> &items);
-
- void AddTexturePath(const CStdString &texturePath); ///< Add a new path to the paths to check when loading media
- void SetTexturePath(const CStdString &texturePath); ///< Set a single path as the path to check when loading media (clear then add)
- void RemoveTexturePath(const CStdString &texturePath); ///< Remove a path from the paths to check when loading media
-
- void FreeUnusedTextures(); ///< Free textures (called from app thread only)
-protected:
- std::vector<CTextureMap*> m_vecTextures;
- std::vector<CTextureMap*> m_unusedTextures;
- typedef std::vector<CTextureMap*>::iterator ivecTextures;
- // we have 2 texture bundles (one for the base textures, one for the theme)
- CTextureBundle m_TexBundle[2];
-
- std::vector<CStdString> m_texturePaths;
-};
-
-/*!
- \ingroup textures
- \brief
- */
-extern CGUITextureManager g_TextureManager;
-#endif
diff --git a/guilib/TransformMatrix.h b/guilib/TransformMatrix.h
deleted file mode 100644
index cc9c19bae6..0000000000
--- a/guilib/TransformMatrix.h
+++ /dev/null
@@ -1,240 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include <math.h>
-#include <memory>
-#include <string.h>
-#include <stdint.h>
-
-#ifdef __GNUC__
-// under gcc, inline will only take place if optimizations are applied (-O). this will force inline even whith optimizations.
-#define XBMC_FORCE_INLINE __attribute__((always_inline))
-#else
-#define XBMC_FORCE_INLINE
-#endif
-
-typedef uint32_t color_t;
-
-class TransformMatrix
-{
-public:
- TransformMatrix()
- {
- Reset();
- };
- void Reset()
- {
- m[0][0] = 1.0f; m[0][1] = m[0][2] = m[0][3] = 0.0f;
- m[1][0] = m[1][2] = m[1][3] = 0.0f; m[1][1] = 1.0f;
- m[2][0] = m[2][1] = m[2][3] = 0.0f; m[2][2] = 1.0f;
- alpha = 1.0f;
- };
- static TransformMatrix CreateTranslation(float transX, float transY, float transZ = 0)
- {
- TransformMatrix translation;
- translation.m[0][3] = transX;
- translation.m[1][3] = transY;
- translation.m[2][3] = transZ;
- return translation;
- }
- void SetTranslation(float transX, float transY, float transZ)
- {
- m[0][1] = m[0][2] = 0.0f; m[0][0] = 1.0f; m[0][3] = transX;
- m[1][0] = m[1][2] = 0.0f; m[1][1] = 1.0f; m[1][3] = transY;
- m[2][0] = m[2][1] = 0.0f; m[2][2] = 1.0f; m[2][3] = transZ;
- alpha = 1.0f;
- }
- static TransformMatrix CreateScaler(float scaleX, float scaleY, float scaleZ = 1.0f)
- {
- TransformMatrix scaler;
- scaler.m[0][0] = scaleX;
- scaler.m[1][1] = scaleY;
- scaler.m[2][2] = scaleZ;
- return scaler;
- };
- void SetScaler(float scaleX, float scaleY, float centerX, float centerY)
- {
- // Trans(centerX,centerY,centerZ)*Scale(scaleX,scaleY,scaleZ)*Trans(-centerX,-centerY,-centerZ)
- float centerZ = 0.0f, scaleZ = 1.0f;
- m[0][0] = scaleX; m[0][1] = 0.0f; m[0][2] = 0.0f; m[0][3] = centerX*(1-scaleX);
- m[1][0] = 0.0f; m[1][1] = scaleY; m[1][2] = 0.0f; m[1][3] = centerY*(1-scaleY);
- m[2][0] = 0.0f; m[2][1] = 0.0f; m[2][2] = scaleZ; m[2][3] = centerZ*(1-scaleZ);
- alpha = 1.0f;
- };
- void SetXRotation(float angle, float y, float z, float ar = 1.0f)
- { // angle about the X axis, centered at y,z where our coordinate system has aspect ratio ar.
- // Trans(0,y,z)*Scale(1,1/ar,1)*RotateX(angle)*Scale(ar,1,1)*Trans(0,-y,-z);
- float c = cos(angle); float s = sin(angle);
- m[0][0] = ar; m[0][1] = 0.0f; m[0][2] = 0.0f; m[0][3] = 0.0f;
- m[1][0] = 0.0f; m[1][1] = c/ar; m[1][2] = -s/ar; m[1][3] = (-y*c+s*z)/ar + y;
- m[2][0] = 0.0f; m[2][1] = s; m[2][2] = c; m[2][3] = (-y*s-c*z) + z;
- angle = 1.0f;
- }
- void SetYRotation(float angle, float x, float z, float ar = 1.0f)
- { // angle about the Y axis, centered at x,z where our coordinate system has aspect ratio ar.
- // Trans(x,0,z)*Scale(1/ar,1,1)*RotateY(angle)*Scale(ar,1,1)*Trans(-x,0,-z);
- float c = cos(angle); float s = sin(angle);
- m[0][0] = c; m[0][1] = 0.0f; m[0][2] = -s/ar; m[0][3] = -x*c + s*z/ar + x;
- m[1][0] = 0.0f; m[1][1] = 1.0f; m[1][2] = 0.0f; m[1][3] = 0.0f;
- m[2][0] = ar*s; m[2][1] = 0.0f; m[2][2] = c; m[2][3] = -ar*x*s - c*z + z;
- angle = 1.0f;
- }
- static TransformMatrix CreateZRotation(float angle, float x, float y, float ar = 1.0f)
- { // angle about the Z axis, centered at x,y where our coordinate system has aspect ratio ar.
- // Trans(x,y,0)*Scale(1/ar,1,1)*RotateZ(angle)*Scale(ar,1,1)*Trans(-x,-y,0)
- float c = cos(angle); float s = sin(angle);
- TransformMatrix rot;
- rot.m[0][0] = c; rot.m[0][1] = -s/ar; rot.m[0][3] = -x*c + s*y/ar + x;
- rot.m[1][0] = s*ar; rot.m[1][1] = c; rot.m[1][3] = -ar*x*s - c*y + y;
- return rot;
- }
- void SetZRotation(float angle, float x, float y, float ar = 1.0f)
- { // angle about the Z axis, centered at x,y where our coordinate system has aspect ratio ar.
- // Trans(x,y,0)*Scale(1/ar,1,1)*RotateZ(angle)*Scale(ar,1,1)*Trans(-x,-y,0)
- float c = cos(angle); float s = sin(angle);
- m[0][0] = c; m[0][1] = -s/ar; m[0][2] = 0.0f; m[0][3] = -x*c + s*y/ar + x;
- m[1][0] = s*ar; m[1][1] = c; m[1][2] = 0.0f; m[1][3] = -ar*x*s - c*y + y;
- m[2][0] = 0.0f; m[2][1] = 0.0f; m[2][2] = 1.0f; m[2][3] = 0.0f;
- angle = 1.0f;
- }
- static TransformMatrix CreateFader(float a)
- {
- TransformMatrix fader;
- fader.alpha = a;
- return fader;
- }
- void SetFader(float a)
- {
- m[0][0] = 1.0f; m[0][1] = 0.0f; m[0][2] = 0.0f; m[0][3] = 0.0f;
- m[1][0] = 0.0f; m[1][1] = 1.0f; m[1][2] = 0.0f; m[1][3] = 0.0f;
- m[2][0] = 0.0f; m[2][1] = 0.0f; m[2][2] = 1.0f; m[2][3] = 0.0f;
- alpha = a;
- }
- // assignment operator
- const TransformMatrix &operator =(const TransformMatrix &right)
- {
- if (this != &right)
- {
- memcpy(m, right.m, 12*sizeof(float));
- alpha = right.alpha;
- }
- return *this;
- }
-
- // multiplication operators
- const TransformMatrix &operator *=(const TransformMatrix &right)
- {
- float t00 = m[0][0] * right.m[0][0] + m[0][1] * right.m[1][0] + m[0][2] * right.m[2][0];
- float t01 = m[0][0] * right.m[0][1] + m[0][1] * right.m[1][1] + m[0][2] * right.m[2][1];
- float t02 = m[0][0] * right.m[0][2] + m[0][1] * right.m[1][2] + m[0][2] * right.m[2][2];
- m[0][3] = m[0][0] * right.m[0][3] + m[0][1] * right.m[1][3] + m[0][2] * right.m[2][3] + m[0][3];
- m[0][0] = t00; m[0][1] = t01; m[0][2] = t02;
- t00 = m[1][0] * right.m[0][0] + m[1][1] * right.m[1][0] + m[1][2] * right.m[2][0];
- t01 = m[1][0] * right.m[0][1] + m[1][1] * right.m[1][1] + m[1][2] * right.m[2][1];
- t02 = m[1][0] * right.m[0][2] + m[1][1] * right.m[1][2] + m[1][2] * right.m[2][2];
- m[1][3] = m[1][0] * right.m[0][3] + m[1][1] * right.m[1][3] + m[1][2] * right.m[2][3] + m[1][3];
- m[1][0] = t00; m[1][1] = t01; m[1][2] = t02;
- t00 = m[2][0] * right.m[0][0] + m[2][1] * right.m[1][0] + m[2][2] * right.m[2][0];
- t01 = m[2][0] * right.m[0][1] + m[2][1] * right.m[1][1] + m[2][2] * right.m[2][1];
- t02 = m[2][0] * right.m[0][2] + m[2][1] * right.m[1][2] + m[2][2] * right.m[2][2];
- m[2][3] = m[2][0] * right.m[0][3] + m[2][1] * right.m[1][3] + m[2][2] * right.m[2][3] + m[2][3];
- m[2][0] = t00; m[2][1] = t01; m[2][2] = t02;
- alpha *= right.alpha;
- return *this;
- }
-
- TransformMatrix operator *(const TransformMatrix &right) const
- {
- TransformMatrix result;
- result.m[0][0] = m[0][0] * right.m[0][0] + m[0][1] * right.m[1][0] + m[0][2] * right.m[2][0];
- result.m[0][1] = m[0][0] * right.m[0][1] + m[0][1] * right.m[1][1] + m[0][2] * right.m[2][1];
- result.m[0][2] = m[0][0] * right.m[0][2] + m[0][1] * right.m[1][2] + m[0][2] * right.m[2][2];
- result.m[0][3] = m[0][0] * right.m[0][3] + m[0][1] * right.m[1][3] + m[0][2] * right.m[2][3] + m[0][3];
- result.m[1][0] = m[1][0] * right.m[0][0] + m[1][1] * right.m[1][0] + m[1][2] * right.m[2][0];
- result.m[1][1] = m[1][0] * right.m[0][1] + m[1][1] * right.m[1][1] + m[1][2] * right.m[2][1];
- result.m[1][2] = m[1][0] * right.m[0][2] + m[1][1] * right.m[1][2] + m[1][2] * right.m[2][2];
- result.m[1][3] = m[1][0] * right.m[0][3] + m[1][1] * right.m[1][3] + m[1][2] * right.m[2][3] + m[1][3];
- result.m[2][0] = m[2][0] * right.m[0][0] + m[2][1] * right.m[1][0] + m[2][2] * right.m[2][0];
- result.m[2][1] = m[2][0] * right.m[0][1] + m[2][1] * right.m[1][1] + m[2][2] * right.m[2][1];
- result.m[2][2] = m[2][0] * right.m[0][2] + m[2][1] * right.m[1][2] + m[2][2] * right.m[2][2];
- result.m[2][3] = m[2][0] * right.m[0][3] + m[2][1] * right.m[1][3] + m[2][2] * right.m[2][3] + m[2][3];
- result.alpha = alpha * right.alpha;
- return result;
- }
-
- inline void TransformPosition(float &x, float &y, float &z) const XBMC_FORCE_INLINE
- {
- float newX = m[0][0] * x + m[0][1] * y + m[0][2] * z + m[0][3];
- float newY = m[1][0] * x + m[1][1] * y + m[1][2] * z + m[1][3];
- z = m[2][0] * x + m[2][1] * y + m[2][2] * z + m[2][3];
- y = newY;
- x = newX;
- }
-
- inline void TransformPositionUnscaled(float &x, float &y, float &z) const XBMC_FORCE_INLINE
- {
- float n;
- // calculate the norm of the transformed (but not translated) vectors involved
- n = sqrt(m[0][0]*m[0][0] + m[0][1]*m[0][1] + m[0][2]*m[0][2]);
- float newX = (m[0][0] * x + m[0][1] * y + m[0][2] * z)/n + m[0][3];
- n = sqrt(m[1][0]*m[1][0] + m[1][1]*m[1][1] + m[1][2]*m[1][2]);
- float newY = (m[1][0] * x + m[1][1] * y + m[1][2] * z)/n + m[1][3];
- n = sqrt(m[2][0]*m[2][0] + m[2][1]*m[2][1] + m[2][2]*m[2][2]);
- float newZ = (m[2][0] * x + m[2][1] * y + m[2][2] * z)/n + m[2][3];
- z = newZ;
- y = newY;
- x = newX;
- }
-
- inline void InverseTransformPosition(float &x, float &y) const XBMC_FORCE_INLINE
- { // used for mouse - no way to find z
- x -= m[0][3]; y -= m[1][3];
- float detM = m[0][0]*m[1][1] - m[0][1]*m[1][0];
- float newX = (m[1][1] * x - m[0][1] * y)/detM;
- y = (-m[1][0] * x + m[0][0] * y)/detM;
- x = newX;
- }
-
- inline float TransformXCoord(float x, float y, float z) const XBMC_FORCE_INLINE
- {
- return m[0][0] * x + m[0][1] * y + m[0][2] * z + m[0][3];
- }
-
- inline float TransformYCoord(float x, float y, float z) const XBMC_FORCE_INLINE
- {
- return m[1][0] * x + m[1][1] * y + m[1][2] * z + m[1][3];
- }
-
- inline float TransformZCoord(float x, float y, float z) const XBMC_FORCE_INLINE
- {
- return m[2][0] * x + m[2][1] * y + m[2][2] * z + m[2][3];
- }
-
- inline color_t TransformAlpha(color_t colour) const XBMC_FORCE_INLINE
- {
- return (color_t)(colour * alpha);
- }
-
- float m[3][4];
- float alpha;
-};
diff --git a/guilib/Tween.h b/guilib/Tween.h
deleted file mode 100644
index 9df3bdcbb7..0000000000
--- a/guilib/Tween.h
+++ /dev/null
@@ -1,408 +0,0 @@
-#ifndef __TWEEN_H__
-#define __TWEEN_H__
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-///////////////////////////////////////////////////////////////////////
-// Tween.h
-// A couple of tweening classes implemented in C++.
-// ref: http://www.robertpenner.com/easing/
-//
-// Author: d4rk <d4rk@xbmc.org>
-///////////////////////////////////////////////////////////////////////
-
-
-///////////////////////////////////////////////////////////////////////
-// Current list of classes:
-//
-// LinearTweener
-// QuadTweener
-// CubicTweener
-// SineTweener
-// CircleTweener
-// BackTweener
-// BounceTweener
-// ElasticTweener
-//
-///////////////////////////////////////////////////////////////////////
-
-#include <math.h>
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846f
-#endif
-
-enum TweenerType
-{
- EASE_IN,
- EASE_OUT,
- EASE_INOUT
-};
-
-
-class Tweener
-{
-public:
- Tweener(TweenerType tweenerType = EASE_OUT) { m_tweenerType = tweenerType; _ref=1; }
- virtual ~Tweener() {};
-
- void SetEasing(TweenerType type) { m_tweenerType = type; }
- virtual float Tween(float time, float start, float change, float duration)=0;
- void Free() { _ref--; if (_ref==0) delete this; }
- void IncRef() { _ref++; }
-
-protected:
- int _ref;
- TweenerType m_tweenerType;
-};
-
-
-class LinearTweener : public Tweener
-{
-public:
- virtual float Tween(float time, float start, float change, float duration)
- {
- return change * time / duration + start;
- }
-};
-
-
-class QuadTweener : public Tweener
-{
-public:
- QuadTweener(float a = 1.0f) { _a=a; }
- virtual float Tween(float time, float start, float change, float duration)
- {
- switch (m_tweenerType)
- {
- case EASE_IN:
- time /= duration;
- return change * time * (_a * time + 1 - _a) + start;
- break;
-
- case EASE_OUT:
- time /= duration;
- return -change * time * (_a * time - 1 - _a) + start;
- break;
-
- case EASE_INOUT:
- time /= duration/2;
- if (time < 1)
- return (change) * time * (_a * time + 1 - _a) + start;
- time--;
- return (-change) * time * (_a * time - 1 - _a) + start;
- break;
- }
- return change * time * time + start;
- }
-private:
- float _a;
-};
-
-
-class CubicTweener : public Tweener
-{
-public:
- virtual float Tween(float time, float start, float change, float duration)
- {
- switch (m_tweenerType)
- {
- case EASE_IN:
- time /= duration;
- return change * time * time * time + start;
- break;
-
- case EASE_OUT:
- time /= duration;
- time--;
- return change * (time * time * time + 1) + start;
- break;
-
- case EASE_INOUT:
- time /= duration/2;
- if (time < 1)
- return (change/2) * time * time * time + start;
- time-=2;
- return (change/2) * (time * time * time + 2) + start;
- break;
- }
- return change * time * time + start;
- }
-};
-
-class CircleTweener : public Tweener
-{
-public:
- virtual float Tween(float time, float start, float change, float duration)
- {
- switch (m_tweenerType)
- {
- case EASE_IN:
- time /= duration;
- return (-change) * (sqrt(1 - time * time) - 1) + start;
- break;
-
- case EASE_OUT:
- time /= duration;
- time--;
- return change * sqrt(1 - time * time) + start;
- break;
-
- case EASE_INOUT:
- time /= duration/2;
- if (time < 1)
- return (-change/2) * (sqrt(1 - time * time) - 1) + start;
- time-=2;
- return change/2 * (sqrt(1 - time * time) + 1) + start;
- break;
- }
- return change * sqrt(1 - time * time) + start;
- }
-};
-
-class BackTweener : public Tweener
-{
-public:
- BackTweener(float s=1.70158) { _s=s; }
-
- virtual float Tween(float time, float start, float change, float duration)
- {
- float s = _s;
- switch (m_tweenerType)
- {
- case EASE_IN:
- time /= duration;
- return change * time * time * ((s + 1) * time - s) + start;
- break;
-
- case EASE_OUT:
- time /= duration;
- time--;
- return change * (time * time * ((s + 1) * time + s) + 1) + start;
- break;
-
- case EASE_INOUT:
- time /= duration/2;
- s*=(1.525f);
- if ((time ) < 1)
- {
- return (change/2) * (time * time * ((s + 1) * time - s)) + start;
- }
- time-=2;
- return (change/2) * (time * time * ((s + 1) * time + s) + 2) + start;
- break;
- }
- return change * ((time-1) * time * ((s + 1) * time + s) + 1) + start;
- }
-
-private:
- float _s;
-
-};
-
-
-class SineTweener : public Tweener
-{
-public:
- virtual float Tween(float time, float start, float change, float duration)
- {
- time /= duration;
- switch (m_tweenerType)
- {
- case EASE_IN:
- return change * (1 - cos(time * M_PI / 2.0f)) + start;
- break;
-
- case EASE_OUT:
- return change * sin(time * M_PI / 2.0f) + start;
- break;
-
- case EASE_INOUT:
- return change/2 * (1 - cos(M_PI * time)) + start;
- break;
- }
- return (change/2) * (1 - cos(M_PI * time)) + start;
- }
-};
-
-
-class BounceTweener : public Tweener
-{
-public:
- virtual float Tween(float time, float start, float change, float duration)
- {
- switch (m_tweenerType)
- {
- case EASE_IN:
- return (change - easeOut(duration - time, 0, change, duration)) + start;
- break;
-
- case EASE_OUT:
- return easeOut(time, start, change, duration);
- break;
-
- case EASE_INOUT:
- if (time < duration/2)
- return (change - easeOut (duration - (time * 2), 0, change, duration) + start) * .5f + start;
- else
- return (easeOut (time * 2 - duration, 0, change, duration) * .5f + change * .5f) + start;
- break;
- }
-
- return easeOut(time, start, change, duration);
- }
-
-protected:
- float easeOut(float time, float start, float change, float duration)
- {
- time /= duration;
- if (time < (1/2.75)) {
- return change * (7.5625f * time * time) + start;
- } else if (time < (2/2.75)) {
- time -= (1.5f/2.75f);
- return change * (7.5625f * time * time + .75f) + start;
- } else if (time < (2.5/2.75)) {
- time -= (2.25f/2.75f);
- return change * (7.5625f * time * time + .9375f) + start;
- } else {
- time -= (2.625f/2.75f);
- return change * (7.5625f * time * time + .984375f) + start;
- }
- }
-};
-
-
-class ElasticTweener : public Tweener
-{
-public:
- ElasticTweener(float a=0.0, float p=0.0) { _a=a; _p=p; }
-
- virtual float Tween(float time, float start, float change, float duration)
- {
- switch (m_tweenerType)
- {
- case EASE_IN:
- return easeIn(time, start, change, duration);
- break;
-
- case EASE_OUT:
- return easeOut(time, start, change, duration);
- break;
-
- case EASE_INOUT:
- return easeInOut(time, start, change, duration);
- break;
- }
- return easeOut(time, start, change, duration);
- }
-
-protected:
- float _a;
- float _p;
-
- float easeIn(float time, float start, float change, float duration)
- {
- float s=0;
- float a=_a;
- float p=_p;
-
- if (time==0)
- return start;
- time /= duration;
- if (time==1)
- return start + change;
- if (!p)
- p=duration*.3f;
- if (!a || a < fabs(change))
- {
- a = change;
- s = p / 4.0f;
- }
- else
- {
- s = p / (2 * M_PI) * asin (change / a);
- }
- time--;
- return -(a * pow(2.0f, 10*time) * sin((time * duration - s) * (2 * M_PI) / p )) + start;
- }
-
- float easeOut(float time, float start, float change, float duration)
- {
- float s=0;
- float a=_a;
- float p=_p;
-
- if (time==0)
- return start;
- time /= duration;
- if (time==1)
- return start + change;
- if (!p)
- p=duration*.3f;
- if (!a || a < fabs(change))
- {
- a = change;
- s = p / 4.0f;
- }
- else
- {
- s = p / (2 * M_PI) * asin (change / a);
- }
- return (a * pow(2.0f, -10*time) * sin((time * duration - s) * (2 * M_PI) / p )) + change + start;
- }
-
- float easeInOut(float time, float start, float change, float duration)
- {
- float s=0;
- float a=_a;
- float p=_p;
-
- if (time==0)
- return start;
- time /= duration/2;
- if (time==2)
- return start + change;
- if (!p)
- p=duration*.3f*1.5f;
- if (!a || a < fabs(change))
- {
- a = change;
- s = p / 4.0f;
- }
- else
- {
- s = p / (2 * M_PI) * asin (change / a);
- }
-
- if (time < 1)
- {
- time--;
- return -.5f * (a * pow(2.0f, 10 * (time)) * sin((time * duration - s) * (2 * M_PI) / p )) + start;
- }
- time--;
- return a * pow(2.0f, -10 * (time)) * sin((time * duration-s) * (2 * M_PI) / p ) * .5f + change + start;
- }
-};
-
-
-
-#endif // __TWEEN_H__
diff --git a/guilib/VisibleEffect.cpp b/guilib/VisibleEffect.cpp
deleted file mode 100644
index 75e8d22364..0000000000
--- a/guilib/VisibleEffect.cpp
+++ /dev/null
@@ -1,702 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "VisibleEffect.h"
-#include "utils/GUIInfoManager.h"
-#include "utils/log.h"
-#include "addons/Skin.h" // for the effect time adjustments
-#include "StringUtils.h"
-#include "Tween.h"
-#include "tinyXML/tinyxml.h"
-
-using namespace std;
-
-CAnimEffect::CAnimEffect(const TiXmlElement *node, EFFECT_TYPE effect)
-{
- m_effect = effect;
- // defaults
- m_delay = m_length = 0;
- m_pTweener = NULL;
- // time and delay
-
- float temp;
- if (TIXML_SUCCESS == node->QueryFloatAttribute("time", &temp)) m_length = (unsigned int)(temp * g_SkinInfo->GetEffectsSlowdown());
- if (TIXML_SUCCESS == node->QueryFloatAttribute("delay", &temp)) m_delay = (unsigned int)(temp * g_SkinInfo->GetEffectsSlowdown());
-
- const char *tween = node->Attribute("tween");
- if (tween)
- {
- if (strcmpi(tween, "linear")==0)
- m_pTweener = new LinearTweener();
- else if (strcmpi(tween, "quadratic")==0)
- m_pTweener = new QuadTweener();
- else if (strcmpi(tween, "cubic")==0)
- m_pTweener = new CubicTweener();
- else if (strcmpi(tween, "sine")==0)
- m_pTweener = new SineTweener();
- else if (strcmpi(tween, "back")==0)
- m_pTweener = new BackTweener();
- else if (strcmpi(tween, "circle")==0)
- m_pTweener = new CircleTweener();
- else if (strcmpi(tween, "bounce")==0)
- m_pTweener = new BounceTweener();
- else if (strcmpi(tween, "elastic")==0)
- m_pTweener = new ElasticTweener();
-
- const char *easing = node->Attribute("easing");
- if (m_pTweener && easing)
- {
- if (strcmpi(easing, "in")==0)
- m_pTweener->SetEasing(EASE_IN);
- else if (strcmpi(easing, "out")==0)
- m_pTweener->SetEasing(EASE_OUT);
- else if (strcmpi(easing, "inout")==0)
- m_pTweener->SetEasing(EASE_INOUT);
- }
- }
-
- float accel = 0;
- node->QueryFloatAttribute("acceleration", &accel);
-
- if (!m_pTweener)
- { // no tweener is specified - use a linear tweener
- // or quadratic if we have acceleration
- if (accel)
- {
- m_pTweener = new QuadTweener(accel);
- m_pTweener->SetEasing(EASE_IN);
- }
- else
- m_pTweener = new LinearTweener();
- }
-}
-
-CAnimEffect::CAnimEffect(unsigned int delay, unsigned int length, EFFECT_TYPE effect)
-{
- m_delay = delay;
- m_length = length;
- m_effect = effect;
- m_pTweener = new LinearTweener();
-}
-
-CAnimEffect::~CAnimEffect()
-{
- if (m_pTweener)
- m_pTweener->Free();
-}
-
-CAnimEffect::CAnimEffect(const CAnimEffect &src)
-{
- m_pTweener = NULL;
- *this = src;
-}
-
-const CAnimEffect &CAnimEffect::operator=(const CAnimEffect &src)
-{
- if (&src == this) return *this;
-
- m_matrix = src.m_matrix;
- m_effect = src.m_effect;
- m_length = src.m_length;
- m_delay = src.m_delay;
-
- if (m_pTweener)
- m_pTweener->Free();
- m_pTweener = src.m_pTweener;
- if (m_pTweener)
- m_pTweener->IncRef();
- return *this;
-}
-
-void CAnimEffect::Calculate(unsigned int time, const CPoint &center)
-{
- assert(m_delay + m_length);
- // calculate offset and tweening
- float offset = 0.0f; // delayed forward, or finished reverse
- if (time >= m_delay && time < m_delay + m_length)
- offset = (float)(time - m_delay) / m_length;
- else if (time >= m_delay + m_length)
- offset = 1.0f;
- if (m_pTweener)
- offset = m_pTweener->Tween(offset, 0.0f, 1.0f, 1.0f);
- // and apply the effect
- ApplyEffect(offset, center);
-}
-
-void CAnimEffect::ApplyState(ANIMATION_STATE state, const CPoint &center)
-{
- float offset = (state == ANIM_STATE_APPLIED) ? 1.0f : 0.0f;
- ApplyEffect(offset, center);
-}
-
-CFadeEffect::CFadeEffect(const TiXmlElement *node, bool reverseDefaults) : CAnimEffect(node, EFFECT_TYPE_FADE)
-{
- if (reverseDefaults)
- { // out effect defaults
- m_startAlpha = 100.0f;
- m_endAlpha = 0;
- }
- else
- { // in effect defaults
- m_startAlpha = 0;
- m_endAlpha = 100.0f;
- }
- node->QueryFloatAttribute("start", &m_startAlpha);
- node->QueryFloatAttribute("end", &m_endAlpha);
- if (m_startAlpha > 100.0f) m_startAlpha = 100.0f;
- if (m_endAlpha > 100.0f) m_endAlpha = 100.0f;
- if (m_startAlpha < 0) m_startAlpha = 0;
- if (m_endAlpha < 0) m_endAlpha = 0;
-}
-
-CFadeEffect::CFadeEffect(float start, float end, unsigned int delay, unsigned int length) : CAnimEffect(delay, length, EFFECT_TYPE_FADE)
-{
- m_startAlpha = start;
- m_endAlpha = end;
-}
-
-void CFadeEffect::ApplyEffect(float offset, const CPoint &center)
-{
- m_matrix.SetFader(((m_endAlpha - m_startAlpha) * offset + m_startAlpha) * 0.01f);
-}
-
-CSlideEffect::CSlideEffect(const TiXmlElement *node) : CAnimEffect(node, EFFECT_TYPE_SLIDE)
-{
- m_startX = m_endX = 0;
- m_startY = m_endY = 0;
- const char *startPos = node->Attribute("start");
- if (startPos)
- {
- vector<CStdString> commaSeparated;
- StringUtils::SplitString(startPos, ",", commaSeparated);
- if (commaSeparated.size() > 1)
- m_startY = (float)atof(commaSeparated[1].c_str());
- m_startX = (float)atof(commaSeparated[0].c_str());
- }
- const char *endPos = node->Attribute("end");
- if (endPos)
- {
- vector<CStdString> commaSeparated;
- StringUtils::SplitString(endPos, ",", commaSeparated);
- if (commaSeparated.size() > 1)
- m_endY = (float)atof(commaSeparated[1].c_str());
- m_endX = (float)atof(commaSeparated[0].c_str());
- }
-}
-
-void CSlideEffect::ApplyEffect(float offset, const CPoint &center)
-{
- m_matrix.SetTranslation((m_endX - m_startX)*offset + m_startX, (m_endY - m_startY)*offset + m_startY, 0);
-}
-
-CRotateEffect::CRotateEffect(const TiXmlElement *node, EFFECT_TYPE effect) : CAnimEffect(node, effect)
-{
- m_startAngle = m_endAngle = 0;
- m_autoCenter = false;
- node->QueryFloatAttribute("start", &m_startAngle);
- node->QueryFloatAttribute("end", &m_endAngle);
-
- // convert to a negative to account for our reversed Y axis (Needed for X and Z ???)
- m_startAngle *= -1;
- m_endAngle *= -1;
-
- const char *centerPos = node->Attribute("center");
- if (centerPos)
- {
- if (strcmpi(centerPos, "auto") == 0)
- m_autoCenter = true;
- else
- {
- vector<CStdString> commaSeparated;
- StringUtils::SplitString(centerPos, ",", commaSeparated);
- if (commaSeparated.size() > 1)
- m_center.y = (float)atof(commaSeparated[1].c_str());
- m_center.x = (float)atof(commaSeparated[0].c_str());
- }
- }
-}
-
-void CRotateEffect::ApplyEffect(float offset, const CPoint &center)
-{
- static const float degree_to_radian = 0.01745329252f;
- if (m_autoCenter)
- m_center = center;
- if (m_effect == EFFECT_TYPE_ROTATE_X)
- m_matrix.SetXRotation(((m_endAngle - m_startAngle)*offset + m_startAngle) * degree_to_radian, m_center.x, m_center.y, 1.0f);
- else if (m_effect == EFFECT_TYPE_ROTATE_Y)
- m_matrix.SetYRotation(((m_endAngle - m_startAngle)*offset + m_startAngle) * degree_to_radian, m_center.x, m_center.y, 1.0f);
- else if (m_effect == EFFECT_TYPE_ROTATE_Z) // note coordinate aspect ratio is not generally square in the XY plane, so correct for it.
- m_matrix.SetZRotation(((m_endAngle - m_startAngle)*offset + m_startAngle) * degree_to_radian, m_center.x, m_center.y, g_graphicsContext.GetScalingPixelRatio());
-}
-
-CZoomEffect::CZoomEffect(const TiXmlElement *node, const CRect &rect) : CAnimEffect(node, EFFECT_TYPE_ZOOM)
-{
- // effect defaults
- m_startX = m_startY = 100;
- m_endX = m_endY = 100;
- m_center = CPoint(0,0);
- m_autoCenter = false;
-
- float startPosX = rect.x1;
- float startPosY = rect.y1;
- float endPosX = rect.x1;
- float endPosY = rect.y1;
-
- float width = max(rect.Width(), 0.001f);
- float height = max(rect.Height(),0.001f);
-
- const char *start = node->Attribute("start");
- if (start)
- {
- CStdStringArray params;
- StringUtils::SplitString(start, ",", params);
- if (params.size() == 1)
- {
- m_startX = (float)atof(params[0].c_str());
- m_startY = m_startX;
- }
- else if (params.size() == 2)
- {
- m_startX = (float)atof(params[0].c_str());
- m_startY = (float)atof(params[1].c_str());
- }
- else if (params.size() == 4)
- { // format is start="x,y,width,height"
- // use width and height from our rect to calculate our sizing
- startPosX = (float)atof(params[0].c_str());
- startPosY = (float)atof(params[1].c_str());
- m_startX = (float)atof(params[2].c_str());
- m_startY = (float)atof(params[3].c_str());
- m_startX *= 100.0f / width;
- m_startY *= 100.0f / height;
- }
- }
- const char *end = node->Attribute("end");
- if (end)
- {
- CStdStringArray params;
- StringUtils::SplitString(end, ",", params);
- if (params.size() == 1)
- {
- m_endX = (float)atof(params[0].c_str());
- m_endY = m_endX;
- }
- else if (params.size() == 2)
- {
- m_endX = (float)atof(params[0].c_str());
- m_endY = (float)atof(params[1].c_str());
- }
- else if (params.size() == 4)
- { // format is start="x,y,width,height"
- // use width and height from our rect to calculate our sizing
- endPosX = (float)atof(params[0].c_str());
- endPosY = (float)atof(params[1].c_str());
- m_endX = (float)atof(params[2].c_str());
- m_endY = (float)atof(params[3].c_str());
- m_endX *= 100.0f / width;
- m_endY *= 100.0f / height;
- }
- }
- const char *centerPos = node->Attribute("center");
- if (centerPos)
- {
- if (strcmpi(centerPos, "auto") == 0)
- m_autoCenter = true;
- else
- {
- vector<CStdString> commaSeparated;
- StringUtils::SplitString(centerPos, ",", commaSeparated);
- if (commaSeparated.size() > 1)
- m_center.y = (float)atof(commaSeparated[1].c_str());
- m_center.x = (float)atof(commaSeparated[0].c_str());
- }
- }
- else
- { // no center specified
- // calculate the center position...
- if (m_startX)
- {
- float scale = m_endX / m_startX;
- if (scale != 1)
- m_center.x = (endPosX - scale*startPosX) / (1 - scale);
- }
- if (m_startY)
- {
- float scale = m_endY / m_startY;
- if (scale != 1)
- m_center.y = (endPosY - scale*startPosY) / (1 - scale);
- }
- }
-}
-
-void CZoomEffect::ApplyEffect(float offset, const CPoint &center)
-{
- if (m_autoCenter)
- m_center = center;
- float scaleX = ((m_endX - m_startX)*offset + m_startX) * 0.01f;
- float scaleY = ((m_endY - m_startY)*offset + m_startY) * 0.01f;
- m_matrix.SetScaler(scaleX, scaleY, m_center.x, m_center.y);
-}
-
-CAnimation::CAnimation()
-{
- m_type = ANIM_TYPE_NONE;
- m_reversible = true;
- m_condition = 0;
- m_repeatAnim = ANIM_REPEAT_NONE;
- m_currentState = ANIM_STATE_NONE;
- m_currentProcess = ANIM_PROCESS_NONE;
- m_queuedProcess = ANIM_PROCESS_NONE;
- m_lastCondition = false;
- m_length = 0;
- m_delay = 0;
- m_start = 0;
- m_amount = 0;
-}
-
-CAnimation::CAnimation(const CAnimation &src)
-{
- *this = src;
-}
-
-CAnimation::~CAnimation()
-{
- for (unsigned int i = 0; i < m_effects.size(); i++)
- delete m_effects[i];
- m_effects.clear();
-}
-
-const CAnimation &CAnimation::operator =(const CAnimation &src)
-{
- if (this == &src) return *this; // same
- m_type = src.m_type;
- m_reversible = src.m_reversible;
- m_condition = src.m_condition;
- m_repeatAnim = src.m_repeatAnim;
- m_lastCondition = src.m_lastCondition;
- m_queuedProcess = src.m_queuedProcess;
- m_currentProcess = src.m_currentProcess;
- m_currentState = src.m_currentState;
- m_start = src.m_start;
- m_length = src.m_length;
- m_delay = src.m_delay;
- m_amount = src.m_amount;
- // clear all our effects
- for (unsigned int i = 0; i < m_effects.size(); i++)
- delete m_effects[i];
- m_effects.clear();
- // and assign the others across
- for (unsigned int i = 0; i < src.m_effects.size(); i++)
- {
- CAnimEffect *newEffect = NULL;
- if (src.m_effects[i]->GetType() == CAnimEffect::EFFECT_TYPE_FADE)
- newEffect = new CFadeEffect(*(CFadeEffect *)src.m_effects[i]);
- else if (src.m_effects[i]->GetType() == CAnimEffect::EFFECT_TYPE_ZOOM)
- newEffect = new CZoomEffect(*(CZoomEffect *)src.m_effects[i]);
- else if (src.m_effects[i]->GetType() == CAnimEffect::EFFECT_TYPE_SLIDE)
- newEffect = new CSlideEffect(*(CSlideEffect *)src.m_effects[i]);
- else if (src.m_effects[i]->GetType() == CAnimEffect::EFFECT_TYPE_ROTATE_X ||
- src.m_effects[i]->GetType() == CAnimEffect::EFFECT_TYPE_ROTATE_Y ||
- src.m_effects[i]->GetType() == CAnimEffect::EFFECT_TYPE_ROTATE_Z)
- newEffect = new CRotateEffect(*(CRotateEffect *)src.m_effects[i]);
- if (newEffect)
- m_effects.push_back(newEffect);
- }
- return *this;
-}
-
-void CAnimation::Animate(unsigned int time, bool startAnim)
-{
- // First start any queued animations
- if (m_queuedProcess == ANIM_PROCESS_NORMAL)
- {
- if (m_currentProcess == ANIM_PROCESS_REVERSE)
- m_start = time - m_amount; // reverse direction of animation
- else
- m_start = time;
- m_currentProcess = ANIM_PROCESS_NORMAL;
- }
- else if (m_queuedProcess == ANIM_PROCESS_REVERSE)
- {
- if (m_currentProcess == ANIM_PROCESS_NORMAL)
- m_start = time - (m_length - m_amount); // reverse direction of animation
- else if (m_currentProcess == ANIM_PROCESS_NONE)
- m_start = time;
- m_currentProcess = ANIM_PROCESS_REVERSE;
- }
- // reset the queued state once we've rendered to ensure allocation has occured
- if (startAnim || m_queuedProcess == ANIM_PROCESS_REVERSE)
- m_queuedProcess = ANIM_PROCESS_NONE;
-
- // Update our animation process
- if (m_currentProcess == ANIM_PROCESS_NORMAL)
- {
- if (time - m_start < m_delay)
- {
- m_amount = 0;
- m_currentState = ANIM_STATE_DELAYED;
- }
- else if (time - m_start < m_length + m_delay)
- {
- m_amount = time - m_start - m_delay;
- m_currentState = ANIM_STATE_IN_PROCESS;
- }
- else
- {
- m_amount = m_length;
- if (m_repeatAnim == ANIM_REPEAT_PULSE && m_lastCondition)
- { // pulsed anims auto-reverse
- m_currentProcess = ANIM_PROCESS_REVERSE;
- m_start = time;
- }
- else if (m_repeatAnim == ANIM_REPEAT_LOOP && m_lastCondition)
- { // looped anims start over
- m_amount = 0;
- m_start = time;
- }
- else
- m_currentState = ANIM_STATE_APPLIED;
- }
- }
- else if (m_currentProcess == ANIM_PROCESS_REVERSE)
- {
- if (time - m_start < m_length)
- {
- m_amount = m_length - (time - m_start);
- m_currentState = ANIM_STATE_IN_PROCESS;
- }
- else
- {
- m_amount = 0;
- if (m_repeatAnim == ANIM_REPEAT_PULSE && m_lastCondition)
- { // pulsed anims auto-reverse
- m_currentProcess = ANIM_PROCESS_NORMAL;
- m_start = time;
- }
- else
- m_currentState = ANIM_STATE_APPLIED;
- }
- }
-}
-
-void CAnimation::ResetAnimation()
-{
- m_queuedProcess = ANIM_PROCESS_NONE;
- m_currentProcess = ANIM_PROCESS_NONE;
- m_currentState = ANIM_STATE_NONE;
-}
-
-void CAnimation::ApplyAnimation()
-{
- m_queuedProcess = ANIM_PROCESS_NONE;
- if (m_repeatAnim == ANIM_REPEAT_PULSE)
- { // pulsed anims auto-reverse
- m_amount = m_length;
- m_currentProcess = ANIM_PROCESS_REVERSE;
- m_currentState = ANIM_STATE_IN_PROCESS;
- }
- else if (m_repeatAnim == ANIM_REPEAT_LOOP)
- { // looped anims start over
- m_amount = 0;
- m_currentProcess = ANIM_PROCESS_NORMAL;
- m_currentState = ANIM_STATE_IN_PROCESS;
- }
- else
- { // set normal process, so that Calculate() knows that we're finishing for zero length effects
- // it will be reset in RenderAnimation()
- m_currentProcess = ANIM_PROCESS_NORMAL;
- m_currentState = ANIM_STATE_APPLIED;
- m_amount = m_length;
- }
- Calculate(CPoint());
-}
-
-void CAnimation::Calculate(const CPoint &center)
-{
- for (unsigned int i = 0; i < m_effects.size(); i++)
- {
- CAnimEffect *effect = m_effects[i];
- if (effect->GetLength())
- effect->Calculate(m_delay + m_amount, center);
- else
- { // effect has length zero, so either apply complete
- if (m_currentProcess == ANIM_PROCESS_NORMAL)
- effect->ApplyState(ANIM_STATE_APPLIED, center);
- else
- effect->ApplyState(ANIM_STATE_NONE, center);
- }
- }
-}
-
-void CAnimation::RenderAnimation(TransformMatrix &matrix, const CPoint &center)
-{
- if (m_currentProcess != ANIM_PROCESS_NONE)
- Calculate(center);
- // If we have finished an animation, reset the animation state
- // We do this here (rather than in Animate()) as we need the
- // currentProcess information in the UpdateStates() function of the
- // window and control classes.
- if (m_currentState == ANIM_STATE_APPLIED)
- {
- m_currentProcess = ANIM_PROCESS_NONE;
- m_queuedProcess = ANIM_PROCESS_NONE;
- }
- if (m_currentState != ANIM_STATE_NONE)
- {
- for (unsigned int i = 0; i < m_effects.size(); i++)
- matrix *= m_effects[i]->GetTransform();
- }
-}
-
-void CAnimation::QueueAnimation(ANIMATION_PROCESS process)
-{
- m_queuedProcess = process;
-}
-
-CAnimation *CAnimation::CreateFader(float start, float end, unsigned int delay, unsigned int length)
-{
- CAnimation *anim = new CAnimation();
- if (anim)
- {
- CFadeEffect *effect = new CFadeEffect(start, end, delay, length);
- if (effect)
- anim->AddEffect(effect);
- }
- return anim;
-}
-
-void CAnimation::UpdateCondition(int contextWindow, const CGUIListItem *item)
-{
- bool condition = g_infoManager.GetBool(m_condition, contextWindow, item);
- if (condition && !m_lastCondition)
- QueueAnimation(ANIM_PROCESS_NORMAL);
- else if (!condition && m_lastCondition)
- {
- if (m_reversible)
- QueueAnimation(ANIM_PROCESS_REVERSE);
- else
- ResetAnimation();
- }
- m_lastCondition = condition;
-}
-
-void CAnimation::SetInitialCondition(int contextWindow)
-{
- m_lastCondition = g_infoManager.GetBool(m_condition, contextWindow);
- if (m_lastCondition)
- ApplyAnimation();
- else
- ResetAnimation();
-}
-
-void CAnimation::Create(const TiXmlElement *node, const CRect &rect)
-{
- if (!node || !node->FirstChild())
- return;
-
- // conditions and reversibility
- const char *condition = node->Attribute("condition");
- if (condition)
- m_condition = g_infoManager.TranslateString(condition);
- const char *reverse = node->Attribute("reversible");
- if (reverse && strcmpi(reverse, "false") == 0)
- m_reversible = false;
-
- const TiXmlElement *effect = node->FirstChildElement("effect");
-
- CStdString type = node->FirstChild()->Value();
- m_type = ANIM_TYPE_CONDITIONAL;
- if (effect) // new layout
- type = node->Attribute("type");
-
- if (type.Left(7).Equals("visible")) m_type = ANIM_TYPE_VISIBLE;
- else if (type.Equals("hidden")) m_type = ANIM_TYPE_HIDDEN;
- else if (type.Equals("focus")) m_type = ANIM_TYPE_FOCUS;
- else if (type.Equals("unfocus")) m_type = ANIM_TYPE_UNFOCUS;
- else if (type.Equals("windowopen")) m_type = ANIM_TYPE_WINDOW_OPEN;
- else if (type.Equals("windowclose")) m_type = ANIM_TYPE_WINDOW_CLOSE;
- // sanity check
- if (m_type == ANIM_TYPE_CONDITIONAL)
- {
- if (!m_condition)
- {
- CLog::Log(LOGERROR, "Control has invalid animation type (no condition or no type)");
- return;
- }
-
- // pulsed or loop animations
- const char *pulse = node->Attribute("pulse");
- if (pulse && strcmpi(pulse, "true") == 0)
- m_repeatAnim = ANIM_REPEAT_PULSE;
- const char *loop = node->Attribute("loop");
- if (loop && strcmpi(loop, "true") == 0)
- m_repeatAnim = ANIM_REPEAT_LOOP;
- }
-
- m_delay = 0xffffffff;
- if (!effect)
- { // old layout:
- // <animation effect="fade" start="0" end="100" delay="10" time="2000" condition="blahdiblah" reversible="false">focus</animation>
- CStdString type = node->Attribute("effect");
- AddEffect(type, node, rect);
- }
- while (effect)
- { // new layout:
- // <animation type="focus" condition="blahdiblah" reversible="false">
- // <effect type="fade" start="0" end="100" delay="10" time="2000" />
- // ...
- // </animation>
- CStdString type = effect->Attribute("type");
- AddEffect(type, effect, rect);
- effect = effect->NextSiblingElement("effect");
- }
-}
-
-void CAnimation::AddEffect(const CStdString &type, const TiXmlElement *node, const CRect &rect)
-{
- CAnimEffect *effect = NULL;
- if (type.Equals("fade"))
- effect = new CFadeEffect(node, m_type < 0);
- else if (type.Equals("slide"))
- effect = new CSlideEffect(node);
- else if (type.Equals("rotate"))
- effect = new CRotateEffect(node, CAnimEffect::EFFECT_TYPE_ROTATE_Z);
- else if (type.Equals("rotatey"))
- effect = new CRotateEffect(node, CAnimEffect::EFFECT_TYPE_ROTATE_Y);
- else if (type.Equals("rotatex"))
- effect = new CRotateEffect(node, CAnimEffect::EFFECT_TYPE_ROTATE_X);
- else if (type.Equals("zoom"))
- effect = new CZoomEffect(node, rect);
-
- if (effect)
- AddEffect(effect);
-}
-
-void CAnimation::AddEffect(CAnimEffect *effect)
-{
- m_effects.push_back(effect);
- // our delay is the minimum of all the effect delays
- if (effect->GetDelay() < m_delay)
- m_delay = effect->GetDelay();
- // our length is the maximum of all the effect lengths
- if (effect->GetLength() > m_delay + m_length)
- m_length = effect->GetLength() - m_delay;
-}
diff --git a/guilib/VisibleEffect.h b/guilib/VisibleEffect.h
deleted file mode 100644
index 36278e618e..0000000000
--- a/guilib/VisibleEffect.h
+++ /dev/null
@@ -1,204 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-enum ANIMATION_PROCESS { ANIM_PROCESS_NONE = 0, ANIM_PROCESS_NORMAL, ANIM_PROCESS_REVERSE };
-enum ANIMATION_STATE { ANIM_STATE_NONE = 0, ANIM_STATE_DELAYED, ANIM_STATE_IN_PROCESS, ANIM_STATE_APPLIED };
-
-// forward definitions
-
-class TiXmlElement;
-class Tweener;
-class CGUIListItem;
-
-#include "TransformMatrix.h" // needed for the TransformMatrix member
-#include "Geometry.h" // for CPoint, CRect
-#include "StdString.h"
-
-enum ANIMATION_TYPE
-{
- ANIM_TYPE_UNFOCUS = -3,
- ANIM_TYPE_HIDDEN,
- ANIM_TYPE_WINDOW_CLOSE,
- ANIM_TYPE_NONE,
- ANIM_TYPE_WINDOW_OPEN,
- ANIM_TYPE_VISIBLE,
- ANIM_TYPE_FOCUS,
- ANIM_TYPE_CONDITIONAL // for animations triggered by a condition change
-};
-
-class CAnimEffect
-{
-public:
- enum EFFECT_TYPE { EFFECT_TYPE_NONE = 0, EFFECT_TYPE_FADE, EFFECT_TYPE_SLIDE, EFFECT_TYPE_ROTATE_X, EFFECT_TYPE_ROTATE_Y, EFFECT_TYPE_ROTATE_Z, EFFECT_TYPE_ZOOM };
-
- CAnimEffect(const TiXmlElement *node, EFFECT_TYPE effect);
- CAnimEffect(unsigned int delay, unsigned int length, EFFECT_TYPE effect);
- CAnimEffect(const CAnimEffect &src);
-
- virtual ~CAnimEffect();
- const CAnimEffect &operator=(const CAnimEffect &src);
-
- void Calculate(unsigned int time, const CPoint &center);
- void ApplyState(ANIMATION_STATE state, const CPoint &center);
-
- unsigned int GetDelay() const { return m_delay; };
- unsigned int GetLength() const { return m_delay + m_length; };
- const TransformMatrix &GetTransform() const { return m_matrix; };
- EFFECT_TYPE GetType() const { return m_effect; };
-
-protected:
- TransformMatrix m_matrix;
- EFFECT_TYPE m_effect;
-
-private:
- virtual void ApplyEffect(float offset, const CPoint &center)=0;
-
- // timing variables
- unsigned int m_length;
- unsigned int m_delay;
-
- Tweener *m_pTweener;
-};
-
-class CFadeEffect : public CAnimEffect
-{
-public:
- CFadeEffect(const TiXmlElement *node, bool reverseDefaults);
- CFadeEffect(float start, float end, unsigned int delay, unsigned int length);
- virtual ~CFadeEffect() {};
-private:
- virtual void ApplyEffect(float offset, const CPoint &center);
-
- float m_startAlpha;
- float m_endAlpha;
-};
-
-class CSlideEffect : public CAnimEffect
-{
-public:
- CSlideEffect(const TiXmlElement *node);
- virtual ~CSlideEffect() {};
-private:
- virtual void ApplyEffect(float offset, const CPoint &center);
-
- float m_startX;
- float m_startY;
- float m_endX;
- float m_endY;
-};
-
-class CRotateEffect : public CAnimEffect
-{
-public:
- CRotateEffect(const TiXmlElement *node, EFFECT_TYPE effect);
- virtual ~CRotateEffect() {};
-private:
- virtual void ApplyEffect(float offset, const CPoint &center);
-
- float m_startAngle;
- float m_endAngle;
-
- bool m_autoCenter;
- CPoint m_center;
-};
-
-class CZoomEffect : public CAnimEffect
-{
-public:
- CZoomEffect(const TiXmlElement *node, const CRect &rect);
- virtual ~CZoomEffect() {};
-private:
- virtual void ApplyEffect(float offset, const CPoint &center);
-
- float m_startX;
- float m_startY;
- float m_endX;
- float m_endY;
-
- bool m_autoCenter;
- CPoint m_center;
-};
-
-class CAnimation
-{
-public:
- CAnimation();
- CAnimation(const CAnimation &src);
-
- virtual ~CAnimation();
-
- const CAnimation &operator=(const CAnimation &src);
-
- static CAnimation *CreateFader(float start, float end, unsigned int delay, unsigned int length);
-
- void Create(const TiXmlElement *node, const CRect &rect);
-
- void Animate(unsigned int time, bool startAnim);
- void ResetAnimation();
- void ApplyAnimation();
- inline void RenderAnimation(TransformMatrix &matrix)
- {
- RenderAnimation(matrix, CPoint());
- }
- void RenderAnimation(TransformMatrix &matrix, const CPoint &center);
- void QueueAnimation(ANIMATION_PROCESS process);
-
- inline bool IsReversible() const { return m_reversible; };
- inline int GetCondition() const { return m_condition; };
- inline ANIMATION_TYPE GetType() const { return m_type; };
- inline ANIMATION_STATE GetState() const { return m_currentState; };
- inline ANIMATION_PROCESS GetProcess() const { return m_currentProcess; };
- inline ANIMATION_PROCESS GetQueuedProcess() const { return m_queuedProcess; };
-
- void UpdateCondition(int contextWindow, const CGUIListItem *item = NULL);
- void SetInitialCondition(int contextWindow);
-
-private:
- void Calculate(const CPoint &point);
- void AddEffect(const CStdString &type, const TiXmlElement *node, const CRect &rect);
- void AddEffect(CAnimEffect *effect);
-
- enum ANIM_REPEAT { ANIM_REPEAT_NONE = 0, ANIM_REPEAT_PULSE, ANIM_REPEAT_LOOP };
-
- // type of animation
- ANIMATION_TYPE m_type;
- bool m_reversible;
- int m_condition;
-
- // conditional anims can repeat
- ANIM_REPEAT m_repeatAnim;
- bool m_lastCondition;
-
- // state of animation
- ANIMATION_PROCESS m_queuedProcess;
- ANIMATION_PROCESS m_currentProcess;
- ANIMATION_STATE m_currentState;
-
- // timing of animation
- unsigned int m_start;
- unsigned int m_length;
- unsigned int m_delay;
- unsigned int m_amount;
-
- std::vector<CAnimEffect *> m_effects;
-};
diff --git a/guilib/XBTF.cpp b/guilib/XBTF.cpp
deleted file mode 100644
index 82c17f19dc..0000000000
--- a/guilib/XBTF.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright (C) 2005-2009 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-#include <cstring>
-#include "XBTF.h"
-
-CXBTFFrame::CXBTFFrame()
-{
- m_width = 0;
- m_height = 0;
- m_packedSize = 0;
- m_unpackedSize = 0;
- m_offset = 0;
- m_format = XB_FMT_UNKNOWN;
-}
-
-uint32_t CXBTFFrame::GetWidth() const
-{
- return m_width;
-}
-
-void CXBTFFrame::SetWidth(uint32_t width)
-{
- m_width = width;
-}
-
-uint32_t CXBTFFrame::GetHeight() const
-{
- return m_height;
-}
-
-void CXBTFFrame::SetHeight(uint32_t height)
-{
- m_height = height;
-}
-
-uint64_t CXBTFFrame::GetPackedSize() const
-{
- return m_packedSize;
-}
-
-void CXBTFFrame::SetPackedSize(uint64_t size)
-{
- m_packedSize = size;
-}
-
-bool CXBTFFrame::IsPacked() const
-{
- return m_unpackedSize != m_packedSize;
-}
-
-uint64_t CXBTFFrame::GetUnpackedSize() const
-{
- return m_unpackedSize;
-}
-
-void CXBTFFrame::SetUnpackedSize(uint64_t size)
-{
- m_unpackedSize = size;
-}
-
-void CXBTFFrame::SetFormat(uint32_t format)
-{
- m_format = format;
-}
-
-uint32_t CXBTFFrame::GetFormat() const
-{
- return m_format;
-}
-
-uint64_t CXBTFFrame::GetOffset() const
-{
- return m_offset;
-}
-
-void CXBTFFrame::SetOffset(uint64_t offset)
-{
- m_offset = offset;
-}
-
-uint32_t CXBTFFrame::GetDuration() const
-{
- return m_duration;
-}
-
-void CXBTFFrame::SetDuration(uint32_t duration)
-{
- m_duration = duration;
-}
-
-uint64_t CXBTFFrame::GetHeaderSize() const
-{
- uint64_t result =
- sizeof(m_width) +
- sizeof(m_height) +
- sizeof(m_format) +
- sizeof(m_packedSize) +
- sizeof(m_unpackedSize) +
- sizeof(m_offset) +
- sizeof(m_duration);
-
- return result;
-}
-
-CXBTFFile::CXBTFFile()
-{
- memset(m_path, 0, sizeof(m_path));
- m_loop = 0;
-}
-
-CXBTFFile::CXBTFFile(const CXBTFFile& ref)
-{
- strcpy(m_path, ref.m_path);
- m_loop = ref.m_loop;
- m_frames = ref.m_frames;
-}
-
-char* CXBTFFile::GetPath()
-{
- return m_path;
-}
-
-void CXBTFFile::SetPath(const std::string& path)
-{
- memset(m_path, 0, sizeof(m_path));
- strncpy(m_path, path.c_str(), sizeof(m_path) - 1);
-}
-
-uint32_t CXBTFFile::GetLoop() const
-{
- return m_loop;
-}
-
-void CXBTFFile::SetLoop(uint32_t loop)
-{
- m_loop = loop;
-}
-
-std::vector<CXBTFFrame>& CXBTFFile::GetFrames()
-{
- return m_frames;
-}
-
-uint64_t CXBTFFile::GetHeaderSize() const
-{
- uint64_t result =
- sizeof(m_path) +
- sizeof(m_loop) +
- sizeof(uint32_t); /* Number of frames */
-
- for (size_t i = 0; i < m_frames.size(); i++)
- {
- result += m_frames[i].GetHeaderSize();
- }
-
- return result;
-}
-
-CXBTF::CXBTF()
-{
-}
-
-uint64_t CXBTF::GetHeaderSize() const
-{
- uint64_t result =
- 4 /* Magic */ +
- 1 /* Vesion */ +
- sizeof(uint32_t) /* Number of Files */;
-
- for (size_t i = 0; i < m_files.size(); i++)
- {
- result += m_files[i].GetHeaderSize();
- }
-
- return result;
-}
-
-std::vector<CXBTFFile>& CXBTF::GetFiles()
-{
- return m_files;
-}
diff --git a/guilib/XBTF.h b/guilib/XBTF.h
deleted file mode 100644
index 83ffa06193..0000000000
--- a/guilib/XBTF.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2005-2009 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-#ifndef XBTF_H_
-#define XBTF_H_
-
-#include <string>
-#include <vector>
-#include <stdint.h>
-
-#define XBTF_MAGIC "XBTF"
-#define XBTF_VERSION "2"
-
-#define XB_FMT_DXT_MASK 15
-#define XB_FMT_UNKNOWN 0
-#define XB_FMT_DXT1 1
-#define XB_FMT_DXT3 2
-#define XB_FMT_DXT5 4
-#define XB_FMT_DXT5_YCoCg 8
-#define XB_FMT_A8R8G8B8 16
-#define XB_FMT_A8 32
-
-class CXBTFFrame
-{
-public:
- CXBTFFrame();
- uint32_t GetWidth() const;
- void SetWidth(uint32_t width);
- uint32_t GetFormat() const;
- void SetFormat(uint32_t format);
- uint32_t GetHeight() const;
- void SetHeight(uint32_t height);
- uint64_t GetUnpackedSize() const;
- void SetUnpackedSize(uint64_t size);
- uint64_t GetPackedSize() const;
- void SetPackedSize(uint64_t size);
- uint64_t GetOffset() const;
- void SetOffset(uint64_t offset);
- uint64_t GetHeaderSize() const;
- uint32_t GetDuration() const;
- void SetDuration(uint32_t duration);
- bool IsPacked() const;
-
-private:
- uint32_t m_width;
- uint32_t m_height;
- uint32_t m_format;
- uint64_t m_packedSize;
- uint64_t m_unpackedSize;
- uint64_t m_offset;
- uint32_t m_duration;
-};
-
-class CXBTFFile
-{
-public:
- CXBTFFile();
- CXBTFFile(const CXBTFFile& ref);
- char* GetPath();
- void SetPath(const std::string& path);
- uint32_t GetLoop() const;
- void SetLoop(uint32_t loop);
- std::vector<CXBTFFrame>& GetFrames();
- uint64_t GetHeaderSize() const;
-
-private:
- char m_path[256];
- uint32_t m_loop;
- std::vector<CXBTFFrame> m_frames;
-};
-
-class CXBTF
-{
-public:
- CXBTF();
- uint64_t GetHeaderSize() const;
- std::vector<CXBTFFile>& GetFiles();
-
-private:
- std::vector<CXBTFFile> m_files;
-};
-
-#endif
diff --git a/guilib/XBTFReader.cpp b/guilib/XBTFReader.cpp
deleted file mode 100644
index f6eecbb38e..0000000000
--- a/guilib/XBTFReader.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (C) 2005-2009 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include <sys/stat.h>
-#include "XBTFReader.h"
-#include "EndianSwap.h"
-#include "CharsetConverter.h"
-#ifdef _WIN32
-#include "FileSystem/SpecialProtocol.h"
-#include "PlatformDefs.h" //for PRIdS, PRId64
-#endif
-
-#define READ_STR(str, size, file) \
- if (!fread(str, size, 1, file)) \
- return false;
-
-#define READ_U32(i, file) \
- if (!fread(&i, 4, 1, file)) \
- return false; \
- i = Endian_SwapLE32(i);
-
-#define READ_U64(i, file) \
- if (!fread(&i, 8, 1, file)) \
- return false; \
- i = Endian_SwapLE64(i);
-
-CXBTFReader::CXBTFReader()
-{
- m_file = NULL;
-}
-
-bool CXBTFReader::IsOpen() const
-{
- return m_file != NULL;
-}
-
-bool CXBTFReader::Open(const CStdString& fileName)
-{
- m_fileName = fileName;
-
-#ifdef _WIN32
- CStdStringW strPathW;
- g_charsetConverter.utf8ToW(_P(m_fileName), strPathW, false);
- m_file = _wfopen(strPathW.c_str(), L"rb");
-#else
- m_file = fopen(m_fileName.c_str(), "rb");
-#endif
- if (m_file == NULL)
- {
- return false;
- }
-
- char magic[4];
- READ_STR(magic, 4, m_file);
-
- if (strncmp(magic, XBTF_MAGIC, sizeof(magic)) != 0)
- {
- return false;
- }
-
- char version[1];
- READ_STR(version, 1, m_file);
-
- if (strncmp(version, XBTF_VERSION, sizeof(version)) != 0)
- {
- return false;
- }
-
- unsigned int nofFiles;
- READ_U32(nofFiles, m_file);
- for (unsigned int i = 0; i < nofFiles; i++)
- {
- CXBTFFile file;
- unsigned int u32;
- uint64_t u64;
-
- READ_STR(file.GetPath(), 256, m_file);
- READ_U32(u32, m_file);
- file.SetLoop(u32);
-
- unsigned int nofFrames;
- READ_U32(nofFrames, m_file);
-
- for (unsigned int j = 0; j < nofFrames; j++)
- {
- CXBTFFrame frame;
-
- READ_U32(u32, m_file);
- frame.SetWidth(u32);
- READ_U32(u32, m_file);
- frame.SetHeight(u32);
- READ_U32(u32, m_file);
- frame.SetFormat(u32);
- READ_U64(u64, m_file);
- frame.SetPackedSize(u64);
- READ_U64(u64, m_file);
- frame.SetUnpackedSize(u64);
- READ_U32(u32, m_file);
- frame.SetDuration(u32);
- READ_U64(u64, m_file);
- frame.SetOffset(u64);
-
- file.GetFrames().push_back(frame);
- }
-
- m_xbtf.GetFiles().push_back(file);
-
- m_filesMap[file.GetPath()] = file;
- }
-
- // Sanity check
- int64_t pos = ftell(m_file);
- if (pos != (int64_t)m_xbtf.GetHeaderSize())
- {
- printf("Expected header size (%"PRId64") != actual size (%"PRId64")\n", m_xbtf.GetHeaderSize(), pos);
- return false;
- }
-
- return true;
-}
-
-void CXBTFReader::Close()
-{
- if (m_file)
- {
- fclose(m_file);
- m_file = NULL;
- }
-
- m_xbtf.GetFiles().clear();
- m_filesMap.clear();
-}
-
-time_t CXBTFReader::GetLastModificationTimestamp()
-{
- if (!m_file)
- {
- return 0;
- }
-
- struct stat fileStat;
- if (fstat(fileno(m_file), &fileStat) == -1)
- {
- return 0;
- }
-
- return fileStat.st_mtime;
-}
-
-bool CXBTFReader::Exists(const CStdString& name)
-{
- return Find(name) != NULL;
-}
-
-CXBTFFile* CXBTFReader::Find(const CStdString& name)
-{
- std::map<CStdString, CXBTFFile>::iterator iter = m_filesMap.find(name);
- if (iter == m_filesMap.end())
- {
- return NULL;
- }
-
- return &(iter->second);
-}
-
-bool CXBTFReader::Load(const CXBTFFrame& frame, unsigned char* buffer)
-{
- if (!m_file)
- {
- return false;
- }
-#if defined(__APPLE__)
- if (fseeko(m_file, (off_t)frame.GetOffset(), SEEK_SET) == -1)
-#else
- if (fseeko64(m_file, (off_t)frame.GetOffset(), SEEK_SET) == -1)
-#endif
- {
- return false;
- }
-
- if (fread(buffer, 1, (size_t)frame.GetPackedSize(), m_file) != frame.GetPackedSize())
- {
- return false;
- }
-
- return true;
-}
-
-std::vector<CXBTFFile>& CXBTFReader::GetFiles()
-{
- return m_xbtf.GetFiles();
-}
diff --git a/guilib/XBTFReader.h b/guilib/XBTFReader.h
deleted file mode 100644
index 3233efc2b7..0000000000
--- a/guilib/XBTFReader.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2005-2009 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#ifndef XBTFREADER_H_
-#define XBTFREADER_H_
-
-#include <vector>
-#include <map>
-#include "StdString.h"
-#include "XBTF.h"
-
-class CXBTFReader
-{
-public:
- CXBTFReader();
- bool IsOpen() const;
- bool Open(const CStdString& fileName);
- void Close();
- time_t GetLastModificationTimestamp();
- bool Exists(const CStdString& name);
- CXBTFFile* Find(const CStdString& name);
- bool Load(const CXBTFFrame& frame, unsigned char* buffer);
- std::vector<CXBTFFile>& GetFiles();
-
-private:
- CXBTF m_xbtf;
- CStdString m_fileName;
- FILE* m_file;
- std::map<CStdString, CXBTFFile> m_filesMap;
-};
-
-#endif
diff --git a/guilib/XMLUtils.cpp b/guilib/XMLUtils.cpp
deleted file mode 100644
index 5ba0b0a6d6..0000000000
--- a/guilib/XMLUtils.cpp
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "XMLUtils.h"
-#include "Util.h"
-#include "FileSystem/SpecialProtocol.h"
-#include "StringUtils.h"
-#ifdef _WIN32
-#include "PlatformDefs.h" //for strcasecmp
-#endif
-
-bool XMLUtils::GetHex(const TiXmlNode* pRootNode, const char* strTag, uint32_t& hexValue)
-{
- const TiXmlNode* pNode = pRootNode->FirstChild(strTag );
- if (!pNode || !pNode->FirstChild()) return false;
- sscanf(pNode->FirstChild()->Value(), "%x", (uint32_t*) &hexValue );
- return true;
-}
-
-
-bool XMLUtils::GetUInt(const TiXmlNode* pRootNode, const char* strTag, uint32_t& uintValue)
-{
- const TiXmlNode* pNode = pRootNode->FirstChild(strTag );
- if (!pNode || !pNode->FirstChild()) return false;
- uintValue = atol(pNode->FirstChild()->Value());
- return true;
-}
-
-bool XMLUtils::GetLong(const TiXmlNode* pRootNode, const char* strTag, long& lLongValue)
-{
- const TiXmlNode* pNode = pRootNode->FirstChild(strTag );
- if (!pNode || !pNode->FirstChild()) return false;
- lLongValue = atol(pNode->FirstChild()->Value());
- return true;
-}
-
-bool XMLUtils::GetInt(const TiXmlNode* pRootNode, const char* strTag, int& iIntValue)
-{
- const TiXmlNode* pNode = pRootNode->FirstChild(strTag );
- if (!pNode || !pNode->FirstChild()) return false;
- iIntValue = atoi(pNode->FirstChild()->Value());
- return true;
-}
-
-bool XMLUtils::GetInt(const TiXmlNode* pRootNode, const char* strTag, int &value, const int min, const int max)
-{
- if (GetInt(pRootNode, strTag, value))
- {
- if (value < min) value = min;
- if (value > max) value = max;
- return true;
- }
- return false;
-}
-
-bool XMLUtils::GetDouble(const TiXmlNode *root, const char *tag, double &value)
-{
- const TiXmlNode* node = root->FirstChild(tag);
- if (!node || !node->FirstChild()) return false;
- value = atof(node->FirstChild()->Value());
- return true;
-}
-
-bool XMLUtils::GetFloat(const TiXmlNode* pRootNode, const char* strTag, float& value)
-{
- const TiXmlNode* pNode = pRootNode->FirstChild(strTag );
- if (!pNode || !pNode->FirstChild()) return false;
- value = (float)atof(pNode->FirstChild()->Value());
- return true;
-}
-
-bool XMLUtils::GetFloat(const TiXmlNode* pRootElement, const char *tagName, float& fValue, const float fMin, const float fMax)
-{
- if (GetFloat(pRootElement, tagName, fValue))
- { // check range
- if (fValue < fMin) fValue = fMin;
- if (fValue > fMax) fValue = fMax;
- return true;
- }
- return false;
-}
-
-bool XMLUtils::GetBoolean(const TiXmlNode* pRootNode, const char* strTag, bool& bBoolValue)
-{
- const TiXmlNode* pNode = pRootNode->FirstChild(strTag );
- if (!pNode || !pNode->FirstChild()) return false;
- CStdString strEnabled = pNode->FirstChild()->Value();
- strEnabled.ToLower();
- if (strEnabled == "off" || strEnabled == "no" || strEnabled == "disabled" || strEnabled == "false" || strEnabled == "0" )
- bBoolValue = false;
- else
- {
- bBoolValue = true;
- if (strEnabled != "on" && strEnabled != "yes" && strEnabled != "enabled" && strEnabled != "true")
- return false; // invalid bool switch - it's probably some other string.
- }
- return true;
-}
-
-bool XMLUtils::GetString(const TiXmlNode* pRootNode, const char* strTag, CStdString& strStringValue)
-{
- const TiXmlElement* pElement = pRootNode->FirstChildElement(strTag );
- if (!pElement) return false;
- const char* encoded = pElement->Attribute("urlencoded");
- const TiXmlNode* pNode = pElement->FirstChild();
- if (pNode != NULL)
- {
- strStringValue = pNode->Value();
- if (encoded && strcasecmp(encoded,"yes") == 0)
- CUtil::URLDecode(strStringValue);
- return true;
- }
- strStringValue.Empty();
- return false;
-}
-
-bool XMLUtils::GetAdditiveString(const TiXmlNode* pRootNode, const char* strTag,
- const CStdString& strSeparator, CStdString& strStringValue)
-{
- CStdString strTemp;
- const TiXmlElement* node = pRootNode->FirstChildElement(strTag);
- bool bResult=false;
- while (node)
- {
- if (node->FirstChild())
- {
- bResult = true;
- strTemp = node->FirstChild()->Value();
- const char* clear=node->Attribute("clear");
- if (strStringValue.IsEmpty() || (clear && strcasecmp(clear,"true")==0))
- strStringValue = strTemp;
- else
- strStringValue += strSeparator+strTemp;
- }
- node = node->NextSiblingElement(strTag);
- }
-
- return bResult;
-}
-
-/*!
- Returns true if the encoding of the document is other then UTF-8.
- /param strEncoding Returns the encoding of the document. Empty if UTF-8
-*/
-bool XMLUtils::GetEncoding(const TiXmlDocument* pDoc, CStdString& strEncoding)
-{
- const TiXmlNode* pNode=NULL;
- while ((pNode=pDoc->IterateChildren(pNode)) && pNode->Type()!=TiXmlNode::DECLARATION) {}
- if (!pNode) return false;
- const TiXmlDeclaration* pDecl=pNode->ToDeclaration();
- if (!pDecl) return false;
- strEncoding=pDecl->Encoding();
- if (strEncoding.Equals("UTF-8") || strEncoding.Equals("UTF8")) strEncoding.Empty();
- strEncoding.MakeUpper();
- return !strEncoding.IsEmpty(); // Other encoding then UTF8?
-}
-
-/*!
- Returns true if the encoding of the document is specified as as UTF-8
- /param strXML The XML file (embedded in a string) to check.
-*/
-bool XMLUtils::HasUTF8Declaration(const CStdString &strXML)
-{
- CStdString test = strXML;
- test.ToLower();
- // test for the encoding="utf-8" string
- if (test.Find("encoding=\"utf-8\"") >= 0)
- return true;
- // TODO: test for plain UTF8 here?
- return false;
-}
-
-bool XMLUtils::GetPath(const TiXmlNode* pRootNode, const char* strTag, CStdString& strStringValue)
-{
- const TiXmlElement* pElement = pRootNode->FirstChildElement(strTag);
- if (!pElement) return false;
-
- int pathVersion = 0;
- pElement->Attribute("pathversion", &pathVersion);
- const char* encoded = pElement->Attribute("urlencoded");
- const TiXmlNode* pNode = pElement->FirstChild();
- if (pNode != NULL)
- {
- strStringValue = pNode->Value();
- if (encoded && strcasecmp(encoded,"yes") == 0)
- CUtil::URLDecode(strStringValue);
- strStringValue = CSpecialProtocol::ReplaceOldPath(strStringValue, pathVersion);
- return true;
- }
- strStringValue.Empty();
- return false;
-}
-
-void XMLUtils::SetAdditiveString(TiXmlNode* pRootNode, const char *strTag, const CStdString& strSeparator, const CStdString& strValue)
-{
- CStdStringArray list;
- StringUtils::SplitString(strValue,strSeparator,list);
- for (unsigned int i=0;i<list.size() && !list[i].IsEmpty();++i)
- SetString(pRootNode,strTag,list[i]);
-}
-
-void XMLUtils::SetString(TiXmlNode* pRootNode, const char *strTag, const CStdString& strValue)
-{
- TiXmlElement newElement(strTag);
- TiXmlNode *pNewNode = pRootNode->InsertEndChild(newElement);
- if (pNewNode)
- {
- TiXmlText value(strValue);
- pNewNode->InsertEndChild(value);
- }
-}
-
-void XMLUtils::SetInt(TiXmlNode* pRootNode, const char *strTag, int value)
-{
- CStdString strValue;
- strValue.Format("%i", value);
- SetString(pRootNode, strTag, strValue);
-}
-
-void XMLUtils::SetLong(TiXmlNode* pRootNode, const char *strTag, long value)
-{
- CStdString strValue;
- strValue.Format("%l", value);
- SetString(pRootNode, strTag, strValue);
-}
-
-void XMLUtils::SetFloat(TiXmlNode* pRootNode, const char *strTag, float value)
-{
- CStdString strValue;
- strValue.Format("%f", value);
- SetString(pRootNode, strTag, strValue);
-}
-
-void XMLUtils::SetBoolean(TiXmlNode* pRootNode, const char *strTag, bool value)
-{
- SetString(pRootNode, strTag, value ? "true" : "false");
-}
-
-void XMLUtils::SetHex(TiXmlNode* pRootNode, const char *strTag, uint32_t value)
-{
- CStdString strValue;
- strValue.Format("%x", value);
- SetString(pRootNode, strTag, strValue);
-}
-
-void XMLUtils::SetPath(TiXmlNode* pRootNode, const char *strTag, const CStdString& strValue)
-{
- TiXmlElement newElement(strTag);
- newElement.SetAttribute("pathversion", CSpecialProtocol::path_version);
- TiXmlNode *pNewNode = pRootNode->InsertEndChild(newElement);
- if (pNewNode)
- {
- TiXmlText value(strValue);
- pNewNode->InsertEndChild(value);
- }
-}
diff --git a/guilib/XMLUtils.h b/guilib/XMLUtils.h
deleted file mode 100644
index 0084af7ba0..0000000000
--- a/guilib/XMLUtils.h
+++ /dev/null
@@ -1,56 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "StdString.h"
-#include "tinyXML/tinyxml.h" // no use forwarding these, as this class is the main workhorse anyway,
- // thus it simplifies the include patterns
-
-class XMLUtils
-{
-public:
- static bool HasUTF8Declaration(const CStdString &strXML);
-
- static bool GetHex(const TiXmlNode* pRootNode, const char* strTag, uint32_t& dwHexValue);
- static bool GetUInt(const TiXmlNode* pRootNode, const char* strTag, uint32_t& dwUIntValue);
- static bool GetLong(const TiXmlNode* pRootNode, const char* strTag, long& lLongValue);
- static bool GetFloat(const TiXmlNode* pRootNode, const char* strTag, float& value);
- static bool GetDouble(const TiXmlNode* pRootNode, const char* strTag, double &value);
- static bool GetInt(const TiXmlNode* pRootNode, const char* strTag, int& iIntValue);
- static bool GetBoolean(const TiXmlNode* pRootNode, const char* strTag, bool& bBoolValue);
- static bool GetString(const TiXmlNode* pRootNode, const char* strTag, CStdString& strStringValue);
- static bool GetAdditiveString(const TiXmlNode* pRootNode, const char* strTag, const CStdString& strSeparator, CStdString& strStringValue);
- static bool GetEncoding(const TiXmlDocument* pDoc, CStdString& strEncoding);
- static bool GetPath(const TiXmlNode* pRootNode, const char* strTag, CStdString& strStringValue);
- static bool GetFloat(const TiXmlNode* pRootNode, const char* strTag, float& value, const float min, const float max);
- static bool GetInt(const TiXmlNode* pRootNode, const char* strTag, int& iIntValue, const int min, const int max);
-
- static void SetString(TiXmlNode* pRootNode, const char *strTag, const CStdString& strValue);
- static void SetAdditiveString(TiXmlNode* pRootNode, const char *strTag, const CStdString& strSeparator, const CStdString& strValue);
- static void SetInt(TiXmlNode* pRootNode, const char *strTag, int value);
- static void SetFloat(TiXmlNode* pRootNode, const char *strTag, float value);
- static void SetBoolean(TiXmlNode* pRootNode, const char *strTag, bool value);
- static void SetHex(TiXmlNode* pRootNode, const char *strTag, uint32_t value);
- static void SetPath(TiXmlNode* pRootNode, const char *strTag, const CStdString& strValue);
- static void SetLong(TiXmlNode* pRootNode, const char *strTag, long iValue);
-};
-
diff --git a/guilib/common/IRServerSuite/IRServerSuite.cpp b/guilib/common/IRServerSuite/IRServerSuite.cpp
deleted file mode 100644
index 3eff632fcf..0000000000
--- a/guilib/common/IRServerSuite/IRServerSuite.cpp
+++ /dev/null
@@ -1,480 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "IRServerSuite.h"
-#include "IrssMessage.h"
-#include "ButtonTranslator.h"
-#include "log.h"
-#include "AdvancedSettings.h"
-#include "utils/TimeUtils.h"
-#include <Ws2tcpip.h>
-
-#define IRSS_PORT 24000
-
-CRemoteControl g_RemoteControl;
-
-CRemoteControl::CRemoteControl()
-{
- m_socket = INVALID_SOCKET;
- m_bInitialized = false;
- m_isConnecting = false;
- Reset();
-}
-
-CRemoteControl::~CRemoteControl()
-{
- Close();
-}
-
-void CRemoteControl::Disconnect()
-{
- StopThread();
- Close();
-}
-
-void CRemoteControl::Close()
-{
- m_isConnecting = false;
- if (m_socket != INVALID_SOCKET)
- {
- if (m_bInitialized)
- {
- m_bInitialized = false;
- CIrssMessage message(IRSSMT_UnregisterClient, IRSSMF_Request | IRSSMF_ForceNotRespond);
- SendPacket(message);
- }
- shutdown(m_socket, SD_BOTH);
- closesocket(m_socket);
- m_socket = INVALID_SOCKET;
- }
-}
-
-void CRemoteControl::Reset()
-{
- m_button = 0;
-}
-
-void CRemoteControl::Initialize()
-{
- if (m_isConnecting || m_bInitialized) return;
- //trying to connect when there is nothing to connect to is kinda slow so kick it off in a thread.
- Create();
- SetName("CRemoteControl");
-}
-
-void CRemoteControl::Process()
-{
- int iTries = 1;
- DWORD iMsRetryDelay = 5000;
- DWORD time = CTimeUtils::GetTimeMS() - iMsRetryDelay;
- // try to connect 60 times @ a 5 second interval (5 minutes)
- // multiple tries because irss service might be up and running a little later then xbmc on boot.
- while (!m_bStop && iTries <= 60)
- {
- if (CTimeUtils::GetTimeMS() - time >= iMsRetryDelay)
- {
- time = CTimeUtils::GetTimeMS();
- if (Connect())
- break;
- iTries++;
- }
- Sleep(1000);
- }
-}
-
-bool CRemoteControl::Connect()
-{
- char namebuf[NI_MAXHOST], portbuf[NI_MAXSERV];
- struct addrinfo hints = {};
- struct addrinfo *result, *addr;
- char service[33];
- int res;
-
- hints.ai_family = AF_UNSPEC;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_protocol = IPPROTO_TCP;
- sprintf(service, "%d", IRSS_PORT);
-
- res = getaddrinfo("localhost", service, &hints, &result);
- if(res)
- {
- CLog::Log(LOGERROR, "CRemoteControl::Connect - failed: %s", __FUNCTION__, gai_strerror(res));
- return false;
- }
-
- for(addr = result; addr; addr = addr->ai_next)
- {
- if(getnameinfo(addr->ai_addr, addr->ai_addrlen, namebuf, sizeof(namebuf), portbuf, sizeof(portbuf),NI_NUMERICHOST))
- {
- strcpy(namebuf, "[unknown]");
- strcpy(portbuf, "[unknown]");
- }
- CLog::Log(LOGDEBUG, "CRemoteControl::Connect - connecting to: %s:%s ...", namebuf, portbuf);
-
- m_socket = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);
- if(m_socket == INVALID_SOCKET)
- continue;
-
- if(connect(m_socket, addr->ai_addr, addr->ai_addrlen) != SOCKET_ERROR)
- break;
-
- closesocket(m_socket);
- m_socket = INVALID_SOCKET;
- }
-
- freeaddrinfo(result);
- if(m_socket == INVALID_SOCKET)
- {
- CLog::Log(LOGERROR, "CRemoteControl::Connect - failed to connect");
- Close();
- return false;
- }
-
- u_long iMode = 1; //non-blocking
- if (ioctlsocket(m_socket, FIONBIO, &iMode) == SOCKET_ERROR)
- {
- CLog::Log(LOGERROR, "IRServerSuite: failed to set socket to non-blocking.");
- Close();
- return false;
- }
-
- //register
- CIrssMessage mess(IRSSMT_RegisterClient, IRSSMF_Request);
- if (!SendPacket(mess))
- {
- CLog::Log(LOGERROR, "IRServerSuite: failed to send RegisterClient packet.");
- return false;
- }
- m_isConnecting = true;
- return true;
-}
-
-bool CRemoteControl::SendPacket(CIrssMessage& message)
-{
- int iSize = 0;
- char* bytes = message.ToBytes(iSize);
- char buffer[4];
- uint32_t len = htonl(iSize);
- memcpy(&buffer[0], &len, 4);
- bool bResult = WriteN(&buffer[0], 4);
- if (bResult)
- {
- bResult = WriteN(bytes, iSize);
- }
- delete[] bytes;
- if (!bResult)
- {
- Close();
- return false;
- }
- return true;
-}
-
-
-void CRemoteControl::Update()
-{
- if ((!m_bInitialized && !m_isConnecting) || (m_socket == INVALID_SOCKET))
- {
- return;
- }
-
- CIrssMessage mess;
- if (!ReadPacket(mess))
- {
- return;
- }
- switch (mess.GetType())
- {
- case IRSSMT_RegisterClient:
- m_isConnecting = false;
- if ((mess.GetFlags() & IRSSMF_Success) != IRSSMF_Success)
- {
- //uh oh, it failed to register
- Close();
- CLog::Log(LOGERROR, "IRServerSuite: failed to register XBMC as a client.");
- }
- else
- {
- m_bInitialized = true;
- //request info about receivers
- CIrssMessage mess(IRSSMT_DetectedReceivers, IRSSMF_Request);
- if (!SendPacket(mess))
- {
- CLog::Log(LOGERROR, "IRServerSuite: failed to send AvailableReceivers packet.");
- }
- mess.SetType(IRSSMT_AvailableReceivers);
- if (!SendPacket(mess))
- {
- CLog::Log(LOGERROR, "IRServerSuite: failed to send AvailableReceivers packet.");
- }
- mess.SetType(IRSSMT_ActiveReceivers);
- if (!SendPacket(mess))
- {
- CLog::Log(LOGERROR, "IRServerSuite: failed to send AvailableReceivers packet.");
- }
- }
- break;
- case IRSSMT_RemoteEvent:
- HandleRemoteEvent(mess);
- break;
- case IRSSMT_Error:
- //I suppose the errormessage is in the packet somewhere...
- CLog::Log(LOGERROR, "IRServerSuite: we got an error message.");
- break;
- case IRSSMT_ServerShutdown:
- Close();
- break;
- case IRSSMT_ServerSuspend:
- //should we do something?
- break;
- case IRSSMT_ServerResume:
- //should we do something?
- break;
- case IRSSMT_AvailableReceivers:
- {
- uint32_t size = mess.GetDataSize();
- if (size > 0)
- {
- char* data = mess.GetData();
- char* availablereceivers = new char[size + 1];
- memcpy(availablereceivers, data, size);
- availablereceivers[size] = '\0';
- CLog::Log(LOGINFO, "IRServerSuite: Available receivers: %s", availablereceivers);
- delete[] availablereceivers;
- }
- }
- break;
- case IRSSMT_DetectedReceivers:
- {
- uint32_t size = mess.GetDataSize();
- if (size > 0)
- {
- char* data = mess.GetData();
- char* detectedreceivers = new char[size + 1];
- memcpy(detectedreceivers, data, size);
- detectedreceivers[size] = '\0';
- CLog::Log(LOGINFO, "IRServerSuite: Detected receivers: %s", detectedreceivers);
- delete[] detectedreceivers;
- }
- }
- break;
- case IRSSMT_ActiveReceivers:
- {
- uint32_t size = mess.GetDataSize();
- if (size > 0)
- {
- char* data = mess.GetData();
- char* activereceivers = new char[size + 1];
- memcpy(activereceivers, data, size);
- activereceivers[size] = '\0';
- CLog::Log(LOGINFO, "IRServerSuite: Active receivers: %s", activereceivers);
- delete[] activereceivers;
- }
- }
- break;
- }
-}
-
-bool CRemoteControl::HandleRemoteEvent(CIrssMessage& message)
-{
- try
- {
- //flag should be notify, maybe check it?
- char* data = message.GetData();
- uint32_t datalen = message.GetDataSize();
- char* deviceName;
- char* keycode;
- uint32_t devicenamelength;
- uint32_t keycodelength;
- if (datalen == 0)
- {
- CLog::Log(LOGERROR, "IRServerSuite: no data in remote message.");
- return false;
- }
- if (datalen <= 8)
- {
- //seems to be version 1.0.4.1, only keycode is sent, use Microsoft MCE mapping??
- devicenamelength = 13;
- deviceName = new char[devicenamelength + 1];
- sprintf(deviceName, "Microsoft MCE");
- keycodelength = datalen;
- keycode = new char[keycodelength + 1];
- memcpy(keycode, data, keycodelength);
- }
- else
- {
- //first 4 bytes is devicename length
- memcpy(&devicenamelength, data, 4);
- //devicename itself
- if (datalen < 4 + devicenamelength)
- {
- CLog::Log(LOGERROR, "IRServerSuite: invalid data in remote message (size: %u).", datalen);
- return false;
- }
- deviceName = new char[devicenamelength + 1];
- memcpy(deviceName, data + 4, devicenamelength);
- if (datalen < 8 + devicenamelength)
- {
- CLog::Log(LOGERROR, "IRServerSuite: invalid data in remote message (size: %u).", datalen);
- delete[] deviceName;
- return false;
- }
- //next 4 bytes is keycode length
- memcpy(&keycodelength, data + 4 + devicenamelength, 4);
- //keycode itself
- if (datalen < 8 + devicenamelength + keycodelength)
- {
- CLog::Log(LOGERROR, "IRServerSuite: invalid data in remote message (size: %u).", datalen);
- delete[] deviceName;
- return false;
- }
- keycode = new char[keycodelength + 1];
- memcpy(keycode, data + 8 + devicenamelength, keycodelength);
- }
- deviceName[devicenamelength] = '\0';
- keycode[keycodelength] = '\0';
- //translate to a buttoncode xbmc understands
- m_button = CButtonTranslator::GetInstance().TranslateLircRemoteString(deviceName, keycode);
- if (g_advancedSettings.m_logLevel == LOG_LEVEL_DEBUG_FREEMEM)
- {
- CLog::Log(LOGINFO, "IRServerSuite, RemoteEvent: %s %s", deviceName, keycode);
- }
- delete[] deviceName;
- delete[] keycode;
- return true;
- }
- catch(...)
- {
- CLog::Log(LOGERROR, "IRServerSuite: exception while processing RemoteEvent.");
- return false;
- }
-}
-
-int CRemoteControl::ReadN(char *buffer, int n)
-{
- int nOriginalSize = n;
- memset(buffer, 0, n);
- char *ptr = buffer;
- while (n > 0)
- {
- int nBytes = 0;
- nBytes = recv(m_socket, ptr, n, 0);
-
- if (WSAGetLastError() == WSAEWOULDBLOCK)
- {
- return nOriginalSize - n;
- }
- if (nBytes < 0)
- {
- if (!m_isConnecting)
- {
- CLog::Log(LOGERROR, "%s, IRServerSuite recv error %d", __FUNCTION__, GetLastError());
- }
- Close();
- return -1;
- }
-
- if (nBytes == 0)
- {
- CLog::Log(LOGDEBUG,"%s, IRServerSuite socket closed by server", __FUNCTION__);
- Close();
- break;
- }
-
- n -= nBytes;
- ptr += nBytes;
- }
-
- return nOriginalSize - n;
-}
-
-bool CRemoteControl::WriteN(const char *buffer, int n)
-{
- const char *ptr = buffer;
- while (n > 0)
- {
- int nBytes = send(m_socket, ptr, n, 0);
- if (nBytes < 0)
- {
- CLog::Log(LOGERROR, "%s, IRServerSuite send error %d (%d bytes)", __FUNCTION__, GetLastError(), n);
- Close();
- return false;
- }
-
- if (nBytes == 0)
- break;
-
- n -= nBytes;
- ptr += nBytes;
- }
-
- return n == 0;
-}
-
-bool CRemoteControl::ReadPacket(CIrssMessage &message)
-{
- try
- {
- char sizebuf[4];
- int iRead = ReadN(&sizebuf[0], 4);
- if (iRead <= 0) return false; //nothing to read
- if (iRead != 4)
- {
- CLog::Log(LOGERROR, "IRServerSuite: failed to read packetsize.");
- return false;
- }
- uint32_t size = 0;
- memcpy(&size, &sizebuf[0], 4);
- size = ntohl(size);
- char* messagebytes = new char[size];
- if (ReadN(messagebytes, size) != size)
- {
- CLog::Log(LOGERROR, "IRServerSuite: failed to read packet.");
- return false;
- }
- if (!CIrssMessage::FromBytes(messagebytes, size, message))
- {
- CLog::Log(LOGERROR, "IRServerSuite: invalid packet received (size: %u).", size);
- return false;
- }
- delete[] messagebytes;
- return true;
- }
- catch(...)
- {
- CLog::Log(LOGERROR, "IRServerSuite: exception while processing packet.");
- return false;
- }
-}
-
-WORD CRemoteControl::GetButton()
-{
- return m_button;
-}
-
-unsigned int CRemoteControl::GetHoldTime() const
-{
- return 0;
-}
-
-void CRemoteControl::setUsed(bool value)
-{
-}
diff --git a/guilib/common/IRServerSuite/IRServerSuite.h b/guilib/common/IRServerSuite/IRServerSuite.h
deleted file mode 100644
index b265abf3f8..0000000000
--- a/guilib/common/IRServerSuite/IRServerSuite.h
+++ /dev/null
@@ -1,67 +0,0 @@
-#pragma once
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include <winsock2.h>
-#include "StdString.h"
-#include "IrssMessage.h"
-#include "Thread.h"
-
-class CRemoteControl : CThread
-{
-public:
- CRemoteControl();
- ~CRemoteControl();
- void Initialize();
- void Disconnect();
- void Reset();
- void Update();
- WORD GetButton();
- unsigned int GetHoldTime() const;
- bool IsInitialized() {return m_bInitialized;}
-
- //lirc stuff, not implemented
- bool IsInUse() {return false;}
- void setUsed(bool value);
- void AddSendCommand(const CStdString& command) {}
-
-protected:
- virtual void Process();
-
-private:
- WORD m_button;
- bool m_bInitialized;
- SOCKET m_socket;
- bool m_isConnecting;
- CStdString m_deviceName;
- CStdString m_keyCode;
-
- bool SendPacket(CIrssMessage& message);
- bool ReadPacket(CIrssMessage& message);
- int ReadN(char *buffer, int n);
- bool WriteN(const char *buffer, int n);
- bool Connect();
- void Close();
-
- bool HandleRemoteEvent(CIrssMessage& message);
-};
-
-extern CRemoteControl g_RemoteControl;
diff --git a/guilib/common/IRServerSuite/IrssMessage.cpp b/guilib/common/IRServerSuite/IrssMessage.cpp
deleted file mode 100644
index 7f8d40b174..0000000000
--- a/guilib/common/IRServerSuite/IrssMessage.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "IrssMessage.h"
-
-CIrssMessage::CIrssMessage()
-{
- m_type = IRSSMT_Unknown;
- m_flags = 0;
- m_data = NULL;
- m_dataSize = 0;
-}
-
-CIrssMessage::CIrssMessage(IRSS_MessageType type, uint32_t flags)
-{
- m_type = type;
- m_flags = flags;
- m_data = NULL;
- m_dataSize = 0;
-}
-
-CIrssMessage::CIrssMessage(IRSS_MessageType type, uint32_t flags, char* data, int size)
-{
- m_type = type;
- m_flags = flags;
- SetDataAsBytes(data, size);
-}
-
-CIrssMessage::CIrssMessage(IRSS_MessageType type, uint32_t flags, const CStdString& data)
-{
- m_type = type;
- m_flags = flags;
- SetDataAsString(data);
-}
-
-CIrssMessage::~CIrssMessage()
-{
- FreeData();
-}
-
-void CIrssMessage::SetDataAsBytes(char* data, int size)
-{
- if (!data)
- {
- FreeData();
- }
- else
- {
- m_data = (char*)malloc(size * sizeof(char));
- memcpy(m_data, data, size);
- m_dataSize = size;
- }
-}
-
-void CIrssMessage::SetDataAsString(const CStdString& data)
-{
- if (!data || data.IsEmpty())
- {
- FreeData();
- }
- else
- {
- m_data = strdup(data.c_str());
- m_dataSize = strlen(data.c_str());
- }
-}
-
-void CIrssMessage::FreeData()
-{
- free(m_data);
- m_data = NULL;
- m_dataSize = 0;
-}
-
-char* CIrssMessage::ToBytes(int& size)
-{
- int dataLength = 0;
- if (m_data)
- {
- dataLength = m_dataSize;
- }
-
- size = 8 + dataLength;
- char* byteArray = new char[size];
-
- memcpy(&byteArray[0], &m_type, 4);
- memcpy(&byteArray[4], &m_flags, 4);
-
- if (m_data)
- {
- memcpy(&byteArray[8], &m_data, m_dataSize);
- }
-
- return byteArray;
-}
-
-bool CIrssMessage::FromBytes(char* from, int size, CIrssMessage& message)
-{
- if (!from)
- return false;
-
- if (size < 8)
- return false;
-
- //IRSS_MessageType type = (MessageType)BitConverter.ToInt32(from, 0);
- //IRSS_MessageFlags flags = (MessageFlags)BitConverter.ToInt32(from, 4);
- uint32_t type;
- memcpy(&type, from, 4);
- uint32_t flags;
- memcpy(&flags, from + 4, 4);
-
- message.SetType((IRSS_MessageType)type);
- message.SetFlags(flags);
- if (size > 8)
- {
- message.SetDataAsBytes(from + 8, size - 8);
- }
- return true;
-}
-
-void CIrssMessage::SetType(IRSS_MessageType type)
-{
- m_type = type;
-}
-void CIrssMessage::SetFlags(uint32_t flags)
-{
- m_flags = flags;
-}
diff --git a/guilib/common/IRServerSuite/IrssMessage.h b/guilib/common/IRServerSuite/IrssMessage.h
deleted file mode 100644
index d5ddefa0a7..0000000000
--- a/guilib/common/IRServerSuite/IrssMessage.h
+++ /dev/null
@@ -1,209 +0,0 @@
-#pragma once
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "StdString.h"
-
- /// <summary>
- /// Type of message.
- /// </summary>
- enum IRSS_MessageType
- {
- /// <summary>
- /// Unknown message type.
- /// </summary>
- IRSSMT_Unknown = 0,
-
- /// <summary>
- /// Register Client.
- /// </summary>
- IRSSMT_RegisterClient = 1,
- /// <summary>
- /// Unregister Client.
- /// </summary>
- IRSSMT_UnregisterClient = 2,
-
- /// <summary>
- /// Register Repeater.
- /// </summary>
- IRSSMT_RegisterRepeater = 3,
- /// <summary>
- /// Unregister Repeater.
- /// </summary>
- IRSSMT_UnregisterRepeater = 4,
-
- /// <summary>
- /// Learn IR Command.
- /// </summary>
- IRSSMT_LearnIR = 5,
- /// <summary>
- /// Blast IR Command.
- /// </summary>
- IRSSMT_BlastIR = 6,
-
- /// <summary>
- /// Error.
- /// </summary>
- IRSSMT_Error = 7,
-
- /// <summary>
- /// Server Shutdown.
- /// </summary>
- IRSSMT_ServerShutdown = 8,
- /// <summary>
- /// Server Suspend.
- /// </summary>
- IRSSMT_ServerSuspend = 9,
- /// <summary>
- /// Server Resume
- /// </summary>
- IRSSMT_ServerResume = 10,
-
- /// <summary>
- /// Remote Event.
- /// </summary>
- IRSSMT_RemoteEvent = 11,
- /// <summary>
- /// Keyboard Event.
- /// </summary>
- IRSSMT_KeyboardEvent = 12,
- /// <summary>
- /// Mouse Event.
- /// </summary>
- IRSSMT_MouseEvent = 13,
-
- /// <summary>
- /// Forward a Remote Event.
- /// </summary>
- IRSSMT_ForwardRemoteEvent = 14,
- /// <summary>
- /// Forward a Keyboard Event.
- /// </summary>
- IRSSMT_ForwardKeyboardEvent = 15,
- /// <summary>
- /// Forward a Mouse Event.
- /// </summary>
- IRSSMT_ForwardMouseEvent = 16,
-
- /// <summary>
- /// Available Receivers.
- /// </summary>
- IRSSMT_AvailableReceivers = 17,
- /// <summary>
- /// Available Blasters.
- /// </summary>
- IRSSMT_AvailableBlasters = 18,
- /// <summary>
- /// Active Receivers.
- /// </summary>
- IRSSMT_ActiveReceivers = 19,
- /// <summary>
- /// Active Blasters.
- /// </summary>
- IRSSMT_ActiveBlasters = 20,
- /// <summary>
- /// Detected Receivers.
- /// </summary>
- IRSSMT_DetectedReceivers = 21,
- /// <summary>
- /// Detected Blasters.
- /// </summary>
- IRSSMT_DetectedBlasters = 22,
- };
-
- /// <summary>
- /// Flags to determine more information about the message.
- /// </summary>
- enum IRSS_MessageFlags
- {
- /// <summary>
- /// No Flags.
- /// </summary>
- IRSSMF_None = 0x0000,
-
- /// <summary>
- /// Message is a Request.
- /// </summary>
- IRSSMF_Request = 0x0001,
- /// <summary>
- /// Message is a Response to a received Message.
- /// </summary>
- IRSSMF_Response = 0x0002,
- /// <summary>
- /// Message is a Notification.
- /// </summary>
- IRSSMF_Notify = 0x0004,
-
- /// <summary>
- /// Operation Success.
- /// </summary>
- IRSSMF_Success = 0x0008,
- /// <summary>
- /// Operation Failure.
- /// </summary>
- IRSSMF_Failure = 0x0010,
- /// <summary>
- /// Operation Time-Out.
- /// </summary>
- IRSSMF_Timeout = 0x0020,
-
- //IRSSMF_Error = 0x0040,
-
- //IRSSMF_DataString = 0x0080,
- //IRSSMF_DataBytes = 0x0100,
-
- //IRSSMF_ForceRespond = 0x0200,
-
- /// <summary>
- /// Force the recipient not to respond.
- /// </summary>
- IRSSMF_ForceNotRespond = 0x0400,
- };
-
-class CIrssMessage
-{
-public:
- CIrssMessage();
- CIrssMessage(IRSS_MessageType type, uint32_t flags);
- CIrssMessage(IRSS_MessageType type, uint32_t flags, char* data, int size);
- CIrssMessage(IRSS_MessageType type, uint32_t flags, const CStdString& data);
- ~CIrssMessage();
-
- void SetDataAsBytes(char* data, int size);
- void SetDataAsString(const CStdString& data);
- char* ToBytes(int& size);
- void SetType(IRSS_MessageType type);
- void SetFlags(uint32_t flags);
- IRSS_MessageType GetType() {return m_type;}
- uint32_t GetFlags() {return m_flags;}
- char* GetData() {return m_data;}
- uint32_t GetDataSize() {return m_dataSize;}
- static bool FromBytes(char* from, int size, CIrssMessage& message);
-
-private:
- IRSS_MessageType m_type;
- uint32_t m_flags;
-
- char* m_data;
- int m_dataSize;
-
- void FreeData();
-};
diff --git a/guilib/common/LIRC.cpp b/guilib/common/LIRC.cpp
deleted file mode 100644
index d406da87df..0000000000
--- a/guilib/common/LIRC.cpp
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
-* Copyright (C) 2007-2010 Team XBMC
-* http://www.xbmc.org
-*
-* This Program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, 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 General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with XBMC; see the file COPYING. If not, write to
-* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-* http://www.gnu.org/copyleft/gpl.html
-*
-*/
-
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/inotify.h>
-#include <limits.h>
-#include <unistd.h>
-#include "LIRC.h"
-#include "ButtonTranslator.h"
-#include "log.h"
-#include "AdvancedSettings.h"
-#include "FileSystem/File.h"
-#include "utils/TimeUtils.h"
-
-CRemoteControl g_RemoteControl;
-
-CRemoteControl::CRemoteControl()
-{
- m_fd = -1;
- m_file = NULL;
- m_bInitialized = false;
- m_button = 0;
- m_holdTime = 0;
- m_used = true;
- m_deviceName = LIRC_DEVICE;
- m_inotify_fd = -1;
- m_inotify_wd = -1;
- m_bLogConnectFailure = true;
- m_lastInitAttempt = -5000;
- m_initRetryPeriod = 5000;
- m_inReply = false;
- m_nrSending = 0;
- Reset();
-}
-
-CRemoteControl::~CRemoteControl()
-{
- if (m_file != NULL)
- fclose(m_file);
-}
-
-void CRemoteControl::setUsed(bool value)
-{
- m_used=value;
- if (!value)
- CLog::Log(LOGINFO, "LIRC %s: disabled", __FUNCTION__);
- else
- {
- m_lastInitAttempt = -5000;
- m_initRetryPeriod = 5000;
- }
-}
-
-void CRemoteControl::Reset()
-{
- m_button = 0;
- m_holdTime = 0;
-}
-
-void CRemoteControl::Disconnect()
-{
- if (!m_used)
- return;
-
- if (m_fd != -1)
- {
- m_bInitialized = false;
- if (m_file != NULL)
- fclose(m_file);
- if (m_fd != -1)
- close(m_fd);
- m_fd = -1;
- m_file = NULL;
- if (m_inotify_wd >= 0) {
- inotify_rm_watch(m_inotify_fd, m_inotify_wd);
- m_inotify_wd = -1;
- }
- if (m_inotify_fd >= 0)
- close(m_inotify_fd);
-
- m_inReply = false;
- m_nrSending = 0;
- m_sendData.clear();
- }
-}
-
-void CRemoteControl::setDeviceName(const CStdString& value)
-{
- if (value.length()>0)
- m_deviceName=value;
- else
- m_deviceName=LIRC_DEVICE;
- if (m_bInitialized)
- {
- Disconnect();
- Initialize();
- }
-}
-
-void CRemoteControl::Initialize()
-{
- struct sockaddr_un addr;
- int now = CTimeUtils::GetTimeMS();
-
- if (!m_used || now < m_lastInitAttempt + m_initRetryPeriod)
- return;
-
- m_lastInitAttempt = now;
- addr.sun_family = AF_UNIX;
- strcpy(addr.sun_path, m_deviceName.c_str());
-
- CLog::Log(LOGINFO, "LIRC %s: using: %s", __FUNCTION__, addr.sun_path);
-
- // Open the socket from which we will receive the remote commands
- if ((m_fd = socket(AF_UNIX, SOCK_STREAM, 0)) != -1)
- {
- // Connect to the socket
- if (connect(m_fd, (struct sockaddr *)&addr, sizeof(addr)) != -1)
- {
- int opts;
- m_bLogConnectFailure = true;
- if ((opts = fcntl(m_fd,F_GETFL)) != -1)
- {
- // Set the socket to non-blocking
- opts = (opts | O_NONBLOCK);
- if (fcntl(m_fd,F_SETFL,opts) != -1)
- {
- if ((m_file = fdopen(m_fd, "r+")) != NULL)
- {
- // Setup inotify so we can disconnect if lircd is restarted
- if ((m_inotify_fd = inotify_init()) >= 0)
- {
- // Set the fd non-blocking
- if ((opts = fcntl(m_inotify_fd, F_GETFL)) != -1)
- {
- opts |= O_NONBLOCK;
- if (fcntl(m_inotify_fd, F_SETFL, opts) != -1)
- {
- // Set an inotify watch on the lirc device
- if ((m_inotify_wd = inotify_add_watch(m_inotify_fd, m_deviceName.c_str(), IN_DELETE_SELF)) != -1)
- {
- m_bInitialized = true;
- CLog::Log(LOGINFO, "LIRC %s: sucessfully started", __FUNCTION__);
- }
- else
- CLog::Log(LOGDEBUG, "LIRC: Failed to initialize Inotify. LIRC device will not be monitored.");
- }
- }
- }
- }
- else
- CLog::Log(LOGERROR, "LIRC %s: fdopen failed: %s", __FUNCTION__, strerror(errno));
- }
- else
- CLog::Log(LOGERROR, "LIRC %s: fcntl(F_SETFL) failed: %s", __FUNCTION__, strerror(errno));
- }
- else
- CLog::Log(LOGERROR, "LIRC %s: fcntl(F_GETFL) failed: %s", __FUNCTION__, strerror(errno));
- }
- else
- {
- if (m_bLogConnectFailure)
- {
- CLog::Log(LOGINFO, "LIRC %s: connect failed: %s", __FUNCTION__, strerror(errno));
- m_bLogConnectFailure = false;
- }
- }
- }
- else
- CLog::Log(LOGINFO, "LIRC %s: socket failed: %s", __FUNCTION__, strerror(errno));
- if (!m_bInitialized)
- {
- Disconnect();
- m_initRetryPeriod *= 2;
- if (m_initRetryPeriod > 60000)
- {
- m_used = false;
- CLog::Log(LOGDEBUG, "Failed to connect to LIRC. Giving up.");
- }
- else
- CLog::Log(LOGDEBUG, "Failed to connect to LIRC. Retry in %ds.", m_initRetryPeriod/1000);
- }
- else
- m_initRetryPeriod = 5000;
-}
-
-bool CRemoteControl::CheckDevice() {
- if (m_inotify_fd < 0 || m_inotify_wd < 0)
- return true; // inotify wasn't setup for some reason, assume all is well
- int bufsize = sizeof(struct inotify_event) + PATH_MAX;
- char buf[bufsize];
- int ret = read(m_inotify_fd, buf, bufsize);
- for (int i = 0; i + (int)sizeof(struct inotify_event) <= ret;) {
- struct inotify_event* e = (struct inotify_event*)(buf+i);
- if (e->mask & IN_DELETE_SELF) {
- CLog::Log(LOGDEBUG, "LIRC device removed, disconnecting...");
- Disconnect();
- return false;
- }
- i += sizeof(struct inotify_event)+e->len;
- }
- return true;
-}
-
-void CRemoteControl::Update()
-{
- if (!m_bInitialized || !m_used )
- return;
-
- if (!CheckDevice())
- return;
-
- uint32_t now = SDL_GetTicks();
-
- // Read a line from the socket
- while (fgets(m_buf, sizeof(m_buf), m_file) != NULL)
- {
- // Remove the \n
- m_buf[strlen(m_buf)-1] = '\0';
-
- // Parse the result. Sample line:
- // 000000037ff07bdd 00 OK mceusb
- char scanCode[128];
- char buttonName[128];
- char repeatStr[4];
- char deviceName[128];
- sscanf(m_buf, "%s %s %s %s", &scanCode[0], &repeatStr[0], &buttonName[0], &deviceName[0]);
-
- //beginning of lirc reply packet
- //we get one when lirc is done sending something
- if (!m_inReply && strcmp("BEGIN", scanCode) == 0)
- {
- m_inReply = true;
- continue;
- }
- else if (m_inReply && strcmp("END", scanCode) == 0) //end of lirc reply packet
- {
- m_inReply = false;
- if (m_nrSending > 0)
- m_nrSending--;
- continue;
- }
-
- if (m_inReply)
- continue;
-
- // Some template LIRC configuration have button names in apostrophes or quotes.
- // If we got a quoted button name, strip 'em
- unsigned int buttonNameLen = strlen(buttonName);
- if ( buttonNameLen > 2
- && ( (buttonName[0] == '\'' && buttonName[buttonNameLen-1] == '\'')
- || ((buttonName[0] == '"' && buttonName[buttonNameLen-1] == '"') ) ) )
- {
- memmove( buttonName, buttonName + 1, buttonNameLen - 2 );
- buttonName[ buttonNameLen - 2 ] = '\0';
- }
-
- m_button = CButtonTranslator::GetInstance().TranslateLircRemoteString(deviceName, buttonName);
-
- char *end = NULL;
- long repeat = strtol(repeatStr, &end, 16);
- if (!end || *end != 0)
- CLog::Log(LOGERROR, "LIRC: invalid non-numeric character in expression %s", repeatStr);
- if (repeat == 0)
- {
- CLog::Log(LOGDEBUG, "LIRC: %s - NEW at %d:%s (%s)", __FUNCTION__, now, m_buf, buttonName);
- m_firstClickTime = now;
- m_holdTime = 0;
- return;
- }
- else if (repeat > g_advancedSettings.m_remoteDelay)
- {
- m_holdTime = now - m_firstClickTime;
- }
- else
- {
- m_holdTime = 0;
- m_button = 0;
- }
- }
-
- //drop commands when already sending
- //because keypresses come in faster than lirc can send we risk hammering the daemon with commands
- if (m_nrSending > 0)
- {
- m_sendData.clear();
- }
- else if (!m_sendData.empty())
- {
- fputs(m_sendData.c_str(), m_file);
- fflush(m_file);
-
- //nr of newlines equals nr of commands
- for (int i = 0; i < (int)m_sendData.size(); i++)
- if (m_sendData[i] == '\n')
- m_nrSending++;
-
- m_sendData.clear();
- }
-
- if (feof(m_file) != 0)
- Disconnect();
-}
-
-WORD CRemoteControl::GetButton()
-{
- return m_button;
-}
-
-unsigned int CRemoteControl::GetHoldTime() const
-{
- return m_holdTime;
-}
-
-void CRemoteControl::AddSendCommand(const CStdString& command)
-{
- if (!m_bInitialized || !m_used)
- return;
-
- m_sendData += command;
- m_sendData += '\n';
-}
-
diff --git a/guilib/common/LIRC.h b/guilib/common/LIRC.h
deleted file mode 100644
index 0bd69f5588..0000000000
--- a/guilib/common/LIRC.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
-* Copyright (C) 2007-2010 Team XBMC
-* http://www.xbmc.org
-*
-* This Program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, 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 General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with XBMC; see the file COPYING. If not, write to
-* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-* http://www.gnu.org/copyleft/gpl.html
-*
-*/
-
-#ifndef LIRC_H
-#define LIRC_H
-
-#include "../system.h"
-#include "StdString.h"
-
-class CRemoteControl
-{
-public:
- CRemoteControl();
- ~CRemoteControl();
- void Initialize();
- void Disconnect();
- void Reset();
- void Update();
- WORD GetButton();
- /*! \brief retrieve the time in milliseconds that the button has been held
- \return time in milliseconds the button has been down
- */
- unsigned int GetHoldTime() const;
- void setDeviceName(const CStdString& value);
- void setUsed(bool value);
- bool IsInUse() const { return m_used; }
- bool IsInitialized() const { return m_bInitialized; }
- void AddSendCommand(const CStdString& command);
-
-private:
- int m_fd;
- int m_inotify_fd;
- int m_inotify_wd;
- int m_lastInitAttempt;
- int m_initRetryPeriod;
- FILE* m_file;
- unsigned int m_holdTime;
- int32_t m_button;
- char m_buf[128];
- bool m_bInitialized;
- bool m_used;
- bool m_bLogConnectFailure;
- uint32_t m_firstClickTime;
- CStdString m_deviceName;
- bool CheckDevice();
- CStdString m_sendData;
- bool m_inReply;
- int m_nrSending;
-};
-
-extern CRemoteControl g_RemoteControl;
-
-#endif
diff --git a/guilib/common/Makefile.in b/guilib/common/Makefile.in
deleted file mode 100644
index 757c468768..0000000000
--- a/guilib/common/Makefile.in
+++ /dev/null
@@ -1,14 +0,0 @@
-ARCH=@ARCH@
-
-INCLUDES=-I. -I../ -I../../xbmc -I../../xbmc/linux -I../../xbmc/utils
-
-ifeq ($(findstring osx,$(ARCH)), osx)
-SRCS=SDLJoystick.cpp
-else
-SRCS=SDLJoystick.cpp LIRC.cpp
-endif
-
-LIB=gui_common.a
-
-include ../../Makefile.include
--include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS)))
diff --git a/guilib/common/SDLJoystick.cpp b/guilib/common/SDLJoystick.cpp
deleted file mode 100644
index fe6ccc974c..0000000000
--- a/guilib/common/SDLJoystick.cpp
+++ /dev/null
@@ -1,412 +0,0 @@
-/*
-* Copyright (C) 2007-2010 Team XBMC
-* http://www.xbmc.org
-*
-* This Program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, 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 General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with XBMC; see the file COPYING. If not, write to
-* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-* http://www.gnu.org/copyleft/gpl.html
-*
-*/
-
-#include "system.h"
-#include "../Key.h"
-#include "SDLJoystick.h"
-#include "ButtonTranslator.h"
-#include "AdvancedSettings.h"
-#include "utils/log.h"
-
-#include <math.h>
-
-#ifdef HAS_SDL_JOYSTICK
-
-using namespace std;
-
-CJoystick g_Joystick; // global
-
-CJoystick::CJoystick()
-{
- Reset();
- m_NumAxes = 0;
- m_AxisId = 0;
- m_JoyId = 0;
- m_ButtonId = 0;
- m_HatId = 0;
- m_HatState = SDL_HAT_CENTERED;
- m_ActiveFlags = JACTIVE_NONE;
- for (int i = 0 ; i<MAX_AXES ; i++)
- m_Amount[i] = 0;
- SetDeadzone(0);
-}
-
-void CJoystick::Initialize()
-{
- // clear old joystick names
- m_JoystickNames.clear();
-
- // any open ones? if so, close them.
- if (m_Joysticks.size()>0)
- {
- for(size_t idJoy = 0; idJoy < m_Joysticks.size(); idJoy++)
- {
- // any joysticks unplugged?
- if(SDL_JoystickOpened(idJoy))
- SDL_JoystickClose(m_Joysticks[idJoy]);
- }
- m_Joysticks.clear();
- m_JoyId = -1;
- }
-
- // Set deadzone range
- SetDeadzone(g_advancedSettings.m_controllerDeadzone);
-
- // any joysticks connected?
- if (SDL_NumJoysticks()>0)
- {
- // load joystick names and open all connected joysticks
- for (int i = 0 ; i<SDL_NumJoysticks() ; i++)
- {
- SDL_Joystick *joy = SDL_JoystickOpen(i);
-
-#ifdef __APPLE__
- // On OS X, the 360 controllers are handled externally, since the SDL code is
- // really buggy and doesn't handle disconnects.
- //
- if (std::string(SDL_JoystickName(i)).find("360") != std::string::npos)
- {
- CLog::Log(LOGNOTICE, "Ignoring joystick: %s", SDL_JoystickName(i));
- continue;
- }
-#endif
-
- m_Joysticks.push_back(joy);
- if (joy)
- {
- m_JoystickNames.push_back(string(SDL_JoystickName(i)));
- CLog::Log(LOGNOTICE, "Enabled Joystick: %s", SDL_JoystickName(i));
- CLog::Log(LOGNOTICE, "Details: Total Axis: %d Total Hats: %d Total Buttons: %d",
- SDL_JoystickNumAxes(joy), SDL_JoystickNumHats(joy), SDL_JoystickNumButtons(joy));
- }
- else
- {
- m_JoystickNames.push_back(string(""));
- }
- }
- }
-
- // disable joystick events, since we'll be polling them
- SDL_JoystickEventState(SDL_DISABLE);
-}
-
-void CJoystick::Reset(bool axis)
-{
- if (axis)
- {
- SetAxisActive(false);
- for (int i = 0 ; i<MAX_AXES ; i++)
- {
- ResetAxis(i);
- }
- }
-}
-
-void CJoystick::Update()
-{
- int buttonId = -1;
- int axisId = -1;
- int hatId = -1;
- int numj = m_Joysticks.size();
- if (numj <= 0)
- return;
-
- // update the state of all opened joysticks
- SDL_JoystickUpdate();
-
- // go through all joysticks
- for (int j = 0; j<numj; j++)
- {
- SDL_Joystick *joy = m_Joysticks[j];
- int numb = SDL_JoystickNumButtons(joy);
- int numhat = SDL_JoystickNumHats(joy);
- int numax = SDL_JoystickNumAxes(joy);
- numax = (numax>MAX_AXES)?MAX_AXES:numax;
- int axisval;
- uint8_t hatval;
-
- // get button states first, they take priority over axis
- for (int b = 0 ; b<numb ; b++)
- {
- if (SDL_JoystickGetButton(joy, b))
- {
- m_JoyId = SDL_JoystickIndex(joy);
- buttonId = b+1;
- j = numj-1;
- break;
- }
- }
-
- for (int h = 0; h < numhat; h++)
- {
- hatval = SDL_JoystickGetHat(joy, h);
- if (hatval != SDL_HAT_CENTERED)
- {
- m_JoyId = SDL_JoystickIndex(joy);
- hatId = h + 1;
- m_HatState = hatval;
- j = numj-1;
- break;
- }
- }
-
- // get axis states
- m_NumAxes = numax;
- for (int a = 0 ; a<numax ; a++)
- {
- axisval = SDL_JoystickGetAxis(joy, a);
- axisId = a+1;
- if (axisId<=0 || axisId>=MAX_AXES)
- {
- CLog::Log(LOGERROR, "Axis Id out of range. Maximum supported axis: %d", MAX_AXES);
- }
- else
- {
- m_Amount[axisId] = axisval; //[-32768 to 32767]
- }
- }
- m_AxisId = GetAxisWithMaxAmount();
- if (m_AxisId)
- {
- m_JoyId = SDL_JoystickIndex(joy);
- j = numj-1;
- break;
- }
- }
-
- if(hatId==-1)
- {
- if(m_HatId!=0)
- CLog::Log(LOGDEBUG, "Joystick %d hat %u Centered", m_JoyId, hatId);
- m_pressTicksHat = 0;
- SetHatActive(false);
- m_HatId = 0;
- }
- else
- {
- if(hatId!=m_HatId)
- {
- CLog::Log(LOGDEBUG, "Joystick %d hat %u Down", m_JoyId, hatId);
- m_HatId = hatId;
- m_pressTicksHat = SDL_GetTicks();
- }
- SetHatActive();
- }
-
- if (buttonId==-1)
- {
- if (m_ButtonId!=0)
- {
- CLog::Log(LOGDEBUG, "Joystick %d button %d Up", m_JoyId, m_ButtonId);
- }
- m_pressTicksButton = 0;
- SetButtonActive(false);
- m_ButtonId = 0;
- }
- else
- {
- if (buttonId!=m_ButtonId)
- {
- CLog::Log(LOGDEBUG, "Joystick %d button %d Down", m_JoyId, buttonId);
- m_ButtonId = buttonId;
- m_pressTicksButton = SDL_GetTicks();
- }
- SetButtonActive();
- }
-
-}
-
-void CJoystick::Update(SDL_Event& joyEvent)
-{
- int buttonId = -1;
- int axisId = -1;
- int joyId = -1;
- bool ignore = false; // not used for now
- bool axis = false;
-
- switch(joyEvent.type)
- {
- case SDL_JOYBUTTONDOWN:
- m_JoyId = joyId = joyEvent.jbutton.which;
- m_ButtonId = buttonId = joyEvent.jbutton.button + 1;
- m_pressTicksButton = SDL_GetTicks();
- SetButtonActive();
- CLog::Log(LOGDEBUG, "Joystick %d button %d Down", joyId, buttonId);
- break;
-
- case SDL_JOYAXISMOTION:
- joyId = joyEvent.jaxis.which;
- axisId = joyEvent.jaxis.axis + 1;
- m_NumAxes = SDL_JoystickNumAxes(m_Joysticks[joyId]);
- if (axisId<=0 || axisId>=MAX_AXES)
- {
- CLog::Log(LOGERROR, "Axis Id out of range. Maximum supported axis: %d", MAX_AXES);
- ignore = true;
- break;
- }
- axis = true;
- m_JoyId = joyId;
- if (joyEvent.jaxis.value==0)
- {
- ignore = true;
- m_Amount[axisId] = 0;
- }
- else
- {
- m_Amount[axisId] = joyEvent.jaxis.value; //[-32768 to 32767]
- }
- m_AxisId = GetAxisWithMaxAmount();
- CLog::Log(LOGDEBUG, "Joystick %d Axis %d Amount %d", joyId, axisId, m_Amount[axisId]);
- break;
-
- case SDL_JOYHATMOTION:
- m_JoyId = joyId = joyEvent.jbutton.which;
- m_HatId = joyEvent.jhat.hat + 1;
- m_pressTicksHat = SDL_GetTicks();
- m_HatState = joyEvent.jhat.value;
- SetHatActive(m_HatState != SDL_HAT_CENTERED);
- CLog::Log(LOGDEBUG, "Joystick %d Hat %d Down with position %d", joyId, buttonId, m_HatState);
- break;
-
- case SDL_JOYBALLMOTION:
- ignore = true;
- break;
-
- case SDL_JOYBUTTONUP:
- m_pressTicksButton = 0;
- SetButtonActive(false);
- CLog::Log(LOGDEBUG, "Joystick %d button %d Up", joyEvent.jbutton.which, m_ButtonId);
-
- default:
- ignore = true;
- break;
- }
-}
-
-bool CJoystick::GetHat(int &id, int &position,bool consider_repeat)
-{
- if (!IsHatActive())
- return false;
- position = m_HatState;
- id = m_HatId;
- if (!consider_repeat)
- return true;
-
- static uint32_t lastPressTicks = 0;
- static uint32_t lastTicks = 0;
- static uint32_t nowTicks = 0;
-
- if ((m_HatId>=0) && m_pressTicksHat)
- {
- // return the id if it's the first press
- if (lastPressTicks!=m_pressTicksHat)
- {
- lastPressTicks = m_pressTicksHat;
- return true;
- }
- nowTicks = SDL_GetTicks();
- if ((nowTicks-m_pressTicksHat)<500) // 500ms delay before we repeat
- return false;
- if ((nowTicks-lastTicks)<100) // 100ms delay before successive repeats
- return false;
-
- lastTicks = nowTicks;
- }
-
- return true;
-}
-
-bool CJoystick::GetButton(int &id, bool consider_repeat)
-{
- if (!IsButtonActive())
- return false;
- if (!consider_repeat)
- {
- id = m_ButtonId;
- return true;
- }
-
- static uint32_t lastPressTicks = 0;
- static uint32_t lastTicks = 0;
- static uint32_t nowTicks = 0;
-
- if ((m_ButtonId>=0) && m_pressTicksButton)
- {
- // return the id if it's the first press
- if (lastPressTicks!=m_pressTicksButton)
- {
- lastPressTicks = m_pressTicksButton;
- id = m_ButtonId;
- return true;
- }
- nowTicks = SDL_GetTicks();
- if ((nowTicks-m_pressTicksButton)<500) // 500ms delay before we repeat
- {
- return false;
- }
- if ((nowTicks-lastTicks)<100) // 100ms delay before successive repeats
- {
- return false;
- }
- lastTicks = nowTicks;
- }
- id = m_ButtonId;
- return true;
-}
-
-int CJoystick::GetAxisWithMaxAmount()
-{
- static int maxAmount;
- static int axis;
- axis = 0;
- maxAmount = 0;
- int tempf;
- for (int i = 1 ; i<=m_NumAxes ; i++)
- {
- tempf = abs(m_Amount[i]);
- if (tempf>m_DeadzoneRange && tempf>maxAmount)
- {
- maxAmount = tempf;
- axis = i;
- }
- }
- SetAxisActive(0 != maxAmount);
- return axis;
-}
-
-float CJoystick::GetAmount(int axis)
-{
- if (m_Amount[axis] > m_DeadzoneRange)
- return (float)(m_Amount[axis]-m_DeadzoneRange)/(float)(MAX_AXISAMOUNT-m_DeadzoneRange);
- if (m_Amount[axis] < -m_DeadzoneRange)
- return (float)(m_Amount[axis]+m_DeadzoneRange)/(float)(MAX_AXISAMOUNT-m_DeadzoneRange);
- return 0;
-}
-
-float CJoystick::SetDeadzone(float val)
-{
- if (val<0) val=0;
- if (val>1) val=1;
- m_DeadzoneRange = (int)(val*MAX_AXISAMOUNT);
- return val;
-}
-
-#endif
diff --git a/guilib/common/SDLJoystick.h b/guilib/common/SDLJoystick.h
deleted file mode 100644
index 884f9beeb5..0000000000
--- a/guilib/common/SDLJoystick.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
-* Copyright (C) 2007-2010 Team XBMC
-* http://www.xbmc.org
-*
-* This Program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, 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 General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with XBMC; see the file COPYING. If not, write to
-* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-* http://www.gnu.org/copyleft/gpl.html
-*
-*/
-
-#ifndef SDL_JOYSTICK_H
-#define SDL_JOYSTICK_H
-
-#include "../system.h" // for HAS_SDL_JOYSTICK
-#include <vector>
-#include <string>
-
-#define JACTIVE_BUTTON 0x00000001
-#define JACTIVE_AXIS 0x00000002
-#define JACTIVE_HAT 0x00000004
-#define JACTIVE_NONE 0x00000000
-
-#ifdef HAS_SDL_JOYSTICK
-
-#include <SDL/SDL_joystick.h>
-#include <SDL/SDL_events.h>
-
-#define MAX_AXES 64
-#define MAX_AXISAMOUNT 32768
-
-
-// Class to manage all connected joysticks
-
-class CJoystick
-{
-public:
- CJoystick();
-
- void Initialize();
- void Reset(bool axis=false);
- void ResetAxis(int axisId) { m_Amount[axisId] = 0; }
- void Update();
- void Update(SDL_Event& event);
- bool GetButton (int& id, bool consider_repeat=true);
- bool GetAxis (int &id) { if (!IsAxisActive()) return false; id=m_AxisId; return true; }
- bool GetHat (int &id, int &position, bool consider_repeat=true);
- std::string GetJoystick() { return (m_JoyId>-1)?m_JoystickNames[m_JoyId]:""; }
- int GetAxisWithMaxAmount();
- float GetAmount(int axis);
- float GetAmount() { return GetAmount(m_AxisId); }
- float SetDeadzone(float val);
-
-private:
- void SetAxisActive(bool active=true) { m_ActiveFlags = active?(m_ActiveFlags|JACTIVE_AXIS):(m_ActiveFlags&(~JACTIVE_AXIS)); }
- void SetButtonActive(bool active=true) { m_ActiveFlags = active?(m_ActiveFlags|JACTIVE_BUTTON):(m_ActiveFlags&(~JACTIVE_BUTTON)); }
- void SetHatActive(bool active=true) { m_ActiveFlags = active?(m_ActiveFlags|JACTIVE_HAT):(m_ActiveFlags&(~JACTIVE_HAT)); }
- bool IsButtonActive() { return (m_ActiveFlags & JACTIVE_BUTTON) == JACTIVE_BUTTON; }
- bool IsAxisActive() { return (m_ActiveFlags & JACTIVE_AXIS) == JACTIVE_AXIS; }
- bool IsHatActive() { return (m_ActiveFlags & JACTIVE_HAT) == JACTIVE_HAT; }
-
- int m_Amount[MAX_AXES];
- int m_AxisId;
- int m_ButtonId;
- uint8_t m_HatState;
- int m_HatId;
- int m_JoyId;
- int m_NumAxes;
- int m_DeadzoneRange;
- uint32_t m_pressTicksButton;
- uint32_t m_pressTicksHat;
- uint8_t m_ActiveFlags;
- std::vector<SDL_Joystick*> m_Joysticks;
- std::vector<std::string> m_JoystickNames;
-};
-
-extern CJoystick g_Joystick;
-
-#endif
-
-#endif
diff --git a/guilib/gui3d.h b/guilib/gui3d.h
deleted file mode 100644
index 65c1c46c3c..0000000000
--- a/guilib/gui3d.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*!
-\file gui3d.h
-\brief
-*/
-
-#ifndef GUILIB_GUI3D_H
-#define GUILIB_GUI3D_H
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "system.h" // for WIN32 types
-
-#define GAMMA_RAMP_FLAG D3DSGR_CALIBRATE
-
-#define D3DPRESENTFLAG_INTERLACED 1
-#define D3DPRESENTFLAG_WIDESCREEN 2
-#define D3DPRESENTFLAG_PROGRESSIVE 4
-
-#define D3DFMT_LIN_A8R8G8B8 D3DFMT_A8R8G8B8
-#define D3DFMT_LIN_X8R8G8B8 D3DFMT_X8R8G8B8
-#define D3DFMT_LIN_L8 D3DFMT_L8
-#define D3DFMT_LIN_D16 D3DFMT_D16
-#define D3DFMT_LIN_A8 D3DFMT_A8
-
-#define D3DPIXELSHADERDEF DWORD
-
-struct D3DTexture
-{
- DWORD Common;
- DWORD Data;
- DWORD Lock;
-
- DWORD Format; // Format information about the texture.
- DWORD Size; // Size of a non power-of-2 texture, must be zero otherwise
-};
-
-#define D3DCOMMON_TYPE_MASK 0x0070000
-#define D3DCOMMON_TYPE_TEXTURE 0x0040000
-
-struct D3DPalette
-{
- DWORD Common;
- DWORD Data;
- DWORD Lock;
-};
-
-typedef D3DPalette* LPDIRECT3DPALETTE8;
-
-#if defined(HAS_GL) || defined(HAS_GLES)
-
-namespace XBMC
-{
- typedef void* DevicePtr;
- typedef GLuint SurfacePtr;
- typedef GLuint TexturePtr;
- typedef void* PalettePtr; // elis change it
- typedef GLint PixelFormat; // elis change it
-}
-
-#if defined(_LINUX) && !defined(GL_GLEXT_PROTOTYPES)
-#define GL_GLEXT_PROTOTYPES
-#endif
-
-#endif // HAS_GL
-
-#ifdef HAS_DX
-
-namespace XBMC
-{
- typedef LPDIRECT3DDEVICE9 DevicePtr;
- typedef LPDIRECT3DTEXTURE9 TexturePtr;
- typedef LPDIRECT3DSURFACE9 SurfacePtr;
- typedef LPDIRECT3DPALETTE8 PalettePtr;
-};
-
-#define DELETE_TEXTURE(texture) texture->Release()
-
-#endif // HAS_DX
-
-#ifdef HAS_GLES
-
-#define GLchar char
-
-#endif
-#endif // GUILIB_GUI3D_H
diff --git a/guilib/guilib_win32.vcproj b/guilib/guilib_win32.vcproj
deleted file mode 100644
index 4837e2253d..0000000000
--- a/guilib/guilib_win32.vcproj
+++ /dev/null
@@ -1,772 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="7.10"
- Name="guilib"
- ProjectGUID="{510441AC-B9E1-4B31-9C0C-EB3AD39D90C4}"
- RootNamespace="guilib"
- Keyword="Win32Proj">
- <Platforms>
- <Platform
- Name="Win32"/>
- </Platforms>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="Debug (Win32)"
- IntermediateDirectory="Debug (Win32)"
- ConfigurationType="4"
- CharacterSet="2">
- <Tool
- Name="VCCLCompilerTool"
- AdditionalOptions="/EHa"
- Optimization="0"
- AdditionalIncludeDirectories="../xbmc/;freetype2/include;../xbmc/lib/boost"
- PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_MSVC;NOMINMAX;_WIN32_WINNT=0x0501;WINVER=0x0500"
- StringPooling="FALSE"
- MinimalRebuild="TRUE"
- ExceptionHandling="FALSE"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="include.h"
- WarningLevel="3"
- Detect64BitPortabilityProblems="FALSE"
- DebugInformationFormat="4"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)/guilib.lib"/>
- <Tool
- Name="VCMIDLTool"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCXMLDataGeneratorTool"/>
- <Tool
- Name="VCManagedWrapperGeneratorTool"/>
- <Tool
- Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release (Win32)"
- IntermediateDirectory="Release (Win32)"
- ConfigurationType="4"
- CharacterSet="2">
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="../xbmc/;freetype2/include;../xbmc/lib/boost"
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_MSVC;NOMINMAX;_WIN32_WINNT=0x0501;WINVER=0x0500"
- RuntimeLibrary="0"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="include.h"
- WarningLevel="3"
- Detect64BitPortabilityProblems="FALSE"
- DebugInformationFormat="3"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)/guilib.lib"
- IgnoreDefaultLibraryNames=""/>
- <Tool
- Name="VCMIDLTool"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCXMLDataGeneratorTool"/>
- <Tool
- Name="VCManagedWrapperGeneratorTool"/>
- <Tool
- Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
- </Configuration>
- <Configuration
- Name="Debug (SDL)|Win32"
- OutputDirectory="$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="4"
- CharacterSet="2">
- <Tool
- Name="VCCLCompilerTool"
- AdditionalOptions="/EHa"
- Optimization="0"
- AdditionalIncludeDirectories="../guilib;../xbmc/Win32;../xbmc/;freetype2/include;../xbmc/lib/boost;../xbmc/utils;&quot;../xbmc/lib/libSDL-WIN32/include&quot;"
- PreprocessorDefinitions="WIN32;_DEBUG;_LIB;HAS_SDL;_MSVC;NOMINMAX;_WIN32_WINNT=0x0501;WINVER=0x0500"
- StringPooling="FALSE"
- MinimalRebuild="TRUE"
- ExceptionHandling="FALSE"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
- EnableEnhancedInstructionSet="0"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="include.h"
- WarningLevel="3"
- Detect64BitPortabilityProblems="FALSE"
- DebugInformationFormat="4"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)/guilib.lib"/>
- <Tool
- Name="VCMIDLTool"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCXMLDataGeneratorTool"/>
- <Tool
- Name="VCManagedWrapperGeneratorTool"/>
- <Tool
- Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
- </Configuration>
- <Configuration
- Name="Release (SDL)|Win32"
- OutputDirectory="$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="4"
- CharacterSet="2">
- <Tool
- Name="VCCLCompilerTool"
- GlobalOptimizations="TRUE"
- FavorSizeOrSpeed="1"
- AdditionalIncludeDirectories="../guilib;../xbmc/win32;../xbmc;freetype2\include;../xbmc/lib/boost;../xbmc/utils;&quot;../xbmc/lib/libSDL-WIN32/include&quot;"
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB;HAS_SDL;_MSVC;NOMINMAX;_WIN32_WINNT=0x0501;WINVER=0x0500"
- MinimalRebuild="FALSE"
- RuntimeLibrary="0"
- EnableEnhancedInstructionSet="2"
- UsePrecompiledHeader="2"
- PrecompiledHeaderThrough="include.h"
- WarningLevel="3"
- Detect64BitPortabilityProblems="FALSE"
- DebugInformationFormat="0"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)/guilib.lib"
- AdditionalLibraryDirectories=""
- IgnoreAllDefaultLibraries="FALSE"
- IgnoreDefaultLibraryNames=""/>
- <Tool
- Name="VCMIDLTool"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCXMLDataGeneratorTool"/>
- <Tool
- Name="VCManagedWrapperGeneratorTool"/>
- <Tool
- Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
- <File
- RelativePath=".\AnimatedGif.cpp">
- </File>
- <File
- RelativePath=".\AudioContext.cpp">
- </File>
- <File
- RelativePath=".\DirectXGraphics.cpp">
- </File>
- <File
- RelativePath=".\FrameBufferObject.cpp">
- </File>
- <File
- RelativePath=".\GraphicContext.cpp">
- </File>
- <File
- RelativePath=".\GUIAudioManager.cpp">
- </File>
- <File
- RelativePath=".\GUIBaseContainer.cpp">
- </File>
- <File
- RelativePath=".\GUIBorderedImage.cpp">
- </File>
- <File
- RelativePath=".\GUIButtonControl.cpp">
- </File>
- <File
- RelativePath=".\GUIButtonScroller.cpp">
- </File>
- <File
- RelativePath=".\GUICheckMarkControl.cpp">
- </File>
- <File
- RelativePath=".\GUIColorManager.cpp">
- </File>
- <File
- RelativePath=".\GUIControl.cpp">
- </File>
- <File
- RelativePath=".\GuiControlFactory.cpp">
- </File>
- <File
- RelativePath=".\GUIControlGroup.cpp">
- </File>
- <File
- RelativePath=".\GUIControlGroupList.cpp">
- </File>
- <File
- RelativePath=".\GUIDialog.cpp">
- </File>
- <File
- RelativePath=".\GUIEditControl.cpp">
- </File>
- <File
- RelativePath=".\GUIFadeLabelControl.cpp">
- </File>
- <File
- RelativePath=".\GUIFixedListContainer.cpp">
- </File>
- <File
- RelativePath=".\GUIFont.cpp">
- </File>
- <File
- RelativePath=".\GUIFontManager.cpp">
- </File>
- <File
- RelativePath=".\GUIFontTTF.cpp">
- </File>
- <File
- RelativePath=".\guiImage.cpp">
- </File>
- <File
- RelativePath=".\GUIIncludes.cpp">
- </File>
- <File
- RelativePath=".\GUIInfoColor.cpp">
- </File>
- <File
- RelativePath=".\GUILabelControl.cpp">
- </File>
- <File
- RelativePath=".\GUIListContainer.cpp">
- </File>
- <File
- RelativePath=".\GUIListGroup.cpp">
- </File>
- <File
- RelativePath=".\GUIListItem.cpp">
- </File>
- <File
- RelativePath=".\GUIListItemLayout.cpp">
- </File>
- <File
- RelativePath=".\GUIListLabel.cpp">
- </File>
- <File
- RelativePath=".\GUIMessage.cpp">
- </File>
- <File
- RelativePath=".\GUIMoverControl.cpp">
- </File>
- <File
- RelativePath=".\GUIMultiImage.cpp">
- </File>
- <File
- RelativePath=".\GUIMultiSelectText.cpp">
- </File>
- <File
- RelativePath=".\GUIPanelContainer.cpp">
- </File>
- <File
- RelativePath=".\GUIProgressControl.cpp">
- </File>
- <File
- RelativePath=".\GUIRadioButtonControl.cpp">
- </File>
- <File
- RelativePath=".\GUIResizeControl.cpp">
- </File>
- <File
- RelativePath=".\GUIRSSControl.cpp">
- </File>
- <File
- RelativePath=".\GUIScrollBarControl.cpp">
- </File>
- <File
- RelativePath=".\GUISelectButtonControl.cpp">
- </File>
- <File
- RelativePath=".\GUISettingsSliderControl.cpp">
- </File>
- <File
- RelativePath=".\GUISliderControl.cpp">
- </File>
- <File
- RelativePath=".\GUISound.cpp">
- </File>
- <File
- RelativePath=".\GUISpinControl.cpp">
- </File>
- <File
- RelativePath=".\GUISpinControlEx.cpp">
- </File>
- <File
- RelativePath=".\GUIStandardWindow.cpp">
- </File>
- <File
- RelativePath=".\GUITextBox.cpp">
- </File>
- <File
- RelativePath=".\GUITextLayout.cpp">
- </File>
- <File
- RelativePath=".\GUITexture.cpp">
- </File>
- <File
- RelativePath=".\GUITextureD3D.cpp">
- </File>
- <File
- RelativePath=".\GUITextureGL.cpp">
- </File>
- <File
- RelativePath=".\GUITextureSDL.cpp">
- </File>
- <File
- RelativePath=".\GUIToggleButtonControl.cpp">
- </File>
- <File
- RelativePath=".\GUIVideoControl.cpp">
- </File>
- <File
- RelativePath=".\GUIVisualisationControl.cpp">
- </File>
- <File
- RelativePath=".\GUIWindow.cpp">
- </File>
- <File
- RelativePath=".\GUIWindowManager.cpp">
- </File>
- <File
- RelativePath=".\GUIWrappingListContainer.cpp">
- </File>
- <File
- RelativePath=".\include.cpp">
- </File>
- <File
- RelativePath=".\IWindowManagerCallback.cpp">
- </File>
- <File
- RelativePath=".\Key.cpp">
- </File>
- <File
- RelativePath=".\LocalizeStrings.cpp">
- </File>
- <File
- RelativePath=".\Shader.cpp">
- </File>
- <File
- RelativePath=".\SkinInfo.cpp">
- </File>
- <File
- RelativePath=".\Surface.cpp">
- </File>
- <File
- RelativePath=".\TextureBundle.cpp">
- </File>
- <File
- RelativePath=".\TextureManager.cpp">
- </File>
- <File
- RelativePath=".\VisibleEffect.cpp">
- </File>
- <File
- RelativePath=".\XMLUtils.cpp">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
- <File
- RelativePath=".\AnimatedGif.h">
- </File>
- <File
- RelativePath=".\AudioContext.h">
- </File>
- <File
- RelativePath=".\DirectXGraphics.h">
- </File>
- <File
- RelativePath=".\FrameBufferObject.h">
- </File>
- <File
- RelativePath=".\Geometry.h">
- </File>
- <File
- RelativePath=".\GraphicContext.h">
- </File>
- <File
- RelativePath=".\gui3d.h">
- </File>
- <File
- RelativePath=".\GUIAudioManager.h">
- </File>
- <File
- RelativePath=".\GUIBaseContainer.h">
- </File>
- <File
- RelativePath=".\GUIBorderedImage.h">
- </File>
- <File
- RelativePath=".\GUIButtonControl.h">
- </File>
- <File
- RelativePath=".\GUIButtonScroller.h">
- </File>
- <File
- RelativePath=".\GUICallback.h">
- </File>
- <File
- RelativePath=".\GUICheckMarkControl.h">
- </File>
- <File
- RelativePath=".\GUIColorManager.h">
- </File>
- <File
- RelativePath=".\GUIControl.h">
- </File>
- <File
- RelativePath=".\GuiControlFactory.h">
- </File>
- <File
- RelativePath=".\GUIControlGroup.h">
- </File>
- <File
- RelativePath=".\GUIControlGroupList.h">
- </File>
- <File
- RelativePath=".\GUIDialog.h">
- </File>
- <File
- RelativePath=".\GUIEditControl.h">
- </File>
- <File
- RelativePath=".\GUIFadeLabelControl.h">
- </File>
- <File
- RelativePath=".\GUIFixedListContainer.h">
- </File>
- <File
- RelativePath=".\GUIFont.h">
- </File>
- <File
- RelativePath=".\GUIFontManager.h">
- </File>
- <File
- RelativePath=".\GUIFontTTF.h">
- </File>
- <File
- RelativePath=".\guiImage.h">
- </File>
- <File
- RelativePath=".\GUIIncludes.h">
- </File>
- <File
- RelativePath=".\GUIInfoColor.h">
- </File>
- <File
- RelativePath=".\GUILabelControl.h">
- </File>
- <File
- RelativePath=".\GUIListContainer.h">
- </File>
- <File
- RelativePath=".\GUIListGroup.h">
- </File>
- <File
- RelativePath=".\GUIListItem.h">
- </File>
- <File
- RelativePath=".\GUIListItemLayout.h">
- </File>
- <File
- RelativePath=".\GUIListLabel.h">
- </File>
- <File
- RelativePath=".\GUIMessage.h">
- </File>
- <File
- RelativePath=".\GUIMoverControl.h">
- </File>
- <File
- RelativePath=".\GUIMultiImage.h">
- </File>
- <File
- RelativePath=".\GUIMultiSelectText.h">
- </File>
- <File
- RelativePath=".\GUIPanelContainer.h">
- </File>
- <File
- RelativePath=".\GUIProgressControl.h">
- </File>
- <File
- RelativePath=".\GUIRadioButtonControl.h">
- </File>
- <File
- RelativePath=".\GUIResizeControl.h">
- </File>
- <File
- RelativePath=".\GUIRSSControl.h">
- </File>
- <File
- RelativePath=".\GUIScrollBarControl.h">
- </File>
- <File
- RelativePath=".\GUISelectButtonControl.h">
- </File>
- <File
- RelativePath=".\GUISettingsSliderControl.h">
- </File>
- <File
- RelativePath=".\GUISliderControl.h">
- </File>
- <File
- RelativePath=".\GUISound.h">
- </File>
- <File
- RelativePath=".\GUISpinControl.h">
- </File>
- <File
- RelativePath=".\GUISpinControlEx.h">
- </File>
- <File
- RelativePath=".\GUIStandardWindow.h">
- </File>
- <File
- RelativePath=".\GUITextBox.h">
- </File>
- <File
- RelativePath=".\GUITextLayout.h">
- </File>
- <File
- RelativePath=".\GUITexture.h">
- </File>
- <File
- RelativePath=".\GUITextureD3D.h">
- </File>
- <File
- RelativePath=".\GUITextureGL.h">
- </File>
- <File
- RelativePath=".\GUITextureSDL.h">
- </File>
- <File
- RelativePath=".\GUIToggleButtonControl.h">
- </File>
- <File
- RelativePath=".\GUIVideoControl.h">
- </File>
- <File
- RelativePath=".\GUIVisualisationControl.h">
- </File>
- <File
- RelativePath=".\GUIWindow.h">
- </File>
- <File
- RelativePath=".\GUIWindowManager.h">
- </File>
- <File
- RelativePath=".\GUIWrappingListContainer.h">
- </File>
- <File
- RelativePath=".\IAudioDeviceChangedCallback.h">
- </File>
- <File
- RelativePath=".\IMsgSenderCallback.h">
- </File>
- <File
- RelativePath=".\IMsgTargetCallback.h">
- </File>
- <File
- RelativePath=".\include.h">
- </File>
- <File
- RelativePath=".\IWindowManagerCallback.h">
- </File>
- <File
- RelativePath=".\Key.h">
- </File>
- <File
- RelativePath=".\LocalizeStrings.h">
- </File>
- <File
- RelativePath=".\Shader.h">
- </File>
- <File
- RelativePath=".\SkinInfo.h">
- </File>
- <File
- RelativePath=".\StdString.h">
- </File>
- <File
- RelativePath=".\Surface.h">
- </File>
- <File
- RelativePath=".\system.h">
- </File>
- <File
- RelativePath=".\TextureBundle.h">
- </File>
- <File
- RelativePath=".\TextureManager.h">
- </File>
- <File
- RelativePath=".\TransformMatrix.h">
- </File>
- <File
- RelativePath=".\Tween.h">
- </File>
- <File
- RelativePath=".\VisibleEffect.h">
- </File>
- <File
- RelativePath=".\XMLUtils.h">
- </File>
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
- </Filter>
- <Filter
- Name="tinyxml"
- Filter="">
- <File
- RelativePath=".\tinyXML\tinystr.cpp">
- </File>
- <File
- RelativePath=".\tinyXML\tinystr.h">
- </File>
- <File
- RelativePath=".\tinyXML\tinyxml.cpp">
- </File>
- <File
- RelativePath=".\tinyXML\tinyxml.h">
- </File>
- <File
- RelativePath=".\tinyXML\tinyxmlerror.cpp">
- </File>
- <File
- RelativePath=".\tinyXML\tinyxmlparser.cpp">
- </File>
- </Filter>
- <Filter
- Name="common"
- Filter="">
- <File
- RelativePath=".\common\DirectInput.cpp">
- </File>
- <File
- RelativePath=".\common\DirectInput.h">
- </File>
- <File
- RelativePath=".\common\DirectInputKeyboard.cpp">
- </File>
- <File
- RelativePath=".\common\DirectInputKeyboard.h">
- </File>
- <File
- RelativePath=".\common\DirectInputMouse.cpp">
- </File>
- <File
- RelativePath=".\common\DirectInputMouse.h">
- </File>
- <File
- RelativePath=".\common\Keyboard.cpp">
- </File>
- <File
- RelativePath=".\common\Keyboard.h">
- </File>
- <File
- RelativePath=".\common\Mouse.cpp">
- </File>
- <File
- RelativePath=".\common\Mouse.h">
- </File>
- <File
- RelativePath=".\common\SDLJoystick.cpp">
- </File>
- <File
- RelativePath=".\common\SDLJoystick.h">
- </File>
- <File
- RelativePath=".\common\SDLKeyboard.cpp">
- </File>
- <File
- RelativePath=".\common\SDLKeyboard.h">
- </File>
- <File
- RelativePath=".\common\SDLMouse.cpp">
- </File>
- <File
- RelativePath=".\common\SDLMouse.h">
- </File>
- <Filter
- Name="IRServerSuite"
- Filter="">
- <File
- RelativePath=".\common\IRServerSuite\IRServerSuite.cpp">
- </File>
- <File
- RelativePath=".\common\IRServerSuite\IRServerSuite.h">
- </File>
- <File
- RelativePath=".\common\IRServerSuite\IrssMessage.cpp">
- </File>
- <File
- RelativePath=".\common\IRServerSuite\IrssMessage.h">
- </File>
- </Filter>
- </Filter>
- <File
- RelativePath=".\ReadMe.txt">
- </File>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/guilib/system.h b/guilib/system.h
deleted file mode 100644
index 7ad7a1cfeb..0000000000
--- a/guilib/system.h
+++ /dev/null
@@ -1,262 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#if defined(HAVE_CONFIG_H) && !defined(_WIN32)
-#include "../config.h"
-#endif
-
-/*****************
- * All platforms
- *****************/
-#ifndef HAS_SDL
-#define HAS_SDL
-#endif
-
-#define HAS_DVD_SWSCALE
-#define HAS_DVDPLAYER
-#define HAS_EVENT_SERVER
-#define HAS_KARAOKE
-#define HAS_SCREENSAVER
-#define HAS_PYTHON
-#define HAS_SYSINFO
-#define HAS_UPNP
-#define HAS_VIDEO_PLAYBACK
-#define HAS_VISUALISATION
-
-#ifdef HAVE_LIBMICROHTTPD
-#define HAS_WEB_SERVER
-#define HAS_WEB_INTERFACE
-#endif
-
-#define HAS_JSONRPC
-#define HAS_HTTPAPI
-
-#ifdef USE_ASAP_CODEC
-#define HAS_ASAP_CODEC
-#endif
-
-#define HAS_FILESYSTEM
-#define HAS_FILESYSTEM_SMB
-#define HAS_FILESYSTEM_CDDA
-#define HAS_FILESYSTEM_RTV
-#define HAS_FILESYSTEM_DAAP
-#define HAS_FILESYSTEM_SAP
-#define HAS_FILESYSTEM_VTP
-#define HAS_FILESYSTEM_HTSP
-#define HAS_FILESYSTEM_MMS
-
-/**********************
- * Non-free Components
- **********************/
-
-#if defined(_LINUX) || defined(__APPLE__)
- #if defined(HAVE_XBMC_NONFREE)
- #define HAS_FILESYSTEM_RAR
- #define HAS_FILESYSTEM_CCX
- #endif
-#else
- #define HAS_FILESYSTEM_RAR
- #define HAS_FILESYSTEM_CCX
-#endif
-
-/*****************
- * Win32 Specific
- *****************/
-
-#ifdef _WIN32
-#define HAS_DVD_DRIVE
-#define HAS_SDL_JOYSTICK
-#define HAS_WIN32_NETWORK
-#define HAS_IRSERVERSUITE
-#define HAS_AUDIO
-#define HAVE_LIBCRYSTALHD 1
-#define HAS_WEB_SERVER
-#define HAS_WEB_INTERFACE
-#define HAVE_LIBSSH
-#define HAS_LIBRTMP
-#define HAVE_LIBBLURAY
-#endif
-
-/*****************
- * Mac Specific
- *****************/
-
-#ifdef __APPLE__
-#define HAS_ZEROCONF
-#define HAS_GL
-#define HAS_LINUX_NETWORK
-#define HAS_SDL_AUDIO
-#define HAS_SDL_OPENGL
-#define HAS_SDL_WIN_EVENTS
-#endif
-
-/*****************
- * Linux Specific
- *****************/
-
-#if defined(_LINUX) && !defined(__APPLE__)
-#ifndef HAS_SDL_OPENGL
-#define HAS_SDL_OPENGL
-#endif
-#if defined(HAVE_LIBAVAHI_COMMON) && defined(HAVE_LIBAVAHI_CLIENT)
-#define HAS_ZEROCONF
-#define HAS_AVAHI
-#endif
-#define HAS_LCD
-#define HAS_DBUS
-#define HAS_DBUS_SERVER
-#define HAS_GL
-#define HAS_GLX
-#define HAS_LINUX_NETWORK
-#define HAS_SDL_AUDIO
-#define HAS_LIRC
-#define HAS_SDL_WIN_EVENTS
-#ifdef HAVE_LIBPULSE
-#define HAS_PULSEAUDIO
-#endif
-#ifdef HAVE_LIBXRANDR
-#define HAS_XRANDR
-#endif
-#endif
-
-#ifdef HAVE_LIBSSH
-#define HAS_FILESYSTEM_SFTP
-#endif
-
-/*****************
- * Git revision
- *****************/
-
-#ifdef __APPLE__
-#include "../git_revision.h"
-#endif
-
-#ifndef GIT_REV
-#define GIT_REV "Unknown"
-#endif
-
-/****************************************
- * Additional platform specific includes
- ****************************************/
-
-#ifdef _WIN32
-#if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H))
-#include <winsock2.h>
-#endif
-#include <windows.h>
-#define DIRECTINPUT_VERSION 0x0800
-#include "mmsystem.h"
-#include "DInput.h"
-#include "DSound.h"
-#define DSSPEAKER_USE_DEFAULT DSSPEAKER_STEREO
-#define LPDIRECTSOUND8 LPDIRECTSOUND
-#undef GetFreeSpace
-#include "PlatformInclude.h"
-#include "D3D9.h" // On Win32, we're always using DirectX for something, whether it be the actual rendering
-#include "D3DX9.h" // or the reference video clock.
-#ifdef HAS_SDL
-#include "SDL\SDL.h"
-#endif
-#endif
-
-#ifdef _LINUX
-#include <unistd.h>
-#include <time.h>
-#include <sys/time.h>
-#include <netdb.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <errno.h>
-#include "PlatformInclude.h"
-#endif
-
-// ARM does not support certain features... disable them here!
-#ifdef _ARMEL
-#undef HAS_AVAHI
-#undef HAS_ZEROCONF
-#undef HAS_VISUALISATION
-#undef HAS_FILESYSTEM_HTSP
-#endif
-
-// EGL detected. Dont use GLX!
-#ifdef HAVE_LIBEGL
-#undef HAS_GLX
-#define HAS_EGL
-#endif
-
-// GLES2.0 detected. Dont use GL!
-#ifdef HAVE_LIBGLESV2
-#undef HAS_GL
-#define HAS_GLES 2
-#endif
-
-// GLES1.0 detected. Dont use GL!
-#ifdef HAVE_LIBGLES
-#undef HAS_GL
-#define HAS_GLES 1
-#endif
-
-
-#ifdef HAS_GL
-#ifdef _WIN32
-#include "GL/glew.h"
-#include <GL/gl.h>
-#include <GL/glu.h>
-//#include <GL/wglext.h>
-#elif defined(__APPLE__)
-#include <GL/glew.h>
-#include <OpenGL/gl.h>
-#elif defined(_LINUX)
-#include <GL/glew.h>
-#include <GL/gl.h>
-#endif
-#endif
-
-#if HAS_GLES == 2
-#ifdef _ARMEL // PowerVR SGX Header
-// not sure about this one tg2 (arm) does not have gl2extimg.h
-//#include <GLES2/gl2extimg.h>
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-#else
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-#endif
-#endif
-
-#ifdef HAS_DVD_DRIVE
-#define HAS_CDDA_RIPPER
-#endif
-
-#define SAFE_DELETE(p) { delete (p); (p)=NULL; }
-#define SAFE_DELETE_ARRAY(p) { delete[] (p); (p)=NULL; }
-#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
-
-// Useful pixel colour manipulation macros
-#define GET_A(color) ((color >> 24) & 0xFF)
-#define GET_R(color) ((color >> 16) & 0xFF)
-#define GET_G(color) ((color >> 8) & 0xFF)
-#define GET_B(color) ((color >> 0) & 0xFF)
-
diff --git a/guilib/tinyXML/Makefile b/guilib/tinyXML/Makefile
deleted file mode 100644
index cdb40e5201..0000000000
--- a/guilib/tinyXML/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-INCLUDES=-I. -I../ -I../../xbmc -I../../xbmc/linux -I../../xbmc/utils
-SRCS=tinystr.cpp tinyxml.cpp tinyxmlerror.cpp tinyxmlparser.cpp
-LIB=tinyxml.a
-
-include ../../Makefile.include
--include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS)))
diff --git a/guilib/tinyXML/tinystr.cpp b/guilib/tinyXML/tinystr.cpp
deleted file mode 100644
index 681250714b..0000000000
--- a/guilib/tinyXML/tinystr.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
-www.sourceforge.net/projects/tinyxml
-Original file by Yves Berquin.
-
-This software is provided 'as-is', without any express or implied
-warranty. In no event will the authors be held liable for any
-damages arising from the use of this software.
-
-Permission is granted to anyone to use this software for any
-purpose, including commercial applications, and to alter it and
-redistribute it freely, subject to the following restrictions:
-
-1. The origin of this software must not be misrepresented; you must
-not claim that you wrote the original software. If you use this
-software in a product, an acknowledgment in the product documentation
-would be appreciated but is not required.
-
-2. Altered source versions must be plainly marked as such, and
-must not be misrepresented as being the original software.
-
-3. This notice may not be removed or altered from any source
-distribution.
-*/
-
-/*
- * THIS FILE WAS ALTERED BY Tyge Løvset, 7. April 2005.
- */
-
-
-#ifndef TIXML_USE_STL
-
-#include "tinystr.h"
-
-// Error value for find primitive
-const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1);
-
-
-// Null rep.
-TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } };
-
-
-void TiXmlString::reserve (size_type cap)
-{
- if (cap > capacity())
- {
- TiXmlString tmp;
- tmp.init(length(), cap);
- memcpy(tmp.start(), data(), length());
- swap(tmp);
- }
-}
-
-
-TiXmlString& TiXmlString::assign(const char* str, size_type len)
-{
- size_type cap = capacity();
- if (len > cap || cap > 3*(len + 8))
- {
- TiXmlString tmp;
- tmp.init(len);
- memcpy(tmp.start(), str, len);
- swap(tmp);
- }
- else
- {
- memmove(start(), str, len);
- set_size(len);
- }
- return *this;
-}
-
-
-TiXmlString& TiXmlString::append(const char* str, size_type len)
-{
- size_type newsize = length() + len;
- if (newsize > capacity())
- {
- reserve (newsize + capacity());
- }
- memmove(finish(), str, len);
- set_size(newsize);
- return *this;
-}
-
-
-TiXmlString operator + (const TiXmlString & a, const TiXmlString & b)
-{
- TiXmlString tmp;
- tmp.reserve(a.length() + b.length());
- tmp += a;
- tmp += b;
- return tmp;
-}
-
-TiXmlString operator + (const TiXmlString & a, const char* b)
-{
- TiXmlString tmp;
- TiXmlString::size_type b_len = static_cast<TiXmlString::size_type>( strlen(b) );
- tmp.reserve(a.length() + b_len);
- tmp += a;
- tmp.append(b, b_len);
- return tmp;
-}
-
-TiXmlString operator + (const char* a, const TiXmlString & b)
-{
- TiXmlString tmp;
- TiXmlString::size_type a_len = static_cast<TiXmlString::size_type>( strlen(a) );
- tmp.reserve(a_len + b.length());
- tmp.append(a, a_len);
- tmp += b;
- return tmp;
-}
-
-
-#endif // TIXML_USE_STL
diff --git a/guilib/tinyXML/tinystr.h b/guilib/tinyXML/tinystr.h
deleted file mode 100644
index 3c2aa9d54d..0000000000
--- a/guilib/tinyXML/tinystr.h
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
-www.sourceforge.net/projects/tinyxml
-Original file by Yves Berquin.
-
-This software is provided 'as-is', without any express or implied
-warranty. In no event will the authors be held liable for any
-damages arising from the use of this software.
-
-Permission is granted to anyone to use this software for any
-purpose, including commercial applications, and to alter it and
-redistribute it freely, subject to the following restrictions:
-
-1. The origin of this software must not be misrepresented; you must
-not claim that you wrote the original software. If you use this
-software in a product, an acknowledgment in the product documentation
-would be appreciated but is not required.
-
-2. Altered source versions must be plainly marked as such, and
-must not be misrepresented as being the original software.
-
-3. This notice may not be removed or altered from any source
-distribution.
-*/
-
-/*
- * THIS FILE WAS ALTERED BY Tyge Lovset, 7. April 2005.
- *
- * - completely rewritten. compact, clean, and fast implementation.
- * - sizeof(TiXmlString) = pointer size (4 bytes on 32-bit systems)
- * - fixed reserve() to work as per specification.
- * - fixed buggy compares operator==(), operator<(), and operator>()
- * - fixed operator+=() to take a const ref argument, following spec.
- * - added "copy" constructor with length, and most compare operators.
- * - added swap(), clear(), size(), capacity(), operator+().
- */
-
-#ifndef TIXML_USE_STL
-
-#ifndef TIXML_STRING_INCLUDED
-#define TIXML_STRING_INCLUDED
-
-#include <assert.h>
-#include <string.h>
-
-/* The support for explicit isn't that universal, and it isn't really
- required - it is used to check that the TiXmlString class isn't incorrectly
- used. Be nice to old compilers and macro it here:
-*/
-#if defined(_MSC_VER) && (_MSC_VER >= 1200 )
- // Microsoft visual studio, version 6 and higher.
- #define TIXML_EXPLICIT explicit
-#elif defined(__GNUC__) && (__GNUC__ >= 3 )
- // GCC version 3 and higher.s
- #define TIXML_EXPLICIT explicit
-#else
- #define TIXML_EXPLICIT
-#endif
-
-
-/*
- TiXmlString is an emulation of a subset of the std::string template.
- Its purpose is to allow compiling TinyXML on compilers with no or poor STL support.
- Only the member functions relevant to the TinyXML project have been implemented.
- The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase
- a string and there's no more room, we allocate a buffer twice as big as we need.
-*/
-class TiXmlString
-{
- public :
- // The size type used
- typedef size_t size_type;
-
- // Error value for find primitive
- static const size_type npos; // = -1;
-
-
- // TiXmlString empty constructor
- TiXmlString () : rep_(&nullrep_)
- {
- }
-
- // TiXmlString copy constructor
- TiXmlString ( const TiXmlString & copy) : rep_(0)
- {
- init(copy.length());
- memcpy(start(), copy.data(), length());
- }
-
- // TiXmlString constructor, based on a string
- TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0)
- {
- init( static_cast<size_type>( strlen(copy) ));
- memcpy(start(), copy, length());
- }
-
- // TiXmlString constructor, based on a string
- TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0)
- {
- init(len);
- memcpy(start(), str, len);
- }
-
- // TiXmlString destructor
- ~TiXmlString ()
- {
- quit();
- }
-
- // = operator
- TiXmlString& operator = (const char * copy)
- {
- return assign( copy, (size_type)strlen(copy));
- }
-
- // = operator
- TiXmlString& operator = (const TiXmlString & copy)
- {
- return assign(copy.start(), copy.length());
- }
-
-
- // += operator. Maps to append
- TiXmlString& operator += (const char * suffix)
- {
- return append(suffix, static_cast<size_type>( strlen(suffix) ));
- }
-
- // += operator. Maps to append
- TiXmlString& operator += (char single)
- {
- return append(&single, 1);
- }
-
- // += operator. Maps to append
- TiXmlString& operator += (const TiXmlString & suffix)
- {
- return append(suffix.data(), suffix.length());
- }
-
-
- // Convert a TiXmlString into a null-terminated char *
- const char * c_str () const { return rep_->str; }
-
- // Convert a TiXmlString into a char * (need not be null terminated).
- const char * data () const { return rep_->str; }
-
- // Return the length of a TiXmlString
- size_type length () const { return rep_->size; }
-
- // Alias for length()
- size_type size () const { return rep_->size; }
-
- // Checks if a TiXmlString is empty
- bool empty () const { return rep_->size == 0; }
-
- // Return capacity of string
- size_type capacity () const { return rep_->capacity; }
-
-
- // single char extraction
- const char& at (size_type index) const
- {
- assert( index < length() );
- return rep_->str[ index ];
- }
-
- // [] operator
- char& operator [] (size_type index) const
- {
- assert( index < length() );
- return rep_->str[ index ];
- }
-
- // find a char in a string. Return TiXmlString::npos if not found
- size_type find (char lookup) const
- {
- return find(lookup, 0);
- }
-
- // find a char in a string from an offset. Return TiXmlString::npos if not found
- size_type find (char tofind, size_type offset) const
- {
- if (offset >= length()) return npos;
-
- for (const char* p = c_str() + offset; *p != '\0'; ++p)
- {
- if (*p == tofind) return static_cast< size_type >( p - c_str() );
- }
- return npos;
- }
-
- void clear ()
- {
- //Lee:
- //The original was just too strange, though correct:
- // TiXmlString().swap(*this);
- //Instead use the quit & re-init:
- quit();
- init(0,0);
- }
-
- /* Function to reserve a big amount of data when we know we'll need it. Be aware that this
- function DOES NOT clear the content of the TiXmlString if any exists.
- */
- void reserve (size_type cap);
-
- TiXmlString& assign (const char* str, size_type len);
-
- TiXmlString& append (const char* str, size_type len);
-
- void swap (TiXmlString& other)
- {
- Rep* r = rep_;
- rep_ = other.rep_;
- other.rep_ = r;
- }
-
- private:
-
- void init(size_type sz) { init(sz, sz); }
- void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; }
- char* start() const { return rep_->str; }
- char* finish() const { return rep_->str + rep_->size; }
-
- struct Rep
- {
- size_type size, capacity;
- char str[1];
- };
-
- void init(size_type sz, size_type cap)
- {
- if (cap)
- {
- // Lee: the original form:
- // rep_ = static_cast<Rep*>(operator new(sizeof(Rep) + cap));
- // doesn't work in some cases of new being overloaded. Switching
- // to the normal allocation, although use an 'int' for systems
- // that are overly picky about structure alignment.
- const size_type bytesNeeded = sizeof(Rep) + cap;
- const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int );
- rep_ = reinterpret_cast<Rep*>( new int[ intsNeeded ] );
-
- rep_->str[ rep_->size = sz ] = '\0';
- rep_->capacity = cap;
- }
- else
- {
- rep_ = &nullrep_;
- }
- }
-
- void quit()
- {
- if (rep_ != &nullrep_)
- {
- // The rep_ is really an array of ints. (see the allocator, above).
- // Cast it back before delete, so the compiler won't incorrectly call destructors.
- delete [] ( reinterpret_cast<int*>( rep_ ) );
- }
- }
-
- Rep * rep_;
- static Rep nullrep_;
-
-} ;
-
-
-inline bool operator == (const TiXmlString & a, const TiXmlString & b)
-{
- return ( a.length() == b.length() ) // optimization on some platforms
- && ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare
-}
-inline bool operator < (const TiXmlString & a, const TiXmlString & b)
-{
- return strcmp(a.c_str(), b.c_str()) < 0;
-}
-
-inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); }
-inline bool operator > (const TiXmlString & a, const TiXmlString & b) { return b < a; }
-inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); }
-inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); }
-
-inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; }
-inline bool operator == (const char* a, const TiXmlString & b) { return b == a; }
-inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); }
-inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); }
-
-TiXmlString operator + (const TiXmlString & a, const TiXmlString & b);
-TiXmlString operator + (const TiXmlString & a, const char* b);
-TiXmlString operator + (const char* a, const TiXmlString & b);
-
-
-/*
- TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString.
- Only the operators that we need for TinyXML have been developped.
-*/
-class TiXmlOutStream : public TiXmlString
-{
-public :
-
- // TiXmlOutStream << operator.
- TiXmlOutStream & operator << (const TiXmlString & in)
- {
- *this += in;
- return *this;
- }
-
- // TiXmlOutStream << operator.
- TiXmlOutStream & operator << (const char * in)
- {
- *this += in;
- return *this;
- }
-
-} ;
-
-#endif // TIXML_STRING_INCLUDED
-#endif // TIXML_USE_STL
diff --git a/guilib/tinyXML/tinyxml.cpp b/guilib/tinyXML/tinyxml.cpp
deleted file mode 100644
index 41685d1f7c..0000000000
--- a/guilib/tinyXML/tinyxml.cpp
+++ /dev/null
@@ -1,2043 +0,0 @@
-/*
-www.sourceforge.net/projects/tinyxml
-Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
-
-This software is provided 'as-is', without any express or implied
-warranty. In no event will the authors be held liable for any
-damages arising from the use of this software.
-
-Permission is granted to anyone to use this software for any
-purpose, including commercial applications, and to alter it and
-redistribute it freely, subject to the following restrictions:
-
-1. The origin of this software must not be misrepresented; you must
-not claim that you wrote the original software. If you use this
-software in a product, an acknowledgment in the product documentation
-would be appreciated but is not required.
-
-2. Altered source versions must be plainly marked as such, and
-must not be misrepresented as being the original software.
-
-3. This notice may not be removed or altered from any source
-distribution.
-*/
-
-#include <ctype.h>
-
-#ifdef TIXML_USE_STL
-#include <sstream>
-#include <iostream>
-#endif
-
-#include "tinyxml.h"
-
-#define USE_XBMC_FILESYSTEM
-
-#ifdef USE_XBMC_FILESYSTEM
-bool TiXmlBase::condenseWhiteSpace = false;
-#include "FileSystem/File.h"
-using namespace XFILE;
-#else
-bool TiXmlBase::condenseWhiteSpace = true;
-#endif
-
-
-
-void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString )
-{
- int i=0;
-
- while( i<(int)str.length() )
- {
- unsigned char c = (unsigned char) str[i];
-
- if ( c == '&' )
- {
- outString->append( entity[0].str, entity[0].strLength );
- ++i;
- }
- else if ( c == '<' )
- {
- outString->append( entity[1].str, entity[1].strLength );
- ++i;
- }
- else if ( c == '>' )
- {
- outString->append( entity[2].str, entity[2].strLength );
- ++i;
- }
- else if ( c == '\"' )
- {
- outString->append( entity[3].str, entity[3].strLength );
- ++i;
- }
- else if ( c == '\'' )
- {
- outString->append( entity[4].str, entity[4].strLength );
- ++i;
- }
- else if ( c < 32 )
- {
- // Easy pass at non-alpha/numeric/symbol
- // Below 32 is symbolic.
- char buf[ 32 ];
-
- #if defined(TIXML_SNPRINTF)
- TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) );
- #else
- sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) );
- #endif
-
- //*ME: warning C4267: convert 'size_t' to 'int'
- //*ME: Int-Cast to make compiler happy ...
- outString->append( buf, (int)strlen( buf ) );
- ++i;
- }
- else
- {
- //char realc = (char) c;
- //outString->append( &realc, 1 );
- *outString += (char) c; // somewhat more efficient function call.
- ++i;
- }
- }
-}
-
-
-TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase()
-{
- parent = 0;
- type = _type;
- firstChild = 0;
- lastChild = 0;
- prev = 0;
- next = 0;
-}
-
-
-TiXmlNode::~TiXmlNode()
-{
- TiXmlNode* node = firstChild;
- TiXmlNode* temp = 0;
-
- while ( node )
- {
- temp = node;
- node = node->next;
- delete temp;
- }
-}
-
-
-void TiXmlNode::CopyTo( TiXmlNode* target ) const
-{
- target->SetValue (value.c_str() );
- target->userData = userData;
-}
-
-
-void TiXmlNode::Clear()
-{
- TiXmlNode* node = firstChild;
- TiXmlNode* temp = 0;
-
- while ( node )
- {
- temp = node;
- node = node->next;
- delete temp;
- }
-
- firstChild = 0;
- lastChild = 0;
-}
-
-
-TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node )
-{
- assert( node->parent == 0 || node->parent == this );
- assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() );
-
- if ( node->Type() == TiXmlNode::DOCUMENT )
- {
- delete node;
- if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
- return 0;
- }
-
- node->parent = this;
-
- node->prev = lastChild;
- node->next = 0;
-
- if ( lastChild )
- lastChild->next = node;
- else
- firstChild = node; // it was an empty list.
-
- lastChild = node;
- return node;
-}
-
-
-TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis )
-{
- if ( addThis.Type() == TiXmlNode::DOCUMENT )
- {
- if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
- return 0;
- }
- TiXmlNode* node = addThis.Clone();
- if ( !node )
- return 0;
-
- return LinkEndChild( node );
-}
-
-
-TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis )
-{
- if ( !beforeThis || beforeThis->parent != this ) {
- return 0;
- }
- if ( addThis.Type() == TiXmlNode::DOCUMENT )
- {
- if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
- return 0;
- }
-
- TiXmlNode* node = addThis.Clone();
- if ( !node )
- return 0;
- node->parent = this;
-
- node->next = beforeThis;
- node->prev = beforeThis->prev;
- if ( beforeThis->prev )
- {
- beforeThis->prev->next = node;
- }
- else
- {
- assert( firstChild == beforeThis );
- firstChild = node;
- }
- beforeThis->prev = node;
- return node;
-}
-
-
-TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis )
-{
- if ( !afterThis || afterThis->parent != this ) {
- return 0;
- }
- if ( addThis.Type() == TiXmlNode::DOCUMENT )
- {
- if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
- return 0;
- }
-
- TiXmlNode* node = addThis.Clone();
- if ( !node )
- return 0;
- node->parent = this;
-
- node->prev = afterThis;
- node->next = afterThis->next;
- if ( afterThis->next )
- {
- afterThis->next->prev = node;
- }
- else
- {
- assert( lastChild == afterThis );
- lastChild = node;
- }
- afterThis->next = node;
- return node;
-}
-
-
-TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis )
-{
- if ( replaceThis->parent != this )
- return 0;
-
- TiXmlNode* node = withThis.Clone();
- if ( !node )
- return 0;
-
- node->next = replaceThis->next;
- node->prev = replaceThis->prev;
-
- if ( replaceThis->next )
- replaceThis->next->prev = node;
- else
- lastChild = node;
-
- if ( replaceThis->prev )
- replaceThis->prev->next = node;
- else
- firstChild = node;
-
- delete replaceThis;
- node->parent = this;
- return node;
-}
-
-
-bool TiXmlNode::RemoveChild( TiXmlNode* removeThis )
-{
- if ( removeThis->parent != this )
- {
- assert( 0 );
- return false;
- }
-
- if ( removeThis->next )
- removeThis->next->prev = removeThis->prev;
- else
- lastChild = removeThis->prev;
-
- if ( removeThis->prev )
- removeThis->prev->next = removeThis->next;
- else
- firstChild = removeThis->next;
-
- delete removeThis;
- return true;
-}
-
-const TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const
-{
- const TiXmlNode* node;
- for ( node = firstChild; node; node = node->next )
- {
- if ( strcmp( node->Value(), _value ) == 0 )
- return node;
- }
- return 0;
-}
-
-
-const TiXmlNode* TiXmlNode::LastChild( const char * _value ) const
-{
- const TiXmlNode* node;
- for ( node = lastChild; node; node = node->prev )
- {
- if ( strcmp( node->Value(), _value ) == 0 )
- return node;
- }
- return 0;
-}
-
-
-const TiXmlNode* TiXmlNode::IterateChildren( const TiXmlNode* previous ) const
-{
- if ( !previous )
- {
- return FirstChild();
- }
- else
- {
- assert( previous->parent == this );
- return previous->NextSibling();
- }
-}
-
-
-const TiXmlNode* TiXmlNode::IterateChildren( const char * val, const TiXmlNode* previous ) const
-{
- if ( !previous )
- {
- return FirstChild( val );
- }
- else
- {
- assert( previous->parent == this );
- return previous->NextSibling( val );
- }
-}
-
-
-const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const
-{
- const TiXmlNode* node;
- for ( node = next; node; node = node->next )
- {
- if ( strcmp( node->Value(), _value ) == 0 )
- return node;
- }
- return 0;
-}
-
-
-const TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const
-{
- const TiXmlNode* node;
- for ( node = prev; node; node = node->prev )
- {
- if ( strcmp( node->Value(), _value ) == 0 )
- return node;
- }
- return 0;
-}
-
-
-void TiXmlElement::RemoveAttribute( const char * name )
-{
- #ifdef TIXML_USE_STL
- TIXML_STRING str( name );
- TiXmlAttribute* node = attributeSet.Find( str );
- #else
- TiXmlAttribute* node = attributeSet.Find( name );
- #endif
- if ( node )
- {
- attributeSet.Remove( node );
- delete node;
- }
-}
-
-const TiXmlElement* TiXmlNode::FirstChildElement() const
-{
- const TiXmlNode* node;
-
- for ( node = FirstChild();
- node;
- node = node->NextSibling() )
- {
- if ( node->ToElement() )
- return node->ToElement();
- }
- return 0;
-}
-
-
-const TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const
-{
- const TiXmlNode* node;
-
- for ( node = FirstChild( _value );
- node;
- node = node->NextSibling( _value ) )
- {
- if ( node->ToElement() )
- return node->ToElement();
- }
- return 0;
-}
-
-
-const TiXmlElement* TiXmlNode::NextSiblingElement() const
-{
- const TiXmlNode* node;
-
- for ( node = NextSibling();
- node;
- node = node->NextSibling() )
- {
- if ( node->ToElement() )
- return node->ToElement();
- }
- return 0;
-}
-
-
-const TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const
-{
- const TiXmlNode* node;
-
- for ( node = NextSibling( _value );
- node;
- node = node->NextSibling( _value ) )
- {
- if ( node->ToElement() )
- return node->ToElement();
- }
- return 0;
-}
-
-
-const TiXmlDocument* TiXmlNode::GetDocument() const
-{
- const TiXmlNode* node;
-
- for( node = this; node; node = node->parent )
- {
- if ( node->ToDocument() )
- return node->ToDocument();
- }
- return 0;
-}
-
-
-TiXmlElement::TiXmlElement (const char * _value)
- : TiXmlNode( TiXmlNode::ELEMENT )
-{
- firstChild = lastChild = 0;
- value = _value;
-}
-
-
-#ifdef TIXML_USE_STL
-TiXmlElement::TiXmlElement( const std::string& _value )
- : TiXmlNode( TiXmlNode::ELEMENT )
-{
- firstChild = lastChild = 0;
- value = _value;
-}
-#endif
-
-
-TiXmlElement::TiXmlElement( const TiXmlElement& copy)
- : TiXmlNode( TiXmlNode::ELEMENT )
-{
- firstChild = lastChild = 0;
- copy.CopyTo( this );
-}
-
-
-void TiXmlElement::operator=( const TiXmlElement& base )
-{
- ClearThis();
- base.CopyTo( this );
-}
-
-
-TiXmlElement::~TiXmlElement()
-{
- ClearThis();
-}
-
-
-void TiXmlElement::ClearThis()
-{
- Clear();
- while( attributeSet.First() )
- {
- TiXmlAttribute* node = attributeSet.First();
- attributeSet.Remove( node );
- delete node;
- }
-}
-
-
-const char* TiXmlElement::Attribute( const char* name ) const
-{
- const TiXmlAttribute* node = attributeSet.Find( name );
- if ( node )
- return node->Value();
- return 0;
-}
-
-
-#ifdef TIXML_USE_STL
-const std::string* TiXmlElement::Attribute( const std::string& name ) const
-{
- const TiXmlAttribute* node = attributeSet.Find( name );
- if ( node )
- return &node->ValueStr();
- return 0;
-}
-#endif
-
-
-const char* TiXmlElement::Attribute( const char* name, int* i ) const
-{
- const char* s = Attribute( name );
- if ( i )
- {
- if ( s ) {
- *i = atoi( s );
- }
- else {
- *i = 0;
- }
- }
- return s;
-}
-
-
-#ifdef TIXML_USE_STL
-const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const
-{
- const std::string* s = Attribute( name );
- if ( i )
- {
- if ( s ) {
- *i = atoi( s->c_str() );
- }
- else {
- *i = 0;
- }
- }
- return s;
-}
-#endif
-
-
-const char* TiXmlElement::Attribute( const char* name, double* d ) const
-{
- const char* s = Attribute( name );
- if ( d )
- {
- if ( s ) {
- *d = atof( s );
- }
- else {
- *d = 0;
- }
- }
- return s;
-}
-
-
-#ifdef TIXML_USE_STL
-const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const
-{
- const std::string* s = Attribute( name );
- if ( d )
- {
- if ( s ) {
- *d = atof( s->c_str() );
- }
- else {
- *d = 0;
- }
- }
- return s;
-}
-#endif
-
-
-int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const
-{
- const TiXmlAttribute* node = attributeSet.Find( name );
- if ( !node )
- return TIXML_NO_ATTRIBUTE;
- return node->QueryIntValue( ival );
-}
-
-
-#ifdef TIXML_USE_STL
-int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const
-{
- const TiXmlAttribute* node = attributeSet.Find( name );
- if ( !node )
- return TIXML_NO_ATTRIBUTE;
- return node->QueryIntValue( ival );
-}
-#endif
-
-
-int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const
-{
- const TiXmlAttribute* node = attributeSet.Find( name );
- if ( !node )
- return TIXML_NO_ATTRIBUTE;
- return node->QueryDoubleValue( dval );
-}
-
-
-#ifdef TIXML_USE_STL
-int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval ) const
-{
- const TiXmlAttribute* node = attributeSet.Find( name );
- if ( !node )
- return TIXML_NO_ATTRIBUTE;
- return node->QueryDoubleValue( dval );
-}
-#endif
-
-
-void TiXmlElement::SetAttribute( const char * name, int val )
-{
- char buf[64];
- #if defined(TIXML_SNPRINTF)
- TIXML_SNPRINTF( buf, sizeof(buf), "%d", val );
- #else
- sprintf( buf, "%d", val );
- #endif
- SetAttribute( name, buf );
-}
-
-
-#ifdef TIXML_USE_STL
-void TiXmlElement::SetAttribute( const std::string& name, int val )
-{
- std::ostringstream oss;
- oss << val;
- SetAttribute( name, oss.str() );
-}
-#endif
-
-
-void TiXmlElement::SetDoubleAttribute( const char * name, double val )
-{
- char buf[256];
- #if defined(TIXML_SNPRINTF)
- TIXML_SNPRINTF( buf, sizeof(buf), "%f", val );
- #else
- sprintf( buf, "%f", val );
- #endif
- SetAttribute( name, buf );
-}
-
-
-void TiXmlElement::SetAttribute( const char * cname, const char * cvalue )
-{
- #ifdef TIXML_USE_STL
- TIXML_STRING _name( cname );
- TIXML_STRING _value( cvalue );
- #else
- const char* _name = cname;
- const char* _value = cvalue;
- #endif
-
- TiXmlAttribute* node = attributeSet.Find( _name );
- if ( node )
- {
- node->SetValue( _value );
- return;
- }
-
- TiXmlAttribute* attrib = new TiXmlAttribute( cname, cvalue );
- if ( attrib )
- {
- attributeSet.Add( attrib );
- }
- else
- {
- TiXmlDocument* document = GetDocument();
- if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
- }
-}
-
-
-#ifdef TIXML_USE_STL
-void TiXmlElement::SetAttribute( const std::string& name, const std::string& _value )
-{
- TiXmlAttribute* node = attributeSet.Find( name );
- if ( node )
- {
- node->SetValue( _value );
- return;
- }
-
- TiXmlAttribute* attrib = new TiXmlAttribute( name, _value );
- if ( attrib )
- {
- attributeSet.Add( attrib );
- }
- else
- {
- TiXmlDocument* document = GetDocument();
- if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
- }
-}
-#endif
-
-
-void TiXmlElement::Print( FILE* cfile, int depth ) const
-{
- int i;
- assert( cfile );
- for ( i=0; i<depth; i++ ) {
- fprintf( cfile, " " );
- }
-
- fprintf( cfile, "<%s", value.c_str() );
-
- const TiXmlAttribute* attrib;
- for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() )
- {
- fprintf( cfile, " " );
- attrib->Print( cfile, depth );
- }
-
- // There are 3 different formatting approaches:
- // 1) An element without children is printed as a <foo /> node
- // 2) An element with only a text child is printed as <foo> text </foo>
- // 3) An element with children is printed on multiple lines.
- TiXmlNode* node;
- if ( !firstChild )
- {
- fprintf( cfile, " />" );
- }
- else if ( firstChild == lastChild && firstChild->ToText() )
- {
- fprintf( cfile, ">" );
- firstChild->Print( cfile, depth + 1 );
- fprintf( cfile, "</%s>", value.c_str() );
- }
- else
- {
- fprintf( cfile, ">" );
-
- for ( node = firstChild; node; node=node->NextSibling() )
- {
- if ( !node->ToText() )
- {
- fprintf( cfile, "\n" );
- }
- node->Print( cfile, depth+1 );
- }
- fprintf( cfile, "\n" );
- for( i=0; i<depth; ++i ) {
- fprintf( cfile, " " );
- }
- fprintf( cfile, "</%s>", value.c_str() );
- }
-}
-
-
-void TiXmlElement::CopyTo( TiXmlElement* target ) const
-{
- // superclass:
- TiXmlNode::CopyTo( target );
-
- // Element class:
- // Clone the attributes, then clone the children.
- const TiXmlAttribute* attribute = 0;
- for( attribute = attributeSet.First();
- attribute;
- attribute = attribute->Next() )
- {
- target->SetAttribute( attribute->Name(), attribute->Value() );
- }
-
- TiXmlNode* node = 0;
- for ( node = firstChild; node; node = node->NextSibling() )
- {
- target->LinkEndChild( node->Clone() );
- }
-}
-
-bool TiXmlElement::Accept( TiXmlVisitor* visitor ) const
-{
- if ( visitor->VisitEnter( *this, attributeSet.First() ) )
- {
- for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() )
- {
- if ( !node->Accept( visitor ) )
- break;
- }
- }
- return visitor->VisitExit( *this );
-}
-
-
-TiXmlNode* TiXmlElement::Clone() const
-{
- TiXmlElement* clone = new TiXmlElement( Value() );
- if ( !clone )
- return 0;
-
- CopyTo( clone );
- return clone;
-}
-
-
-const char* TiXmlElement::GetText() const
-{
- const TiXmlNode* child = this->FirstChild();
- if ( child ) {
- const TiXmlText* childText = child->ToText();
- if ( childText ) {
- return childText->Value();
- }
- }
- return 0;
-}
-
-
-TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::DOCUMENT )
-{
- tabsize = 4;
- useMicrosoftBOM = false;
-#ifdef HAS_ICONV
- convertToUtf8 = false;
- iconvContext = (iconv_t) -1;
-#endif
- ClearError();
-}
-
-TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::DOCUMENT )
-{
- tabsize = 4;
- useMicrosoftBOM = false;
-#ifdef HAS_ICONV
- convertToUtf8 = false;
- iconvContext = (iconv_t) -1;
-#endif
- value = documentName;
- ClearError();
-}
-
-
-#ifdef TIXML_USE_STL
-TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::DOCUMENT )
-{
- tabsize = 4;
- useMicrosoftBOM = false;
-#ifdef HAS_ICONV
- convertToUtf8 = false;
- iconvContext = (iconv_t) -1;
-#endif
- value = documentName;
- ClearError();
-}
-#endif
-
-
-TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::DOCUMENT )
-{
- copy.CopyTo( this );
-}
-
-TiXmlDocument::~TiXmlDocument()
-{
-#ifdef HAS_ICONV
- if (iconvContext != (iconv_t) -1)
- {
- iconv_close(iconvContext);
- iconvContext = (iconv_t) -1;
- }
-#endif
-}
-
-void TiXmlDocument::operator=( const TiXmlDocument& copy )
-{
- Clear();
- copy.CopyTo( this );
-}
-
-
-bool TiXmlDocument::LoadFile( TiXmlEncoding encoding )
-{
- // See STL_STRING_BUG below.
- //StringToBuffer buf( value );
-
- return LoadFile( Value(), encoding );
-}
-
-
-bool TiXmlDocument::SaveFile() const
-{
- // See STL_STRING_BUG below.
-// StringToBuffer buf( value );
-//
-// if ( buf.buffer && SaveFile( buf.buffer ) )
-// return true;
-//
-// return false;
- return SaveFile( Value() );
-}
-
-#ifdef USE_XBMC_FILESYSTEM
-bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding )
-{
- // There was a really terrifying little bug here. The code:
- // value = filename
- // in the STL case, cause the assignment method of the std::string to
- // be called. What is strange, is that the std::string had the same
- // address as it's c_str() method, and so bad things happen. Looks
- // like a bug in the Microsoft STL implementation.
- // Add an extra string to avoid the crash.
- TIXML_STRING filename( _filename );
- value = filename;
-
- CFile file;
- if (!file.Open(value))
- {
- SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN );
- return false;
- }
-
- // Delete the existing data:
- Clear();
- location.Clear();
-
- // Get the file size, so we can pre-allocate the string. HUGE speed impact.
- long length = -1;
- int64_t filelen = file.GetLength();
- if (filelen > 0)
- length = (long)filelen;
-
- // We might be streaming it, correct length will be fixed by reading
- if( length < 0 )
- length = 1024;
-
- // Subtle bug here. TinyXml did use fgets. But from the XML spec:
- // 2.11 End-of-Line Handling
- // <snip>
- // <quote>
- // ...the XML processor MUST behave as if it normalized all line breaks in external
- // parsed entities (including the document entity) on input, before parsing, by translating
- // both the two-character sequence #xD #xA and any #xD that is not followed by #xA to
- // a single #xA character.
- // </quote>
- //
- // It is not clear fgets does that, and certainly isn't clear it works cross platform.
- // Generally, you expect fgets to translate from the convention of the OS to the c/unix
- // convention, and not work generally.
-
- /*
- while( fgets( buf, sizeof(buf), file ) )
- {
- data += buf;
- }
- */
-
- char* buf = (char*)malloc(length+1);
- long pos = 0;
- long len;
- while( (len = file.Read(buf+pos, length-pos)) > 0 ) {
- pos += len;
- assert(pos <= length);
- if(pos == length) {
- length *= 2;
- buf = (char*)realloc(buf, length);
- }
- }
- length = pos;
-
- file.Close();
-
- // Strange case, but good to handle up front.
- if ( length == 0 )
- {
- SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
- return false;
- }
-
- // If we have a file, assume it is all one big XML file, and read it in.
- // The document parser may decide the document ends sooner than the entire file, however.
- TIXML_STRING data;
- data.reserve( length );
-
- const char* lastPos = buf;
- const char* p = buf;
-
- buf[length] = 0;
- while( *p ) {
- assert( p < (buf+length) );
- if ( *p == 0xa ) {
- // Newline character. No special rules for this. Append all the characters
- // since the last string, and include the newline.
- data.append( lastPos, (p-lastPos+1) ); // append, include the newline
- ++p; // move past the newline
- lastPos = p; // and point to the new buffer (may be 0)
- assert( p <= (buf+length) );
- }
- else if ( *p == 0xd ) {
- // Carriage return. Append what we have so far, then
- // handle moving forward in the buffer.
- if ( (p-lastPos) > 0 ) {
- data.append( lastPos, p-lastPos ); // do not add the CR
- }
- data += (char)0xa; // a proper newline
-
- if ( *(p+1) == 0xa ) {
- // Carriage return - new line sequence
- p += 2;
- lastPos = p;
- assert( p <= (buf+length) );
- }
- else {
- // it was followed by something else...that is presumably characters again.
- ++p;
- lastPos = p;
- assert( p <= (buf+length) );
- }
- }
- else {
- ++p;
- }
- }
- // Handle any left over characters.
- if ( p-lastPos ) {
- data.append( lastPos, p-lastPos );
- }
- free(buf);
- buf = 0;
-
- Parse( data.c_str(), 0, encoding );
-
- if ( Error() )
- return false;
- else
- return true;
-}
-
-bool TiXmlDocument::SaveFile( const char *filename ) const
-{
- XFILE::CFile file;
- if (file.OpenForWrite(filename, true))
- {
- TiXmlPrinter printer;
- Accept(&printer);
- file.Write(printer.CStr(), printer.Size());
- return true;
- }
- return false;
-}
-#else
-
-bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding )
-{
- // There was a really terrifying little bug here. The code:
- // value = filename
- // in the STL case, cause the assignment method of the std::string to
- // be called. What is strange, is that the std::string had the same
- // address as it's c_str() method, and so bad things happen. Looks
- // like a bug in the Microsoft STL implementation.
- // Add an extra string to avoid the crash.
- TIXML_STRING filename( _filename );
- value = filename;
-
- // reading in binary mode so that tinyxml can normalize the EOL
- FILE* file = fopen( value.c_str(), "rb" );
- if ( file )
- {
- bool result = LoadFile( file, encoding );
- fclose( file );
- return result;
- }
- else
- {
- SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN );
- return false;
- }
-}
-
-bool TiXmlDocument::SaveFile( const char * filename ) const
-{
- // The old c stuff lives on...
- FILE* fp = fopen( filename, "w" );
- if ( fp )
- {
- bool result = SaveFile( fp );
- fclose( fp );
- return result;
- }
- return false;
-}
-#endif
-
-bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding )
-{
- if ( !file )
- {
- SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN );
- return false;
- }
-
- // Delete the existing data:
- Clear();
- location.Clear();
-
- // Get the file size, so we can pre-allocate the string. HUGE speed impact.
- long length = -1;
- if( fseek( file, 0, SEEK_END ) == 0 ) {
- length = ftell( file );
- fseek( file, 0, SEEK_SET );
- }
-
- // We might be streaming it, correct length will be fixed by reading
- if( length < 0 )
- length = 1024;
-
- // Subtle bug here. TinyXml did use fgets. But from the XML spec:
- // 2.11 End-of-Line Handling
- // <snip>
- // <quote>
- // ...the XML processor MUST behave as if it normalized all line breaks in external
- // parsed entities (including the document entity) on input, before parsing, by translating
- // both the two-character sequence #xD #xA and any #xD that is not followed by #xA to
- // a single #xA character.
- // </quote>
- //
- // It is not clear fgets does that, and certainly isn't clear it works cross platform.
- // Generally, you expect fgets to translate from the convention of the OS to the c/unix
- // convention, and not work generally.
-
- /*
- while( fgets( buf, sizeof(buf), file ) )
- {
- data += buf;
- }
- */
-
- char* buf = (char*)malloc(length+1);
- long pos = 0;
- long len;
- while( (len = fread(buf+pos, 1, length-pos, file)) > 0 ) {
- pos += len;
- assert(pos <= length);
- if(pos == length) {
- length *= 2;
- buf = (char*)realloc(buf, length);
- }
- }
- length = pos;
-
- // Strange case, but good to handle up front.
- if ( length == 0 )
- {
- SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
- return false;
- }
-
- // If we have a file, assume it is all one big XML file, and read it in.
- // The document parser may decide the document ends sooner than the entire file, however.
- TIXML_STRING data;
- data.reserve( length );
-
- const char* lastPos = buf;
- const char* p = buf;
-
- buf[length] = 0;
- while( *p ) {
- assert( p < (buf+length) );
- if ( *p == 0xa ) {
- // Newline character. No special rules for this. Append all the characters
- // since the last string, and include the newline.
- data.append( lastPos, (p-lastPos+1) ); // append, include the newline
- ++p; // move past the newline
- lastPos = p; // and point to the new buffer (may be 0)
- assert( p <= (buf+length) );
- }
- else if ( *p == 0xd ) {
- // Carriage return. Append what we have so far, then
- // handle moving forward in the buffer.
- if ( (p-lastPos) > 0 ) {
- data.append( lastPos, p-lastPos ); // do not add the CR
- }
- data += (char)0xa; // a proper newline
-
- if ( *(p+1) == 0xa ) {
- // Carriage return - new line sequence
- p += 2;
- lastPos = p;
- assert( p <= (buf+length) );
- }
- else {
- // it was followed by something else...that is presumably characters again.
- ++p;
- lastPos = p;
- assert( p <= (buf+length) );
- }
- }
- else {
- ++p;
- }
- }
- // Handle any left over characters.
- if ( p-lastPos ) {
- data.append( lastPos, p-lastPos );
- }
- free(buf);
- buf = 0;
-
- Parse( data.c_str(), 0, encoding );
-
- if ( Error() )
- return false;
- else
- return true;
-}
-
-bool TiXmlDocument::SaveFile( FILE* fp ) const
-{
- if ( useMicrosoftBOM )
- {
- const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
- const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
- const unsigned char TIXML_UTF_LEAD_2 = 0xbfU;
-
- fputc( TIXML_UTF_LEAD_0, fp );
- fputc( TIXML_UTF_LEAD_1, fp );
- fputc( TIXML_UTF_LEAD_2, fp );
- }
- Print( fp, 0 );
- return (ferror(fp) == 0);
-}
-
-
-void TiXmlDocument::CopyTo( TiXmlDocument* target ) const
-{
- TiXmlNode::CopyTo( target );
-
- target->error = error;
- target->errorId = errorId;
- target->errorDesc = errorDesc;
- target->tabsize = tabsize;
- target->errorLocation = errorLocation;
- target->useMicrosoftBOM = useMicrosoftBOM;
-#ifdef HAS_ICONV
- target->convertToUtf8 = convertToUtf8;
- target->iconvContext = (iconv_t) -1;
-#endif
-
- TiXmlNode* node = 0;
- for ( node = firstChild; node; node = node->NextSibling() )
- {
- target->LinkEndChild( node->Clone() );
- }
-}
-
-
-TiXmlNode* TiXmlDocument::Clone() const
-{
- TiXmlDocument* clone = new TiXmlDocument();
- if ( !clone )
- return 0;
-
- CopyTo( clone );
- return clone;
-}
-
-
-void TiXmlDocument::Print( FILE* cfile, int depth ) const
-{
- assert( cfile );
- for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() )
- {
- node->Print( cfile, depth );
- fprintf( cfile, "\n" );
- }
-}
-
-
-bool TiXmlDocument::Accept( TiXmlVisitor* visitor ) const
-{
- if ( visitor->VisitEnter( *this ) )
- {
- for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() )
- {
- if ( !node->Accept( visitor ) )
- break;
- }
- }
- return visitor->VisitExit( *this );
-}
-
-
-const TiXmlAttribute* TiXmlAttribute::Next() const
-{
- // We are using knowledge of the sentinel. The sentinel
- // have a value or name.
- if ( next->value.empty() && next->name.empty() )
- return 0;
- return next;
-}
-
-/*
-TiXmlAttribute* TiXmlAttribute::Next()
-{
- // We are using knowledge of the sentinel. The sentinel
- // have a value or name.
- if ( next->value.empty() && next->name.empty() )
- return 0;
- return next;
-}
-*/
-
-const TiXmlAttribute* TiXmlAttribute::Previous() const
-{
- // We are using knowledge of the sentinel. The sentinel
- // have a value or name.
- if ( prev->value.empty() && prev->name.empty() )
- return 0;
- return prev;
-}
-
-/*
-TiXmlAttribute* TiXmlAttribute::Previous()
-{
- // We are using knowledge of the sentinel. The sentinel
- // have a value or name.
- if ( prev->value.empty() && prev->name.empty() )
- return 0;
- return prev;
-}
-*/
-
-void TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const
-{
- TIXML_STRING n, v;
-
- EncodeString( name, &n );
- EncodeString( value, &v );
-
- if (value.find ('\"') == TIXML_STRING::npos) {
- if ( cfile ) {
- fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() );
- }
- if ( str ) {
- (*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\"";
- }
- }
- else {
- if ( cfile ) {
- fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() );
- }
- if ( str ) {
- (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'";
- }
- }
-}
-
-
-int TiXmlAttribute::QueryIntValue( int* ival ) const
-{
- if ( TIXML_SSCANF( value.c_str(), "%d", ival ) == 1 )
- return TIXML_SUCCESS;
- return TIXML_WRONG_TYPE;
-}
-
-int TiXmlAttribute::QueryDoubleValue( double* dval ) const
-{
- if ( TIXML_SSCANF( value.c_str(), "%lf", dval ) == 1 )
- return TIXML_SUCCESS;
- return TIXML_WRONG_TYPE;
-}
-
-void TiXmlAttribute::SetIntValue( int _value )
-{
- char buf [64];
- #if defined(TIXML_SNPRINTF)
- TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value);
- #else
- sprintf (buf, "%d", _value);
- #endif
- SetValue (buf);
-}
-
-void TiXmlAttribute::SetDoubleValue( double _value )
-{
- char buf [256];
- #if defined(TIXML_SNPRINTF)
- TIXML_SNPRINTF( buf, sizeof(buf), "%f", _value);
- #else
- sprintf (buf, "%f", _value);
- #endif
- SetValue (buf);
-}
-
-int TiXmlAttribute::IntValue() const
-{
- return atoi (value.c_str ());
-}
-
-double TiXmlAttribute::DoubleValue() const
-{
- return atof (value.c_str ());
-}
-
-
-TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::COMMENT )
-{
- copy.CopyTo( this );
-}
-
-
-void TiXmlComment::operator=( const TiXmlComment& base )
-{
- Clear();
- base.CopyTo( this );
-}
-
-
-void TiXmlComment::Print( FILE* cfile, int depth ) const
-{
- assert( cfile );
- for ( int i=0; i<depth; i++ )
- {
- fprintf( cfile, " " );
- }
- fprintf( cfile, "<!--%s-->", value.c_str() );
-}
-
-
-void TiXmlComment::CopyTo( TiXmlComment* target ) const
-{
- TiXmlNode::CopyTo( target );
-}
-
-
-bool TiXmlComment::Accept( TiXmlVisitor* visitor ) const
-{
- return visitor->Visit( *this );
-}
-
-
-TiXmlNode* TiXmlComment::Clone() const
-{
- TiXmlComment* clone = new TiXmlComment();
-
- if ( !clone )
- return 0;
-
- CopyTo( clone );
- return clone;
-}
-
-
-void TiXmlText::Print( FILE* cfile, int depth ) const
-{
- assert( cfile );
- if ( cdata )
- {
- int i;
- fprintf( cfile, "\n" );
- for ( i=0; i<depth; i++ ) {
- fprintf( cfile, " " );
- }
- fprintf( cfile, "<![CDATA[%s]]>\n", value.c_str() ); // unformatted output
- }
- else
- {
- TIXML_STRING buffer;
- EncodeString( value, &buffer );
- fprintf( cfile, "%s", buffer.c_str() );
- }
-}
-
-
-void TiXmlText::CopyTo( TiXmlText* target ) const
-{
- TiXmlNode::CopyTo( target );
- target->cdata = cdata;
-}
-
-
-bool TiXmlText::Accept( TiXmlVisitor* visitor ) const
-{
- return visitor->Visit( *this );
-}
-
-
-TiXmlNode* TiXmlText::Clone() const
-{
- TiXmlText* clone = 0;
- clone = new TiXmlText( "" );
-
- if ( !clone )
- return 0;
-
- CopyTo( clone );
- return clone;
-}
-
-
-TiXmlDeclaration::TiXmlDeclaration( const char * _version,
- const char * _encoding,
- const char * _standalone )
- : TiXmlNode( TiXmlNode::DECLARATION )
-{
- version = _version;
- encoding = _encoding;
- standalone = _standalone;
-}
-
-
-#ifdef TIXML_USE_STL
-TiXmlDeclaration::TiXmlDeclaration( const std::string& _version,
- const std::string& _encoding,
- const std::string& _standalone )
- : TiXmlNode( TiXmlNode::DECLARATION )
-{
- version = _version;
- encoding = _encoding;
- standalone = _standalone;
-}
-#endif
-
-
-TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy )
- : TiXmlNode( TiXmlNode::DECLARATION )
-{
- copy.CopyTo( this );
-}
-
-
-void TiXmlDeclaration::operator=( const TiXmlDeclaration& copy )
-{
- Clear();
- copy.CopyTo( this );
-}
-
-
-void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const
-{
- if ( cfile ) fprintf( cfile, "<?xml " );
- if ( str ) (*str) += "<?xml ";
-
- if ( !version.empty() ) {
- if ( cfile ) fprintf (cfile, "version=\"%s\" ", version.c_str ());
- if ( str ) { (*str) += "version=\""; (*str) += version; (*str) += "\" "; }
- }
- if ( !encoding.empty() ) {
- if ( cfile ) fprintf (cfile, "encoding=\"%s\" ", encoding.c_str ());
- if ( str ) { (*str) += "encoding=\""; (*str) += encoding; (*str) += "\" "; }
- }
- if ( !standalone.empty() ) {
- if ( cfile ) fprintf (cfile, "standalone=\"%s\" ", standalone.c_str ());
- if ( str ) { (*str) += "standalone=\""; (*str) += standalone; (*str) += "\" "; }
- }
- if ( cfile ) fprintf( cfile, "?>" );
- if ( str ) (*str) += "?>";
-}
-
-
-void TiXmlDeclaration::CopyTo( TiXmlDeclaration* target ) const
-{
- TiXmlNode::CopyTo( target );
-
- target->version = version;
- target->encoding = encoding;
- target->standalone = standalone;
-}
-
-
-bool TiXmlDeclaration::Accept( TiXmlVisitor* visitor ) const
-{
- return visitor->Visit( *this );
-}
-
-
-TiXmlNode* TiXmlDeclaration::Clone() const
-{
- TiXmlDeclaration* clone = new TiXmlDeclaration();
-
- if ( !clone )
- return 0;
-
- CopyTo( clone );
- return clone;
-}
-
-
-void TiXmlUnknown::Print( FILE* cfile, int depth ) const
-{
- for ( int i=0; i<depth; i++ )
- fprintf( cfile, " " );
- fprintf( cfile, "<%s>", value.c_str() );
-}
-
-
-void TiXmlUnknown::CopyTo( TiXmlUnknown* target ) const
-{
- TiXmlNode::CopyTo( target );
-}
-
-
-bool TiXmlUnknown::Accept( TiXmlVisitor* visitor ) const
-{
- return visitor->Visit( *this );
-}
-
-
-TiXmlNode* TiXmlUnknown::Clone() const
-{
- TiXmlUnknown* clone = new TiXmlUnknown();
-
- if ( !clone )
- return 0;
-
- CopyTo( clone );
- return clone;
-}
-
-
-TiXmlAttributeSet::TiXmlAttributeSet()
-{
- sentinel.next = &sentinel;
- sentinel.prev = &sentinel;
-}
-
-
-TiXmlAttributeSet::~TiXmlAttributeSet()
-{
- assert( sentinel.next == &sentinel );
- assert( sentinel.prev == &sentinel );
-}
-
-
-void TiXmlAttributeSet::Add( TiXmlAttribute* addMe )
-{
- #ifdef TIXML_USE_STL
- assert( !Find( TIXML_STRING( addMe->Name() ) ) ); // Shouldn't be multiply adding to the set.
- #else
- assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set.
- #endif
-
- addMe->next = &sentinel;
- addMe->prev = sentinel.prev;
-
- sentinel.prev->next = addMe;
- sentinel.prev = addMe;
-}
-
-void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe )
-{
- TiXmlAttribute* node;
-
- for( node = sentinel.next; node != &sentinel; node = node->next )
- {
- if ( node == removeMe )
- {
- node->prev->next = node->next;
- node->next->prev = node->prev;
- node->next = 0;
- node->prev = 0;
- return;
- }
- }
- assert( 0 ); // we tried to remove a non-linked attribute.
-}
-
-
-#ifdef TIXML_USE_STL
-const TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const
-{
- for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
- {
- if ( node->name == name )
- return node;
- }
- return 0;
-}
-
-/*
-TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name )
-{
- for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
- {
- if ( node->name == name )
- return node;
- }
- return 0;
-}
-*/
-#endif
-
-
-const TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const
-{
- for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
- {
- if ( strcmp( node->name.c_str(), name ) == 0 )
- return node;
- }
- return 0;
-}
-
-/*
-TiXmlAttribute* TiXmlAttributeSet::Find( const char* name )
-{
- for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
- {
- if ( strcmp( node->name.c_str(), name ) == 0 )
- return node;
- }
- return 0;
-}
-*/
-
-#ifdef TIXML_USE_STL
-std::istream& operator>> (std::istream & in, TiXmlNode & base)
-{
- TIXML_STRING tag;
- tag.reserve( 8 * 1000 );
- base.StreamIn( &in, &tag );
-
- base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING );
- return in;
-}
-#endif
-
-
-#ifdef TIXML_USE_STL
-std::ostream& operator<< (std::ostream & out, const TiXmlNode & base)
-{
- TiXmlPrinter printer;
- printer.SetStreamPrinting();
- base.Accept( &printer );
- out << printer.Str();
-
- return out;
-}
-
-
-std::string& operator<< (std::string& out, const TiXmlNode& base )
-{
- TiXmlPrinter printer;
- printer.SetStreamPrinting();
- base.Accept( &printer );
- out.append( printer.Str() );
-
- return out;
-}
-#endif
-
-
-TiXmlHandle TiXmlHandle::FirstChild() const
-{
- if ( node )
- {
- TiXmlNode* child = node->FirstChild();
- if ( child )
- return TiXmlHandle( child );
- }
- return TiXmlHandle( 0 );
-}
-
-
-TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const
-{
- if ( node )
- {
- TiXmlNode* child = node->FirstChild( value );
- if ( child )
- return TiXmlHandle( child );
- }
- return TiXmlHandle( 0 );
-}
-
-
-TiXmlHandle TiXmlHandle::FirstChildElement() const
-{
- if ( node )
- {
- TiXmlElement* child = node->FirstChildElement();
- if ( child )
- return TiXmlHandle( child );
- }
- return TiXmlHandle( 0 );
-}
-
-
-TiXmlHandle TiXmlHandle::FirstChildElement( const char * value ) const
-{
- if ( node )
- {
- TiXmlElement* child = node->FirstChildElement( value );
- if ( child )
- return TiXmlHandle( child );
- }
- return TiXmlHandle( 0 );
-}
-
-
-TiXmlHandle TiXmlHandle::Child( int count ) const
-{
- if ( node )
- {
- int i;
- TiXmlNode* child = node->FirstChild();
- for ( i=0;
- child && i<count;
- child = child->NextSibling(), ++i )
- {
- // nothing
- }
- if ( child )
- return TiXmlHandle( child );
- }
- return TiXmlHandle( 0 );
-}
-
-
-TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const
-{
- if ( node )
- {
- int i;
- TiXmlNode* child = node->FirstChild( value );
- for ( i=0;
- child && i<count;
- child = child->NextSibling( value ), ++i )
- {
- // nothing
- }
- if ( child )
- return TiXmlHandle( child );
- }
- return TiXmlHandle( 0 );
-}
-
-
-TiXmlHandle TiXmlHandle::ChildElement( int count ) const
-{
- if ( node )
- {
- int i;
- TiXmlElement* child = node->FirstChildElement();
- for ( i=0;
- child && i<count;
- child = child->NextSiblingElement(), ++i )
- {
- // nothing
- }
- if ( child )
- return TiXmlHandle( child );
- }
- return TiXmlHandle( 0 );
-}
-
-
-TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const
-{
- if ( node )
- {
- int i;
- TiXmlElement* child = node->FirstChildElement( value );
- for ( i=0;
- child && i<count;
- child = child->NextSiblingElement( value ), ++i )
- {
- // nothing
- }
- if ( child )
- return TiXmlHandle( child );
- }
- return TiXmlHandle( 0 );
-}
-
-
-bool TiXmlPrinter::VisitEnter( const TiXmlDocument& )
-{
- return true;
-}
-
-bool TiXmlPrinter::VisitExit( const TiXmlDocument& )
-{
- return true;
-}
-
-bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute )
-{
- DoIndent();
- buffer += "<";
- buffer += element.Value();
-
- for( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() )
- {
- buffer += " ";
- attrib->Print( 0, 0, &buffer );
- }
-
- if ( !element.FirstChild() )
- {
- buffer += " />";
- DoLineBreak();
- }
- else
- {
- buffer += ">";
- if ( element.FirstChild()->ToText()
- && element.LastChild() == element.FirstChild()
- && element.FirstChild()->ToText()->CDATA() == false )
- {
- simpleTextPrint = true;
- // no DoLineBreak()!
- }
- else
- {
- DoLineBreak();
- }
- }
- ++depth;
- return true;
-}
-
-
-bool TiXmlPrinter::VisitExit( const TiXmlElement& element )
-{
- --depth;
- if ( !element.FirstChild() )
- {
- // nothing.
- }
- else
- {
- if ( simpleTextPrint )
- {
- simpleTextPrint = false;
- }
- else
- {
- DoIndent();
- }
- buffer += "</";
- buffer += element.Value();
- buffer += ">";
- DoLineBreak();
- }
- return true;
-}
-
-
-bool TiXmlPrinter::Visit( const TiXmlText& text )
-{
- if ( text.CDATA() )
- {
- DoIndent();
- buffer += "<![CDATA[";
- buffer += text.Value();
- buffer += "]]>";
- DoLineBreak();
- }
- else if ( simpleTextPrint )
- {
- TIXML_STRING str;
- TiXmlBase::EncodeString( text.ValueTStr(), &str );
- buffer += str;
- }
- else
- {
- DoIndent();
- TIXML_STRING str;
- TiXmlBase::EncodeString( text.ValueTStr(), &str );
- buffer += str;
- DoLineBreak();
- }
- return true;
-}
-
-
-bool TiXmlPrinter::Visit( const TiXmlDeclaration& declaration )
-{
- DoIndent();
- declaration.Print( 0, 0, &buffer );
- DoLineBreak();
- return true;
-}
-
-
-bool TiXmlPrinter::Visit( const TiXmlComment& comment )
-{
- DoIndent();
- buffer += "<!--";
- buffer += comment.Value();
- buffer += "-->";
- DoLineBreak();
- return true;
-}
-
-
-bool TiXmlPrinter::Visit( const TiXmlUnknown& unknown )
-{
- DoIndent();
- buffer += "<";
- buffer += unknown.Value();
- buffer += ">";
- DoLineBreak();
- return true;
-}
-
diff --git a/guilib/tinyXML/tinyxml.h b/guilib/tinyXML/tinyxml.h
deleted file mode 100644
index 253b989c79..0000000000
--- a/guilib/tinyXML/tinyxml.h
+++ /dev/null
@@ -1,1834 +0,0 @@
-/*
-www.sourceforge.net/projects/tinyxml
-Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
-
-This software is provided 'as-is', without any express or implied
-warranty. In no event will the authors be held liable for any
-damages arising from the use of this software.
-
-Permission is granted to anyone to use this software for any
-purpose, including commercial applications, and to alter it and
-redistribute it freely, subject to the following restrictions:
-
-1. The origin of this software must not be misrepresented; you must
-not claim that you wrote the original software. If you use this
-software in a product, an acknowledgment in the product documentation
-would be appreciated but is not required.
-
-2. Altered source versions must be plainly marked as such, and
-must not be misrepresented as being the original software.
-
-3. This notice may not be removed or altered from any source
-distribution.
-*/
-
-
-#ifndef TINYXML_INCLUDED
-#define TINYXML_INCLUDED
-
-#ifdef _MSC_VER
-#pragma warning( push )
-#pragma warning( disable : 4530 )
-#pragma warning( disable : 4786 )
-#endif
-
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-// Help out windows (but don't mess up OSX):
-#if defined( _WIN32 ) || defined(WIN32)
-#if defined( _DEBUG ) && !defined( DEBUG )
-#define DEBUG
-#endif
-#endif
-
-#ifndef TIXML_USE_STL
-#define TIXML_USE_STL
-#endif
-
-#ifndef HAS_ICONV
-#define HAS_ICONV
-#endif
-
-#ifdef TIXML_USE_STL
- #include <string>
- #include <iostream>
- #include <sstream>
- #define TIXML_STRING std::string
-#else
- #include "tinystr.h"
- #define TIXML_STRING TiXmlString
-#endif
-
-#ifdef HAS_ICONV
-#include <iconv.h>
-#endif
-
-// Deprecated library function hell. Compilers want to use the
-// new safe versions. This probably doesn't fully address the problem,
-// but it gets closer. There are too many compilers for me to fully
-// test. If you get compilation troubles, undefine TIXML_SAFE
-#define TIXML_SAFE
-
-#ifdef TIXML_SAFE
- #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
- // Microsoft visual studio, version 2005 and higher.
- #define TIXML_SNPRINTF _snprintf_s
- #define TIXML_SNSCANF _snscanf_s
- #define TIXML_SSCANF sscanf_s
- #elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
- // Microsoft visual studio, version 6 and higher.
- //#pragma message( "Using _sn* functions." )
- #define TIXML_SNPRINTF _snprintf
- #define TIXML_SNSCANF _snscanf
- #define TIXML_SSCANF sscanf
- #elif defined(__GNUC__) && (__GNUC__ >= 3 )
- // GCC version 3 and higher.s
- //#warning( "Using sn* functions." )
- #define TIXML_SNPRINTF snprintf
- #define TIXML_SNSCANF snscanf
- #define TIXML_SSCANF sscanf
- #else
- #define TIXML_SSCANF sscanf
- #endif
-#endif
-
-class TiXmlDocument;
-class TiXmlElement;
-class TiXmlComment;
-class TiXmlUnknown;
-class TiXmlAttribute;
-class TiXmlText;
-class TiXmlDeclaration;
-class TiXmlParsingData;
-
-const int TIXML_MAJOR_VERSION = 2;
-const int TIXML_MINOR_VERSION = 5;
-const int TIXML_PATCH_VERSION = 3;
-
-/* Internal structure for tracking location of items
- in the XML file.
-*/
-struct TiXmlCursor
-{
- TiXmlCursor() { Clear(); }
- void Clear() { row = col = -1; }
-
- int row; // 0 based.
- int col; // 0 based.
-};
-
-
-/**
- If you call the Accept() method, it requires being passed a TiXmlVisitor
- class to handle callbacks. For nodes that contain other nodes (Document, Element)
- you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves
- are simple called with Visit().
-
- If you return 'true' from a Visit method, recursive parsing will continue. If you return
- false, <b>no children of this node or its sibilings</b> will be Visited.
-
- All flavors of Visit methods have a default implementation that returns 'true' (continue
- visiting). You need to only override methods that are interesting to you.
-
- Generally Accept() is called on the TiXmlDocument, although all nodes suppert Visiting.
-
- You should never change the document from a callback.
-
- @sa TiXmlNode::Accept()
-*/
-class TiXmlVisitor
-{
-public:
- virtual ~TiXmlVisitor() {}
-
- /// Visit a document.
- virtual bool VisitEnter( const TiXmlDocument& /*doc*/ ) { return true; }
- /// Visit a document.
- virtual bool VisitExit( const TiXmlDocument& /*doc*/ ) { return true; }
-
- /// Visit an element.
- virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ ) { return true; }
- /// Visit an element.
- virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; }
-
- /// Visit a declaration
- virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { return true; }
- /// Visit a text node
- virtual bool Visit( const TiXmlText& /*text*/ ) { return true; }
- /// Visit a comment node
- virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; }
- /// Visit an unknow node
- virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; }
-};
-
-// Only used by Attribute::Query functions
-enum
-{
- TIXML_SUCCESS,
- TIXML_NO_ATTRIBUTE,
- TIXML_WRONG_TYPE
-};
-
-
-// Used by the parsing routines.
-enum TiXmlEncoding
-{
- TIXML_ENCODING_UNKNOWN,
- TIXML_ENCODING_UTF8,
- TIXML_ENCODING_LEGACY
-};
-
-const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN;
-
-/** TiXmlBase is a base class for every class in TinyXml.
- It does little except to establish that TinyXml classes
- can be printed and provide some utility functions.
-
- In XML, the document and elements can contain
- other elements and other types of nodes.
-
- @verbatim
- A Document can contain: Element (container or leaf)
- Comment (leaf)
- Unknown (leaf)
- Declaration( leaf )
-
- An Element can contain: Element (container or leaf)
- Text (leaf)
- Attributes (not on tree)
- Comment (leaf)
- Unknown (leaf)
-
- A Decleration contains: Attributes (not on tree)
- @endverbatim
-*/
-class TiXmlBase
-{
- friend class TiXmlNode;
- friend class TiXmlElement;
- friend class TiXmlDocument;
-
-public:
- TiXmlBase() : userData(0) {}
- virtual ~TiXmlBase() {}
-
- /** All TinyXml classes can print themselves to a filestream
- or the string class (TiXmlString in non-STL mode, std::string
- in STL mode.) Either or both cfile and str can be null.
-
- This is a formatted print, and will insert
- tabs and newlines.
-
- (For an unformatted stream, use the << operator.)
- */
- virtual void Print( FILE* cfile, int depth ) const = 0;
-
- /** The world does not agree on whether white space should be kept or
- not. In order to make everyone happy, these global, static functions
- are provided to set whether or not TinyXml will condense all white space
- into a single space or not. The default is to condense. Note changing this
- value is not thread safe.
- */
- static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; }
-
- /// Return the current white space setting.
- static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; }
-
- /** Return the position, in the original source file, of this node or attribute.
- The row and column are 1-based. (That is the first row and first column is
- 1,1). If the returns values are 0 or less, then the parser does not have
- a row and column value.
-
- Generally, the row and column value will be set when the TiXmlDocument::Load(),
- TiXmlDocument::LoadFile(), or any TiXmlNode::Parse() is called. It will NOT be set
- when the DOM was created from operator>>.
-
- The values reflect the initial load. Once the DOM is modified programmatically
- (by adding or changing nodes and attributes) the new values will NOT update to
- reflect changes in the document.
-
- There is a minor performance cost to computing the row and column. Computation
- can be disabled if TiXmlDocument::SetTabSize() is called with 0 as the value.
-
- @sa TiXmlDocument::SetTabSize()
- */
- int Row() const { return location.row + 1; }
- int Column() const { return location.col + 1; } ///< See Row()
-
- void SetUserData( void* user ) { userData = user; } ///< Set a pointer to arbitrary user data.
- void* GetUserData() { return userData; } ///< Get a pointer to arbitrary user data.
- const void* GetUserData() const { return userData; } ///< Get a pointer to arbitrary user data.
-
- // Table that returs, for a given lead byte, the total number of bytes
- // in the UTF-8 sequence.
- static const int utf8ByteTable[256];
-
- virtual const char* Parse( const char* p,
- TiXmlParsingData* data,
- TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0;
-
- /** Expands entities in a string. Note this should not contian the tag's '<', '>', etc,
- or they will be transformed into entities!
- */
- static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out );
-
- enum
- {
- TIXML_NO_ERROR = 0,
- TIXML_ERROR,
- TIXML_ERROR_OPENING_FILE,
- TIXML_ERROR_OUT_OF_MEMORY,
- TIXML_ERROR_PARSING_ELEMENT,
- TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
- TIXML_ERROR_READING_ELEMENT_VALUE,
- TIXML_ERROR_READING_ATTRIBUTES,
- TIXML_ERROR_PARSING_EMPTY,
- TIXML_ERROR_READING_END_TAG,
- TIXML_ERROR_PARSING_UNKNOWN,
- TIXML_ERROR_PARSING_COMMENT,
- TIXML_ERROR_PARSING_DECLARATION,
- TIXML_ERROR_DOCUMENT_EMPTY,
- TIXML_ERROR_EMBEDDED_NULL,
- TIXML_ERROR_PARSING_CDATA,
- TIXML_ERROR_DOCUMENT_TOP_ONLY,
-
- TIXML_ERROR_STRING_COUNT
- };
-
-protected:
-
-#ifdef HAS_ICONV
- static void ConvertToUtf8(TiXmlDocument* document, TIXML_STRING* text);
-#endif
-
- static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
- inline static bool IsWhiteSpace( char c )
- {
- return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
- }
- inline static bool IsWhiteSpace( int c )
- {
- if ( c < 256 )
- return IsWhiteSpace( (char) c );
- return false; // Again, only truly correct for English/Latin...but usually works.
- }
-
- #ifdef TIXML_USE_STL
- static bool StreamWhiteSpace( std::istream * in, TIXML_STRING * tag );
- static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag );
- #endif
-
- /* Reads an XML name into the string provided. Returns
- a pointer just past the last character of the name,
- or 0 if the function has an error.
- */
- static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding );
-
- /* Reads text. Returns a pointer past the given end tag.
- Wickedly complex options, but it keeps the (sensitive) code in one place.
- */
- static const char* ReadText( const char* in, // where to start
- TIXML_STRING* text, // the string read
- bool ignoreWhiteSpace, // whether to keep the white space
- const char* endTag, // what ends this text
- bool ignoreCase, // whether to ignore case in the end tag
- TiXmlEncoding encoding ); // the current encoding
-
- // If an entity has been found, transform it into a character.
- static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding );
-
- // Get a character, while interpreting entities.
- // The length can be from 0 to 4 bytes.
- inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding )
- {
- assert( p );
- if ( encoding == TIXML_ENCODING_UTF8 )
- {
- *length = utf8ByteTable[ *((const unsigned char*)p) ];
- assert( *length >= 0 && *length < 5 );
- }
- else
- {
- *length = 1;
- }
-
- if ( *length == 1 )
- {
- if ( *p == '&' )
- return GetEntity( p, _value, length, encoding );
- *_value = *p;
- return p+1;
- }
- else if ( *length )
- {
- //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe),
- // and the null terminator isn't needed
- for( int i=0; p[i] && i<*length; ++i ) {
- _value[i] = p[i];
- }
- return p + (*length);
- }
- else
- {
- // Not valid text.
- return 0;
- }
- }
-
- // Return true if the next characters in the stream are any of the endTag sequences.
- // Ignore case only works for english, and should only be relied on when comparing
- // to English words: StringEqual( p, "version", true ) is fine.
- static bool StringEqual( const char* p,
- const char* endTag,
- bool ignoreCase,
- TiXmlEncoding encoding );
-
- static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
-
- TiXmlCursor location;
-
- /// Field containing a generic user pointer
- void* userData;
-
- // None of these methods are reliable for any language except English.
- // Good for approximation, not great for accuracy.
- static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding );
- static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding );
- inline static int ToLower( int v, TiXmlEncoding encoding )
- {
- if ( encoding == TIXML_ENCODING_UTF8 )
- {
- if ( v < 128 ) return tolower( v );
- return v;
- }
- else
- {
- return tolower( v );
- }
- }
- static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
-
-private:
- TiXmlBase( const TiXmlBase& ); // not implemented.
- void operator=( const TiXmlBase& base ); // not allowed.
-
- struct Entity
- {
- const char* str;
- unsigned int strLength;
- char chr;
- };
- enum
- {
- NUM_ENTITY = 5,
- MAX_ENTITY_LENGTH = 6
-
- };
- static Entity entity[ NUM_ENTITY ];
- static bool condenseWhiteSpace;
-};
-
-
-/** The parent class for everything in the Document Object Model.
- (Except for attributes).
- Nodes have siblings, a parent, and children. A node can be
- in a document, or stand on its own. The type of a TiXmlNode
- can be queried, and it can be cast to its more defined type.
-*/
-class TiXmlNode : public TiXmlBase
-{
- friend class TiXmlDocument;
- friend class TiXmlElement;
-
-public:
- #ifdef TIXML_USE_STL
-
- /** An input stream operator, for every class. Tolerant of newlines and
- formatting, but doesn't expect them.
- */
- friend std::istream& operator >> (std::istream& in, TiXmlNode& base);
-
- /** An output stream operator, for every class. Note that this outputs
- without any newlines or formatting, as opposed to Print(), which
- includes tabs and new lines.
-
- The operator<< and operator>> are not completely symmetric. Writing
- a node to a stream is very well defined. You'll get a nice stream
- of output, without any extra whitespace or newlines.
-
- But reading is not as well defined. (As it always is.) If you create
- a TiXmlElement (for example) and read that from an input stream,
- the text needs to define an element or junk will result. This is
- true of all input streams, but it's worth keeping in mind.
-
- A TiXmlDocument will read nodes until it reads a root element, and
- all the children of that root element.
- */
- friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base);
-
- /// Appends the XML node or attribute to a std::string.
- friend std::string& operator<< (std::string& out, const TiXmlNode& base );
-
- #endif
-
- /** The types of XML nodes supported by TinyXml. (All the
- unsupported types are picked up by UNKNOWN.)
- */
- enum NodeType
- {
- DOCUMENT,
- ELEMENT,
- COMMENT,
- UNKNOWN,
- TEXT,
- DECLARATION,
- TYPECOUNT
- };
-
- virtual ~TiXmlNode();
-
- /** The meaning of 'value' changes for the specific type of
- TiXmlNode.
- @verbatim
- Document: filename of the xml file
- Element: name of the element
- Comment: the comment text
- Unknown: the tag contents
- Text: the text string
- @endverbatim
-
- The subclasses will wrap this function.
- */
- const char *Value() const { return value.c_str (); }
-
- #ifdef TIXML_USE_STL
- /** Return Value() as a std::string. If you only use STL,
- this is more efficient than calling Value().
- Only available in STL mode.
- */
- const std::string& ValueStr() const { return value; }
- #endif
-
- const TIXML_STRING& ValueTStr() const { return value; }
-
- /** Changes the value of the node. Defined as:
- @verbatim
- Document: filename of the xml file
- Element: name of the element
- Comment: the comment text
- Unknown: the tag contents
- Text: the text string
- @endverbatim
- */
- void SetValue(const char * _value) { value = _value;}
-
- #ifdef TIXML_USE_STL
- /// STL std::string form.
- void SetValue( const std::string& _value ) { value = _value; }
- #endif
-
- /// Delete all the children of this node. Does not affect 'this'.
- void Clear();
-
- /// One step up the DOM.
- TiXmlNode* Parent() { return parent; }
- const TiXmlNode* Parent() const { return parent; }
-
- const TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children.
- TiXmlNode* FirstChild() { return firstChild; }
- const TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found.
- /// The first child of this node with the matching 'value'. Will be null if none found.
- TiXmlNode* FirstChild( const char * _value ) {
- // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe)
- // call the method, cast the return back to non-const.
- return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value ));
- }
- const TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children.
- TiXmlNode* LastChild() { return lastChild; }
-
- const TiXmlNode* LastChild( const char * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children.
- TiXmlNode* LastChild( const char * _value ) {
- return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value ));
- }
-
- #ifdef TIXML_USE_STL
- const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); } ///< STL std::string form.
- TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); } ///< STL std::string form.
- const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); } ///< STL std::string form.
- TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); } ///< STL std::string form.
- #endif
-
- /** An alternate way to walk the children of a node.
- One way to iterate over nodes is:
- @verbatim
- for( child = parent->FirstChild(); child; child = child->NextSibling() )
- @endverbatim
-
- IterateChildren does the same thing with the syntax:
- @verbatim
- child = 0;
- while( child = parent->IterateChildren( child ) )
- @endverbatim
-
- IterateChildren takes the previous child as input and finds
- the next one. If the previous child is null, it returns the
- first. IterateChildren will return null when done.
- */
- const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const;
- TiXmlNode* IterateChildren( const TiXmlNode* previous ) {
- return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) );
- }
-
- /// This flavor of IterateChildren searches for children with a particular 'value'
- const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const;
- TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) {
- return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) );
- }
-
- #ifdef TIXML_USE_STL
- const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form.
- TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form.
- #endif
-
- /** Add a new node related to this. Adds a child past the LastChild.
- Returns a pointer to the new object or NULL if an error occured.
- */
- TiXmlNode* InsertEndChild( const TiXmlNode& addThis );
-
-
- /** Add a new node related to this. Adds a child past the LastChild.
-
- NOTE: the node to be added is passed by pointer, and will be
- henceforth owned (and deleted) by tinyXml. This method is efficient
- and avoids an extra copy, but should be used with care as it
- uses a different memory model than the other insert functions.
-
- @sa InsertEndChild
- */
- TiXmlNode* LinkEndChild( TiXmlNode* addThis );
-
- /** Add a new node related to this. Adds a child before the specified child.
- Returns a pointer to the new object or NULL if an error occured.
- */
- TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis );
-
- /** Add a new node related to this. Adds a child after the specified child.
- Returns a pointer to the new object or NULL if an error occured.
- */
- TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis );
-
- /** Replace a child of this node.
- Returns a pointer to the new object or NULL if an error occured.
- */
- TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis );
-
- /// Delete a child of this node.
- bool RemoveChild( TiXmlNode* removeThis );
-
- /// Navigate to a sibling node.
- const TiXmlNode* PreviousSibling() const { return prev; }
- TiXmlNode* PreviousSibling() { return prev; }
-
- /// Navigate to a sibling node.
- const TiXmlNode* PreviousSibling( const char * ) const;
- TiXmlNode* PreviousSibling( const char *_prev ) {
- return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) );
- }
-
- #ifdef TIXML_USE_STL
- const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); } ///< STL std::string form.
- TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); } ///< STL std::string form.
- const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); } ///< STL std::string form.
- TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); } ///< STL std::string form.
- #endif
-
- /// Navigate to a sibling node.
- const TiXmlNode* NextSibling() const { return next; }
- TiXmlNode* NextSibling() { return next; }
-
- /// Navigate to a sibling node with the given 'value'.
- const TiXmlNode* NextSibling( const char * ) const;
- TiXmlNode* NextSibling( const char* _next ) {
- return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) );
- }
-
- /** Convenience function to get through elements.
- Calls NextSibling and ToElement. Will skip all non-Element
- nodes. Returns 0 if there is not another element.
- */
- const TiXmlElement* NextSiblingElement() const;
- TiXmlElement* NextSiblingElement() {
- return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() );
- }
-
- /** Convenience function to get through elements.
- Calls NextSibling and ToElement. Will skip all non-Element
- nodes. Returns 0 if there is not another element.
- */
- const TiXmlElement* NextSiblingElement( const char * ) const;
- TiXmlElement* NextSiblingElement( const char *_next ) {
- return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) );
- }
-
- #ifdef TIXML_USE_STL
- const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form.
- TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form.
- #endif
-
- /// Convenience function to get through elements.
- const TiXmlElement* FirstChildElement() const;
- TiXmlElement* FirstChildElement() {
- return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() );
- }
-
- /// Convenience function to get through elements.
- const TiXmlElement* FirstChildElement( const char * _value ) const;
- TiXmlElement* FirstChildElement( const char * _value ) {
- return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) );
- }
-
- #ifdef TIXML_USE_STL
- const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); } ///< STL std::string form.
- TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); } ///< STL std::string form.
- #endif
-
- /** Query the type (as an enumerated value, above) of this node.
- The possible types are: DOCUMENT, ELEMENT, COMMENT,
- UNKNOWN, TEXT, and DECLARATION.
- */
- int Type() const { return type; }
-
- /** Return a pointer to the Document this node lives in.
- Returns null if not in a document.
- */
- const TiXmlDocument* GetDocument() const;
- TiXmlDocument* GetDocument() {
- return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() );
- }
-
- /// Returns true if this node has no children.
- bool NoChildren() const { return !firstChild; }
-
- virtual const TiXmlDocument* ToDocument() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
- virtual const TiXmlElement* ToElement() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
- virtual const TiXmlComment* ToComment() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
- virtual const TiXmlUnknown* ToUnknown() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
- virtual const TiXmlText* ToText() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
- virtual const TiXmlDeclaration* ToDeclaration() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
-
- virtual TiXmlDocument* ToDocument() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
- virtual TiXmlElement* ToElement() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
- virtual TiXmlComment* ToComment() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
- virtual TiXmlUnknown* ToUnknown() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
- virtual TiXmlText* ToText() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
- virtual TiXmlDeclaration* ToDeclaration() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
-
- /** Create an exact duplicate of this node and return it. The memory must be deleted
- by the caller.
- */
- virtual TiXmlNode* Clone() const = 0;
-
- /** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the
- XML tree will be conditionally visited and the host will be called back
- via the TiXmlVisitor interface.
-
- This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse
- the XML for the callbacks, so the performance of TinyXML is unchanged by using this
- interface versus any other.)
-
- The interface has been based on ideas from:
-
- - http://www.saxproject.org/
- - http://c2.com/cgi/wiki?HierarchicalVisitorPattern
-
- Which are both good references for "visiting".
-
- An example of using Accept():
- @verbatim
- TiXmlPrinter printer;
- tinyxmlDoc.Accept( &printer );
- const char* xmlcstr = printer.CStr();
- @endverbatim
- */
- virtual bool Accept( TiXmlVisitor* visitor ) const = 0;
-
-protected:
- TiXmlNode( NodeType _type );
-
- // Copy to the allocated object. Shared functionality between Clone, Copy constructor,
- // and the assignment operator.
- void CopyTo( TiXmlNode* target ) const;
-
- #ifdef TIXML_USE_STL
- // The real work of the input operator.
- virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0;
- #endif
-
- // Figure out what is at *p, and parse it. Returns null if it is not an xml node.
- TiXmlNode* Identify( const char* start, TiXmlEncoding encoding );
-
- TiXmlNode* parent;
- NodeType type;
-
- TiXmlNode* firstChild;
- TiXmlNode* lastChild;
-
- TIXML_STRING value;
-
- TiXmlNode* prev;
- TiXmlNode* next;
-
-private:
- TiXmlNode( const TiXmlNode& ); // not implemented.
- void operator=( const TiXmlNode& base ); // not allowed.
-};
-
-
-/** An attribute is a name-value pair. Elements have an arbitrary
- number of attributes, each with a unique name.
-
- @note The attributes are not TiXmlNodes, since they are not
- part of the tinyXML document object model. There are other
- suggested ways to look at this problem.
-*/
-class TiXmlAttribute : public TiXmlBase
-{
- friend class TiXmlAttributeSet;
-
-public:
- /// Construct an empty attribute.
- TiXmlAttribute() : TiXmlBase()
- {
- document = 0;
- prev = next = 0;
- }
-
- #ifdef TIXML_USE_STL
- /// std::string constructor.
- TiXmlAttribute( const std::string& _name, const std::string& _value )
- {
- name = _name;
- value = _value;
- document = 0;
- prev = next = 0;
- }
- #endif
-
- /// Construct an attribute with a name and value.
- TiXmlAttribute( const char * _name, const char * _value )
- {
- name = _name;
- value = _value;
- document = 0;
- prev = next = 0;
- }
-
- const char* Name() const { return name.c_str(); } ///< Return the name of this attribute.
- const char* Value() const { return value.c_str(); } ///< Return the value of this attribute.
- #ifdef TIXML_USE_STL
- const std::string& NameStr() const { return name; } ///< Return the name of this attribute.
- const std::string& ValueStr() const { return value; } ///< Return the value of this attribute.
- #endif
- int IntValue() const; ///< Return the value of this attribute, converted to an integer.
- double DoubleValue() const; ///< Return the value of this attribute, converted to a double.
-
- // Get the tinyxml string representation
- const TIXML_STRING& NameTStr() const { return name; }
-
- /** QueryIntValue examines the value string. It is an alternative to the
- IntValue() method with richer error checking.
- If the value is an integer, it is stored in 'value' and
- the call returns TIXML_SUCCESS. If it is not
- an integer, it returns TIXML_WRONG_TYPE.
-
- A specialized but useful call. Note that for success it returns 0,
- which is the opposite of almost all other TinyXml calls.
- */
- int QueryIntValue( int* _value ) const;
- /// QueryDoubleValue examines the value string. See QueryIntValue().
- int QueryDoubleValue( double* _value ) const;
-
- void SetName( const char* _name ) { name = _name; } ///< Set the name of this attribute.
- void SetValue( const char* _value ) { value = _value; } ///< Set the value.
-
- void SetIntValue( int _value ); ///< Set the value from an integer.
- void SetDoubleValue( double _value ); ///< Set the value from a double.
-
- #ifdef TIXML_USE_STL
- /// STL std::string form.
- void SetName( const std::string& _name ) { name = _name; }
- /// STL std::string form.
- void SetValue( const std::string& _value ) { value = _value; }
- #endif
-
- /// Get the next sibling attribute in the DOM. Returns null at end.
- const TiXmlAttribute* Next() const;
- TiXmlAttribute* Next() {
- return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() );
- }
-
- /// Get the previous sibling attribute in the DOM. Returns null at beginning.
- const TiXmlAttribute* Previous() const;
- TiXmlAttribute* Previous() {
- return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() );
- }
-
- bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; }
- bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; }
- bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; }
-
- /* Attribute parsing starts: first letter of the name
- returns: the next char after the value end quote
- */
- virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
-
- // Prints this Attribute to a FILE stream.
- virtual void Print( FILE* cfile, int depth ) const {
- Print( cfile, depth, 0 );
- }
- void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
-
- // [internal use]
- // Set the document pointer so the attribute can report errors.
- void SetDocument( TiXmlDocument* doc ) { document = doc; }
-
-private:
- TiXmlAttribute( const TiXmlAttribute& ); // not implemented.
- void operator=( const TiXmlAttribute& base ); // not allowed.
-
- TiXmlDocument* document; // A pointer back to a document, for error reporting.
- TIXML_STRING name;
- TIXML_STRING value;
- TiXmlAttribute* prev;
- TiXmlAttribute* next;
-};
-
-
-/* A class used to manage a group of attributes.
- It is only used internally, both by the ELEMENT and the DECLARATION.
-
- The set can be changed transparent to the Element and Declaration
- classes that use it, but NOT transparent to the Attribute
- which has to implement a next() and previous() method. Which makes
- it a bit problematic and prevents the use of STL.
-
- This version is implemented with circular lists because:
- - I like circular lists
- - it demonstrates some independence from the (typical) doubly linked list.
-*/
-class TiXmlAttributeSet
-{
-public:
- TiXmlAttributeSet();
- ~TiXmlAttributeSet();
-
- void Add( TiXmlAttribute* attribute );
- void Remove( TiXmlAttribute* attribute );
-
- const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
- TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
- const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
- TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
-
- const TiXmlAttribute* Find( const char* _name ) const;
- TiXmlAttribute* Find( const char* _name ) {
- return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) );
- }
- #ifdef TIXML_USE_STL
- const TiXmlAttribute* Find( const std::string& _name ) const;
- TiXmlAttribute* Find( const std::string& _name ) {
- return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) );
- }
-
- #endif
-
-private:
- //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element),
- //*ME: this class must be also use a hidden/disabled copy-constructor !!!
- TiXmlAttributeSet( const TiXmlAttributeSet& ); // not allowed
- void operator=( const TiXmlAttributeSet& ); // not allowed (as TiXmlAttribute)
-
- TiXmlAttribute sentinel;
-};
-
-
-/** The element is a container class. It has a value, the element name,
- and can contain other elements, text, comments, and unknowns.
- Elements also contain an arbitrary number of attributes.
-*/
-class TiXmlElement : public TiXmlNode
-{
-public:
- /// Construct an element.
- TiXmlElement (const char * in_value);
-
- #ifdef TIXML_USE_STL
- /// std::string constructor.
- TiXmlElement( const std::string& _value );
- #endif
-
- TiXmlElement( const TiXmlElement& );
-
- void operator=( const TiXmlElement& base );
-
- virtual ~TiXmlElement();
-
- /** Given an attribute name, Attribute() returns the value
- for the attribute of that name, or null if none exists.
- */
- const char* Attribute( const char* name ) const;
-
- /** Given an attribute name, Attribute() returns the value
- for the attribute of that name, or null if none exists.
- If the attribute exists and can be converted to an integer,
- the integer value will be put in the return 'i', if 'i'
- is non-null.
- */
- const char* Attribute( const char* name, int* i ) const;
-
- /** Given an attribute name, Attribute() returns the value
- for the attribute of that name, or null if none exists.
- If the attribute exists and can be converted to an double,
- the double value will be put in the return 'd', if 'd'
- is non-null.
- */
- const char* Attribute( const char* name, double* d ) const;
-
- /** QueryIntAttribute examines the attribute - it is an alternative to the
- Attribute() method with richer error checking.
- If the attribute is an integer, it is stored in 'value' and
- the call returns TIXML_SUCCESS. If it is not
- an integer, it returns TIXML_WRONG_TYPE. If the attribute
- does not exist, then TIXML_NO_ATTRIBUTE is returned.
- */
- int QueryIntAttribute( const char* name, int* _value ) const;
- /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
- int QueryDoubleAttribute( const char* name, double* _value ) const;
- /// QueryFloatAttribute examines the attribute - see QueryIntAttribute().
- int QueryFloatAttribute( const char* name, float* _value ) const {
- double d;
- int result = QueryDoubleAttribute( name, &d );
- if ( result == TIXML_SUCCESS ) {
- *_value = (float)d;
- }
- return result;
- }
-
- #ifdef TIXML_USE_STL
- /** Template form of the attribute query which will try to read the
- attribute into the specified type. Very easy, very powerful, but
- be careful to make sure to call this with the correct type.
-
- NOTE: This method doesn't work correctly for 'string' types.
-
- @return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE
- */
- template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const
- {
- const TiXmlAttribute* node = attributeSet.Find( name );
- if ( !node )
- return TIXML_NO_ATTRIBUTE;
-
- std::stringstream sstream( node->ValueStr() );
- sstream >> *outValue;
- if ( !sstream.fail() )
- return TIXML_SUCCESS;
- return TIXML_WRONG_TYPE;
- }
- /*
- This is - in theory - a bug fix for "QueryValueAtribute returns truncated std::string"
- but template specialization is hard to get working cross-compiler. Leaving the bug for now.
-
- // The above will fail for std::string because the space character is used as a seperator.
- // Specialize for strings. Bug [ 1695429 ] QueryValueAtribute returns truncated std::string
- template<> int QueryValueAttribute( const std::string& name, std::string* outValue ) const
- {
- const TiXmlAttribute* node = attributeSet.Find( name );
- if ( !node )
- return TIXML_NO_ATTRIBUTE;
- *outValue = node->ValueStr();
- return TIXML_SUCCESS;
- }
- */
- #endif
-
- /** Sets an attribute of name to a given value. The attribute
- will be created if it does not exist, or changed if it does.
- */
- void SetAttribute( const char* name, const char * _value );
-
- #ifdef TIXML_USE_STL
- const std::string* Attribute( const std::string& name ) const;
- const std::string* Attribute( const std::string& name, int* i ) const;
- const std::string* Attribute( const std::string& name, double* d ) const;
- int QueryIntAttribute( const std::string& name, int* _value ) const;
- int QueryDoubleAttribute( const std::string& name, double* _value ) const;
-
- /// STL std::string form.
- void SetAttribute( const std::string& name, const std::string& _value );
- ///< STL std::string form.
- void SetAttribute( const std::string& name, int _value );
- #endif
-
- /** Sets an attribute of name to a given value. The attribute
- will be created if it does not exist, or changed if it does.
- */
- void SetAttribute( const char * name, int value );
-
- /** Sets an attribute of name to a given value. The attribute
- will be created if it does not exist, or changed if it does.
- */
- void SetDoubleAttribute( const char * name, double value );
-
- /** Deletes an attribute with the given name.
- */
- void RemoveAttribute( const char * name );
- #ifdef TIXML_USE_STL
- void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); } ///< STL std::string form.
- #endif
-
- const TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); } ///< Access the first attribute in this element.
- TiXmlAttribute* FirstAttribute() { return attributeSet.First(); }
- const TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); } ///< Access the last attribute in this element.
- TiXmlAttribute* LastAttribute() { return attributeSet.Last(); }
-
- /** Convenience function for easy access to the text inside an element. Although easy
- and concise, GetText() is limited compared to getting the TiXmlText child
- and accessing it directly.
-
- If the first child of 'this' is a TiXmlText, the GetText()
- returns the character string of the Text node, else null is returned.
-
- This is a convenient method for getting the text of simple contained text:
- @verbatim
- <foo>This is text</foo>
- const char* str = fooElement->GetText();
- @endverbatim
-
- 'str' will be a pointer to "This is text".
-
- Note that this function can be misleading. If the element foo was created from
- this XML:
- @verbatim
- <foo><b>This is text</b></foo>
- @endverbatim
-
- then the value of str would be null. The first child node isn't a text node, it is
- another element. From this XML:
- @verbatim
- <foo>This is <b>text</b></foo>
- @endverbatim
- GetText() will return "This is ".
-
- WARNING: GetText() accesses a child node - don't become confused with the
- similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are
- safe type casts on the referenced node.
- */
- const char* GetText() const;
-
- /// Creates a new Element and returns it - the returned element is a copy.
- virtual TiXmlNode* Clone() const;
- // Print the Element to a FILE stream.
- virtual void Print( FILE* cfile, int depth ) const;
-
- /* Attribtue parsing starts: next char past '<'
- returns: next char past '>'
- */
- virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
-
- virtual const TiXmlElement* ToElement() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
- virtual TiXmlElement* ToElement() { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
-
- /** Walk the XML tree visiting this node and all of its children.
- */
- virtual bool Accept( TiXmlVisitor* visitor ) const;
-
-protected:
-
- void CopyTo( TiXmlElement* target ) const;
- void ClearThis(); // like clear, but initializes 'this' object as well
-
- // Used to be public [internal use]
- #ifdef TIXML_USE_STL
- virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
- #endif
- /* [internal use]
- Reads the "value" of the element -- another element, or text.
- This should terminate with the current end tag.
- */
- const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding );
-
-private:
-
- TiXmlAttributeSet attributeSet;
-};
-
-
-/** An XML comment.
-*/
-class TiXmlComment : public TiXmlNode
-{
-public:
- /// Constructs an empty comment.
- TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {}
- /// Construct a comment from text.
- TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::COMMENT ) {
- SetValue( _value );
- }
- TiXmlComment( const TiXmlComment& );
- void operator=( const TiXmlComment& base );
-
- virtual ~TiXmlComment() {}
-
- /// Returns a copy of this Comment.
- virtual TiXmlNode* Clone() const;
- // Write this Comment to a FILE stream.
- virtual void Print( FILE* cfile, int depth ) const;
-
- /* Attribtue parsing starts: at the ! of the !--
- returns: next char past '>'
- */
- virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
-
- virtual const TiXmlComment* ToComment() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
- virtual TiXmlComment* ToComment() { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
-
- /** Walk the XML tree visiting this node and all of its children.
- */
- virtual bool Accept( TiXmlVisitor* visitor ) const;
-
-protected:
- void CopyTo( TiXmlComment* target ) const;
-
- // used to be public
- #ifdef TIXML_USE_STL
- virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
- #endif
-// virtual void StreamOut( TIXML_OSTREAM * out ) const;
-
-private:
-
-};
-
-
-/** XML text. A text node can have 2 ways to output the next. "normal" output
- and CDATA. It will default to the mode it was parsed from the XML file and
- you generally want to leave it alone, but you can change the output mode with
- SetCDATA() and query it with CDATA().
-*/
-class TiXmlText : public TiXmlNode
-{
- friend class TiXmlElement;
-public:
- /** Constructor for text element. By default, it is treated as
- normal, encoded text. If you want it be output as a CDATA text
- element, set the parameter _cdata to 'true'
- */
- TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TEXT)
- {
- SetValue( initValue );
- cdata = false;
- }
- virtual ~TiXmlText() {}
-
- #ifdef TIXML_USE_STL
- /// Constructor.
- TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT)
- {
- SetValue( initValue );
- cdata = false;
- }
- #endif
-
- TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TEXT ) { copy.CopyTo( this ); }
- void operator=( const TiXmlText& base ) { base.CopyTo( this ); }
-
- // Write this text object to a FILE stream.
- virtual void Print( FILE* cfile, int depth ) const;
-
- /// Queries whether this represents text using a CDATA section.
- bool CDATA() const { return cdata; }
- /// Turns on or off a CDATA representation of text.
- void SetCDATA( bool _cdata ) { cdata = _cdata; }
-
- virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
-
- virtual const TiXmlText* ToText() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
- virtual TiXmlText* ToText() { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
-
- /** Walk the XML tree visiting this node and all of its children.
- */
- virtual bool Accept( TiXmlVisitor* content ) const;
-
-protected :
- /// [internal use] Creates a new Element and returns it.
- virtual TiXmlNode* Clone() const;
- void CopyTo( TiXmlText* target ) const;
-
- bool Blank() const; // returns true if all white space and new lines
- // [internal use]
- #ifdef TIXML_USE_STL
- virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
- #endif
-
-private:
- bool cdata; // true if this should be input and output as a CDATA style text element
-};
-
-
-/** In correct XML the declaration is the first entry in the file.
- @verbatim
- <?xml version="1.0" standalone="yes"?>
- @endverbatim
-
- TinyXml will happily read or write files without a declaration,
- however. There are 3 possible attributes to the declaration:
- version, encoding, and standalone.
-
- Note: In this version of the code, the attributes are
- handled as special cases, not generic attributes, simply
- because there can only be at most 3 and they are always the same.
-*/
-class TiXmlDeclaration : public TiXmlNode
-{
-public:
- /// Construct an empty declaration.
- TiXmlDeclaration() : TiXmlNode( TiXmlNode::DECLARATION ) {}
-
-#ifdef TIXML_USE_STL
- /// Constructor.
- TiXmlDeclaration( const std::string& _version,
- const std::string& _encoding,
- const std::string& _standalone );
-#endif
-
- /// Construct.
- TiXmlDeclaration( const char* _version,
- const char* _encoding,
- const char* _standalone );
-
- TiXmlDeclaration( const TiXmlDeclaration& copy );
- void operator=( const TiXmlDeclaration& copy );
-
- virtual ~TiXmlDeclaration() {}
-
- /// Version. Will return an empty string if none was found.
- const char *Version() const { return version.c_str (); }
- /// Encoding. Will return an empty string if none was found.
- const char *Encoding() const { return encoding.c_str (); }
- /// Is this a standalone document?
- const char *Standalone() const { return standalone.c_str (); }
-
- /// Creates a copy of this Declaration and returns it.
- virtual TiXmlNode* Clone() const;
- // Print this declaration to a FILE stream.
- virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
- virtual void Print( FILE* cfile, int depth ) const {
- Print( cfile, depth, 0 );
- }
-
- virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
-
- virtual const TiXmlDeclaration* ToDeclaration() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
- virtual TiXmlDeclaration* ToDeclaration() { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
-
- /** Walk the XML tree visiting this node and all of its children.
- */
- virtual bool Accept( TiXmlVisitor* visitor ) const;
-
-protected:
- void CopyTo( TiXmlDeclaration* target ) const;
- // used to be public
- #ifdef TIXML_USE_STL
- virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
- #endif
-
-private:
-
- TIXML_STRING version;
- TIXML_STRING encoding;
- TIXML_STRING standalone;
-};
-
-
-/** Any tag that tinyXml doesn't recognize is saved as an
- unknown. It is a tag of text, but should not be modified.
- It will be written back to the XML, unchanged, when the file
- is saved.
-
- DTD tags get thrown into TiXmlUnknowns.
-*/
-class TiXmlUnknown : public TiXmlNode
-{
-public:
- TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN ) {}
- virtual ~TiXmlUnknown() {}
-
- TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::UNKNOWN ) { copy.CopyTo( this ); }
- void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); }
-
- /// Creates a copy of this Unknown and returns it.
- virtual TiXmlNode* Clone() const;
- // Print this Unknown to a FILE stream.
- virtual void Print( FILE* cfile, int depth ) const;
-
- virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
-
- virtual const TiXmlUnknown* ToUnknown() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
- virtual TiXmlUnknown* ToUnknown() { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
-
- /** Walk the XML tree visiting this node and all of its children.
- */
- virtual bool Accept( TiXmlVisitor* content ) const;
-
-protected:
- void CopyTo( TiXmlUnknown* target ) const;
-
- #ifdef TIXML_USE_STL
- virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
- #endif
-
-private:
-
-};
-
-
-/** Always the top level node. A document binds together all the
- XML pieces. It can be saved, loaded, and printed to the screen.
- The 'value' of a document node is the xml file name.
-*/
-class TiXmlDocument : public TiXmlNode
-{
-public:
- /// Create an empty document, that has no name.
- TiXmlDocument();
- /// Create a document with a name. The name of the document is also the filename of the xml.
- TiXmlDocument( const char * documentName );
-
- #ifdef TIXML_USE_STL
- /// Constructor.
- TiXmlDocument( const std::string& documentName );
- #endif
-
- TiXmlDocument( const TiXmlDocument& copy );
- void operator=( const TiXmlDocument& copy );
-
- virtual ~TiXmlDocument();
-
- /** Load a file using the current document value.
- Returns true if successful. Will delete any existing
- document data before loading.
- */
- bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
- /// Save a file using the current document value. Returns true if successful.
- bool SaveFile() const;
- /// Load a file using the given filename. Returns true if successful.
- bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
- /// Save a file using the given filename. Returns true if successful.
- bool SaveFile( const char * filename ) const;
- /** Load a file using the given FILE*. Returns true if successful. Note that this method
- doesn't stream - the entire object pointed at by the FILE*
- will be interpreted as an XML file. TinyXML doesn't stream in XML from the current
- file location. Streaming may be added in the future.
- */
- bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
- /// Save a file using the given FILE*. Returns true if successful.
- bool SaveFile( FILE* ) const;
-
- #ifdef TIXML_USE_STL
- bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) ///< STL std::string version.
- {
-// StringToBuffer f( filename );
-// return ( f.buffer && LoadFile( f.buffer, encoding ));
- return LoadFile( filename.c_str(), encoding );
- }
- bool SaveFile( const std::string& filename ) const ///< STL std::string version.
- {
-// StringToBuffer f( filename );
-// return ( f.buffer && SaveFile( f.buffer ));
- return SaveFile( filename.c_str() );
- }
- /** Parse the given block of xml data. Returns true on success, false on error.
- */
- bool Parse(const std::string& xml)
- {
- Parse(xml.c_str(), NULL, TIXML_DEFAULT_ENCODING);
- return !Error();
- }
- #endif
-
- /** Parse the given null terminated block of xml data. Passing in an encoding to this
- method (either TIXML_ENCODING_LEGACY or TIXML_ENCODING_UTF8 will force TinyXml
- to use that encoding, regardless of what TinyXml might otherwise try to detect.
- */
- virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
-
- /** Get the root element -- the only top level element -- of the document.
- In well formed XML, there should only be one. TinyXml is tolerant of
- multiple elements at the document level.
- */
- const TiXmlElement* RootElement() const { return FirstChildElement(); }
- TiXmlElement* RootElement() { return FirstChildElement(); }
-
- /** If an error occurs, Error will be set to true. Also,
- - The ErrorId() will contain the integer identifier of the error (not generally useful)
- - The ErrorDesc() method will return the name of the error. (very useful)
- - The ErrorRow() and ErrorCol() will return the location of the error (if known)
- */
- bool Error() const { return error; }
-
- /// Contains a textual (english) description of the error if one occurs.
- const char * ErrorDesc() const { return errorDesc.c_str (); }
-
- /** Generally, you probably want the error string ( ErrorDesc() ). But if you
- prefer the ErrorId, this function will fetch it.
- */
- int ErrorId() const { return errorId; }
-
- /** Returns the location (if known) of the error. The first column is column 1,
- and the first row is row 1. A value of 0 means the row and column wasn't applicable
- (memory errors, for example, have no row/column) or the parser lost the error. (An
- error in the error reporting, in that case.)
-
- @sa SetTabSize, Row, Column
- */
- int ErrorRow() const { return errorLocation.row+1; }
- int ErrorCol() const { return errorLocation.col+1; } ///< The column where the error occured. See ErrorRow()
-
- /** SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol())
- to report the correct values for row and column. It does not change the output
- or input in any way.
-
- By calling this method, with a tab size
- greater than 0, the row and column of each node and attribute is stored
- when the file is loaded. Very useful for tracking the DOM back in to
- the source file.
-
- The tab size is required for calculating the location of nodes. If not
- set, the default of 4 is used. The tabsize is set per document. Setting
- the tabsize to 0 disables row/column tracking.
-
- Note that row and column tracking is not supported when using operator>>.
-
- The tab size needs to be enabled before the parse or load. Correct usage:
- @verbatim
- TiXmlDocument doc;
- doc.SetTabSize( 8 );
- doc.Load( "myfile.xml" );
- @endverbatim
-
- @sa Row, Column
- */
- void SetTabSize( int _tabsize ) { tabsize = _tabsize; }
-
- int TabSize() const { return tabsize; }
-
- /** If you have handled the error, it can be reset with this call. The error
- state is automatically cleared if you Parse a new XML block.
- */
- void ClearError() { error = false;
- errorId = 0;
- errorDesc = "";
- errorLocation.row = errorLocation.col = 0;
- //errorLocation.last = 0;
- }
-
- /** Write the document to standard out using formatted printing ("pretty print"). */
- void Print() const { Print( stdout, 0 ); }
-
- /* Write the document to a string using formatted printing ("pretty print"). This
- will allocate a character array (new char[]) and return it as a pointer. The
- calling code pust call delete[] on the return char* to avoid a memory leak.
- */
- //char* PrintToMemory() const;
-
- /// Print this Document to a FILE stream.
- virtual void Print( FILE* cfile, int depth = 0 ) const;
- // [internal use]
- void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding );
-
- virtual const TiXmlDocument* ToDocument() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
- virtual TiXmlDocument* ToDocument() { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
-
- /** Walk the XML tree visiting this node and all of its children.
- */
- virtual bool Accept( TiXmlVisitor* content ) const;
-
-#ifdef HAS_ICONV
- void SetConvertToUtf8(bool convert) { convertToUtf8 = convert; }
- bool convertToUtf8;
- iconv_t iconvContext;
-#endif
-
-protected :
- // [internal use]
- virtual TiXmlNode* Clone() const;
- #ifdef TIXML_USE_STL
- virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
- #endif
-
-private:
- void CopyTo( TiXmlDocument* target ) const;
-
- bool error;
- int errorId;
- TIXML_STRING errorDesc;
- int tabsize;
- TiXmlCursor errorLocation;
- bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and try to write.
-};
-
-
-/**
- A TiXmlHandle is a class that wraps a node pointer with null checks; this is
- an incredibly useful thing. Note that TiXmlHandle is not part of the TinyXml
- DOM structure. It is a separate utility class.
-
- Take an example:
- @verbatim
- <Document>
- <Element attributeA = "valueA">
- <Child attributeB = "value1" />
- <Child attributeB = "value2" />
- </Element>
- <Document>
- @endverbatim
-
- Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very
- easy to write a *lot* of code that looks like:
-
- @verbatim
- TiXmlElement* root = document.FirstChildElement( "Document" );
- if ( root )
- {
- TiXmlElement* element = root->FirstChildElement( "Element" );
- if ( element )
- {
- TiXmlElement* child = element->FirstChildElement( "Child" );
- if ( child )
- {
- TiXmlElement* child2 = child->NextSiblingElement( "Child" );
- if ( child2 )
- {
- // Finally do something useful.
- @endverbatim
-
- And that doesn't even cover "else" cases. TiXmlHandle addresses the verbosity
- of such code. A TiXmlHandle checks for null pointers so it is perfectly safe
- and correct to use:
-
- @verbatim
- TiXmlHandle docHandle( &document );
- TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).ToElement();
- if ( child2 )
- {
- // do something useful
- @endverbatim
-
- Which is MUCH more concise and useful.
-
- It is also safe to copy handles - internally they are nothing more than node pointers.
- @verbatim
- TiXmlHandle handleCopy = handle;
- @endverbatim
-
- What they should not be used for is iteration:
-
- @verbatim
- int i=0;
- while ( true )
- {
- TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", i ).ToElement();
- if ( !child )
- break;
- // do something
- ++i;
- }
- @endverbatim
-
- It seems reasonable, but it is in fact two embedded while loops. The Child method is
- a linear walk to find the element, so this code would iterate much more than it needs
- to. Instead, prefer:
-
- @verbatim
- TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild( "Child" ).ToElement();
-
- for( child; child; child=child->NextSiblingElement() )
- {
- // do something
- }
- @endverbatim
-*/
-class TiXmlHandle
-{
-public:
- /// Create a handle from any node (at any depth of the tree.) This can be a null pointer.
- TiXmlHandle( TiXmlNode* _node ) { this->node = _node; }
- /// Copy constructor
- TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; }
- TiXmlHandle operator=( const TiXmlHandle& ref ) { this->node = ref.node; return *this; }
-
- /// Return a handle to the first child node.
- TiXmlHandle FirstChild() const;
- /// Return a handle to the first child node with the given name.
- TiXmlHandle FirstChild( const char * value ) const;
- /// Return a handle to the first child element.
- TiXmlHandle FirstChildElement() const;
- /// Return a handle to the first child element with the given name.
- TiXmlHandle FirstChildElement( const char * value ) const;
-
- /** Return a handle to the "index" child with the given name.
- The first child is 0, the second 1, etc.
- */
- TiXmlHandle Child( const char* value, int index ) const;
- /** Return a handle to the "index" child.
- The first child is 0, the second 1, etc.
- */
- TiXmlHandle Child( int index ) const;
- /** Return a handle to the "index" child element with the given name.
- The first child element is 0, the second 1, etc. Note that only TiXmlElements
- are indexed: other types are not counted.
- */
- TiXmlHandle ChildElement( const char* value, int index ) const;
- /** Return a handle to the "index" child element.
- The first child element is 0, the second 1, etc. Note that only TiXmlElements
- are indexed: other types are not counted.
- */
- TiXmlHandle ChildElement( int index ) const;
-
- #ifdef TIXML_USE_STL
- TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); }
- TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); }
-
- TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); }
- TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); }
- #endif
-
- /** Return the handle as a TiXmlNode. This may return null.
- */
- TiXmlNode* ToNode() const { return node; }
- /** Return the handle as a TiXmlElement. This may return null.
- */
- TiXmlElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
- /** Return the handle as a TiXmlText. This may return null.
- */
- TiXmlText* ToText() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
- /** Return the handle as a TiXmlUnknown. This may return null.
- */
- TiXmlUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); }
-
- /** @deprecated use ToNode.
- Return the handle as a TiXmlNode. This may return null.
- */
- TiXmlNode* Node() const { return ToNode(); }
- /** @deprecated use ToElement.
- Return the handle as a TiXmlElement. This may return null.
- */
- TiXmlElement* Element() const { return ToElement(); }
- /** @deprecated use ToText()
- Return the handle as a TiXmlText. This may return null.
- */
- TiXmlText* Text() const { return ToText(); }
- /** @deprecated use ToUnknown()
- Return the handle as a TiXmlUnknown. This may return null.
- */
- TiXmlUnknown* Unknown() const { return ToUnknown(); }
-
-private:
- TiXmlNode* node;
-};
-
-
-/** Print to memory functionality. The TiXmlPrinter is useful when you need to:
-
- -# Print to memory (especially in non-STL mode)
- -# Control formatting (line endings, etc.)
-
- When constructed, the TiXmlPrinter is in its default "pretty printing" mode.
- Before calling Accept() you can call methods to control the printing
- of the XML document. After TiXmlNode::Accept() is called, the printed document can
- be accessed via the CStr(), Str(), and Size() methods.
-
- TiXmlPrinter uses the Visitor API.
- @verbatim
- TiXmlPrinter printer;
- printer.SetIndent( "\t" );
-
- doc.Accept( &printer );
- fprintf( stdout, "%s", printer.CStr() );
- @endverbatim
-*/
-class TiXmlPrinter : public TiXmlVisitor
-{
-public:
- TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ),
- buffer(), indent( " " ), lineBreak( "\n" ) {}
-
- virtual bool VisitEnter( const TiXmlDocument& doc );
- virtual bool VisitExit( const TiXmlDocument& doc );
-
- virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute );
- virtual bool VisitExit( const TiXmlElement& element );
-
- virtual bool Visit( const TiXmlDeclaration& declaration );
- virtual bool Visit( const TiXmlText& text );
- virtual bool Visit( const TiXmlComment& comment );
- virtual bool Visit( const TiXmlUnknown& unknown );
-
- /** Set the indent characters for printing. By default 4 spaces
- but tab (\t) is also useful, or null/empty string for no indentation.
- */
- void SetIndent( const char* _indent ) { indent = _indent ? _indent : "" ; }
- /// Query the indention string.
- const char* Indent() { return indent.c_str(); }
- /** Set the line breaking string. By default set to newline (\n).
- Some operating systems prefer other characters, or can be
- set to the null/empty string for no indenation.
- */
- void SetLineBreak( const char* _lineBreak ) { lineBreak = _lineBreak ? _lineBreak : ""; }
- /// Query the current line breaking string.
- const char* LineBreak() { return lineBreak.c_str(); }
-
- /** Switch over to "stream printing" which is the most dense formatting without
- linebreaks. Common when the XML is needed for network transmission.
- */
- void SetStreamPrinting() { indent = "";
- lineBreak = "";
- }
- /// Return the result.
- const char* CStr() { return buffer.c_str(); }
- /// Return the length of the result string.
- size_t Size() { return buffer.size(); }
-
- #ifdef TIXML_USE_STL
- /// Return the result.
- const std::string& Str() { return buffer; }
- #endif
-
-private:
- void DoIndent() {
- for( int i=0; i<depth; ++i )
- buffer += indent;
- }
- void DoLineBreak() {
- buffer += lineBreak;
- }
-
- int depth;
- bool simpleTextPrint;
- TIXML_STRING buffer;
- TIXML_STRING indent;
- TIXML_STRING lineBreak;
-};
-
-
-#ifdef _MSC_VER
-#pragma warning( pop )
-#endif
-
-#endif
-
diff --git a/guilib/tinyXML/tinyxmlerror.cpp b/guilib/tinyXML/tinyxmlerror.cpp
deleted file mode 100644
index d24f63b2e5..0000000000
--- a/guilib/tinyXML/tinyxmlerror.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-www.sourceforge.net/projects/tinyxml
-Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
-
-This software is provided 'as-is', without any express or implied
-warranty. In no event will the authors be held liable for any
-damages arising from the use of this software.
-
-Permission is granted to anyone to use this software for any
-purpose, including commercial applications, and to alter it and
-redistribute it freely, subject to the following restrictions:
-
-1. The origin of this software must not be misrepresented; you must
-not claim that you wrote the original software. If you use this
-software in a product, an acknowledgment in the product documentation
-would be appreciated but is not required.
-
-2. Altered source versions must be plainly marked as such, and
-must not be misrepresented as being the original software.
-
-3. This notice may not be removed or altered from any source
-distribution.
-*/
-
-#include "tinyxml.h"
-
-// The goal of the seperate error file is to make the first
-// step towards localization. tinyxml (currently) only supports
-// english error messages, but the could now be translated.
-//
-// It also cleans up the code a bit.
-//
-
-const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] =
-{
- "No error",
- "Error",
- "Failed to open file",
- "Memory allocation failed.",
- "Error parsing Element.",
- "Failed to read Element name",
- "Error reading Element value.",
- "Error reading Attributes.",
- "Error: empty tag.",
- "Error reading end tag.",
- "Error parsing Unknown.",
- "Error parsing Comment.",
- "Error parsing Declaration.",
- "Error document empty.",
- "Error null (0) or unexpected EOF found in input stream.",
- "Error parsing CDATA.",
- "Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.",
-};
diff --git a/guilib/tinyXML/tinyxmlparser.cpp b/guilib/tinyXML/tinyxmlparser.cpp
deleted file mode 100644
index 712eb10654..0000000000
--- a/guilib/tinyXML/tinyxmlparser.cpp
+++ /dev/null
@@ -1,1683 +0,0 @@
-/*
-www.sourceforge.net/projects/tinyxml
-Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com)
-
-This software is provided 'as-is', without any express or implied
-warranty. In no event will the authors be held liable for any
-damages arising from the use of this software.
-
-Permission is granted to anyone to use this software for any
-purpose, including commercial applications, and to alter it and
-redistribute it freely, subject to the following restrictions:
-
-1. The origin of this software must not be misrepresented; you must
-not claim that you wrote the original software. If you use this
-software in a product, an acknowledgment in the product documentation
-would be appreciated but is not required.
-
-2. Altered source versions must be plainly marked as such, and
-must not be misrepresented as being the original software.
-
-3. This notice may not be removed or altered from any source
-distribution.
-*/
-
-#include <ctype.h>
-#include <stddef.h>
-
-#include "tinyxml.h"
-#include "CharsetConverter.h"
-
-//#define DEBUG_PARSER
-#if defined( DEBUG_PARSER )
-# if defined( DEBUG ) && defined( _MSC_VER )
-# include <windows.h>
-# define TIXML_LOG OutputDebugString
-# else
-# define TIXML_LOG printf
-# endif
-#endif
-
-// Note tha "PutString" hardcodes the same list. This
-// is less flexible than it appears. Changing the entries
-// or order will break putstring.
-TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] =
-{
- { "&amp;", 5, '&' },
- { "&lt;", 4, '<' },
- { "&gt;", 4, '>' },
- { "&quot;", 6, '\"' },
- { "&apos;", 6, '\'' }
-};
-
-// Bunch of unicode info at:
-// http://www.unicode.org/faq/utf_bom.html
-// Including the basic of this table, which determines the #bytes in the
-// sequence from the lead byte. 1 placed for invalid sequences --
-// although the result will be junk, pass it through as much as possible.
-// Beware of the non-characters in UTF-8:
-// ef bb bf (Microsoft "lead bytes")
-// ef bf be
-// ef bf bf
-
-const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
-const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
-const unsigned char TIXML_UTF_LEAD_2 = 0xbfU;
-
-const int TiXmlBase::utf8ByteTable[256] =
-{
- // 0 1 2 3 4 5 6 7 8 9 a b c d e f
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x20
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x30
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x50
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x70 End of ASCII range
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 0x80 to 0xc1 invalid
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0
- 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xc0 0xc2 to 0xdf 2 byte
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xd0
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xe0 0xe0 to 0xef 3 byte
- 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // 0xf0 0xf0 to 0xf4 4 byte, 0xf5 and higher invalid
-};
-
-
-void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length )
-{
- const unsigned long BYTE_MASK = 0xBF;
- const unsigned long BYTE_MARK = 0x80;
- const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
-
- if (input < 0x80)
- *length = 1;
- else if ( input < 0x800 )
- *length = 2;
- else if ( input < 0x10000 )
- *length = 3;
- else if ( input < 0x200000 )
- *length = 4;
- else
- { *length = 0; return; } // This code won't covert this correctly anyway.
-
- output += *length;
-
- // Scary scary fall throughs.
- switch (*length)
- {
- case 4:
- --output;
- *output = (char)((input | BYTE_MARK) & BYTE_MASK);
- input >>= 6;
- case 3:
- --output;
- *output = (char)((input | BYTE_MARK) & BYTE_MASK);
- input >>= 6;
- case 2:
- --output;
- *output = (char)((input | BYTE_MARK) & BYTE_MASK);
- input >>= 6;
- case 1:
- --output;
- *output = (char)(input | FIRST_BYTE_MARK[*length]);
- }
-}
-
-
-/*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding /*encoding*/ )
-{
- // This will only work for low-ascii, everything else is assumed to be a valid
- // letter. I'm not sure this is the best approach, but it is quite tricky trying
- // to figure out alhabetical vs. not across encoding. So take a very
- // conservative approach.
-
-// if ( encoding == TIXML_ENCODING_UTF8 )
-// {
- if ( anyByte < 127 )
- return isalpha( anyByte );
- else
- return 1; // What else to do? The unicode set is huge...get the english ones right.
-// }
-// else
-// {
-// return isalpha( anyByte );
-// }
-}
-
-
-/*static*/ int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding /*encoding*/ )
-{
- // This will only work for low-ascii, everything else is assumed to be a valid
- // letter. I'm not sure this is the best approach, but it is quite tricky trying
- // to figure out alhabetical vs. not across encoding. So take a very
- // conservative approach.
-
-// if ( encoding == TIXML_ENCODING_UTF8 )
-// {
- if ( anyByte < 127 )
- return isalnum( anyByte );
- else
- return 1; // What else to do? The unicode set is huge...get the english ones right.
-// }
-// else
-// {
-// return isalnum( anyByte );
-// }
-}
-
-
-class TiXmlParsingData
-{
- friend class TiXmlDocument;
- public:
- void Stamp( const char* now, TiXmlEncoding encoding );
-
- const TiXmlCursor& Cursor() { return cursor; }
-
- private:
- // Only used by the document!
- TiXmlParsingData( const char* start, int _tabsize, int row, int col )
- {
- assert( start );
- stamp = start;
- tabsize = _tabsize;
- cursor.row = row;
- cursor.col = col;
- }
-
- TiXmlCursor cursor;
- const char* stamp;
- int tabsize;
-};
-
-
-void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding )
-{
- assert( now );
-
- // Do nothing if the tabsize is 0.
- if ( tabsize < 1 )
- {
- return;
- }
-
- // Get the current row, column.
- int row = cursor.row;
- int col = cursor.col;
- const char* p = stamp;
- assert( p );
-
- while ( p < now )
- {
- // Treat p as unsigned, so we have a happy compiler.
- const unsigned char* pU = (const unsigned char*)p;
-
- // Code contributed by Fletcher Dunn: (modified by lee)
- switch (*pU) {
- case 0:
- // We *should* never get here, but in case we do, don't
- // advance past the terminating null character, ever
- return;
-
- case '\r':
- // bump down to the next line
- ++row;
- col = 0;
- // Eat the character
- ++p;
-
- // Check for \r\n sequence, and treat this as a single character
- if (*p == '\n') {
- ++p;
- }
- break;
-
- case '\n':
- // bump down to the next line
- ++row;
- col = 0;
-
- // Eat the character
- ++p;
-
- // Check for \n\r sequence, and treat this as a single
- // character. (Yes, this bizarre thing does occur still
- // on some arcane platforms...)
- if (*p == '\r') {
- ++p;
- }
- break;
-
- case '\t':
- // Eat the character
- ++p;
-
- // Skip to next tab stop
- col = (col / tabsize + 1) * tabsize;
- break;
-
- case TIXML_UTF_LEAD_0:
- if ( encoding == TIXML_ENCODING_UTF8 )
- {
- if ( *(p+1) && *(p+2) )
- {
- // In these cases, don't advance the column. These are
- // 0-width spaces.
- if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 )
- p += 3;
- else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU )
- p += 3;
- else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU )
- p += 3;
- else
- { p +=3; ++col; } // A normal character.
- }
- }
- else
- {
- ++p;
- ++col;
- }
- break;
-
- default:
- if ( encoding == TIXML_ENCODING_UTF8 )
- {
- // Eat the 1 to 4 byte utf8 character.
- int step = TiXmlBase::utf8ByteTable[*((const unsigned char*)p)];
- if ( step == 0 )
- step = 1; // Error case from bad encoding, but handle gracefully.
- p += step;
-
- // Just advance one column, of course.
- ++col;
- }
- else
- {
- ++p;
- ++col;
- }
- break;
- }
- }
- cursor.row = row;
- cursor.col = col;
- assert( cursor.row >= -1 );
- assert( cursor.col >= -1 );
- stamp = p;
- assert( stamp );
-}
-
-
-const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding )
-{
- if ( !p || !*p )
- {
- return 0;
- }
- if ( encoding == TIXML_ENCODING_UTF8 )
- {
- while ( *p )
- {
- const unsigned char* pU = (const unsigned char*)p;
-
- // Skip the stupid Microsoft UTF-8 Byte order marks
- if ( *(pU+0)==TIXML_UTF_LEAD_0
- && *(pU+1)==TIXML_UTF_LEAD_1
- && *(pU+2)==TIXML_UTF_LEAD_2 )
- {
- p += 3;
- continue;
- }
- else if(*(pU+0)==TIXML_UTF_LEAD_0
- && *(pU+1)==0xbfU
- && *(pU+2)==0xbeU )
- {
- p += 3;
- continue;
- }
- else if(*(pU+0)==TIXML_UTF_LEAD_0
- && *(pU+1)==0xbfU
- && *(pU+2)==0xbfU )
- {
- p += 3;
- continue;
- }
-
- if ( IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ) // Still using old rules for white space.
- ++p;
- else
- break;
- }
- }
- else
- {
- while ( *p && (IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ))
- ++p;
- }
-
- return p;
-}
-
-#ifdef TIXML_USE_STL
-/*static*/ bool TiXmlBase::StreamWhiteSpace( std::istream * in, TIXML_STRING * tag )
-{
- for( ;; )
- {
- if ( !in->good() ) return false;
-
- int c = in->peek();
- // At this scope, we can't get to a document. So fail silently.
- if ( !IsWhiteSpace( c ) || c <= 0 )
- return true;
-
- *tag += (char) in->get();
- }
-}
-
-/*static*/ bool TiXmlBase::StreamTo( std::istream * in, int character, TIXML_STRING * tag )
-{
- //assert( character > 0 && character < 128 ); // else it won't work in utf-8
- while ( in->good() )
- {
- int c = in->peek();
- if ( c == character )
- return true;
- if ( c <= 0 ) // Silent failure: can't get document at this scope
- return false;
-
- in->get();
- *tag += (char) c;
- }
- return false;
-}
-#endif
-
-// One of TinyXML's more performance demanding functions. Try to keep the memory overhead down. The
-// "assign" optimization removes over 10% of the execution time.
-//
-const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncoding encoding )
-{
- // Oddly, not supported on some comilers,
- //name->clear();
- // So use this:
- *name = "";
- assert( p );
-
- // Names start with letters or underscores.
- // Of course, in unicode, tinyxml has no idea what a letter *is*. The
- // algorithm is generous.
- //
- // After that, they can be letters, underscores, numbers,
- // hyphens, or colons. (Colons are valid ony for namespaces,
- // but tinyxml can't tell namespaces from names.)
- if ( p && *p
- && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) )
- {
- const char* start = p;
- while( p && *p
- && ( IsAlphaNum( (unsigned char ) *p, encoding )
- || *p == '_'
- || *p == '-'
- || *p == '.'
- || *p == ':' ) )
- {
- //(*name) += *p; // expensive
- ++p;
- }
- if ( p-start > 0 ) {
- name->assign( start, p-start );
- }
- return p;
- }
- return 0;
-}
-
-const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXmlEncoding encoding )
-{
- // Presume an entity, and pull it out.
- TIXML_STRING ent;
- int i;
-
- if ( *(p+1) && *(p+1) == '#' && *(p+2) )
- {
- unsigned long ucs = 0;
- ptrdiff_t delta = 0;
- unsigned mult = 1;
-
- if ( *(p+2) == 'x' )
- {
- // Hexadecimal.
- if ( !*(p+3) ) return 0;
-
- const char* q = p+3;
- q = strchr( q, ';' );
-
- if ( !q || !*q ) return 0;
-
- delta = q-p;
- --q;
-
- while ( *q != 'x' )
- {
- if ( *q >= '0' && *q <= '9' )
- ucs += mult * (*q - '0');
- else if ( *q >= 'a' && *q <= 'f' )
- ucs += mult * (*q - 'a' + 10);
- else if ( *q >= 'A' && *q <= 'F' )
- ucs += mult * (*q - 'A' + 10 );
- else
- return 0;
- mult *= 16;
- --q;
- }
- }
- else
- {
- // Decimal.
- if ( !*(p+2) ) return 0;
-
- const char* q = p+2;
- q = strchr( q, ';' );
-
- if ( !q || !*q ) return 0;
-
- delta = q-p;
- --q;
-
- while ( *q != '#' )
- {
- if ( *q >= '0' && *q <= '9' )
- ucs += mult * (*q - '0');
- else
- return 0;
- mult *= 10;
- --q;
- }
- }
- if ( encoding == TIXML_ENCODING_UTF8 )
- {
- // convert the UCS to UTF-8
- ConvertUTF32ToUTF8( ucs, value, length );
- }
- else
- {
- *value = (char)ucs;
- *length = 1;
- }
- return p + delta + 1;
- }
-
- // Now try to match it.
- for( i=0; i<NUM_ENTITY; ++i )
- {
- if ( strncmp( entity[i].str, p, entity[i].strLength ) == 0 )
- {
- assert( strlen( entity[i].str ) == entity[i].strLength );
- *value = entity[i].chr;
- *length = 1;
- return ( p + entity[i].strLength );
- }
- }
-
- // So it wasn't an entity, its unrecognized, or something like that.
- *value = *p; // Don't put back the last one, since we return it!
- *length = 1; // Leave unrecognized entities - this doesn't really work.
- // Just writes strange XML.
- return p+1;
-}
-
-
-bool TiXmlBase::StringEqual( const char* p,
- const char* tag,
- bool ignoreCase,
- TiXmlEncoding encoding )
-{
- assert( p );
- assert( tag );
- if ( !p || !*p )
- {
- assert( 0 );
- return false;
- }
-
- const char* q = p;
-
- if ( ignoreCase )
- {
- while ( *q && *tag && ToLower( *q, encoding ) == ToLower( *tag, encoding ) )
- {
- ++q;
- ++tag;
- }
-
- if ( *tag == 0 )
- return true;
- }
- else
- {
- while ( *q && *tag && *q == *tag )
- {
- ++q;
- ++tag;
- }
-
- if ( *tag == 0 ) // Have we found the end of the tag, and everything equal?
- return true;
- }
- return false;
-}
-
-const char* TiXmlBase::ReadText( const char* p,
- TIXML_STRING * text,
- bool trimWhiteSpace,
- const char* endTag,
- bool caseInsensitive,
- TiXmlEncoding encoding )
-{
- *text = "";
- if ( !trimWhiteSpace // certain tags always keep whitespace
- || !condenseWhiteSpace ) // if true, whitespace is always kept
- {
- // Keep all the white space.
- while ( p && *p
- && !StringEqual( p, endTag, caseInsensitive, encoding )
- )
- {
- int len;
- char cArr[4] = { 0, 0, 0, 0 };
- p = GetChar( p, cArr, &len, encoding );
- text->append( cArr, len );
- }
- }
- else
- {
- bool whitespace = false;
-
- // Remove leading white space:
- p = SkipWhiteSpace( p, encoding );
- while ( p && *p
- && !StringEqual( p, endTag, caseInsensitive, encoding ) )
- {
- if ( *p == '\r' || *p == '\n' )
- {
- whitespace = true;
- ++p;
- }
- else if ( IsWhiteSpace( *p ) )
- {
- whitespace = true;
- ++p;
- }
- else
- {
- // If we've found whitespace, add it before the
- // new character. Any whitespace just becomes a space.
- if ( whitespace )
- {
- (*text) += ' ';
- whitespace = false;
- }
- int len;
- char cArr[4] = { 0, 0, 0, 0 };
- p = GetChar( p, cArr, &len, encoding );
- if ( len == 1 )
- (*text) += cArr[0]; // more efficient
- else
- text->append( cArr, len );
- }
- }
- }
- if ( p )
- p += strlen( endTag );
- return p;
-}
-
-#ifdef HAS_ICONV
-void TiXmlBase::ConvertToUtf8(TiXmlDocument* document, TIXML_STRING* text)
-{
- if (!document) return;
- if (!document->convertToUtf8) return;
- if (document->iconvContext == (iconv_t) -1) return;
-
-#ifdef TIXML_USE_STL
-
- size_t olen = (text->size() * 4) + 1;
- char* output = new char[olen];
- char* obuf = output;
- size_t ilen = text->size() + 1;
- const char* ibuf = (const char*) text->c_str();
-
- if (iconv_const(document->iconvContext, &ibuf, &ilen, &obuf, &olen) == (size_t) -1)
- {
- delete [] output;
- return;
- }
-
- *text = output;
- delete [] output;
-#endif
-}
-#endif
-
-#ifdef TIXML_USE_STL
-
-void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag )
-{
- // The basic issue with a document is that we don't know what we're
- // streaming. Read something presumed to be a tag (and hope), then
- // identify it, and call the appropriate stream method on the tag.
- //
- // This "pre-streaming" will never read the closing ">" so the
- // sub-tag can orient itself.
-
- if ( !StreamTo( in, '<', tag ) )
- {
- SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
- return;
- }
-
- while ( in->good() )
- {
- int tagIndex = (int) tag->length();
- while ( in->good() && in->peek() != '>' )
- {
- int c = in->get();
- if ( c <= 0 )
- {
- SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
- break;
- }
- (*tag) += (char) c;
- }
-
- if ( in->good() )
- {
- // We now have something we presume to be a node of
- // some sort. Identify it, and call the node to
- // continue streaming.
- TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING );
-
- if ( node )
- {
- node->StreamIn( in, tag );
- bool isElement = node->ToElement() != 0;
- delete node;
- node = 0;
-
- // If this is the root element, we're done. Parsing will be
- // done by the >> operator.
- if ( isElement )
- {
- return;
- }
- }
- else
- {
- SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN );
- return;
- }
- }
- }
- // We should have returned sooner.
- SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN );
-}
-
-#endif
-
-const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiXmlEncoding encoding )
-{
- ClearError();
-
- // Parse away, at the document level. Since a document
- // contains nothing but other tags, most of what happens
- // here is skipping white space.
- if ( !p || !*p )
- {
- SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
- return 0;
- }
-
- // Note that, for a document, this needs to come
- // before the while space skip, so that parsing
- // starts from the pointer we are given.
- location.Clear();
- if ( prevData )
- {
- location.row = prevData->cursor.row;
- location.col = prevData->cursor.col;
- }
- else
- {
- location.row = 0;
- location.col = 0;
- }
- TiXmlParsingData data( p, TabSize(), location.row, location.col );
- location = data.Cursor();
-
- if ( encoding == TIXML_ENCODING_UNKNOWN )
- {
- // Check for the Microsoft UTF-8 lead bytes.
- const unsigned char* pU = (const unsigned char*)p;
- if ( *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0
- && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1
- && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 )
- {
- encoding = TIXML_ENCODING_UTF8;
- useMicrosoftBOM = true;
- }
- }
-
- p = SkipWhiteSpace( p, encoding );
- if ( !p )
- {
- SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
- return 0;
- }
-
- while ( p && *p )
- {
- TiXmlNode* node = Identify( p, encoding );
- if ( node )
- {
- p = node->Parse( p, &data, encoding );
- LinkEndChild( node );
- }
- else
- {
- break;
- }
-
- // Did we get encoding info?
- if ( encoding == TIXML_ENCODING_UNKNOWN
- && node->ToDeclaration() )
- {
- TiXmlDeclaration* dec = node->ToDeclaration();
- const char* enc = dec->Encoding();
- assert( enc );
-
- if ( *enc == 0 )
- encoding = TIXML_ENCODING_UTF8;
- else if ( StringEqual( enc, "UTF-8", true, TIXML_ENCODING_UNKNOWN ) )
- encoding = TIXML_ENCODING_UTF8;
- else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) )
- encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice
- else
- {
-#ifdef HAS_ICONV
- if (convertToUtf8)
- {
- if (iconvContext != (iconv_t) -1)
- {
- iconv_close(iconvContext);
- iconvContext = (iconv_t) -1;
- }
-
- iconvContext = iconv_open("UTF8", enc);
- }
-#endif
- encoding = TIXML_ENCODING_LEGACY;
- }
- }
-
- p = SkipWhiteSpace( p, encoding );
- }
-
- // Was this empty?
- if ( !firstChild ) {
- SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding );
- return 0;
- }
-
- // All is well.
- return p;
-}
-
-void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* data, TiXmlEncoding encoding )
-{
- // The first error in a chain is more accurate - don't set again!
- if ( error )
- return;
-
- assert( err > 0 && err < TIXML_ERROR_STRING_COUNT );
- error = true;
- errorId = err;
- errorDesc = errorString[ errorId ];
-
- errorLocation.Clear();
- if ( pError && data )
- {
- data->Stamp( pError, encoding );
- errorLocation = data->Cursor();
- }
-}
-
-
-TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding )
-{
- TiXmlNode* returnNode = 0;
-
- p = SkipWhiteSpace( p, encoding );
- if( !p || !*p || *p != '<' )
- {
- return 0;
- }
-
- TiXmlDocument* doc = GetDocument();
- p = SkipWhiteSpace( p, encoding );
-
- if ( !p || !*p )
- {
- return 0;
- }
-
- // What is this thing?
- // - Elements start with a letter or underscore, but xml is reserved.
- // - Comments: <!--
- // - Decleration: <?xml
- // - Everthing else is unknown to tinyxml.
- //
-
- const char* xmlHeader = { "<?xml" };
- const char* commentHeader = { "<!--" };
- const char* dtdHeader = { "<!" };
- const char* cdataHeader = { "<![CDATA[" };
-
- if ( StringEqual( p, xmlHeader, true, encoding ) )
- {
- #ifdef DEBUG_PARSER
- TIXML_LOG( "XML parsing Declaration\n" );
- #endif
- returnNode = new TiXmlDeclaration();
- }
- else if ( StringEqual( p, commentHeader, false, encoding ) )
- {
- #ifdef DEBUG_PARSER
- TIXML_LOG( "XML parsing Comment\n" );
- #endif
- returnNode = new TiXmlComment();
- }
- else if ( StringEqual( p, cdataHeader, false, encoding ) )
- {
- #ifdef DEBUG_PARSER
- TIXML_LOG( "XML parsing CDATA\n" );
- #endif
- TiXmlText* text = new TiXmlText( "" );
- text->SetCDATA( true );
- returnNode = text;
- }
- else if ( StringEqual( p, dtdHeader, false, encoding ) )
- {
- #ifdef DEBUG_PARSER
- TIXML_LOG( "XML parsing Unknown(1)\n" );
- #endif
- returnNode = new TiXmlUnknown();
- }
- else if ( IsAlpha( *(p+1), encoding )
- || *(p+1) == '_' )
- {
- #ifdef DEBUG_PARSER
- TIXML_LOG( "XML parsing Element\n" );
- #endif
- returnNode = new TiXmlElement( "" );
- }
- else
- {
- #ifdef DEBUG_PARSER
- TIXML_LOG( "XML parsing Unknown(2)\n" );
- #endif
- returnNode = new TiXmlUnknown();
- }
-
- if ( returnNode )
- {
- // Set the parent, so it can report errors
- returnNode->parent = this;
- }
- else
- {
- if ( doc )
- doc->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
- }
- return returnNode;
-}
-
-#ifdef TIXML_USE_STL
-
-void TiXmlElement::StreamIn (std::istream * in, TIXML_STRING * tag)
-{
- // We're called with some amount of pre-parsing. That is, some of "this"
- // element is in "tag". Go ahead and stream to the closing ">"
- while( in->good() )
- {
- int c = in->get();
- if ( c <= 0 )
- {
- TiXmlDocument* document = GetDocument();
- if ( document )
- document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
- return;
- }
- (*tag) += (char) c ;
-
- if ( c == '>' )
- break;
- }
-
- if ( tag->length() < 3 ) return;
-
- // Okay...if we are a "/>" tag, then we're done. We've read a complete tag.
- // If not, identify and stream.
-
- if ( tag->at( tag->length() - 1 ) == '>'
- && tag->at( tag->length() - 2 ) == '/' )
- {
- // All good!
- return;
- }
- else if ( tag->at( tag->length() - 1 ) == '>' )
- {
- // There is more. Could be:
- // text
- // cdata text (which looks like another node)
- // closing tag
- // another node.
- for ( ;; )
- {
- StreamWhiteSpace( in, tag );
-
- // Do we have text?
- if ( in->good() && in->peek() != '<' )
- {
- // Yep, text.
- TiXmlText text( "" );
- text.StreamIn( in, tag );
-
- // What follows text is a closing tag or another node.
- // Go around again and figure it out.
- continue;
- }
-
- // We now have either a closing tag...or another node.
- // We should be at a "<", regardless.
- if ( !in->good() ) return;
- assert( in->peek() == '<' );
- int tagIndex = (int) tag->length();
-
- bool closingTag = false;
- bool firstCharFound = false;
-
- for( ;; )
- {
- if ( !in->good() )
- return;
-
- int c = in->peek();
- if ( c <= 0 )
- {
- TiXmlDocument* document = GetDocument();
- if ( document )
- document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
- return;
- }
-
- if ( c == '>' )
- break;
-
- *tag += (char) c;
- in->get();
-
- // Early out if we find the CDATA id.
- if ( c == '[' && tag->size() >= 9 )
- {
- size_t len = tag->size();
- const char* start = tag->c_str() + len - 9;
- if ( strcmp( start, "<![CDATA[" ) == 0 ) {
- assert( !closingTag );
- break;
- }
- }
-
- if ( !firstCharFound && c != '<' && !IsWhiteSpace( c ) )
- {
- firstCharFound = true;
- if ( c == '/' )
- closingTag = true;
- }
- }
- // If it was a closing tag, then read in the closing '>' to clean up the input stream.
- // If it was not, the streaming will be done by the tag.
- if ( closingTag )
- {
- if ( !in->good() )
- return;
-
- int c = in->get();
- if ( c <= 0 )
- {
- TiXmlDocument* document = GetDocument();
- if ( document )
- document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
- return;
- }
- assert( c == '>' );
- *tag += (char) c;
-
- // We are done, once we've found our closing tag.
- return;
- }
- else
- {
- // If not a closing tag, id it, and stream.
- const char* tagloc = tag->c_str() + tagIndex;
- TiXmlNode* node = Identify( tagloc, TIXML_DEFAULT_ENCODING );
- if ( !node )
- return;
- node->StreamIn( in, tag );
- delete node;
- node = 0;
-
- // No return: go around from the beginning: text, closing tag, or node.
- }
- }
- }
-}
-#endif
-
-const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
-{
- p = SkipWhiteSpace( p, encoding );
- TiXmlDocument* document = GetDocument();
-
- if ( !p || !*p )
- {
- if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, 0, 0, encoding );
- return 0;
- }
-
- if ( data )
- {
- data->Stamp( p, encoding );
- location = data->Cursor();
- }
-
- if ( *p != '<' )
- {
- if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, p, data, encoding );
- return 0;
- }
-
- p = SkipWhiteSpace( p+1, encoding );
-
- // Read the name.
- const char* pErr = p;
-
- p = ReadName( p, &value, encoding );
- if ( !p || !*p )
- {
- if ( document ) document->SetError( TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, pErr, data, encoding );
- return 0;
- }
-
- TIXML_STRING endTag ("</");
- endTag += value;
- endTag += ">";
-
- // Check for and read attributes. Also look for an empty
- // tag or an end tag.
- while ( p && *p )
- {
- pErr = p;
- p = SkipWhiteSpace( p, encoding );
- if ( !p || !*p )
- {
- if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding );
- return 0;
- }
- if ( *p == '/' )
- {
- ++p;
- // Empty tag.
- if ( *p != '>' )
- {
- if ( document ) document->SetError( TIXML_ERROR_PARSING_EMPTY, p, data, encoding );
- return 0;
- }
- return (p+1);
- }
- else if ( *p == '>' )
- {
- // Done with attributes (if there were any.)
- // Read the value -- which can include other
- // elements -- read the end tag, and return.
- ++p;
- p = ReadValue( p, data, encoding ); // Note this is an Element method, and will set the error if one happens.
- if ( !p || !*p ) {
- // We were looking for the end tag, but found nothing.
- // Fix for [ 1663758 ] Failure to report error on bad XML
- if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
- return 0;
- }
-
- // We should find the end tag now
- if ( StringEqual( p, endTag.c_str(), false, encoding ) )
- {
- p += endTag.length();
- return p;
- }
- else
- {
- if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
- return 0;
- }
- }
- else
- {
- // Try to read an attribute:
- TiXmlAttribute* attrib = new TiXmlAttribute();
- if ( !attrib )
- {
- if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, pErr, data, encoding );
- return 0;
- }
-
- attrib->SetDocument( document );
- pErr = p;
- p = attrib->Parse( p, data, encoding );
-
- if ( !p || !*p )
- {
- if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding );
- delete attrib;
- return 0;
- }
-
- // Handle the strange case of double attributes:
- #ifdef TIXML_USE_STL
- TiXmlAttribute* node = attributeSet.Find( attrib->NameTStr() );
- #else
- TiXmlAttribute* node = attributeSet.Find( attrib->Name() );
- #endif
- if ( node )
- {
- node->SetValue( attrib->Value() );
- delete attrib;
- return 0;
- }
-
- attributeSet.Add( attrib );
- }
- }
- return p;
-}
-
-
-const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
-{
- TiXmlDocument* document = GetDocument();
- // Read in text and elements in any order.
- const char* pWithWhiteSpace = p;
- p = SkipWhiteSpace( p, encoding );
-
- while ( p && *p )
- {
- if ( *p != '<' )
- {
- // Take what we have, make a text element.
- TiXmlText* textNode = new TiXmlText( "" );
-
- if ( !textNode )
- {
- if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, encoding );
- return 0;
- }
-
- if ( TiXmlBase::IsWhiteSpaceCondensed() )
- {
- p = textNode->Parse( p, data, encoding );
- }
- else
- {
- // Special case: we want to keep the white space
- // so that leading spaces aren't removed.
- p = textNode->Parse( pWithWhiteSpace, data, encoding );
- }
-
- if ( !textNode->Blank() )
- {
- LinkEndChild( textNode );
-#ifdef HAS_ICONV
- ConvertToUtf8(document, &textNode->value);
-#endif
- }
- else
- delete textNode;
- }
- else
- {
- // We hit a '<'
- // Have we hit a new element or an end tag? This could also be
- // a TiXmlText in the "CDATA" style.
- if ( StringEqual( p, "</", false, encoding ) )
- {
- return p;
- }
- else
- {
- TiXmlNode* node = Identify( p, encoding );
- if ( node )
- {
- p = node->Parse( p, data, encoding );
- LinkEndChild( node );
- }
- else
- {
- return 0;
- }
- }
- }
- pWithWhiteSpace = p;
- p = SkipWhiteSpace( p, encoding );
- }
-
- if ( !p )
- {
- if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0, encoding );
- }
- return p;
-}
-
-
-#ifdef TIXML_USE_STL
-void TiXmlUnknown::StreamIn( std::istream * in, TIXML_STRING * tag )
-{
- while ( in->good() )
- {
- int c = in->get();
- if ( c <= 0 )
- {
- TiXmlDocument* document = GetDocument();
- if ( document )
- document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
- return;
- }
- (*tag) += (char) c;
-
- if ( c == '>' )
- {
- // All is well.
- return;
- }
- }
-}
-#endif
-
-
-const char* TiXmlUnknown::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
-{
- TiXmlDocument* document = GetDocument();
- p = SkipWhiteSpace( p, encoding );
-
- if ( data )
- {
- data->Stamp( p, encoding );
- location = data->Cursor();
- }
- if ( !p || !*p || *p != '<' )
- {
- if ( document ) document->SetError( TIXML_ERROR_PARSING_UNKNOWN, p, data, encoding );
- return 0;
- }
- ++p;
- value = "";
-
- while ( p && *p && *p != '>' )
- {
- value += *p;
- ++p;
- }
-
- if ( !p )
- {
- if ( document ) document->SetError( TIXML_ERROR_PARSING_UNKNOWN, 0, 0, encoding );
- }
- if ( *p == '>' )
- return p+1;
- return p;
-}
-
-#ifdef TIXML_USE_STL
-void TiXmlComment::StreamIn( std::istream * in, TIXML_STRING * tag )
-{
- while ( in->good() )
- {
- int c = in->get();
- if ( c <= 0 )
- {
- TiXmlDocument* document = GetDocument();
- if ( document )
- document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
- return;
- }
-
- (*tag) += (char) c;
-
- if ( c == '>'
- && tag->at( tag->length() - 2 ) == '-'
- && tag->at( tag->length() - 3 ) == '-' )
- {
- // All is well.
- return;
- }
- }
-}
-#endif
-
-
-const char* TiXmlComment::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
-{
- TiXmlDocument* document = GetDocument();
- value = "";
-
- p = SkipWhiteSpace( p, encoding );
-
- if ( data )
- {
- data->Stamp( p, encoding );
- location = data->Cursor();
- }
- const char* startTag = "<!--";
- const char* endTag = "-->";
-
- if ( !StringEqual( p, startTag, false, encoding ) )
- {
- document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding );
- return 0;
- }
- p += strlen( startTag );
-
- // [ 1475201 ] TinyXML parses entities in comments
- // Oops - ReadText doesn't work, because we don't want to parse the entities.
- // p = ReadText( p, &value, false, endTag, false, encoding );
- //
- // from the XML spec:
- /*
- [Definition: Comments may appear anywhere in a document outside other markup; in addition,
- they may appear within the document type declaration at places allowed by the grammar.
- They are not part of the document's character data; an XML processor MAY, but need not,
- make it possible for an application to retrieve the text of comments. For compatibility,
- the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity
- references MUST NOT be recognized within comments.
-
- An example of a comment:
-
- <!-- declarations for <head> & <body> -->
- */
-
- value = "";
- // Keep all the white space.
- while ( p && *p && !StringEqual( p, endTag, false, encoding ) )
- {
- value.append( p, 1 );
- ++p;
- }
- if ( p )
- p += strlen( endTag );
-
- return p;
-}
-
-
-const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
-{
- p = SkipWhiteSpace( p, encoding );
- if ( !p || !*p ) return 0;
-
-// int tabsize = 4;
-// if ( document )
-// tabsize = document->TabSize();
-
- if ( data )
- {
- data->Stamp( p, encoding );
- location = data->Cursor();
- }
- // Read the name, the '=' and the value.
- const char* pErr = p;
- p = ReadName( p, &name, encoding );
- if ( !p || !*p )
- {
- if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding );
- return 0;
- }
- p = SkipWhiteSpace( p, encoding );
- if ( !p || !*p || *p != '=' )
- {
- if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
- return 0;
- }
-
- ++p; // skip '='
- p = SkipWhiteSpace( p, encoding );
- if ( !p || !*p )
- {
- if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
- return 0;
- }
-
- const char* end;
- const char SINGLE_QUOTE = '\'';
- const char DOUBLE_QUOTE = '\"';
-
- if ( *p == SINGLE_QUOTE )
- {
- ++p;
- end = "\'"; // single quote in string
- p = ReadText( p, &value, false, end, false, encoding );
- }
- else if ( *p == DOUBLE_QUOTE )
- {
- ++p;
- end = "\""; // double quote in string
- p = ReadText( p, &value, false, end, false, encoding );
- }
- else
- {
- // All attribute values should be in single or double quotes.
- // But this is such a common error that the parser will try
- // its best, even without them.
- value = "";
- while ( p && *p // existence
- && !IsWhiteSpace( *p ) && *p != '\n' && *p != '\r' // whitespace
- && *p != '/' && *p != '>' ) // tag end
- {
- if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) {
- // [ 1451649 ] Attribute values with trailing quotes not handled correctly
- // We did not have an opening quote but seem to have a
- // closing one. Give up and throw an error.
- if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
- return 0;
- }
- value += *p;
- ++p;
- }
- }
- return p;
-}
-
-#ifdef TIXML_USE_STL
-void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag )
-{
- while ( in->good() )
- {
- int c = in->peek();
- if ( !cdata && (c == '<' ) )
- {
- return;
- }
- if ( c <= 0 )
- {
- TiXmlDocument* document = GetDocument();
- if ( document )
- document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
- return;
- }
-
- (*tag) += (char) c;
- in->get(); // "commits" the peek made above
-
- if ( cdata && c == '>' && tag->size() >= 3 ) {
- size_t len = tag->size();
- if ( (*tag)[len-2] == ']' && (*tag)[len-3] == ']' ) {
- // terminator of cdata.
- return;
- }
- }
- }
-}
-#endif
-
-const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
-{
- value = "";
- TiXmlDocument* document = GetDocument();
-
- if ( data )
- {
- data->Stamp( p, encoding );
- location = data->Cursor();
- }
-
- const char* const startTag = "<![CDATA[";
- const char* const endTag = "]]>";
-
- if ( cdata || StringEqual( p, startTag, false, encoding ) )
- {
- cdata = true;
-
- if ( !StringEqual( p, startTag, false, encoding ) )
- {
- document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding );
- return 0;
- }
- p += strlen( startTag );
-
- // Keep all the white space, ignore the encoding, etc.
- while ( p && *p
- && !StringEqual( p, endTag, false, encoding )
- )
- {
- value += *p;
- ++p;
- }
-
- TIXML_STRING dummy;
- p = ReadText( p, &dummy, false, endTag, false, encoding );
- return p;
- }
- else
- {
- bool ignoreWhite = true;
-
- const char* end = "<";
- p = ReadText( p, &value, ignoreWhite, end, false, encoding );
- if ( p )
- return p-1; // don't truncate the '<'
- return 0;
- }
-}
-
-#ifdef TIXML_USE_STL
-void TiXmlDeclaration::StreamIn( std::istream * in, TIXML_STRING * tag )
-{
- while ( in->good() )
- {
- int c = in->get();
- if ( c <= 0 )
- {
- TiXmlDocument* document = GetDocument();
- if ( document )
- document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
- return;
- }
- (*tag) += (char) c;
-
- if ( c == '>' )
- {
- // All is well.
- return;
- }
- }
-}
-#endif
-
-const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding _encoding )
-{
- p = SkipWhiteSpace( p, _encoding );
- // Find the beginning, find the end, and look for
- // the stuff in-between.
- TiXmlDocument* document = GetDocument();
- if ( !p || !*p || !StringEqual( p, "<?xml", true, _encoding ) )
- {
- if ( document ) document->SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding );
- return 0;
- }
- if ( data )
- {
- data->Stamp( p, _encoding );
- location = data->Cursor();
- }
- p += 5;
-
- version = "";
- encoding = "";
- standalone = "";
-
- while ( p && *p )
- {
- if ( *p == '>' )
- {
- ++p;
- return p;
- }
-
- p = SkipWhiteSpace( p, _encoding );
- if ( StringEqual( p, "version", true, _encoding ) )
- {
- TiXmlAttribute attrib;
- p = attrib.Parse( p, data, _encoding );
- version = attrib.Value();
- }
- else if ( StringEqual( p, "encoding", true, _encoding ) )
- {
- TiXmlAttribute attrib;
- p = attrib.Parse( p, data, _encoding );
- encoding = attrib.Value();
- }
- else if ( StringEqual( p, "standalone", true, _encoding ) )
- {
- TiXmlAttribute attrib;
- p = attrib.Parse( p, data, _encoding );
- standalone = attrib.Value();
- }
- else
- {
- // Read over whatever it is.
- while( p && *p && *p != '>' && !IsWhiteSpace( *p ) )
- ++p;
- }
- }
- return 0;
-}
-
-bool TiXmlText::Blank() const
-{
- for ( unsigned i=0; i<value.length(); i++ )
- if ( !IsWhiteSpace( value[i] ) )
- return false;
- return true;
-}
-