blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 5
146
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
7
| license_type
stringclasses 2
values | repo_name
stringlengths 6
79
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 4
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.07k
426M
⌀ | star_events_count
int64 0
27
| fork_events_count
int64 0
12
| gha_license_id
stringclasses 3
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 6
values | src_encoding
stringclasses 26
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 1
class | length_bytes
int64 20
6.28M
| extension
stringclasses 20
values | content
stringlengths 20
6.28M
| authors
listlengths 1
16
| author_lines
listlengths 1
16
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3003b81b85bf27e209284ba7e6678e377491b403 | 5efdf4f304c39c1aa8a24ab5a9690afad3340c00 | /src/GLBitmap.h | 9527984eb702e346ed4bd6f4d469b25357713ad5 | []
| no_license | asquared/hockeyboard | 286f57d8bea282e74425cbe77d915d692398f722 | 06480cb228dcd6d4792964837e20a1dddea89d1b | refs/heads/master | 2016-09-06T11:16:20.947224 | 2011-01-09T21:23:16 | 2011-01-09T21:23:16 | 1,236,086 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 951 | h | #ifndef _glbitmap_h_
#define _glbitmap_h_
#ifdef WINDOWS
#include <windows.h>
#endif
#include <stdio.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <string>
typedef unsigned char byte;
using std::string;
struct rgba {
byte r;
byte g;
byte b;
byte a;
rgba() {}
rgba(byte ri, byte gi, byte bi, byte ai) {
r = ri;
g = gi;
b = bi;
a = ai;
}
};
//bool drawRect(int xl, int xh, int yl, int yh, int z);
class GLBitmap {
private:
int xt, yt;
rgba transcol;
rgba** tile;
public:
GLBitmap();
GLBitmap(string& filename);
~GLBitmap();
bool load(string& filename);
bool unload();
void setTransColor(unsigned char r, unsigned char g, unsigned char b);
void drawPixels(float x, float y);
void drawTexture(float x, float y, float z);
private:
void readRow(int y, int xlen, unsigned char* row);
inline void setTilePixel(int x, int y, rgba col);
};
#endif
| [
"pymlofy@4cf78214-6c29-4fb8-b038-d2ccc4421ee9",
"[email protected]"
]
| [
[
[
1,
2
],
[
5,
5
],
[
8,
8
],
[
11,
61
]
],
[
[
3,
4
],
[
6,
7
],
[
9,
10
],
[
62,
62
]
]
]
|
a1fe8841509bb8d9e6ace03e7319f10fae693374 | b22c254d7670522ec2caa61c998f8741b1da9388 | /common/WorldInfo.h | 2ebc72d962f2eb882ab79f9e027e232e9e4ff5c3 | []
| no_license | ldaehler/lbanet | 341ddc4b62ef2df0a167caff46c2075fdfc85f5c | ecb54fc6fd691f1be3bae03681e355a225f92418 | refs/heads/master | 2021-01-23T13:17:19.963262 | 2011-03-22T21:49:52 | 2011-03-22T21:49:52 | 39,529,945 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 5,543 | h | /*
------------------------[ Lbanet Source ]-------------------------
Copyright (C) 2009
Author: Vivien Delage [Rincevent_123]
Email : [email protected]
-------------------------------[ GNU License ]-------------------------------
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
*/
#ifndef __LBA_NET_MAP_WORLD_INFO_H__
#define __LBA_NET_MAP_WORLD_INFO_H__
#include <string>
#include <map>
#include <vector>
#include "ConditionBase.h"
class DialogHandler;
typedef boost::shared_ptr<DialogHandler> DialogHandlerPtr;
class Quest;
typedef boost::shared_ptr<Quest> QuestPtr;
// contain information about a light element
struct LighInfo
{
// light name
std::string Name;
// light type: e.g spot/main
std::string Type;
// light position
int PosX;
int PosY;
int PosZ;
// light direction
int DirX;
int DirY;
int DirZ;
};
// contain information about a spawning point
struct SpawningInfo
{
// name
std::string Name;
// position
float PosX;
float PosY;
float PosZ;
// rotation at arrival in degree
int Rotation;
};
// contain information about a exit area
struct ExitInfo
{
// name
std::string Name;
// top left corner
float TopRightX;
float TopRightY;
float TopRightZ;
// bottom right corner
float BottomLeftX;
float BottomLeftY;
float BottomLeftZ;
// arrival point of the exit
std::string NewMap;
std::string Spawning;
};
// contain information about a teleport place
struct TPInfo
{
// name
std::string Name;
// arrival point
std::string NewMap;
std::string Spawning;
};
// contains information about an LBA map
struct MapInfo
{
// map name
std::string Name;
// map type: e.g interior/exterior
std::string Type;
// map description
std::string Description;
// path to the music file to be played
std::string Music;
// number of time the music should be played
int MusicLoop;
// files to be loaded
std::map<std::string, std::string> Files;
// lights
std::map<std::string, LighInfo> Lights;
// spawning points
std::map<std::string, SpawningInfo> Spawnings;
// exit points
std::map<std::string, ExitInfo> Exits;
};
// contains information about an LBA world
struct WorldInfo
{
// world name
std::string Name;
// map description
std::string Description;
// map used at arrival in the world
std::string FirstMap;
// spawn area used at arrival in the world
std::string FirstSpawning;
// description of the maps constituing the world
std::map<std::string, MapInfo> Maps;
// teleport places
std::map<std::string, TPInfo> Teleports;
// files to be loaded
std::map<std::string, std::string> Files;
};
// quad info
struct QuadImageInfo
{
// top left corner
float BottomLeftCornerX;
float BottomLeftCornerY;
float BottomLeftCornerZ;
float BottomRightCornerX;
float BottomRightCornerY;
float BottomRightCornerZ;
// bottom right corner
float TopRightCornerX;
float TopRightCornerY;
float TopRightCornerZ;
float TopLeftCornerX;
float TopLeftCornerY;
float TopLeftCornerZ;
// flag saying if we use full image
bool UseFullImage;
// top left texture coordinate
int TopLeftTextcoordX;
int TopLeftTextcoordY;
// top right texture coordinate
int TopRightTextcoordX;
int TopRightTextcoordY;
// bottom left texture coordinate
int BottomLeftTextcoordX;
int BottomLeftTextcoordY;
// bottom right texture coordinate
int BottomRightTextcoordX;
int BottomRightTextcoordY;
};
//sprite info
struct SpriteInfo
{
long id;
std::string filename;
std::vector<QuadImageInfo> quadsInfo;
};
//model info
struct ModelInfo
{
long id;
std::string filename;
float ScaleX;
float ScaleY;
float ScaleZ;
float TransX;
float TransY;
float TransZ;
float RotX;
float RotY;
float RotZ;
};
struct ItemInfo
{
long id;
std::string filename;
int type;
int valueA;
int Max;
long DescriptionId;
int Effect;
int Price;
bool Ephemere;
long FromId;
std::string Date;
long SubjectId;
};
struct ItemGroupElement
{
long id;
int number;
float probability;
};
struct ItemGroup
{
std::vector<ItemGroupElement> groupelements;
double lastSpawningTime;
double RespawningTime;
long currpicked;
};
struct TraderItem
{
long id;
ConditionBasePtr condition;
};
struct PlayerChoiceDisplay
{
std::string Text;
bool QuitDialog;
bool ResetDialog;
bool StartTrade;
size_t Index;
};
struct DialogDisplay
{
std::string NPCTalk;
std::vector<PlayerChoiceDisplay> PlayerChoices;
};
struct QuestInfo
{
long Id;
std::string Tittle;
std::string Description;
bool Visible;
std::string QuestArea;
};
#endif
| [
"vdelage@3806491c-8dad-11de-9a8c-6d5b7d1e4d13"
]
| [
[
[
1,
309
]
]
]
|
d52c02b03dacd084153f942adb81f55aa8961f25 | 1e976ee65d326c2d9ed11c3235a9f4e2693557cf | /CommonSources/GdiplusUtilities.h | 8df93784c996c490ba3eeda5f9f34e67bd7207fd | []
| no_license | outcast1000/Jaangle | 062c7d8d06e058186cb65bdade68a2ad8d5e7e65 | 18feb537068f1f3be6ecaa8a4b663b917c429e3d | refs/heads/master | 2020-04-08T20:04:56.875651 | 2010-12-25T10:44:38 | 2010-12-25T10:44:38 | 19,334,292 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,107 | h | // /*
// *
// * Copyright (C) 2003-2010 Alexandros Economou
// *
// * This file is part of Jaangle (http://www.jaangle.com)
// *
// * 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 GNU Make; 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 <GdiPlus.h>
enum RectangleCorners
{
None = 0, TopLeft = 1, TopRight = 2,
BottomLeft = 4, BottomRight = 8,
All = TopLeft | TopRight | BottomLeft | BottomRight
};
class GdiplusUtilities
{
public:
//Creates a bitmap from an ICON. This corrects the GDI+ bug in the Icons alpha channel
static Gdiplus::Bitmap* FromHICON32(HICON hIcon);
static Gdiplus::Color COLORREF2Color(COLORREF value, BYTE opacity = 255);
static Gdiplus::Rect RECT2GdiplusRect(const RECT& value);
static RECT GdiplusRect2RECT(const Gdiplus::Rect& value);
//This gets a GraphicsPath for a round rectangle which is missing from GDI+
static BOOL GetRoundRectGraphicsPath(Gdiplus::GraphicsPath& path, int x, int y, int width, int height, int radius, RectangleCorners corners);
static BOOL GetRoundRectGraphicsPath(Gdiplus::GraphicsPath& path, Gdiplus::Rect rect, int radius, RectangleCorners corners);
static BOOL GetRoundRectGraphicsPath(Gdiplus::GraphicsPath& path, int x, int y, int width, int height, int radius);
static BOOL GetRoundRectGraphicsPath(Gdiplus::GraphicsPath& path, Gdiplus::Rect rect, int radius);
static BOOL GetRoundRectGraphicsPath(Gdiplus::GraphicsPath& path, int x, int y, int width, int height);
static BOOL GetRoundRectGraphicsPath(Gdiplus::GraphicsPath& path, Gdiplus::Rect rect);
static BOOL DrawTextOutline(Gdiplus::Graphics& graphics,
LPCTSTR lpchText, int cchText, const Gdiplus::Rect& rc, const Gdiplus::StringFormat& format,
const Gdiplus::Font& font, Gdiplus::Color fill, Gdiplus::Color outline, INT outlineWidth,
BOOL bCalcOnly = FALSE, Gdiplus::Rect* rcCalc = NULL);
static BOOL DrawTextOutline(Gdiplus::Graphics& graphics,
LPCTSTR lpchText, int cchText, const RECT* lprc, UINT format,
const LOGFONT& lf, COLORREF fill, COLORREF outline, INT outlineWidth,
BOOL bCalcOnly = FALSE, RECT* rcCalc = NULL);
static Gdiplus::RectF DrawTextMeasure(Gdiplus::Graphics& graphics, LPCTSTR lpchText, int cchText, const Gdiplus::Font& font);
static Gdiplus::RectF DrawTextMeasure(Gdiplus::Graphics& graphics, LPCTSTR lpchText, int cchText, const LOGFONT& lf);
};
| [
"outcast1000@dc1b949e-fa36-4f9e-8e5c-de004ec35678"
]
| [
[
[
1,
68
]
]
]
|
1cafdc706a6f0b7dd3542170312c884de3ff6c01 | 9df2486e5d0489f83cc7dcfb3ccc43374ab2500c | /src/level/level_editor.cpp | 46e1ac7cc79bfe9543fff982e889280a079df8cd | []
| no_license | renardchien/Eta-Chronicles | 27ad4ffb68385ecaafae4f12b0db67c096f62ad1 | d77d54184ec916baeb1ab7cc00ac44005d4f5624 | refs/heads/master | 2021-01-10T19:28:28.394781 | 2011-09-05T14:40:38 | 2011-09-05T14:40:38 | 1,914,623 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 10,574 | cpp | /***************************************************************************
* level_editor.cpp - Level Editor class
*
* Copyright (C) 2006 - 2009 Florian Richter
***************************************************************************/
/*
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 3 of the License, or
(at your option) any later version.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../core/globals.h"
#include "../level/level_editor.h"
#include "../level/level.h"
#include "../core/game_core.h"
#include "../core/sprite_manager.h"
#include "../user/preferences.h"
#include "../input/mouse.h"
#include "../input/keyboard.h"
#include "../audio/audio.h"
#include "../core/i18n.h"
#include "../player/player.h"
#include "../core/filesystem/filesystem.h"
namespace SMC
{
/* *** *** *** *** *** *** *** cEditor_Level *** *** *** *** *** *** *** *** *** *** */
cEditor_Level :: cEditor_Level( void )
: cEditor()
{
menu_filename = DATA_DIR "/" GAME_EDITOR_DIR "/level_menu.xml";
items_filename = DATA_DIR "/" GAME_EDITOR_DIR "/level_items.xml";
editor_item_tag = "level";
pSettings = new cLevel_Settings();
}
cEditor_Level :: ~cEditor_Level( void )
{
delete pSettings;
}
void cEditor_Level :: Init( void )
{
// already loaded
if( editor_window )
{
return;
}
// nothing
cEditor::Init();
}
void cEditor_Level :: Enable( void )
{
// already enabled
if( enabled )
{
return;
}
editor_level_enabled = 1;
if( Game_Mode == MODE_LEVEL )
{
editor_enabled = 1;
}
// reset ground object
// player
pPlayer->Reset_On_Ground();
// sprite manager
for( cSprite_List::iterator itr = pActive_Sprite_Manager->objects.begin(), itr_end = pActive_Sprite_Manager->objects.end(); itr != itr_end; ++itr )
{
// get object pointer
cSprite *obj = (*itr);
// skip destroyed objects
if( obj->m_auto_destroy )
{
continue;
}
// enemies
if( obj->m_sprite_array == ARRAY_ENEMY )
{
cMovingSprite *moving_sprite = static_cast<cMovingSprite *>(obj);
moving_sprite->Reset_On_Ground();
}
}
cEditor::Enable();
}
void cEditor_Level :: Disable( bool native_mode /* = 0 */ )
{
// already disabled
if( !enabled )
{
return;
}
pHud_Debug->Set_Text( _("Level Editor disabled") );
editor_level_enabled = 0;
if( Game_Mode == MODE_LEVEL )
{
native_mode = 1;
editor_enabled = 0;
}
cEditor::Disable( native_mode );
}
bool cEditor_Level :: Key_Down( SDLKey key )
{
if( !enabled )
{
return 0;
}
// check basic editor events
if( cEditor::Key_Down( key ) )
{
return 1;
}
// save level
else if( key == SDLK_s && input_event.key.keysym.mod & KMOD_CTRL )
{
pActive_Level->Save();
}
// focus last levelexit
else if( key == SDLK_END )
{
float new_cameraposx = 0;
float new_cameraposy = 0;
for( cSprite_List::iterator itr = pActive_Sprite_Manager->objects.begin(), itr_end = pActive_Sprite_Manager->objects.end(); itr != itr_end; ++itr )
{
cSprite *obj = (*itr);
if( obj->m_sprite_array != ARRAY_ACTIVE )
{
continue;
}
if( obj->m_type == TYPE_LEVEL_EXIT && new_cameraposx < obj->m_pos_x )
{
new_cameraposx = obj->m_pos_x;
new_cameraposy = obj->m_pos_y;
}
}
if( new_cameraposx != 0 || new_cameraposy != 0 )
{
pActive_Camera->Set_Pos( new_cameraposx - ( game_res_w * 0.5f ), new_cameraposy - ( game_res_h * 0.5f ) );
}
}
// modify selected objects state
else if( key == SDLK_m )
{
if( !pMouseCursor->m_selected_objects.empty() )
{
cSprite *mouse_obj = pMouseCursor->m_selected_objects[0]->obj;
// change state of the base object
if( Switch_Object_State( mouse_obj ) )
{
// change all object states to the base object state
for( SelectedObjectList::iterator itr = pMouseCursor->m_selected_objects.begin(), itr_end = pMouseCursor->m_selected_objects.end(); itr != itr_end; ++itr )
{
cSprite *obj = (*itr)->obj;
// skip base object
if( obj == mouse_obj )
{
continue;
}
// sprites need additional data
if( obj->m_type == TYPE_PASSIVE || obj->m_type == TYPE_FRONT_PASSIVE || obj->m_type == TYPE_MASSIVE || obj->m_type == TYPE_CLIMBABLE || obj->m_type == TYPE_HALFMASSIVE )
{
obj->m_type = mouse_obj->m_type;
obj->m_sprite_array = mouse_obj->m_sprite_array;
obj->m_can_be_ground = mouse_obj->m_can_be_ground;
}
// special objects
else if( obj->m_type == TYPE_MOVING_PLATFORM )
{
// fall through
}
else
{
// massivetype change is not valid
continue;
}
// set state
obj->Set_Massive_Type( mouse_obj->m_massive_type );
}
}
}
}
// modify mouse object state
else if( key == SDLK_m && pMouseCursor->m_hovering_object->obj )
{
Switch_Object_State( pMouseCursor->m_hovering_object->obj );
pMouseCursor->Clear_Mouse_Object();
}
else
{
// not processed
return 0;
}
// key got processed
return 1;
}
void cEditor_Level :: Activate_Menu_Item( cEditor_Menu_Object *entry )
{
// If Function
if( entry->bfunction )
{
if( entry->tags.compare( "new" ) == 0 )
{
Function_New();
}
else if( entry->tags.compare( "load" ) == 0 )
{
Function_Load();
}
else if( entry->tags.compare( "save" ) == 0 )
{
Function_Save();
}
else if( entry->tags.compare( "save_as" ) == 0 )
{
Function_Save_as();
}
else if( entry->tags.compare( "delete" ) == 0 )
{
Function_Delete();
}
else if( entry->tags.compare( "reload" ) == 0 )
{
Function_Reload();
}
else if( entry->tags.compare( "clear" ) == 0 )
{
Function_Clear();
}
else if( entry->tags.compare( "settings" ) == 0 )
{
Function_Settings();
}
// unknown level function
else
{
cEditor::Activate_Menu_Item( entry );
}
}
// unknown level function
else
{
cEditor::Activate_Menu_Item( entry );
}
}
bool cEditor_Level :: Switch_Object_State( cSprite *obj ) const
{
// empty object
if( !obj )
{
return 0;
}
// from Passive to Front Passive
if( obj->m_type == TYPE_PASSIVE )
{
obj->Set_Sprite_Type( TYPE_FRONT_PASSIVE );
}
// from Front Passive to Massive
else if( obj->m_type == TYPE_FRONT_PASSIVE )
{
obj->Set_Sprite_Type( TYPE_MASSIVE );
}
// from Massive to Halfmassive
else if( obj->m_type == TYPE_MASSIVE )
{
obj->Set_Sprite_Type( TYPE_HALFMASSIVE );
}
// from Halfmassive to Climbable
else if( obj->m_type == TYPE_HALFMASSIVE )
{
obj->Set_Sprite_Type( TYPE_CLIMBABLE );
}
// from Climbable to Passive
else if( obj->m_type == TYPE_CLIMBABLE )
{
obj->Set_Sprite_Type( TYPE_PASSIVE );
}
// moving platform
else if( obj->m_type == TYPE_MOVING_PLATFORM )
{
if( obj->m_massive_type == MASS_PASSIVE )
{
obj->Set_Massive_Type( MASS_MASSIVE );
}
else if( obj->m_massive_type == MASS_MASSIVE )
{
obj->Set_Massive_Type( MASS_HALFMASSIVE );
}
else if( obj->m_massive_type == MASS_HALFMASSIVE )
{
obj->Set_Massive_Type( MASS_CLIMBABLE );
}
else if( obj->m_massive_type == MASS_CLIMBABLE )
{
obj->Set_Massive_Type( MASS_PASSIVE );
}
}
// invalid object type
else
{
return 0;
}
return 1;
}
bool cEditor_Level :: Function_New( void )
{
std::string level_name = Box_Text_Input( _("Create a new Level"), _("Name") );
// aborted/invalid
if( level_name.empty() )
{
return 0;
}
if( pActive_Level->New( level_name ) )
{
pHud_Debug->Set_Text( _("Created ") + level_name );
return 1;
}
else
{
pHud_Debug->Set_Text( _("Level ") + level_name + _(" already exists") );
}
return 0;
}
void cEditor_Level :: Function_Load( void )
{
std::string level_name = _("Name");
// valid level
while( level_name.length() )
{
level_name = Box_Text_Input( level_name, _("Load a Level"), level_name.compare( _("Name") ) == 0 ? 1 : 0 );
// break if empty
if( level_name.empty() )
{
break;
}
// if available
if( pActive_Level->Get_Path( level_name ) )
{
Game_Action = GA_ENTER_LEVEL;
Game_Mode_Type = MODE_TYPE_LEVEL_CUSTOM;
Game_Action_Data.add( "level", level_name.c_str() );
pHud_Debug->Set_Text( _("Loaded ") + Trim_Filename( level_name, 0, 0 ) );
break;
}
// not found
else
{
pAudio->Play_Sound( "error.ogg" );
}
}
}
void cEditor_Level :: Function_Save( bool with_dialog /* = 0 */ )
{
// not loaded
if( !pActive_Level->Is_Loaded() )
{
return;
}
// if denied
if( with_dialog && !Box_Question( _("Save ") + Trim_Filename( pActive_Level->m_level_filename, 0, 0 ) + " ?" ) )
{
return;
}
pActive_Level->Save();
}
void cEditor_Level :: Function_Save_as( void )
{
std::string levelname = Box_Text_Input( _("Save Level as"), _("New name"), 1 );
// aborted/invalid
if( levelname.empty() )
{
return;
}
pActive_Level->Set_Levelfile( levelname, 0 );
pActive_Level->Save();
}
void cEditor_Level :: Function_Delete( void )
{
std::string filename = pActive_Level->m_level_filename;
if( !pActive_Level->Get_Path( filename, 1 ) )
{
return;
}
// if denied
if( !Box_Question( _("Delete and Unload ") + Trim_Filename( filename, 0, 0 ) + " ?" ) )
{
return;
}
pActive_Level->Delete();
Disable();
Game_Action = GA_ENTER_MENU;
}
void cEditor_Level :: Function_Reload( void )
{
// if denied
if( !Box_Question( _("Reload Level ?") ) )
{
return;
}
pActive_Level->Save();
if( pActive_Level->Load( Trim_Filename( pActive_Level->data_file, 0 ) ) )
{
pActive_Level->Enter();
}
}
void cEditor_Level :: Function_Clear( void )
{
// if denied
if( !Box_Question( _("Clear Level ?") ) )
{
return;
}
pActive_Sprite_Manager->Delete_All();
}
void cEditor_Level :: Function_Settings( void )
{
Game_Action = GA_ENTER_LEVEL_SETTINGS;
}
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
cEditor_Level *pLevel_Editor = NULL;
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
} // namespace SMC
| [
"[email protected]"
]
| [
[
[
1,
489
]
]
]
|
6ecdf35db4a2e3074976719f49798098497c3671 | 335783c9e5837a1b626073d1288b492f9f6b057f | /source/fbxcmd/daolib/Model/MMH/MMHFile.cpp | 12e1e54867bc616f70e79e85c96ca9319b75d6e3 | [
"BSD-3-Clause",
"LicenseRef-scancode-warranty-disclaimer",
"BSD-2-Clause"
]
| permissive | code-google-com/fbx4eclipse | 110766ee9760029d5017536847e9f3dc09e6ebd2 | cc494db4261d7d636f8c4d0313db3953b781e295 | refs/heads/master | 2016-09-08T01:55:57.195874 | 2009-12-03T20:35:48 | 2009-12-03T20:35:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 859 | cpp | /**********************************************************************
*<
FILE: MMHFile.h
DESCRIPTION: MMH File Format
HISTORY:
*> Copyright (c) 2009, All Rights Reserved.
**********************************************************************/
#include <stdafx.h>
#include <windows.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <stdexcept>
#include <stdio.h>
#include <stdarg.h>
#include <tchar.h>
#include "GFF/GFFFile.h"
#include "MMH/MMHFile.h"
#include "MMH/MMHFile.h"
#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
#endif
#include <math.h>
using namespace std;
using namespace DAO;
using namespace DAO::GFF;
using namespace DAO::MMH;
using namespace DAO::MMH;
MMHFile::MMHFile() {
}
DAO::MMH::MDLHPtr DAO::MMH::MMHFile::get_Root()
{
return StructPtrCast<MDLH>( this->get_RootStruct() );
} | [
"tazpn314@ccf8930c-dfc1-11de-9043-17b7bd24f792"
]
| [
[
[
1,
41
]
]
]
|
c08ac407fba0def94d74e5d22c5831e3538cf27c | 6e563096253fe45a51956dde69e96c73c5ed3c18 | /os/AX_Text_Log.h | 1b5c958d1779d7b2ec12b5aec8f1b8b7d48d3ab5 | []
| no_license | 15831944/phoebemail | 0931b76a5c52324669f902176c8477e3bd69f9b1 | e10140c36153aa00d0251f94bde576c16cab61bd | refs/heads/master | 2023-03-16T00:47:40.484758 | 2010-10-11T02:31:02 | 2010-10-11T02:31:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,499 | h | #ifndef _AX_TEXT_LOG_H
#define _AX_TEXT_LOG_H
#include "AX_Mutex.h"
class AX_Text_Format
{
public:
AX_Text_Format(const char *buf, int len)
:_pos((char*)buf),_buf((char*)buf),_len(len)
{
}
~AX_Text_Format()
{
}
public:
AX_Text_Format& operator<<(char c)
{
if(0<_len)
{
#ifdef _WIN32
int ret=_snprintf(_pos,_len,"%c",c);
#else
int ret=snprintf(_pos,_len,"%c",c);
#endif
if(0<ret)
{
_pos+=ret;
_len-=ret;
}
}
return *this;
}
AX_Text_Format& operator<<(unsigned char uc)
{
if(0<_len)
{
#ifdef _WIN32
int ret=_snprintf(_pos,_len,"%c",uc);
#else
int ret=snprintf(_pos,_len,"%c",uc);
#endif
if(0<ret)
{
_pos+=ret;
_len-=ret;
}
}
return *this;
}
AX_Text_Format& operator<<(short s)
{
if(0<_len)
{
#ifdef _WIN32
int ret=_snprintf(_pos,_len,"%hd",s);
#else
int ret=snprintf(_pos,_len,"%hd",s);
#endif
if(0<ret)
{
_pos+=ret;
_len-=ret;
}
}
return *this;
}
AX_Text_Format& operator<<(unsigned short us)
{
if(0<_len)
{
#ifdef _WIN32
int ret=_snprintf(_pos,_len,"%hu",us);
#else
int ret=snprintf(_pos,_len,"%hu",us);
#endif
if(0<ret)
{
_pos+=ret;
_len-=ret;
}
}
return *this;
}
AX_Text_Format& operator<<(int i)
{
if(0<_len)
{
#ifdef _WIN32
int ret=_snprintf(_pos,_len,"%d",i);
#else
int ret=snprintf(_pos,_len,"%d",i);
#endif
if(0<ret)
{
_pos+=ret;
_len-=ret;
}
}
return *this;
}
AX_Text_Format& operator<<(unsigned int ui)
{
if(0<_len)
{
#ifdef _WIN32
int ret=_snprintf(_pos,_len,"%u",ui);
#else
int ret=snprintf(_pos,_len,"%u",ui);
#endif
if(0<ret)
{
_pos+=ret;
_len-=ret;
}
}
return *this;
}
AX_Text_Format& operator<<(long l)
{
if(0<_len)
{
#ifdef _WIN32
int ret=_snprintf(_pos,_len,"%ld",l);
#else
int ret=snprintf(_pos,_len,"%ld",l);
#endif
if(0<ret)
{
_pos+=ret;
_len-=ret;
}
}
return *this;
}
AX_Text_Format& operator<<(unsigned long ul)
{
if(0<_len)
{
#ifdef _WIN32
int ret=_snprintf(_pos,_len,"%lu",ul);
#else
int ret=snprintf(_pos,_len,"%lu",ul);
#endif
if(0<ret)
{
_pos+=ret;
_len-=ret;
}
}
return *this;
}
AX_Text_Format& operator<<(float f)
{
if(0<_len)
{
#ifdef _WIN32
int ret=_snprintf(_pos,_len,"%f",f);
#else
int ret=snprintf(_pos,_len,"%f",f);
#endif
if(0<ret)
{
_pos+=ret;
_len-=ret;
}
}
return *this;
}
AX_Text_Format& operator<<(double d)
{
if(0<_len)
{
#ifdef _WIN32
int ret=_snprintf(_pos,_len,"%f",d);
#else
int ret=snprintf(_pos,_len,"%f",d);
#endif
if(0<ret)
{
_pos+=ret;
_len-=ret;
}
}
return *this;
}
AX_Text_Format& operator<<(const char * str)
{
if(0<_len)
{
if(NULL!=str)
{
#ifdef _WIN32
int ret=_snprintf(_pos,_len,"%s",str);
#else
int ret=snprintf(_pos,_len,"%s",str);
#endif
if(0<ret)
{
_pos+=ret;
_len-=ret;
}
}
else
{
#ifdef _WIN32
int ret=_snprintf(_pos,_len,"NULL");
#else
int ret=snprintf(_pos,_len,"NULL");
#endif
if(0<ret)
{
_pos+=ret;
_len-=ret;
}
}
}
return *this;
}
protected:
char* _pos;
char* _buf;
int _len;
};
struct AX_Logger_Config_Unit
{
int _level;
const char* _configNam;
bool _enabled;
};
class AX_Logger
{
public:
~AX_Logger();
public:
bool levelEnabled(int level);
void refreshLoggerLevel();
void trace(int level, const char* str);
static AX_Logger& instance();
protected:
void initLogFile();
bool getProcessName(char* buf,int maxLen);
protected:
static AX_Logger _logger;
static AX_Logger_Config_Unit _configSet[];
static bool s_inited;
FILE* _errorFile;
FILE* _warningFile;
FILE* _infoFile;
AX_Mutex _mutex;
private:
void operator = (AX_Logger&);
AX_Logger();
};
#define AX_TRACE(level, tag, str) \
{ \
if(AX_Logger::instance().levelEnabled((level))) \
{ \
char tmpBuf[2048]={0}; \
AX_Text_Format txtFormat(tmpBuf,sizeof(tmpBuf)); \
txtFormat<<tag<<str; \
AX_Logger::instance().trace(level,tmpBuf); \
} \
}
#define INFOTRACE(str) \
AX_TRACE(21,"Info:",str<<"\n")
#define WARNINGTRACE(str) \
AX_TRACE(11,"Warning:",str<<"\n")
#define ERRTRACE(str) \
AX_TRACE(1,"Error:",str<<"\n")
#endif
| [
"guoqiao@a83c37f4-16cc-5f24-7598-dca3a346d5dd"
]
| [
[
[
1,
282
]
]
]
|
2e5f53574324333c3025184733bcf9cc9e387635 | c2153dcfa8bcf5b6d7f187e5a337b904ad9f91ac | /src/Engine/Entity/EntityReg.h | cb6b7fcef86cf0e375651ff752e25a1ccdce02d1 | [
"Zlib"
]
| permissive | ptrefall/smn6200fluidmechanics | 841541a26023f72aa53d214fe4787ed7f5db88e1 | 77e5f919982116a6cdee59f58ca929313dfbb3f7 | refs/heads/master | 2020-08-09T17:03:59.726027 | 2011-01-13T22:39:03 | 2011-01-13T22:39:03 | 32,448,422 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 981 | h | #pragma once
#include "EntityFactory.h"
#include <Core/CoreMgr.h>
#include <Resource/ResMgr.h>
//Specials
#include <Entities/Volume.h>
#include <Entities/StlMesh.h>
#include <Entities/Skybox.h>
#include <Entities/Flow3D.h>
namespace Engine
{
class EntityReg
{
public:
static void Register(EntityFactory *factory, CoreMgr *coreMgr)
{
//Register special C++ entity types
factory->RegisterSpecial(Volume::GetStaticSpecialType(), &Volume::Create);
factory->RegisterSpecial(StlMesh::GetStaticSpecialType(), &StlMesh::Create);
factory->RegisterSpecial(Skybox::GetStaticSpecialType(), &Skybox::Create);
factory->RegisterSpecial(Flow3D::GetStaticSpecialType(), &Flow3D::Create);
//Register XML defined entities
std::vector<CL_String> entities = coreMgr->getResMgr()->getFilesInDir("/XML/Entities/");
for(unsigned int i = 0; i < entities.size(); i++)
{
factory->registerEntity(entities[i].c_str());
}
}
};
}
| [
"[email protected]@c628178a-a759-096a-d0f3-7c7507b30227"
]
| [
[
[
1,
34
]
]
]
|
d0dca0dd6849f729f4ef26b47a25fa07b60e8f9c | 1193b8d2ab6bb40ce2adbf9ada5b3d1124f1abb3 | /trunk/libsonetto/include/SonettoPlayerInput.h | 2178695107c8b1338a0ad1fe00e9035f3df1e445 | []
| no_license | sonetto/legacy | 46bb60ef8641af618d22c08ea198195fd597240b | e94a91950c309fc03f9f52e6bc3293007c3a0bd1 | refs/heads/master | 2021-01-01T16:45:02.531831 | 2009-09-10T21:50:42 | 2009-09-10T21:50:42 | 32,183,635 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 7,623 | h | /*-----------------------------------------------------------------------------
Copyright (c) 2009, Sonetto Project Developers
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the Sonetto Project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------*/
#ifndef SONETTO_PLAYERINPUT_H
#define SONETTO_PLAYERINPUT_H
#include <vector>
#include "SonettoPrerequisites.h"
#include "SonettoJoystick.h"
// Types needed by other headers
namespace Sonetto
{
/// Vector of PlayerInput's
typedef std::vector<PlayerInput *> PlayerInputVector;
/** Describes a Sonetto virtual button
These virtual buttons are going to be attached to physical
keyboard keys, joystick buttons or axes using an InputSource.
*/
enum Button
{
BTN_TRIANGLE,
BTN_CIRCLE,
BTN_CROSS,
BTN_SQUARE,
BTN_L2,
BTN_R2,
BTN_L1,
BTN_R1,
BTN_START,
BTN_SELECT,
BTN_L3,
BTN_R3,
BTN_DPAD_UP,
BTN_DPAD_RIGHT,
BTN_DPAD_DOWN,
BTN_DPAD_LEFT,
BTN_LAST = BTN_DPAD_LEFT
};
/** Describes a Sonetto virtual axis
These virtual axes are going to be attached to physical
keyboard keys, joystick buttons and axes using an InputSource.
*/
enum Axis
{
AX_LEFT,
AXE_LEFT_UP,
AXE_LEFT_RIGHT,
AXE_LEFT_DOWN,
AXE_LEFT_LEFT,
AX_RIGHT,
AXE_RIGHT_UP,
AXE_RIGHT_RIGHT,
AXE_RIGHT_DOWN,
AXE_RIGHT_LEFT
};
/** Describes a Sonetto virtual button state
Each virtual button or keyboard key can assume one of these states.
@see
Sonetto::PlayerInput::getBtnState()
@see
Sonetto::InputManager::getDirectKeyState()
*/
enum KeyState
{
/// Not pressed
KS_NONE = 0,
/// Has just been pressed
KS_PRESS,
/// Has just been release
KS_RELEASE,
/// Is currentlu being held down
KS_HOLD
};
} // namespace
#include <OgreVector2.h>
#include "SonettoInputManager.h"
#include "SonettoInputSource.h"
namespace Sonetto
{
/** Player input class
This class is the interface used to configure and retrieve information
regarding one player's input. They are maintened by Sonetto::InputManager
and are all disabled by default. To use a PlayerInput class, you first
have to configure and enable it. You can assign buttons and axes to your
joysticks and keyboard using configBtn(), configAxis() and
config() methods. After you are done, you can just enable it by
calling setEnabled(true).
@see
Sonetto::InputManager
*/
class SONETTO_API PlayerInput
{
public:
/** Size of input configuration arrays
@see
mInputCfg
*/
static const size_t INPUT_SRC_NUM = 24;
/** Constructor
Should never be called directly. Use InputManager instead.
@param
enabled Whether this instance is enabled or not.
@param
joyID Joystick ID from which this instance will get input from.
A value of zero means no joystick will be used.
*/
PlayerInput(bool enabled = false,uint32 joyID = 0);
/// Destructor
~PlayerInput() {}
/** Updates input states
@remarks
This is called by InputManager::update(), so you don't
really have to worry about it.
*/
void update();
/// Configures a single button
inline void configBtn(Button btn,const InputSource &input)
{ mInputCfg[btn] = input; }
/// Configures a single axis
void configAxis(Axis axs,const InputSource &input);
/// Gets a single button input source configuration
inline const InputSource &getBtnConfig(Button btn) const { return mInputCfg[btn]; }
/// Gets a single axis input source configuration
inline const InputSource &getAxisConfig(Axis axs) const
{ return mInputCfg[ (BTN_LAST + 1) + axs ]; }
/** Sets joystick ID from which this class will get information from
@param
joyID Joystick ID to be used. A value of zero means no joystick
will be used.
*/
void setJoystick(uint32 joyID);
/** Gets joystick ID from which this class will get information from
@return
Joystick ID. A value of zero means no joystick is being used.
*/
inline uint32 getJoystick() const { return mJoyID; }
/// Enables or disables this player's input updates
inline void setEnabled(bool enable) { mEnabled = enable; }
/// Checks whether this PlayerInput is enabled or not
inline bool isEnabled() const { return mEnabled; }
/// Checks whether the attached joystick is physically plugged or not
bool isPlugged() const;
/// Gets a button state
inline const KeyState getBtnState(Button btn) const { return mBtnStates[btn]; }
/// Gets an axis current values
Ogre::Vector2 getAnalogValue(Axis axs);
private:
/// Whether this PlayerInput is enabled or not
bool mEnabled;
/// Joystick ID (0 for none)
uint32 mJoyID;
/// Joystick shared pointer from which this PlayerInput will get its input from
JoystickPtr mJoy;
/// Input source attachments
InputSource mInputCfg[INPUT_SRC_NUM];
/// Button states
KeyState mBtnStates[BTN_LAST + 1];
/// Axes' values
Ogre::Vector2 mAxesValues[2];
};
} // namespace
#endif
| [
"[email protected]"
]
| [
[
[
1,
224
]
]
]
|
b1f260177fab9e4a2d77da1f754faee0d8de28bb | 4c7ed342d9d1d083475734a891e4e8df3918e36e | /KeyMan/inc/KeyManView1.h | 5d4227981b88e7f86c3eeba7db35c4e52491b83c | []
| no_license | pety3bi/keymans60 | c1c72630d0f6be2f3353f1f7c4eaff7760a5ef3c | 38202208483e5767ef49159c1da9d48998611171 | refs/heads/master | 2021-01-10T21:10:33.448842 | 2010-11-08T03:37:43 | 2010-11-08T03:37:43 | 34,176,487 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,338 | h | #ifndef KEYMANVIEW1_H
#define KEYMANVIEW1_H
#include <KeyMan.hrh>
// View
#include <aknview.h>
// Menu
#include <eikmenup.h>
// Tab Group
#include <akntabgrp.h>
//#include <aknnavide.h>
//#include <akntabobserver.h>
// ListBox
#include <KeyManListBox.h>
// Container
#include "KeyManContainerSettings.h"
// Shared data
#include "shared.h"
const TUid KView1Id = {1};
class CKeyManView1 : public CAknView
{
public:
void ConstructL();
~CKeyManView1();
TUid Id() const;
void HandleCommandL(TInt aCommand);
void HandleClientRectChange();
CAknTabGroup* TabGroup();
void TabChangedL(TInt aIndex);
private:
CAknNavigationControlContainer* iNaviPane;
CAknNavigationDecorator* iDecoratedTabGroup;
CAknTabGroup* iTabGroup;
public:
TInt OfferKeyEventTabGroupL (const TKeyEvent& aKeyEvent, TEventCode aType );
void UpdateSettings();
private:
void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,const TDesC8& aCustomMessage);
void DoDeactivate();
void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane *aMenuPane);
void CreateListBoxL(TInt aResourceId);
private:
CKeyManContainerSettings* iContainer;
CKeyManListbox* iListBox;
RSharedDataClient sd;
public:
CKeyManAppUi* ui;
};
#endif
| [
"[email protected]@7ae75f86-5c51-0410-bd6e-896d651d5528"
]
| [
[
[
1,
63
]
]
]
|
52658a1e0a6116b71a1c12662525d770a68239a1 | 188058ec6dbe8b1a74bf584ecfa7843be560d2e5 | /GodDK/lang/IndexOutOfBoundsException.h | d386664e11b4f6c448fe77afec706091a4c3f9b4 | []
| no_license | mason105/red5cpp | 636e82c660942e2b39c4bfebc63175c8539f7df0 | fcf1152cb0a31560af397f24a46b8402e854536e | refs/heads/master | 2021-01-10T07:21:31.412996 | 2007-08-23T06:29:17 | 2007-08-23T06:29:17 | 36,223,621 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 770 | h |
#ifndef _CLASS_GOD_LANG_INDEXOUTOFBOUNDSEXCEPTION_H
#define _CLASS_GOD_LANG_INDEXOUTOFBOUNDSEXCEPTION_H
#ifdef __cplusplus
#include "lang/RuntimeException.h"
using namespace goddk::lang;
namespace goddk {
namespace lang {
/* \ingroup CXX_LANG_m
*/
class IndexOutOfBoundsException : public virtual RuntimeException
{
public:
inline IndexOutOfBoundsException()
{
}
inline IndexOutOfBoundsException(const char* message) : RuntimeException(message)
{
}
inline IndexOutOfBoundsException(const String* message) : RuntimeException(message)
{
}
inline ~IndexOutOfBoundsException()
{
}
};
typedef CSmartPtr<IndexOutOfBoundsException> IndexOutOfBoundsExceptionPtr;
}
}
#endif
#endif
| [
"soaris@46205fef-a337-0410-8429-7db05d171fc8"
]
| [
[
[
1,
36
]
]
]
|
58ddac5f801b994f9ce97030adfe1373e1db04bb | 877bad5999a3eeab5d6d20b5b69a273b730c5fd8 | /TestKhoaLuan/DirectShowTVSample/Chapter-4/capturegraphbuilder2/capturegraphbuilder2.cpp | bf68d49182ddeb9885f272d83f5226086aec61eb | []
| no_license | eaglezhao/tracnghiemweb | ebdca23cb820769303d27204156a2999b8381e03 | aaae7bb7b9393a8000d395c1d98dcfc389e3c4ed | refs/heads/master | 2021-01-10T12:26:27.694468 | 2010-10-06T01:15:35 | 2010-10-06T01:15:35 | 45,880,587 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,819 | cpp | // capturegraphbuilder2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
//#include "streams.h"
#include <dshow.h>
IBaseFilter *GetAudioDevice (){
// Create the system device enumerator.
ICreateDevEnum *pDevEnum = NULL;
CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC,
IID_ICreateDevEnum, (void **)&pDevEnum);
// Create an enumerator for video capture devices.
IEnumMoniker *pClassEnum = NULL;
pDevEnum->CreateClassEnumerator(CLSID_AudioInputDeviceCategory, &pClassEnum, 0);
ULONG cFetched;
IMoniker *pMoniker = NULL;
IBaseFilter *pSrc = NULL;
if (pClassEnum->Next(1, &pMoniker, &cFetched) == S_OK)
{
// Bind the first moniker to a filter object.
pMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)&pSrc);
pMoniker->Release();
}
pClassEnum->Release();
pDevEnum->Release();
return pSrc;
}
/*class CProgress : public CUnknown, public IAMCopyCaptureFileProgress
{
public:
CProgress(TCHAR *pName, LPUNKNOWN pUnk, HRESULT *phr) :
CUnknown(pName, pUnk, phr) {};
~CProgress() {};
STDMETHODIMP_(ULONG) AddRef() {return 1;};
STDMETHODIMP_(ULONG) Release() {return 0;};
STDMETHODIMP QueryInterface(REFIID iid, void **p) {
CheckPointer(p, E_POINTER);
if (iid == IID_IAMCopyCaptureFileProgress) {
return GetInterface((IAMCopyCaptureFileProgress *)this, p);
} else {
return E_NOINTERFACE;
}
};
STDMETHODIMP Progress(int i) {
TCHAR tach[80];
wsprintf(tach, TEXT("Save File Progress: %d%%"), i);
return S_OK;
};
};*/
int main(int argc, char* argv[])
{
IGraphBuilder *pGraph = NULL;
ICaptureGraphBuilder2 *pBuilder = NULL;
IBaseFilter *pSrc = NULL;
IBaseFilter *ppf = NULL;
IFileSinkFilter *pSink = NULL;
IMediaControl *pMC = NULL;
HRESULT hr;
CoInitialize (NULL);
// Create the filter graph.
CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC,
IID_IGraphBuilder, (void **)&pGraph);
// Create the capture graph builder.
CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC,
IID_ICaptureGraphBuilder2, (void **)&pBuilder);
pBuilder->SetFiltergraph(pGraph);
pSrc=GetAudioDevice ();
// add the first audio filter in the list
pGraph->AddFilter(pSrc, L"Video Capture");
/* pBuilder->SetOutputFileName(
&MEDIASUBTYPE_Avi,
L"C:\\Example.avi",
&ppf,
&pSink);*/
// pBuilder->AllocCapFile (L"C:\\temp.avi", _MAX_PATH);
pBuilder->RenderStream(
&PIN_CATEGORY_CAPTURE, // Pin category
&MEDIATYPE_Audio, // Media type
pSrc, // Capture filter
NULL, // Compression filter (optional)
ppf // Multiplexer or renderer filter
);
REFERENCE_TIME rtStart = 20000000,
rtStop = 50000000;
/* pBuilder->ControlStream(
&PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Audio,
pSrc, // Source filter
&rtStart, // Start time
&rtStop, // Stop time
0, // Start cookie
0 // Stop cookie
);*/
pGraph->QueryInterface (IID_IMediaControl, (void **) &pMC);
pMC->Run ();
MessageBox (NULL, "Stop Recording", NULL, NULL);
pMC->Stop ();
/* CProgress *pProg = new CProgress(TEXT(""), NULL, &hr);
IAMCopyCaptureFileProgress *pIProg = NULL;
hr = pProg->QueryInterface(IID_IAMCopyCaptureFileProgress,
(void **)&pIProg);
//pBuilder->CopyCaptureFile (L"C:\\temp.avi", L"C:\\final.avi", TRUE, pIProg);*/
CoUninitialize ();
return 0;
}
| [
"[email protected]"
]
| [
[
[
1,
134
]
]
]
|
97aaa69a2fdd2490f156442e57fb45740fbdf189 | 629e4fdc23cb90c0144457e994d1cbb7c6ab8a93 | /lib/graphics/distance_fields/distancefieldconverter.cpp | 2bb3a276754a6cb159ff2dd729f7ab8897c875f5 | []
| no_license | akin666/ice | 4ed846b83bcdbd341b286cd36d1ef5b8dc3c0bf2 | 7cfd26a246f13675e3057ff226c17d95a958d465 | refs/heads/master | 2022-11-06T23:51:57.273730 | 2011-12-06T22:32:53 | 2011-12-06T22:32:53 | 276,095,011 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,613 | cpp | /*
* distancefieldconverter.cpp
*
* Created on: 27.3.2011
* Author: akin
*/
#include "distancefieldconverter.h"
#include <cmath>
namespace ice
{
DistanceFieldConverter::DistanceFieldConverter()
{
}
DistanceFieldConverter::~DistanceFieldConverter()
{
}
// Source/References/Concepts/Ideas:
// http://labs.qt.nokia.com/2011/07/15/text-rendering-in-the-qml-scene-graph/
// http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf
// http://bitsquid.blogspot.com/2010/04/distance-field-based-rendering-of.html
// http://www.gamedev.net/topic/491938-signed-distance-bitmap-font-tool/
// http://ghostinthecode.posterous.com/better-contour-rendering
// http://www.gbuffer.net/vector-textures
// http://contourtextures.wikidot.com/
// http://forum.unity3d.com/threads/68647-Scaling-Bitmap-Fonts
// http://forum.unity3d.com/threads/10348-Distance-Field-Alpha-Testing-Cheap-Smooth-Outlines
// http://www.horde3d.org/wiki/index.php5?title=Preprocessing_Technique_-_Distance_Field_Vector_Textures
// http://www.horde3d.org/forums/viewtopic.php?f=1&t=605&view=next
// http://iphone-3d-programming.labs.oreilly.com/ch07.html
// http://www.idevgames.com/forums/thread-205.html
//
// Note!
// this was hacked together from some C# code, and as
// I do not know C#, this whole thing might be blashemy..
// NOTE!
// The original source uses floats to represent channels,
// I use unsigned char arrays to represent channels.
//
unsigned char signedDistance(
const unsigned char *bitmap ,
const int width,
const int height,
int cx,
int cy,
float clamp );
/**
* Computes a distance field transform of a high resolution binary source channel
* and returns the result as a low resolution channel.
* </summary>
*
* src_bitmap,src_width,src_height
* The source channel
*
* dst_bitmap,dst_width,dst_height
* The destination channel
*
* scale
* The amount the source channel will be scaled down.
* A value of 8 means the destination image will be 1/8th the size of the source
* image.
*
* spread
* The spread in pixels before the distance field clamps to (zero/one). The value
* is specified in units of the destination image. The spread in the source image
* will be spread*scale_down.
*/
/*
void DistanceFieldConverter::transform( const unsigned char *src_bitmap ,
const int src_width,
const int src_height,
unsigned char *dst_bitmap,
const int dst_width,
const int dst_height,
const int scale,
const float spread )
{
float source_spread = spread * scale;
// Go through every pixel in dst_image
int ytmp;
const int w_diff = (( dst_width * scale ) - dst_width) / 2;
const int h_diff = (( dst_height * scale ) - dst_height) / 2;
int virtual_x;
int virtual_y;
for( int y = 0 ; y < dst_height ; ++y )
{
ytmp = y * dst_width;
for( int x = 0 ; x < dst_width ; ++x )
{
virtual_x = x * scale - w_diff;
virtual_y = y * scale - h_diff;
float sd = signedDistance(
src_bitmap ,
src_width ,
src_height ,
virtual_x + scale/2 ,
virtual_y + scale/2 ,
source_spread
);
dst_bitmap[ytmp + x] = (unsigned char)((( sd + source_spread ) / ( source_spread * 2 )) * 0xFF);
}
}
}
#include <cmath>
float signedDistance(
const unsigned char *bitmap ,
const int width,
const int height,
int cx,
int cy,
float clamp )
{
int cd = - 0x7F;
if( cx > 0 && cy > 0 && cx < width && cy < height )
{
cd = (int)(bitmap[cy * width + cx]) - 0x7F;
}
int min_x = cx - (int)clamp - 1;
if( min_x < 0 )
{
min_x = 0;
}
int max_x = cx + (int)clamp + 1;
if( max_x >= width )
{
max_x = width - 1;
}
float distance = clamp;
int d;
for( int dy = 0 ; dy <= (int)clamp + 1 ; ++dy )
{
if( dy > distance )
{
continue;
}
if( cy - dy >= 0 )
{
int y1 = cy-dy;
for( int x = min_x ; x <= max_x ; ++x )
{
if( x - cx > distance )
{
continue;
}
d = - 0x7F;
if( y1 >= 0 && x >= 0 )
{
d = (int)(bitmap[y1*width+x]) - 0x7F;
}
if( cd * d <= 0 )
{
float d2 = (y1 - cy)*(y1 - cy) + (x-cx)*(x-cx);
if( d2 < distance*distance )
{
distance = sqrtf(d2);
}
}
}
}
if(dy != 0 && cy+dy < height)
{
int y2 = cy + dy;
for( int x = min_x ; x <= max_x ; ++x )
{
if( x - cx > distance )
{
continue;
}
d = - 0x7F;
if( y2 >= 0 && x >= 0 )
{
d = (int)(bitmap[y2*width+x]) - 0x7F;
}
if( cd * d <= 0 )
{
float d2 = (y2 - cy)*(y2 - cy) + (x-cx)*(x-cx);
if( d2 < distance*distance )
{
distance = sqrtf(d2);
}
}
}
}
}
// basically return abs( distance ); for float.
if (cd > 0)
return distance;
else
return -distance;
}
/**/
void DistanceFieldConverter::transform( const unsigned char *src_bitmap ,
const int src_width,
const int src_height,
unsigned char *dst_bitmap,
const int dst_width,
const int dst_height,
const int scale,
const float radius )
{
const float source_radius = radius * scale;
// Go through every pixel in dst_image
int ytmp;
int virtual_x;
int virtual_y;
for( int y = 0 ; y < dst_height ; ++y )
{
ytmp = y * dst_width;
virtual_y = (y - radius) * scale;
for( int x = 0 ; x < dst_width ; ++x )
{
virtual_x = (x - radius) * scale;
unsigned char sd = signedDistance(
src_bitmap ,
src_width ,
src_height ,
virtual_x ,
virtual_y ,
source_radius
);
dst_bitmap[ytmp + x] = sd;//(unsigned char) (sd * 0xFF);// (unsigned char)((( sd + source_spread ) / ( source_spread * 2 )) * 0xFF);
}
}
}
unsigned char signedDistance(
const unsigned char *bitmap ,
const int width,
const int height,
int cx,
int cy,
float radius )
{
if( cx < 0 || cy < 0 || cx > width || cy > height ) return 0x00;
return bitmap[cy*width+cx];
// // area that possibly reaches the radius distance
// int sx,sy;
// int ex,ey;
//
// sx = cx - (int)radius;
// sy = cy - (int)radius;
// ex = cx + (int)radius;
// ey = cy + (int)radius;
//
// // not seen
// if( ex < 0 || ey < 0 || sx > width || sy > height )
// {
// return 0;
// }
//
// if( sx < 0 ) sx = 0;
// if( sy < 0 ) sy = 0;
// if( ex >= width ) ex = width - 1;
// if( ey >= height ) ey = height - 1;
//
// unsigned char val = 0;
// unsigned char current = 0;
// int tmp;
// int tmpx;
// int tmpy;
// int tt;
// const int distance2 = (int)(radius * radius);
// const float weight = ((float)0x7F) / distance2;
//
// for( int y = sy ; y < ey ; ++y )
// {
// if( val == 0x7F ) break;
// tmpy = std::abs( (float)(cy - y) );
//
// if( (float)tmpy*weight*(float)0xFF < current )
// continue;
//
// tmp = y*width;
// for( int x = sx ; x < ex ; ++x )
// {
// current = bitmap[tmp+x];
// if( val < current )
// {
// // calculate distance
// tmpx = std::abs( (float)(cx - x) );
//
// tt = (tmpx*tmpx + tmpy*tmpy) * weight * current;
//
// if( tt > val )
// {
// val = tt;
// }
// }
// }
// }
//
// return val;
}
}
| [
"akin@lich"
]
| [
[
[
1,
326
]
]
]
|
2e770afe75e5da5d0334f0b5a503bfc55df89a5c | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/mw/classicui/uifw/apps/S60_SDK3.0/bctesteditor/inc/bctesteditorcontainer.h | 1137587f86eaa9db2b138d00a27c717f0c8056b9 | []
| no_license | SymbianSource/oss.FCL.sftools.ana.compatanamdw | a6a8abf9ef7ad71021d43b7f2b2076b504d4445e | 1169475bbf82ebb763de36686d144336fcf9d93b | refs/heads/master | 2020-12-24T12:29:44.646072 | 2010-11-11T14:03:20 | 2010-11-11T14:03:20 | 72,994,432 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,997 | h | /*
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: container
*
*/
#ifndef BCTEST_EDITORCONTAINER_H
#define BCTEST_EDITORCONTAINER_H
#include <coecntrl.h>
/**
* container class
*/
class CBCTestEditorContainer: public CCoeControl
{
public: // constructor and destructor
/**
* C++ default constructor
*/
CBCTestEditorContainer();
/**
* Destructor
*/
virtual ~CBCTestEditorContainer();
/**
* Symbian 2nd constructor
*/
void ConstructL( const TRect& aRect );
public: // new functions
/**
* Set component control, and container will own the control
* @param aControl pointer to a control.
*/
void SetControlL( CCoeControl* aControl );
/**
* Delete control
*/
void ResetControl();
public: // from CCoeControl
/**
* Return count of component controls
*/
TInt CountComponentControls() const;
/**
* Return pointer to component control specified by index
* @param aIndex, a index to specify a component control
*/
CCoeControl* ComponentControl( TInt aIndex ) const;
private: // from CCoeControl
/**
* From CCoeControl, Draw.
* Fills the window's rectangle.
* @param aRect Region of the control to be (re)drawn.
*/
void Draw( const TRect& aRect ) const;
private: // data
/**
* Pointer to component control.
* own
*/
CCoeControl* iControl;
};
#endif // BCTEST_EditorCONTAINER_H | [
"none@none"
]
| [
[
[
1,
90
]
]
]
|
5fdd2c3d9e96142164bd3d74866ae116e8de8217 | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/boost/spirit/fusion/sequence/detail/joint_view_begin_end_traits.hpp | 17788f4269151dbfaaa7c84d61733654e97a8af4 | [
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | willrebuild/flyffsf | e5911fb412221e00a20a6867fd00c55afca593c7 | d38cc11790480d617b38bb5fc50729d676aef80d | refs/heads/master | 2021-01-19T20:27:35.200154 | 2011-02-10T12:34:43 | 2011-02-10T12:34:43 | 32,710,780 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,742 | hpp | /*=============================================================================
Copyright (c) 2003 Joel de Guzman
Copyright (c) 2004 Peder Holt
Use, modification and distribution is subject to the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(FUSION_SEQUENCE_DETAIL_JOINT_VIEW_BEGIN_END_TRAITS_HPP)
#define FUSION_SEQUENCE_DETAIL_JOINT_VIEW_BEGIN_END_TRAITS_HPP
#include <boost/spirit/fusion/detail/config.hpp>
#include <boost/spirit/fusion/iterator/equal_to.hpp>
#include <boost/mpl/if.hpp>
namespace boost { namespace fusion
{
struct joint_view_tag;
template <typename First, typename Last, typename Concat>
struct joint_view_iterator;
namespace joint_view_detail {
template <typename Sequence>
struct begin_traits_impl
{
typedef typename Sequence::first_type first_type;
typedef typename Sequence::last_type last_type;
typedef typename Sequence::concat_type concat_type;
typedef boost::fusion::meta::equal_to<first_type, last_type> equal_to;
typedef typename
boost::mpl::if_<
equal_to
, concat_type
, boost::fusion::joint_view_iterator<first_type, last_type, concat_type>
>::type
type;
static type
call(Sequence& s);
};
template<typename Sequence>
typename begin_traits_impl<Sequence>::type
call(Sequence& s, boost::mpl::true_) {
return s.concat();
}
template<typename Sequence>
typename begin_traits_impl<Sequence>::type
call(Sequence& s, boost::mpl::false_) {
typedef BOOST_DEDUCED_TYPENAME begin_traits_impl<Sequence>::type type;
return type(s.first(), s.concat());
}
template<typename Sequence>
typename begin_traits_impl<Sequence>::type
begin_traits_impl<Sequence>::call(Sequence& s)
{
return joint_view_detail::call(s, equal_to());
}
template <typename Sequence>
struct end_traits_impl
{
typedef typename Sequence::concat_last_type type;
static type
call(Sequence& s);
};
template<typename Sequence>
typename end_traits_impl<Sequence>::type
end_traits_impl<Sequence>::call(Sequence& s)
{
return s.concat_last();
}
}
namespace meta
{
template <typename Tag>
struct begin_impl;
template <>
struct begin_impl<joint_view_tag>
{
template <typename Sequence>
struct apply : joint_view_detail::begin_traits_impl<Sequence>
{};
};
template <typename Tag>
struct end_impl;
template <>
struct end_impl<joint_view_tag>
{
template <typename Sequence>
struct apply : joint_view_detail::end_traits_impl<Sequence>
{};
};
}
}}
namespace boost { namespace mpl
{
template <typename Tag>
struct begin_impl;
template <typename Tag>
struct end_impl;
template <>
struct begin_impl<fusion::joint_view_tag>
: fusion::meta::begin_impl<fusion::joint_view_tag> {};
template <>
struct end_impl<fusion::joint_view_tag>
: fusion::meta::end_impl<fusion::joint_view_tag> {};
}}
#endif
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
126
]
]
]
|
64457427c79978deda614f670545d9a109888e1f | c2a70374051ef8f96105d65c84023d97c90f4806 | /bin/src/loadBmp/win/paintlib/plStreamSink.cpp | e6ae286045adb864456ef93b726c07d6fe9c04de | []
| no_license | haselab-net/SpringheadOne | dcf6f10cb1144b17790a782f519ae25cbe522bb2 | 004335b64ec7bea748ae65a85463c0e85b98edbd | refs/heads/master | 2023-08-04T20:27:17.158435 | 2006-04-15T16:49:35 | 2006-04-15T16:49:35 | 407,701,182 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,140 | cpp | /*
/--------------------------------------------------------------------
|
| $Id: plStreamSink.cpp,v 1.2 2001/10/06 22:03:26 uzadow Exp $
| Copyright (c) 1996-2000 Ulrich von Zadow
|
\--------------------------------------------------------------------
*/
#include "plstdpch.h"
#include "ole2.h"
#include "plStreamSink.h"
#include "plpaintlibdefs.h"
PLStreamSink::PLStreamSink()
: PLDataSink(),
m_pIStream (NULL),
m_pDataBuf (NULL),
m_hMem (NULL )
{
}
PLStreamSink::~PLStreamSink()
{
if (m_pDataBuf)
{
GlobalUnlock(m_hMem);
m_pDataBuf = NULL;
}
if (m_hMem)
{
m_hMem = GlobalFree(m_hMem);
}
if (m_pIStream)
{
m_pIStream->Release();
m_pIStream = NULL;
}
}
int PLStreamSink::Open (int MaxFileSize)
{
// Create the stream
m_hMem = GlobalAlloc(GMEM_MOVEABLE, MaxFileSize);
if (m_hMem == 0)
throw PLTextException (PL_ERRNO_MEMORY, "PLStreamSink::Open - Error allocating memory.\n");
if ((m_pDataBuf = (PLBYTE*)GlobalLock(m_hMem))==NULL)
throw PLTextException (PL_ERRINTERNAL, "PLStreamSink::Open - Error locking memory.\n");
PLDataSink::Open("HGlobalStream", m_pDataBuf, MaxFileSize);
return 0;
/*
if ((CreateStreamOnHGlobal(hMem, true, &m_pIStream) == S_OK) &&
(m_pDataBuf = new PLBYTE [MaxFileSize]))
{
PLDataSink::Open("HGlobalStream", m_pDataBuf, MaxFileSize);
return 0;
}
else
throw PLTextException (PL_ERRINTERNAL, "Error creating HGlobalStream.\n");
*/
}
// now flush the data to the stream
void PLStreamSink::Close ()
{
GlobalUnlock(m_hMem);
m_pDataBuf = NULL;
// by setting fDeleteOnRelease to true the stream owns the global memory block
// and we don't have to call GlobalUnalloc.
// So we can safely set m_hMem to 0.
if (CreateStreamOnHGlobal(m_hMem, true, &m_pIStream) != S_OK)
throw PLTextException (PL_ERRINTERNAL, "Error creating HGlobalStream.\n");
m_hMem = 0;
// Truncate the stream
ULARGE_INTEGER uli_size; // Size of the written data, not of the author of paintlib
uli_size.LowPart = GetDataSize();
uli_size.HighPart = 0;
m_pIStream->SetSize(uli_size);
// reset pointer to beginning of stream
LARGE_INTEGER li_NULL;
li_NULL.LowPart = 0;
li_NULL.HighPart = 0;
m_pIStream->Seek(li_NULL,STREAM_SEEK_SET,NULL);
PLDataSink::Close();
}
IStream * PLStreamSink::GetIStream()
{
return m_pIStream;
}
/*
/--------------------------------------------------------------------
|
| $Log: /Project/Springhead/bin/src/loadBmp/win/paintlib/plStreamSink.cpp $
*
* 1 04/07/12 13:35 Hase
| Revision 1.2 2001/10/06 22:03:26 uzadow
| Added PL prefix to basic data types.
|
| Revision 1.1 2001/09/16 19:03:23 uzadow
| Added global name prefix PL, changed most filenames.
|
| Revision 1.2 2001/02/04 14:31:52 uzadow
| Member initialization list cleanup (Erik Hoffmann).
|
| Revision 1.1 2000/09/01 14:19:46 Administrator
| no message
|
|
\--------------------------------------------------------------------
*/
| [
"jumius@05cee5c3-a2e9-0310-9523-9dfc2f93dbe1"
]
| [
[
[
1,
120
]
]
]
|
b7d4967f808d513b93fe279da098c48eb304caad | b2d46af9c6152323ce240374afc998c1574db71f | /cursovideojuegos/flostiproyect/quakegame/Arena.cpp | 2fa58ecc44119f8fdd9ff41308076a810e507a9f | []
| no_license | bugbit/cipsaoscar | 601b4da0f0a647e71717ed35ee5c2f2d63c8a0f4 | 52aa8b4b67d48f59e46cb43527480f8b3552e96d | refs/heads/master | 2021-01-10T21:31:18.653163 | 2011-09-28T16:39:12 | 2011-09-28T16:39:12 | 33,032,640 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,793 | cpp | #include "__PCH_Tests.h"
#include "Arena.h"
#include "QuakePlayer.h"
#include "QuakePhysicsData.h"
#include "Enemy.h"
CArena::CArena(void)
:m_World(NULL)
,m_Enemy(NULL)
,m_VisibleWorld(true)
{
m_Enemy=new CEnemy();
}
CArena::~CArena(void)
{
Release();
}
void CArena::ReleasePlayers()
{
std::vector<CQuakePlayer *>::iterator it=m_Players.begin(),
it_end=m_Players.end();
for (;it!=it_end;it++)
{
CQuakePlayer *player=*it;
delete player;
}
std::vector<CQuakePhysicsData *>::iterator itd=m_PlayerDatas.begin(),
itd_end=m_PlayerDatas.end();
for (;itd!=itd_end;itd++)
{
CQuakePhysicsData *userData=*itd;
delete userData;
}
}
void CArena::Release()
{
if (m_World!=NULL)
{
m_World->Release();
delete m_World;
m_World=NULL;
}
ReleasePlayers();
}
void CArena::LoadWorld(const char *pathtextures,const char *pathfmt,int numRooms)
{
m_World=new CWorld();
m_World->CreateRooms(pathtextures,pathfmt,numRooms);
}
void CArena::UpdatePlayers(float elapsedTime)
{
std::vector<CQuakePlayer *>::iterator it=m_Players.begin(),
it_end=m_Players.end();
for (;it!=it_end;it++)
{
CQuakePlayer *item=*it;
item->Update(elapsedTime);
}
}
void CArena::Update(float elapsedTime)
{
UpdatePlayers(elapsedTime);
m_Enemy->Update(elapsedTime);
}
void CArena::RenderPlayers(CRenderManager* renderManager)
{
std::vector<CQuakePlayer *>::iterator it=m_Players.begin(),
it_end=m_Players.end();
for (;it!=it_end;it++)
{
CQuakePlayer *item=*it;
item->RenderScene(renderManager);
}
}
void CArena::RenderScene(CRenderManager* renderManager)
{
if (m_VisibleWorld)
m_World->RenderScene(renderManager);
RenderPlayers(renderManager);
m_Enemy->RenderScene(renderManager);
}
| [
"ohernandezba@71d53fa2-cca5-e1f2-4b5e-677cbd06613a"
]
| [
[
[
1,
92
]
]
]
|
8fdef6255ceaa9ee6fd1c2720467f0d1901ea546 | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/mw/web/favourites_api/inc/FavouritesDbTestObserver.h | 0f9a683d9a467e42a7c80ce6ea4015081a225cfc | []
| no_license | SymbianSource/oss.FCL.sftools.ana.compatanamdw | a6a8abf9ef7ad71021d43b7f2b2076b504d4445e | 1169475bbf82ebb763de36686d144336fcf9d93b | refs/heads/master | 2020-12-24T12:29:44.646072 | 2010-11-11T14:03:20 | 2010-11-11T14:03:20 | 72,994,432 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,303 | h | /*
* Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: Declaration of class CFavouritesDbTestObserver.
*
*/
#ifndef FAVOURITES_DB_TEST_OBSERVER_H
#define FAVOURITES_DB_TEST_OBSERVER_H
// INCLUDES
#include <e32base.h>
#include <FavouritesDbObserver.h>
#include "FavouritesBCTest.h"
// FORWARD DECLARATION
class CActiveFavouritesDbNotifier;
// CLASS DECLARATION
/**
* Favourites Engine test observer.
*/
class CFavouritesDbTestObserver: public CActive, public MFavouritesDbObserver
{
public: // Constructors and destructor
/**
* Constructor.
* @param aTester Tester object.
*/
CFavouritesDbTestObserver( CFavouritesBCTest& aTester );
/**
* Destructor.
*/
virtual ~CFavouritesDbTestObserver();
protected: // from CActive
/**
* Run a step of the observer test.
*/
void RunL();
/**
* Cancel protocol implementation.
*/
void DoCancel();
public: // from MFavouritesDbObserver
/**
* Act accordingly to database events.
* @param aEvent Database event.
*/
void HandleFavouritesDbEventL( RDbNotifier::TEvent aEvent );
public: // new methods
/**
* Start the test.
*/
void Start();
/**
* Continue the test.
*/
void Next();
private: // data
CFavouritesBCTest* iTester; ///< Tester; not owned.
CActiveFavouritesDbNotifier* iNotifier; ///< Database notifier.
TInt iStep; ///< Test step.
TInt iLastEvent; ///< Last event occurred.
TInt iEventCount; ///< Count of events.
};
#endif
// End of File
| [
"none@none"
]
| [
[
[
1,
96
]
]
]
|
1166d5a974ee8500b9d2043c77437105681cbcb4 | 9aba8b0e3b75f0c7c89b494206bf6ebc8edab2ce | /WpdPack/Include/include/ucos.h | 4566c0f2b23b2435142b2ccf68db780426512026 | []
| no_license | lhansel/scc-jaus-ethercat | 16f1ddd2448cc6fcdf807fe601e8a38f087606b1 | b8798cdcb8099b93c0521de0d8c2336182354b9e | refs/heads/master | 2021-01-01T17:46:49.599299 | 2011-10-06T20:20:01 | 2011-10-06T20:20:01 | 2,528,446 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,660 | h | /* Rev:$Revision: 1.25 $ */
#ifndef _UCOS_H
#define _UCOS_H
#ifdef _COLDFIRE_INTERRUPT_H
#error UCOS FIRST
#endif
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef _COLDFIRE_INTERRUPT_H
#error MUST Include UCOS before cfinter.h
#endif
#include <basictypes.h>
/***********************************************************
* UCOS.H
* SYSTEM DECLARATIONS
***********************************************************
*/
#define OS_LO_PRIO 63 /*IDLE task priority */
/*TASK STATUS */
#define OS_STAT_RDY 0x00 /*Ready to run */
#define OS_STAT_MBOX 0x01 /*Pending on mailbox */
#define OS_STAT_SEM 0x02 /*Pending on semaphore */
#define OS_STAT_Q 0x04 /*Pending on queue */
#define OS_STAT_FIFO 0x08 /*Pending on FIFO */
#define OS_STAT_CRIT 0x10 /*Pending on Critical Section*/
#define OS_STAT_RES3 0x20 /*Reserved */
#define OS_STAT_RES4 0x40 /*Reserved */
#define OS_STAT_RES5 0x80 /*Reserved */
#define OS_NO_ERR 0
#define OS_TIMEOUT 10
#define OS_MBOX_FULL 20
#define OS_Q_FULL 30
#define OS_PRIO_EXIST 40
#define OS_SEM_ERR 50
#define OS_SEM_OVF 51
#define OS_CRIT_ERR 60
#define OS_NO_MORE_TCB 70 //No TCBs free to create task
/*
***********************************************************
* uCOS TASK CONTROL BLOCK DATA STRUCTURE
***********************************************************
*/
typedef struct os_tcb
{
void *OSTCBStkPtr;
BYTE OSTCBStat;
BYTE OSTCBPrio;
WORD OSTCBDly;
const char * pOSTCBName;
#ifdef UCOS_STACKCHECK
long *OSTCBStkBot;
long *OSTCBStkTop;
#endif
struct os_tcb *OSTCBNext;
struct os_tcb *OSTCBPrev;
} OS_TCB;
/*
***********************************************************
* SEMAPHORE DATA STRUCTURE
***********************************************************
*/
typedef struct os_sem
{
volatile long OSSemCnt;
volatile BYTE OSSemGrp;
volatile BYTE OSSemTbl[8];
} OS_SEM;
/*
***********************************************************
* MAILBOX DATA STRUCTURE
***********************************************************
*/
typedef struct os_mbox
{
void *OSMboxMsg;
BYTE OSMboxGrp;
BYTE OSMboxTbl[8];
} OS_MBOX;
/*
***********************************************************
* QUEUE DATA STRUCTURE
***********************************************************
*/
typedef struct os_q
{
void **OSQStart;
void **OSQEnd;
void **OSQIn;
void **OSQOut;
BYTE OSQSize;
BYTE OSQEntries;
BYTE OSQGrp;
BYTE OSQTbl[8];
} OS_Q;
/*
***********************************************************
* FIFO DATA STRUCTURES
*
* Added by PTB 5/25/98
***********************************************************
*/
typedef struct os_fifo_el
{
struct os_fifo_el *pNext;
}OS_FIFO_EL;
typedef struct os_fifo
{
OS_FIFO_EL *pHead;
OS_FIFO_EL *pTail;
BYTE OSFifoGrp;
BYTE OSFifoTbl[8];
} OS_FIFO;
/*
***********************************************************
* Critical Section DATA STRUCTURES
*
* Added by PTB 5/09/99
***********************************************************
*/
typedef struct os_crit_section
{
BYTE OSCritTaskNum;
DWORD OSCritDepthCount;
BYTE OSCritGrp;
BYTE OSCritTbl[8];
} OS_CRIT;
typedef struct os_flags
{
VDWORD current_flags;
void * pWaitinglist;
} OS_FLAGS;
/*
***********************************************************
* uCOS GLOBAL VARIABLES
***********************************************************
*/
extern volatile OS_TCB *OSTCBPrioTbl[];
extern volatile BYTE OSRdyTbl[];
extern OS_TCB OSTCBTbl[];
extern OS_TCB *OSTCBList;
extern volatile OS_TCB *OSTCBCur;
extern volatile OS_TCB *OSTCBHighRdy;
extern OS_TCB *OSTCBFreeList;
extern volatile DWORD OSIntNesting;
extern volatile DWORD OSLockNesting;
extern volatile DWORD OSRdyGrp;
extern volatile WORD OSISRLevel;
extern volatile BOOLEAN OSRunning;
extern volatile BOOLEAN OSShowTasksOnLeds;
#ifndef UCOS_C /*Required to stop GNU compiler complaining - DJF */
extern BYTE OSMapTbl[];
extern BYTE OSUnMapTbl[];
#endif
/*
***********************************************************
* uCOS FUNCTION PROTOTYPES
***********************************************************
*/
void OSInit( void *idle_stk_top, void *idle_Stk_bot, BYTE maxtasks );
void OSStart( void );
BYTE OSTaskCreate( void ( *task ) ( void *dptr ),
void *data,
void *pstktop,
void *pstkbot,
BYTE prio );
BYTE OSTaskCreatewName( void ( *task ) ( void *dptr ),
void *data,
void *pstktop,
void *pstkbot,
BYTE prio, const char * name);
#define OSSimpleTaskCreate(x,p) { static DWORD func_##x_Stk[USER_TASK_STK_SIZE] __attribute__( ( aligned( 4 ) ) ); OSTaskCreate(x,NULL,(void *)&func_##x_Stk[USER_TASK_STK_SIZE],(void*)func_##x_Stk,p); }
#define OSSimpleTaskCreatewName(x,p,n) { static DWORD func_##x_Stk[USER_TASK_STK_SIZE] __attribute__( ( aligned( 4 ) ) ); OSTaskCreatewName(x,NULL,(void *)&func_##x_Stk[USER_TASK_STK_SIZE],(void*)func_##x_Stk,p,n); }
void OSTimeDly( WORD ticks );
void OSTimeTick( void );
void OSIntEnter( void );
void OSIntExit( void );
void OSCtxSw( void );
void OSIntCtxSw( void );
void OSTickISR( void );
void OSStartHighRdy( void );
void OSSetupVBR( void );
void OSSched( void );
OS_TCB *OSTCBGetFree( void );
BYTE OSChangePrio( BYTE newp );
void OSSetName(const char * cp);
void OSTaskDelete( void );
void OSLock( void );
void OSUnlock( void );
BYTE OSSemInit( OS_SEM *psem, long value );
BYTE OSSemPost( OS_SEM *psem );
BYTE OSSemPend( OS_SEM *psem, WORD timeout );
BYTE OSSemPendNoWait( OS_SEM *psem );
BYTE OSMboxInit( OS_MBOX *pmbox, void *msg );
BYTE OSMboxPost( OS_MBOX *pmbox, void *msg );
void *OSMboxPend( OS_MBOX *pmbox, WORD timeout, BYTE *err );
void *OSMboxPendNoWait( OS_MBOX *pmbox, BYTE *err );
BYTE OSQInit( OS_Q *pq, void **start, BYTE size );
BYTE OSQPost( OS_Q *pq, void *msg );
BYTE OSQPostFirst( OS_Q *pq, void *msg );
void *OSQPend( OS_Q *pq, WORD timeout, BYTE *err );
void *OSQPendNoWait( OS_Q *pq, BYTE *err );
BYTE OSFifoInit( OS_FIFO *pFifo );
BYTE OSFifoPost( OS_FIFO *pFifo, OS_FIFO_EL *pToPost );
BYTE OSFifoPostFirst( OS_FIFO *pFifo, OS_FIFO_EL *pToPost );
OS_FIFO_EL *OSFifoPend( OS_FIFO *pFifo, WORD timeout );
OS_FIFO_EL *OSFifoPendNoWait( OS_FIFO *pFifo );
BYTE OSCritInit( OS_CRIT *pCrit );
BYTE OSCritEnter( OS_CRIT *pCrit, WORD timeout );
BYTE OSCritEnterNoWait( OS_CRIT *pCrit );
BYTE OSCritLeave( OS_CRIT *pCrit );
/*
This function returns the current tasks priority
*/
BYTE OSTaskID( void );
/*
This function returns the current tasks name
*/
const char * OSTaskName();
/* Create and initialize an OS flags object
This function must be called beofre you use an OS_FLAGS object.
*/
void OSFlagCreate( OS_FLAGS *);
/* Set bits in a OS_FLAG object, this sets or clears whatever bits are set in bits_to_set
flags, a pointer to the OS_FLAG object you whish to operate on
bits_to_set A bit or of the flag bits you want to set.
*/
void OSFlagSet(OS_FLAGS * flags, DWORD bits_to_set);
/* Clears bits in a OS_FLAG object, this sets or clears whatever bits are set in bits_to_set
flags, a pointer to the OS_FLAG object you whish to operate on
bits_to_clr A bit or of the flag bits you want to clear.
*/
void OSFlagClear(OS_FLAGS * flags, DWORD bits_to_clr);
/* This call waits until ANY of the flags indicated by mask are set
flags the OS_FLAGS object to wait on.
bit_mask The set of bits to wait on
timeout the number of time ticks to wait for a flag.
This returns:
OS_NO_ERR If the flags condition is satisfied
OS_TIMEOUT If the timeout expired
*/
BYTE OSFlagPendAny(OS_FLAGS * flags, DWORD bit_mask, WORD timeout);
BYTE OSFlagPendAnyNoWait(OS_FLAGS * flags, DWORD bit_mask);
/* This call waits until ALL of the flags indicated by mask are set *
flags the OS_FLAGS object to wait on.
bit_mask The set of bits to wait on, all of these bit must be set to triger a return.
timeout the number of time ticks to wait for a flag.
This returns:
OS_NO_ERR If the flags condition is satisfied
OS_TIMEOUT If the timeout expired
*/
BYTE OSFlagPendAll(OS_FLAGS * flags, DWORD bit_mask, WORD timeout);
BYTE OSFlagPendAllNoWait(OS_FLAGS * flags, DWORD bit_mask);
/* This returns the current value of flags stored in the OS_FLAGS structure.
flags a pointer to the OS_FLAGS structure whoose state you want to return.
returns:
The state of the flags object.
*/
DWORD OSFlagState(OS_FLAGS * flags);
void OSChangeTaskDly( WORD task_prio, WORD newticks );
#ifdef UCOS_STACKCHECK
void OSDumpTCBStacks( void );
void OSDumpTasks( void );
#endif
#ifdef UCOS_TASKLIST
void ShowTaskList( void );
#endif
#ifdef __cplusplus
}
/*Some CPP Classes for use */
class OSLockObj
{
public:
OSLockObj()
{
OSLock();
};
~OSLockObj()
{
OSUnlock();
};
};
class OSCriticalSectionObj
{
OS_CRIT *pcrit;
public:
OSCriticalSectionObj( OS_CRIT &ocrit )
{
pcrit = &ocrit;
OSCritEnter( &ocrit, 0 );
};
~OSCriticalSectionObj()
{
OSCritLeave( pcrit );
}
};
#endif
#endif
| [
"[email protected]"
]
| [
[
[
1,
383
]
]
]
|
83b1f86d8f07220104148bf951fb8ad0add0a1ad | d397b0d420dffcf45713596f5e3db269b0652dee | /src/Axe/Response.hpp | 7129add3bb8175f89abc9d0eece9a039d3c2677b | []
| no_license | irov/Axe | 62cf29def34ee529b79e6dbcf9b2f9bf3709ac4f | d3de329512a4251470cbc11264ed3868d9261d22 | refs/heads/master | 2021-01-22T20:35:54.710866 | 2010-09-15T14:36:43 | 2010-09-15T14:36:43 | 85,337,070 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 573 | hpp | # pragma once
# include <AxeUtil/Shared.hpp>
# include <Axe/Exception.hpp>
# include <Axe/AxeCallback.hpp>
namespace Axe
{
class ArchiveDispatcher;
class Response
: virtual public AxeUtil::Shared
{
public:
virtual void responseCall( ArchiveDispatcher & _ar, std::size_t _size ) = 0;
virtual void exceptionCall( std::size_t _exceptionId, ArchiveDispatcher & _ar, std::size_t _size );
public:
bool dispatch( ArchiveDispatcher & _ar, std::size_t _size );
protected:
virtual void throw_exception( const Exception & _ex ) = 0;
};
} | [
"yuriy_levchenko@b35ac3e7-fb55-4080-a4c2-184bb04a16e0"
]
| [
[
[
1,
25
]
]
]
|
04ed800c2648962a77343b2e07a029fbf8992035 | 1b75922773bf9e61f5c9c8572ffcdae73d34a158 | /include/bsError.h | be2200595dd05e39e33dcd110705ad7763b09a0e | []
| no_license | warvair/bulletscript | a6db7ad4caa661e830373f4953e35053852008bc | 3f499c3afba07c251fa95cb012801ef820705f7f | refs/heads/master | 2021-01-10T20:46:53.665684 | 2010-07-03T18:50:43 | 2010-07-03T18:50:43 | 35,000,416 | 5 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 625 | h | /*
BulletScript: a script for firing bullets.
See /doc/license.txt for license details.
*/
#ifndef __BS_ERROR_H__
#define __BS_ERROR_H__
#include "bsPrerequisites.h"
namespace BS_NMSP
{
enum ErrorCode
{
BS_TreeLocked = -2,
BS_NotFound = -1,
BS_OK = 0,
BS_NoStates,
BS_BadEvent,
BS_PropertyExists,
BS_TooManyProperties,
BS_TooManyMemberVariables,
BS_EmitterExists,
BS_ControllerExists,
BS_NativeFunctionExists,
BS_GlobalVariableExists,
BS_MemberVariableExists,
BS_EmitFunctionExists,
BS_CompileErrors,
};
String getErrorMessage(int code);
}
#endif | [
"[email protected]@fe84ce02-70a6-11de-8b73-c1edde54a3c7"
]
| [
[
[
1,
37
]
]
]
|
5c7d02303c4d6fd5ce4cfc554d4922eae2b71d08 | fcf03ead74f6dc103ec3b07ffe3bce81c820660d | /Basics/MClasses3/MClasses3.cpp | 4cb041508c62179c8312bf0b57ede76b062e6a3b | []
| no_license | huellif/symbian-example | 72097c9aec6d45d555a79a30d576dddc04a65a16 | 56f6c5e67a3d37961408fc51188d46d49bddcfdc | refs/heads/master | 2016-09-06T12:49:32.021854 | 2010-10-14T06:31:20 | 2010-10-14T06:31:20 | 38,062,421 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,059 | cpp | // MClasses3.CPP
//
// Copyright (c) 1997-1999 Symbian Ltd. All rights reserved.
//
/*
Demonstrate use of M classes, or mixins - the
only use of multiple inheritance that has been
sanctioned by the E32 architecture team
This example shows how mixins can be used to
pass some protocol, and an associated object, from
a protocol provider to an protocol user. The user
is not supposed to know everything about the provider,
only about the protocol it's interested in.
In this specific example, the provider is derived from
an appropriate base class, and a mixin class representing
the protocol. The benefits of the method shown in example EUTYPEM2
are thus gained, without the inconvenience of intermediary
classes.
*/
#include "CommonFramework.h"
//////////////////////////////////////////////////////////////////////////////
//
// -----> CProtocol (definition)
//
// A protocol class for mixing in
//
//////////////////////////////////////////////////////////////////////////////
class MProtocol
{
public:
virtual void HandleEvent(TInt aEventCode)=0;
};
//////////////////////////////////////////////////////////////////////////////
//
// -----> CProtocolUser (definition)
//
// Define a protocol user which uses this protocol
//
//////////////////////////////////////////////////////////////////////////////
class CProtocolUser : public CBase
{
public:
// Construction
static CProtocolUser* NewLC();
static CProtocolUser* NewL();
// Destruction
~CProtocolUser();
// Some function which uses a protocol
void DoSomething(MProtocol* aProtocol);
protected:
// Construction assistance
void ConstructL();
};
//////////////////////////////////////////////////////////////////////////////
//
// -----> CProtocolProvider (definition)
//
// A simple class which uses the mixin
//
//////////////////////////////////////////////////////////////////////////////
class CProtocolProvider : public CBase, public MProtocol
{
public:
// Construction
static CProtocolProvider* NewLC();
// Destruction
~CProtocolProvider();
// Calls the protocol user
void CallProtocolUser();
// Implement the protocol (handles the protocol)
void HandleEvent(TInt aEventCode);
protected:
// Construction assistance
void ConstructL();
private:
// data members defined by this class
CProtocolUser* iProtocolUser;
};
//////////////////////////////////////////////////////////////////////////////
//
// -----> CProtocolUser (implementation)
//
//////////////////////////////////////////////////////////////////////////////
CProtocolUser* CProtocolUser::NewLC()
{
CProtocolUser* self=new(ELeave) CProtocolUser;
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
CProtocolUser* CProtocolUser::NewL()
{
CProtocolUser* self=NewLC();
CleanupStack::Pop();
return self;
}
CProtocolUser::~CProtocolUser()
{
}
void CProtocolUser::ConstructL()
{
}
void CProtocolUser::DoSomething(MProtocol* aProtocol)
{
// Do something that requires a protocol
_LIT(KTxtExtSystemDoing,"External system doing something\n");
console->Printf(KTxtExtSystemDoing);
_LIT(KTxtInvokingProtocol,"invoking protocol - event 3\n");
console->Printf(KTxtInvokingProtocol);
// Handle an event
aProtocol->HandleEvent(3);
}
//////////////////////////////////////////////////////////////////////////////
//
// -----> CProtocolProvider (implementation)
//
//////////////////////////////////////////////////////////////////////////////
CProtocolProvider* CProtocolProvider::NewLC()
{
CProtocolProvider* self=new(ELeave) CProtocolProvider;
CleanupStack::PushL(self);
self->ConstructL();
return self;
};
CProtocolProvider::~CProtocolProvider()
{
delete iProtocolUser;
}
void CProtocolProvider::ConstructL()
{
iProtocolUser=CProtocolUser::NewL();
}
void CProtocolProvider::CallProtocolUser()
{
// Call the protocol user to do some work
_LIT(KTxtCallProtUser,"CProtocolProvider calling protocol user\n");
console->Printf(KTxtCallProtUser);
iProtocolUser->DoSomething(this);
// pass ourselves, disguised as our mixin
// protocol base, to the protocol user
}
void CProtocolProvider::HandleEvent(TInt aEventCode)
{
// A concrete implementation of the abstract protocol.
// Handle an event in the protocol user
_LIT(KFormat1,"CProtocolProvider handling event %d\n");
console->Printf(KFormat1,aEventCode);
}
//////////////////////////////////////////////////////////////////////////////
//
// Do the example
//
//////////////////////////////////////////////////////////////////////////////
LOCAL_C void doExampleL()
{
// show use of mixin with simple class
CProtocolProvider* simpleProvider=CProtocolProvider::NewLC();
// call protocol user
simpleProvider->CallProtocolUser();
// Remove simpleProvider from cleanup stack and destroy
CleanupStack::PopAndDestroy();
}
| [
"liuxk99@bdc341c6-17c0-11de-ac9f-1d9250355bca"
]
| [
[
[
1,
196
]
]
]
|
490237be2e18dbb2fe3c2182f4fa77fd9186c371 | a84b013cd995870071589cefe0ab060ff3105f35 | /webdriver/branches/chrome/chrome/src/cpp/include/v8/src/execution.h | 206f5c48145b05b4c96eb2e49551e89092739888 | [
"Apache-2.0"
]
| permissive | vdt/selenium | 137bcad58b7184690b8785859d77da0cd9f745a0 | 30e5e122b068aadf31bcd010d00a58afd8075217 | refs/heads/master | 2020-12-27T21:35:06.461381 | 2009-08-18T15:56:32 | 2009-08-18T15:56:32 | 13,650,409 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,897 | h | // Copyright 2006-2008 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef V8_EXECUTION_H_
#define V8_EXECUTION_H_
namespace v8 { namespace internal {
// Flag used to set the interrupt causes.
enum InterruptFlag {
INTERRUPT = 1 << 0,
DEBUGBREAK = 1 << 1,
PREEMPT = 1 << 2
};
class Execution : public AllStatic {
public:
// Call a function, the caller supplies a receiver and an array
// of arguments. Arguments are Object* type. After function returns,
// pointers in 'args' might be invalid.
//
// *pending_exception tells whether the invoke resulted in
// a pending exception.
//
static Handle<Object> Call(Handle<JSFunction> func,
Handle<Object> receiver,
int argc,
Object*** args,
bool* pending_exception);
// Construct object from function, the caller supplies an array of
// arguments. Arguments are Object* type. After function returns,
// pointers in 'args' might be invalid.
//
// *pending_exception tells whether the invoke resulted in
// a pending exception.
//
static Handle<Object> New(Handle<JSFunction> func,
int argc,
Object*** args,
bool* pending_exception);
// Call a function, just like Call(), but make sure to silently catch
// any thrown exceptions. The return value is either the result of
// calling the function (if caught exception is false) or the exception
// that occurred (if caught exception is true).
static Handle<Object> TryCall(Handle<JSFunction> func,
Handle<Object> receiver,
int argc,
Object*** args,
bool* caught_exception);
// ECMA-262 9.2
static Handle<Object> ToBoolean(Handle<Object> obj);
// ECMA-262 9.3
static Handle<Object> ToNumber(Handle<Object> obj, bool* exc);
// ECMA-262 9.4
static Handle<Object> ToInteger(Handle<Object> obj, bool* exc);
// ECMA-262 9.5
static Handle<Object> ToInt32(Handle<Object> obj, bool* exc);
// ECMA-262 9.6
static Handle<Object> ToUint32(Handle<Object> obj, bool* exc);
// ECMA-262 9.8
static Handle<Object> ToString(Handle<Object> obj, bool* exc);
// ECMA-262 9.8
static Handle<Object> ToDetailString(Handle<Object> obj, bool* exc);
// ECMA-262 9.9
static Handle<Object> ToObject(Handle<Object> obj, bool* exc);
// Create a new date object from 'time'.
static Handle<Object> NewDate(double time, bool* exc);
// Used to implement [] notation on strings (calls JS code)
static Handle<Object> CharAt(Handle<String> str, uint32_t index);
static Handle<Object> GetFunctionFor();
static Handle<JSFunction> InstantiateFunction(
Handle<FunctionTemplateInfo> data, bool* exc);
static Handle<JSObject> InstantiateObject(Handle<ObjectTemplateInfo> data,
bool* exc);
static void ConfigureInstance(Handle<Object> instance,
Handle<Object> data,
bool* exc);
static Handle<String> GetStackTraceLine(Handle<Object> recv,
Handle<JSFunction> fun,
Handle<Object> pos,
Handle<Object> is_global);
static Object* DebugBreakHelper();
// If the stack guard is triggered, but it is not an actual
// stack overflow, then handle the interruption accordingly.
static Object* HandleStackGuardInterrupt();
// Get a function delegate (or undefined) for the given non-function
// object. Used for support calling objects as functions.
static Handle<Object> GetFunctionDelegate(Handle<Object> object);
};
class ExecutionAccess;
// Stack guards are used to limit the number of nested invocations of
// JavaScript and the stack size used in each invocation.
class StackGuard BASE_EMBEDDED {
public:
StackGuard();
~StackGuard();
static void SetStackLimit(uintptr_t limit);
static Address address_of_jslimit() {
return reinterpret_cast<Address>(&thread_local_.jslimit_);
}
// Threading support.
static char* ArchiveStackGuard(char* to);
static char* RestoreStackGuard(char* from);
static int ArchiveSpacePerThread();
static bool IsStackOverflow();
static bool IsPreempted();
static void Preempt();
static bool IsInterrupted();
static void Interrupt();
static bool IsDebugBreak();
static void DebugBreak();
static void Continue(InterruptFlag after_what);
private:
// You should hold the ExecutionAccess lock when calling this method.
static bool IsSet(const ExecutionAccess& lock);
// This provides an asynchronous read of the stack limit for the current
// thread. There are no locks protecting this, but it is assumed that you
// have the global V8 lock if you are using multiple V8 threads.
static uintptr_t climit() {
return thread_local_.climit_;
}
// You should hold the ExecutionAccess lock when calling this method.
static void set_limits(uintptr_t value, const ExecutionAccess& lock) {
thread_local_.jslimit_ = value;
thread_local_.climit_ = value;
}
// Reset limits to initial values. For example after handling interrupt.
// You should hold the ExecutionAccess lock when calling this method.
static void reset_limits(const ExecutionAccess& lock) {
if (thread_local_.nesting_ == 0) {
// No limits have been set yet.
set_limits(kIllegalLimit, lock);
} else {
thread_local_.jslimit_ = thread_local_.initial_jslimit_;
thread_local_.climit_ = thread_local_.initial_climit_;
}
}
// Enable or disable interrupts.
static void EnableInterrupts();
static void DisableInterrupts();
static const uintptr_t kLimitSize = 512 * KB;
static const uintptr_t kInterruptLimit = 0xfffffffe;
static const uintptr_t kIllegalLimit = 0xffffffff;
class ThreadLocal {
public:
ThreadLocal()
: initial_jslimit_(kIllegalLimit),
jslimit_(kIllegalLimit),
initial_climit_(kIllegalLimit),
climit_(kIllegalLimit),
nesting_(0),
postpone_interrupts_nesting_(0),
interrupt_flags_(0) {}
uintptr_t initial_jslimit_;
uintptr_t jslimit_;
uintptr_t initial_climit_;
uintptr_t climit_;
int nesting_;
int postpone_interrupts_nesting_;
int interrupt_flags_;
};
static ThreadLocal thread_local_;
friend class StackLimitCheck;
friend class PostponeInterruptsScope;
};
// Support for checking for stack-overflows in C++ code.
class StackLimitCheck BASE_EMBEDDED {
public:
bool HasOverflowed() const {
// Stack has overflowed in C++ code only if stack pointer exceeds the C++
// stack guard and the limits are not set to interrupt values.
// TODO(214): Stack overflows are ignored if a interrupt is pending. This
// code should probably always use the initial C++ limit.
return (reinterpret_cast<uintptr_t>(this) < StackGuard::climit()) &&
StackGuard::IsStackOverflow();
}
};
// Support for temporarily postponing interrupts. When the outermost
// postpone scope is left the interrupts will be re-enabled and any
// interrupts that occurred while in the scope will be taken into
// account.
class PostponeInterruptsScope BASE_EMBEDDED {
public:
PostponeInterruptsScope() {
StackGuard::thread_local_.postpone_interrupts_nesting_++;
StackGuard::DisableInterrupts();
}
~PostponeInterruptsScope() {
if (--StackGuard::thread_local_.postpone_interrupts_nesting_ == 0) {
StackGuard::EnableInterrupts();
}
}
};
class GCExtension : public v8::Extension {
public:
GCExtension() : v8::Extension("v8/gc", kSource) {}
virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
v8::Handle<v8::String> name);
static v8::Handle<v8::Value> GC(const v8::Arguments& args);
private:
static const char* kSource;
};
} } // namespace v8::internal
#endif // V8_EXECUTION_H_
| [
"noel.gordon@07704840-8298-11de-bf8c-fd130f914ac9"
]
| [
[
[
1,
273
]
]
]
|
b90141a7b9a74a8fb6b009d7b8f918fc4bad3b80 | a2904986c09bd07e8c89359632e849534970c1be | /topcoder/completed/ColorfulBoxesAndBalls.cpp | 7dcbfab357ae4f9c984543a09ff710bb669b7a50 | []
| no_license | naturalself/topcoder_srms | 20bf84ac1fd959e9fbbf8b82a93113c858bf6134 | 7b42d11ac2cc1fe5933c5bc5bc97ee61b6ec55e5 | refs/heads/master | 2021-01-22T04:36:40.592620 | 2010-11-29T17:30:40 | 2010-11-29T17:30:40 | 444,669 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,019 | cpp | // BEGIN CUT HERE
// END CUT HERE
#line 5 "ColorfulBoxesAndBalls.cpp"
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
#define forv(i, v) for (int i = 0; i < (int)(v.size()); ++i)
#define fors(i, s) for (int i = 0; i < (int)(s.length()); ++i)
#define all(a) a.begin(), a.end()
class ColorfulBoxesAndBalls {
public:
int getMaximum(int numRed, int numBlue, int onlyRed, int onlyBlue, int bothColors) {
int score_t = 0;
int score = -100000000;
if(onlyRed == onlyBlue && onlyRed == bothColors) return (numRed+numBlue)*(onlyRed);
for(int i=0;i<=min(numRed,numBlue);i++){
score_t += (numRed-i) * onlyRed;
score_t += (numBlue-i) * onlyBlue;
score_t += i*2* bothColors;
score = max(score,score_t);
score_t = 0;
}
return score;
}
// BEGIN CUT HERE
public:
void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); if ((Case == -1) || (Case == 3)) test_case_3(); if ((Case == -1) || (Case == 4)) test_case_4(); }
private:
template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); }
void verify_case(int Case, const int &Expected, const int &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } }
void test_case_0() { int Arg0 = 2; int Arg1 = 3; int Arg2 = 100; int Arg3 = 400; int Arg4 = 200; int Arg5 = 1400; verify_case(0, Arg5, getMaximum(Arg0, Arg1, Arg2, Arg3, Arg4)); }
void test_case_1() { int Arg0 = 2; int Arg1 = 3; int Arg2 = 100; int Arg3 = 400; int Arg4 = 300; int Arg5 = 1600; verify_case(1, Arg5, getMaximum(Arg0, Arg1, Arg2, Arg3, Arg4)); }
void test_case_2() { int Arg0 = 5; int Arg1 = 5; int Arg2 = 464; int Arg3 = 464; int Arg4 = 464; int Arg5 = 4640; verify_case(2, Arg5, getMaximum(Arg0, Arg1, Arg2, Arg3, Arg4)); }
void test_case_3() { int Arg0 = 1; int Arg1 = 4; int Arg2 = 20; int Arg3 = -30; int Arg4 = -10; int Arg5 = -100; verify_case(3, Arg5, getMaximum(Arg0, Arg1, Arg2, Arg3, Arg4)); }
void test_case_4() { int Arg0 = 9; int Arg1 = 1; int Arg2 = -1; int Arg3 = -10; int Arg4 = 4; int Arg5 = 0; verify_case(4, Arg5, getMaximum(Arg0, Arg1, Arg2, Arg3, Arg4)); }
// END CUT HERE
};
// BEGIN CUT HERE
int main() {
ColorfulBoxesAndBalls ___test;
___test.run_test(-1);
}
// END CUT HERE
| [
"shin@CF-7AUJ41TT52JO.(none)"
]
| [
[
[
1,
72
]
]
]
|
eecb9a635a6b92b6e89f9c33d71a59a7bd065eb6 | 1bbd5854d4a2efff9ee040e3febe3f846ed3ecef | /src/scrview/scrmaker.h | cced9ce60f0736091d69cd982a7bab02b82fcb27 | []
| no_license | amanuelg3/screenviewer | 2b896452a05cb135eb7b9eb919424fe6c1ce8dd7 | 7fc4bb61060e785aa65922551f0e3ff8423eccb6 | refs/heads/master | 2021-01-01T18:54:06.167154 | 2011-12-21T02:19:10 | 2011-12-21T02:19:10 | 37,343,569 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 437 | h | #ifndef SCRMAKER_H
#define SCRMAKER_H
#include <QThread>
#include <QMutex>
//#include "server.h"
class Server;
class ScrMaker: public QThread
{
private:
QMutex* scrMutex;
QString format;
int w;
int h;
bool stoped;
Server *serv;
public:
ScrMaker(QMutex* mutex, Server *serv, int w, int h, QString format);
void run();
void stop() { stoped = true; }
};
#endif // SCRMAKER_H
| [
"JuliusR@localhost"
]
| [
[
[
1,
25
]
]
]
|
8de6d8bf4dde51a8edf612491080fd2288668c60 | 709cd826da3ae55945fd7036ecf872ee7cdbd82a | /Term/WildMagic2/Source/Meshes/WmlMTMesh.cpp | 0ea1b1c1de6d19799f58e78d83c8778f46f2bc86 | []
| no_license | argapratama/kucgbowling | 20dbaefe1596358156691e81ccceb9151b15efb0 | 65e40b6f33c5511bddf0fa350c1eefc647ace48a | refs/heads/master | 2018-01-08T15:27:44.784437 | 2011-06-19T15:23:39 | 2011-06-19T15:23:39 | 36,738,655 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 24,862 | cpp | // Magic Software, Inc.
// http://www.magic-software.com
// http://www.wild-magic.com
// Copyright (c) 2003. All Rights Reserved
//
// The Wild Magic Library (WML) source code is supplied under the terms of
// the license agreement http://www.magic-software.com/License/WildMagic.pdf
// and may not be copied or disclosed except in accordance with the terms of
// that agreement.
#include "WmlMTMesh.h"
#include <fstream>
using namespace Wml;
using namespace std;
//----------------------------------------------------------------------------
MTMesh::MTMesh (int iVQuantity, int iEQuantity, int iTQuantity)
:
m_akVertex(iVQuantity),
m_akEdge(iEQuantity),
m_akTriangle(iTQuantity)
{
m_iInitialELabel = -1;
m_iInitialTLabel = -1;
}
//----------------------------------------------------------------------------
MTMesh::MTMesh (const MTMesh& rkMesh)
{
*this = rkMesh;
}
//----------------------------------------------------------------------------
MTMesh::~MTMesh ()
{
}
//----------------------------------------------------------------------------
void MTMesh::Reset (int iVQuantity, int iEQuantity, int iTQuantity)
{
m_akVertex.Reset(iVQuantity);
m_akEdge.Reset(iEQuantity);
m_akTriangle.Reset(iTQuantity);
m_kVMap.clear();
m_kEMap.clear();
m_kTMap.clear();
}
//----------------------------------------------------------------------------
MTMesh& MTMesh::operator= (const MTMesh& rkMesh)
{
m_akVertex = rkMesh.m_akVertex;
m_akEdge = rkMesh.m_akEdge;
m_akTriangle = rkMesh.m_akTriangle;
m_kVMap = rkMesh.m_kVMap;
m_kEMap = rkMesh.m_kEMap;
m_kTMap = rkMesh.m_kTMap;
m_iInitialELabel = rkMesh.m_iInitialELabel;
m_iInitialTLabel = rkMesh.m_iInitialTLabel;
return *this;
}
//----------------------------------------------------------------------------
bool MTMesh::Insert (int iLabel0, int iLabel1, int iLabel2)
{
// insert triangle
int iT = InsertTriangle(iLabel0,iLabel1,iLabel2);
if ( iT == -1 )
{
// triangle already exists
return true;
}
// insert vertices
int iV0 = InsertVertex(iLabel0);
int iV1 = InsertVertex(iLabel1);
int iV2 = InsertVertex(iLabel2);
// insert edges
int iE0 = InsertEdge(iLabel0,iLabel1);
int iE1 = InsertEdge(iLabel1,iLabel2);
int iE2 = InsertEdge(iLabel2,iLabel0);
// set the connections between components
MTTriangle& rkT = m_akTriangle[iT];
MTVertex& rkV0 = m_akVertex[iV0];
MTVertex& rkV1 = m_akVertex[iV1];
MTVertex& rkV2 = m_akVertex[iV2];
MTEdge& rkE0 = m_akEdge[iE0];
MTEdge& rkE1 = m_akEdge[iE1];
MTEdge& rkE2 = m_akEdge[iE2];
// attach edges to vertices
rkV0.InsertEdge(iE2);
rkV0.InsertEdge(iE0);
rkV1.InsertEdge(iE0);
rkV1.InsertEdge(iE1);
rkV2.InsertEdge(iE1);
rkV2.InsertEdge(iE2);
rkE0.Vertex(0) = iV0;
rkE0.Vertex(1) = iV1;
rkE1.Vertex(0) = iV1;
rkE1.Vertex(1) = iV2;
rkE2.Vertex(0) = iV2;
rkE2.Vertex(1) = iV0;
// attach triangles to vertices
rkV0.InsertTriangle(iT);
rkV1.InsertTriangle(iT);
rkV2.InsertTriangle(iT);
rkT.Vertex(0) = iV0;
rkT.Vertex(1) = iV1;
rkT.Vertex(2) = iV2;
// attach triangle to edges
AttachTriangleToEdge(iT,rkT,0,iE0,rkE0);
AttachTriangleToEdge(iT,rkT,1,iE1,rkE1);
AttachTriangleToEdge(iT,rkT,2,iE2,rkE2);
return true;
}
//----------------------------------------------------------------------------
int MTMesh::InsertVertex (int iLabel)
{
MTIVertex kV(iLabel);
int iV;
VIter pkV = m_kVMap.find(kV);
if ( pkV != m_kVMap.end() )
{
// vertex already exists
iV = pkV->second;
}
else
{
// create new vertex
iV = m_akVertex.Append(MTVertex(iLabel));
m_kVMap.insert(make_pair(kV,iV));
}
return iV;
}
//----------------------------------------------------------------------------
int MTMesh::InsertEdge (int iLabel0, int iLabel1)
{
MTIEdge kE(iLabel0,iLabel1);
int iE;
EIter pkE = m_kEMap.find(kE);
if ( pkE != m_kEMap.end() )
{
// edge already exists
iE = pkE->second;
}
else
{
// create new edge
iE = m_akEdge.Append(MTEdge(m_iInitialELabel));
m_kEMap.insert(make_pair(kE,iE));
}
return iE;
}
//----------------------------------------------------------------------------
int MTMesh::InsertTriangle (int iLabel0, int iLabel1, int iLabel2)
{
MTITriangle kT(iLabel0,iLabel1,iLabel2);
int iT;
TIter pkT = m_kTMap.find(kT);
if ( pkT != m_kTMap.end() )
{
// triangle already exists
iT = -1;
}
else
{
// create new triangle
iT = m_akTriangle.Append(MTTriangle(m_iInitialTLabel));
m_kTMap.insert(make_pair(kT,iT));
}
return iT;
}
//----------------------------------------------------------------------------
bool MTMesh::Remove (int iLabel0, int iLabel1, int iLabel2)
{
MTITriangle kT(iLabel0,iLabel1,iLabel2);
TIter pkT = m_kTMap.find(kT);
if ( pkT == m_kTMap.end() )
{
// triangle does not exist
return false;
}
int iT = pkT->second;
MTTriangle& rkT = m_akTriangle[iT];
// detach triangle from edges
int iE0 = rkT.Edge(0), iE1 = rkT.Edge(1), iE2 = rkT.Edge(2);
MTEdge& rkE0 = m_akEdge[iE0];
MTEdge& rkE1 = m_akEdge[iE1];
MTEdge& rkE2 = m_akEdge[iE2];
DetachTriangleFromEdge(iT,rkT,0,iE0,rkE0);
DetachTriangleFromEdge(iT,rkT,1,iE1,rkE1);
DetachTriangleFromEdge(iT,rkT,2,iE2,rkE2);
// detach triangles from vertices
int iV0 = rkT.Vertex(0);
MTVertex& rkV0 = m_akVertex[iV0];
rkV0.RemoveTriangle(iT);
int iV1 = rkT.Vertex(1);
MTVertex& rkV1 = m_akVertex[iV1];
rkV1.RemoveTriangle(iT);
int iV2 = rkT.Vertex(2);
MTVertex& rkV2 = m_akVertex[iV2];
rkV2.RemoveTriangle(iT);
// detach edges from vertices (only if last edge to reference vertex)
bool bE0Destroy = (rkE0.Triangle(0) == -1);
if ( bE0Destroy )
{
rkV0.RemoveEdge(iE0);
rkV1.RemoveEdge(iE0);
}
bool bE1Destroy = (rkE1.Triangle(0) == -1);
if ( bE1Destroy )
{
rkV1.RemoveEdge(iE1);
rkV2.RemoveEdge(iE1);
}
bool bE2Destroy = (rkE2.Triangle(0) == -1);
if ( bE2Destroy )
{
rkV0.RemoveEdge(iE2);
rkV2.RemoveEdge(iE2);
}
// Removal of components from the sets and maps starts here. Be careful
// using set indices, component references, and map iterators since
// deletion has side effects. Deletion of a component might cause another
// component to be moved within the corresponding set or map.
bool bV0Destroy = (rkV0.GetEdgeQuantity() == 0);
bool bV1Destroy = (rkV1.GetEdgeQuantity() == 0);
bool bV2Destroy = (rkV2.GetEdgeQuantity() == 0);
// remove edges if no longer used
if ( bE0Destroy )
RemoveEdge(iLabel0,iLabel1);
if ( bE1Destroy )
RemoveEdge(iLabel1,iLabel2);
if ( bE2Destroy )
RemoveEdge(iLabel2,iLabel0);
// remove vertices if no longer used
if ( bV0Destroy )
RemoveVertex(iLabel0);
if ( bV1Destroy )
RemoveVertex(iLabel1);
if ( bV2Destroy )
RemoveVertex(iLabel2);
// remove triangle (definitely no longer used)
RemoveTriangle(iLabel0,iLabel1,iLabel2);
return true;
}
//----------------------------------------------------------------------------
void MTMesh::RemoveVertex (int iLabel)
{
// get array location of vertex
VIter pkV = m_kVMap.find(MTIVertex(iLabel));
assert( pkV != m_kVMap.end() );
int iV = pkV->second;
// remove the vertex from the array and from the map
int iVOld, iVNew;
m_akVertex.RemoveAt(iV,&iVOld,&iVNew);
m_kVMap.erase(pkV);
if ( iVNew >= 0 )
{
// The vertex at the end of the array moved into the slot vacated by
// the deleted vertex. Update all the components sharing the moved
// vertex.
MTVertex& rkV = m_akVertex[iVNew];
int i;
// inform edges about location change
for (i = 0; i < rkV.GetEdgeQuantity(); i++)
{
MTEdge& rkE = m_akEdge[rkV.GetEdge(i)];
rkE.ReplaceVertex(iVOld,iVNew);
}
// inform triangles about location change
for (i = 0; i < rkV.GetTriangleQuantity(); i++)
{
MTTriangle& rkT = m_akTriangle[rkV.GetTriangle(i)];
rkT.ReplaceVertex(iVOld,iVNew);
}
pkV = m_kVMap.find(MTIVertex(rkV.GetLabel()));
assert( pkV != m_kVMap.end() );
pkV->second = iVNew;
}
}
//----------------------------------------------------------------------------
void MTMesh::RemoveEdge (int iLabel0, int iLabel1)
{
// get array location of edge
EIter pkE = m_kEMap.find(MTIEdge(iLabel0,iLabel1));
assert( pkE != m_kEMap.end() );
int iE = pkE->second;
// remove the edge from the array and from the map
int iEOld, iENew;
m_akEdge.RemoveAt(iE,&iEOld,&iENew);
m_kEMap.erase(pkE);
if ( iENew >= 0 )
{
// The edge at the end of the array moved into the slot vacated by
// the deleted edge. Update all the components sharing the moved
// edge.
MTEdge& rkE = m_akEdge[iENew];
// inform vertices about location change
MTVertex& rkV0 = m_akVertex[rkE.Vertex(0)];
MTVertex& rkV1 = m_akVertex[rkE.Vertex(1)];
rkV0.ReplaceEdge(iEOld,iENew);
rkV1.ReplaceEdge(iEOld,iENew);
// inform triangles about location change
for (int i = 0; i < 2; i++)
{
int iT = rkE.GetTriangle(i);
if ( iT != -1 )
{
MTTriangle& rkT = m_akTriangle[iT];
rkT.ReplaceEdge(iEOld,iENew);
}
}
pkE = m_kEMap.find(MTIEdge(rkV0.GetLabel(),rkV1.GetLabel()));
assert( pkE != m_kEMap.end() );
pkE->second = iENew;
}
}
//----------------------------------------------------------------------------
void MTMesh::RemoveTriangle (int iLabel0, int iLabel1, int iLabel2)
{
// get array location of triangle
TIter pkT = m_kTMap.find(MTITriangle(iLabel0,iLabel1,iLabel2));
assert( pkT != m_kTMap.end() );
int iT = pkT->second;
// remove the triangle from the array and from the map
int iTOld, iTNew;
m_akTriangle.RemoveAt(iT,&iTOld,&iTNew);
m_kTMap.erase(pkT);
if ( iTNew >= 0 )
{
// The triangle at the end of the array moved into the slot vacated by
// the deleted triangle. Update all the components sharing the moved
// triangle.
MTTriangle& rkT = m_akTriangle[iTNew];
// inform vertices about location change
MTVertex& rkV0 = m_akVertex[rkT.Vertex(0)];
MTVertex& rkV1 = m_akVertex[rkT.Vertex(1)];
MTVertex& rkV2 = m_akVertex[rkT.Vertex(2)];
rkV0.ReplaceTriangle(iTOld,iTNew);
rkV1.ReplaceTriangle(iTOld,iTNew);
rkV2.ReplaceTriangle(iTOld,iTNew);
// inform edges about location change
int i;
for (i = 0; i < 3; i++)
{
MTEdge& rkE = m_akEdge[rkT.GetEdge(i)];
rkE.ReplaceTriangle(iTOld,iTNew);
}
// inform adjacents about location change
for (i = 0; i < 3; i++)
{
int iA = rkT.GetAdjacent(i);
if ( iA != -1 )
{
MTTriangle& rkA = m_akTriangle[iA];
rkA.ReplaceAdjacent(iTOld,iTNew);
}
}
pkT = m_kTMap.find(MTITriangle(rkV0.GetLabel(),rkV1.GetLabel(),
rkV2.GetLabel()));
assert( pkT != m_kTMap.end() );
pkT->second = iTNew;
}
}
//----------------------------------------------------------------------------
void MTMesh::AttachTriangleToEdge (int iT, MTTriangle& rkT, int i, int iE,
MTEdge& rkE)
{
if ( rkE.Triangle(0) == -1 )
{
rkE.Triangle(0) = iT;
}
else
{
int iTAdj = rkE.Triangle(0);
MTTriangle& rkTAdj = m_akTriangle[iTAdj];
rkT.Adjacent(i) = iTAdj;
for (int j = 0; j < 3; j++)
{
if ( rkTAdj.Edge(j) == iE )
{
rkTAdj.Adjacent(j) = iT;
break;
}
}
if ( rkE.Triangle(1) == -1 )
{
rkE.Triangle(1) = iT;
}
else
{
// mesh is not manifold
assert( false );
}
}
rkT.Edge(i) = iE;
}
//----------------------------------------------------------------------------
void MTMesh::DetachTriangleFromEdge (int iT, MTTriangle& rkT, int i, int iE,
MTEdge& rkE)
{
// This function leaves T only partially complete. The edge E is no
// longer referenced by T, even though the vertices of T reference the
// end points of E. If T has an adjacent triangle A that shares E, then
// A is a complete triangle.
if ( rkE.Triangle(0) == iT )
{
int iTAdj = rkE.Triangle(1);
if ( iTAdj != -1 )
{
// T and TAdj share E, update adjacency information for both
MTTriangle& rkTAdj = m_akTriangle[iTAdj];
for (int j = 0; j < 3; j++)
{
if ( rkTAdj.Edge(j) == iE )
{
rkTAdj.Adjacent(j) = -1;
break;
}
}
}
rkE.Triangle(0) = iTAdj;
}
else if ( rkE.Triangle(1) == iT )
{
// T and TAdj share E, update adjacency information for both
MTTriangle& rkTAdj = m_akTriangle[rkE.Triangle(0)];
for (int j = 0; j < 3; j++)
{
if ( rkTAdj.Edge(j) == iE )
{
rkTAdj.Adjacent(j) = -1;
break;
}
}
}
else
{
// Should not get here. The specified edge must share the input
// triangle.
assert( false );
}
rkE.Triangle(1) = -1;
rkT.Edge(i) = -1;
rkT.Adjacent(i) = -1;
}
//----------------------------------------------------------------------------
bool MTMesh::SubdivideCentroid (int iLabel0, int iLabel1, int iLabel2,
int& riNextLabel)
{
int iT = T(iLabel0,iLabel1,iLabel2);
if ( iT == -1 )
return false;
if ( m_kVMap.find(MTIVertex(riNextLabel)) != m_kVMap.end() )
{
// vertex already exists with this label
return false;
}
// subdivide the triangle
Remove(iLabel0,iLabel1,iLabel2);
Insert(iLabel0,iLabel1,riNextLabel);
Insert(iLabel1,iLabel2,riNextLabel);
Insert(iLabel2,iLabel0,riNextLabel);
riNextLabel++;
return true;
}
//----------------------------------------------------------------------------
bool MTMesh::SubdivideCentroidAll (int& riNextLabel)
{
// verify that the next-label range is valid
int iT, iTMax = m_akTriangle.GetQuantity();
int iTempLabel = riNextLabel;
for (iT = 0; iT < iTMax; iT++, iTempLabel++)
{
if ( m_kVMap.find(MTIVertex(iTempLabel)) != m_kVMap.end() )
{
// vertex already exists with this label
return false;
}
}
// Care must be taken when processing the triangles iteratively. The
// side of effect of removing the first triangle is that the last triangle
// in the array is moved into the vacated position. The first problem is
// that the moved triangle will be skipped in the iteration. The second
// problem is that the insertions cause the triangle array to grow. To
// avoid skipping the moved triangle, a different algorithm than the one
// in SubdivideCentroid(int,int,int,int&) is used. The triangle to be
// removed is detached from two edges. Two of the subtriangles are added
// to the mesh. The third subtriangle is calculated in the already
// existing memory that stored the original triangle. To avoid the
// infinite recursion induced by a growing array, the original size of
// the triangle array is stored int iTMax. This guarantees that only the
// original triangles are subdivided and that newly added triangles are
// not.
for (iT = 0; iT < iTMax; iT++, riNextLabel++)
{
// the triangle to subdivide
MTTriangle& rkT = m_akTriangle[iT];
int iLabel0 = GetVLabel(rkT.Vertex(0));
int iLabel1 = GetVLabel(rkT.Vertex(1));
int iLabel2 = GetVLabel(rkT.Vertex(2));
// detach the triangle from two edges
int iE1 = rkT.Edge(1), iE2 = rkT.Edge(2);
MTEdge& rkE1 = m_akEdge[iE1];
MTEdge& rkE2 = m_akEdge[iE2];
DetachTriangleFromEdge(iT,rkT,1,iE1,rkE1);
DetachTriangleFromEdge(iT,rkT,2,iE2,rkE2);
// Insert the two subtriangles that share edges E1 and E2. A
// potential side effect is that the triangle array is reallocated
// to make room for the new triangles. This will invalidate the
// reference rkT from the code above, but the index iT into the array
// is still correct. A reallocation of the vertex array might also
// occur.
Insert(iLabel1,iLabel2,riNextLabel);
Insert(iLabel2,iLabel0,riNextLabel);
// stitch the third subtriangle to the other subtriangles.
MTTriangle& rkTN = m_akTriangle[iT];
int iSubE1 = E(iLabel1,riNextLabel);
int iSubE2 = E(iLabel0,riNextLabel);
MTEdge& rkSubE1 = m_akEdge[iSubE1];
MTEdge& rkSubE2 = m_akEdge[iSubE2];
AttachTriangleToEdge(iT,rkTN,1,iSubE1,rkSubE1);
AttachTriangleToEdge(iT,rkTN,2,iSubE2,rkSubE2);
}
return true;
}
//----------------------------------------------------------------------------
bool MTMesh::SubdivideEdge (int iLabel0, int iLabel1, int& riNextLabel)
{
int iE = E(iLabel0,iLabel1);
if ( iE == -1 )
return false;
if ( m_kVMap.find(MTIVertex(riNextLabel)) != m_kVMap.end() )
{
// vertex already exists with this label
return false;
}
// split the triangles sharing the edge
MTEdge& rkE = m_akEdge[iE];
int iT0 = rkE.Triangle(0), iT1 = rkE.Triangle(1);
int iT0L0, iT0L1, iT0L2, iT1L0, iT1L1, iT1L2;
int iT0E0, iT0E1, iT1E0, iT1E1;
if ( iT0 >= 0 && iT1 == -1 )
{
// edge shared by only T0
MTTriangle& rkT0 = m_akTriangle[iT0];
iT0L0 = GetVLabel(rkT0.Vertex(0));
iT0L1 = GetVLabel(rkT0.Vertex(1));
iT0L2 = GetVLabel(rkT0.Vertex(2));
iT0E0 = rkT0.Edge(0);
iT0E1 = rkT0.Edge(1);
Remove(iT0L0,iT0L1,iT0L2);
if ( iT0E0 == iE )
{
Insert(iT0L0,riNextLabel,iT0L2);
Insert(riNextLabel,iT0L1,iT0L2);
}
else if ( iT0E1 == iE )
{
Insert(iT0L1,riNextLabel,iT0L0);
Insert(riNextLabel,iT0L2,iT0L0);
}
else
{
Insert(iT0L2,riNextLabel,iT0L1);
Insert(riNextLabel,iT0L0,iT0L1);
}
}
else if ( iT1 >= 0 && iT0 == -1 )
{
// Edge shared by only T1. The Remove(int,int,int) call is not
// factored outside the conditional statements to avoid potential
// reallocation side effects that would invalidate the reference rkT1.
MTTriangle& rkT1 = m_akTriangle[iT1];
iT1L0 = GetVLabel(rkT1.Vertex(0));
iT1L1 = GetVLabel(rkT1.Vertex(1));
iT1L2 = GetVLabel(rkT1.Vertex(2));
iT1E0 = rkT1.Edge(0);
iT1E1 = rkT1.Edge(1);
Remove(iT1L0,iT1L1,iT1L2);
if ( iT1E0 == iE )
{
Insert(iT1L0,riNextLabel,iT1L2);
Insert(riNextLabel,iT1L1,iT1L2);
}
else if ( iT1E1 == iE )
{
Insert(iT1L1,riNextLabel,iT1L0);
Insert(riNextLabel,iT1L2,iT1L0);
}
else
{
Insert(iT1L2,riNextLabel,iT1L1);
Insert(riNextLabel,iT1L0,iT1L1);
}
}
else
{
assert( iT0 >= 0 && iT1 >= 0 );
// Edge shared by both T0 and T1. The Remove(int,int,int) call is not
// factored outside the conditional statements to avoid potential
// reallocation side effects that would invalidate the references
// rkT0 and rkT1.
MTTriangle& rkT0 = m_akTriangle[iT0];
iT0L0 = GetVLabel(rkT0.Vertex(0));
iT0L1 = GetVLabel(rkT0.Vertex(1));
iT0L2 = GetVLabel(rkT0.Vertex(2));
iT0E0 = rkT0.Edge(0);
iT0E1 = rkT0.Edge(1);
MTTriangle& rkT1 = m_akTriangle[iT1];
iT1L0 = GetVLabel(rkT1.Vertex(0));
iT1L1 = GetVLabel(rkT1.Vertex(1));
iT1L2 = GetVLabel(rkT1.Vertex(2));
iT1E0 = rkT1.Edge(0);
iT1E1 = rkT1.Edge(1);
// Both triangles must be removed before the insertions to guarantee
// that the common edge is deleted from the mesh first.
Remove(iT0L0,iT0L1,iT0L2);
Remove(iT1L0,iT1L1,iT1L2);
if ( iT0E0 == iE )
{
Insert(iT0L0,riNextLabel,iT0L2);
Insert(riNextLabel,iT0L1,iT0L2);
}
else if ( iT0E1 == iE )
{
Insert(iT0L1,riNextLabel,iT0L0);
Insert(riNextLabel,iT0L2,iT0L0);
}
else
{
Insert(iT0L2,riNextLabel,iT0L1);
Insert(riNextLabel,iT0L0,iT0L1);
}
if ( iT1E0 == iE )
{
Insert(iT1L0,riNextLabel,iT1L2);
Insert(riNextLabel,iT1L1,iT1L2);
}
else if ( iT1E1 == iE )
{
Insert(iT1L1,riNextLabel,iT1L0);
Insert(riNextLabel,iT1L2,iT1L0);
}
else
{
Insert(iT1L2,riNextLabel,iT1L1);
Insert(riNextLabel,iT1L0,iT1L1);
}
}
riNextLabel++;
return true;
}
//----------------------------------------------------------------------------
void MTMesh::Print (ofstream& rkOStr) const
{
int i;
// print vertices
rkOStr << "vertex quantity = " << m_akVertex.GetQuantity() << endl;
for (int iV = 0; iV < m_akVertex.GetQuantity(); iV++)
{
const MTVertex& rkV = m_akVertex.Get(iV);
rkOStr << "vertex<" << iV << ">" << endl;
rkOStr << " l: " << rkV.GetLabel() << endl;
rkOStr << " e: ";
for (i = 0; i < rkV.GetEdgeQuantity(); i++)
rkOStr << rkV.GetEdge(i) << ' ';
rkOStr << endl;
rkOStr << " t: ";
for (i = 0; i < rkV.GetTriangleQuantity(); i++)
rkOStr << rkV.GetTriangle(i) << ' ';
rkOStr << endl;
}
rkOStr << endl;
// print edges
rkOStr << "edge quantity = " << m_akEdge.GetQuantity() << endl;
for (int iE = 0; iE < m_akEdge.GetQuantity(); iE++)
{
const MTEdge& rkE = m_akEdge.Get(iE);
rkOStr << "edge<" << iE << ">" << endl;
rkOStr << " v: "
<< rkE.GetVertex(0) << ' '
<< rkE.GetVertex(1) << endl;
rkOStr << " t: " << rkE.GetTriangle(0) << ' ' << rkE.GetTriangle(1)
<< endl;
}
rkOStr << endl;
// print triangles
rkOStr << "triangle quantity = " << m_akTriangle.GetQuantity() << endl;
for (int iT = 0; iT < m_akTriangle.GetQuantity(); iT++)
{
const MTTriangle& rkT = m_akTriangle.Get(iT);
rkOStr << "triangle<" << iT << ">" << endl;
rkOStr << " v: "
<< rkT.GetVertex(0) << ' '
<< rkT.GetVertex(1) << ' '
<< rkT.GetVertex(2) << endl;
rkOStr << " e: " << rkT.GetEdge(0) << ' ' << rkT.GetEdge(1)
<< ' ' << rkT.GetEdge(2) << endl;
rkOStr << " a: " << rkT.GetAdjacent(0) << ' ' << rkT.GetAdjacent(1)
<< ' ' << rkT.GetAdjacent(2) << endl;
}
rkOStr << endl;
}
//----------------------------------------------------------------------------
bool MTMesh::Print (const char* acFilename) const
{
ofstream kOStr(acFilename);
if ( !kOStr )
return false;
Print(kOStr);
return true;
}
//----------------------------------------------------------------------------
| [
"[email protected]"
]
| [
[
[
1,
783
]
]
]
|
7d3b261c10c475d5032cbeabe175e98bfb30ea24 | c6f4fe2766815616b37beccf07db82c0da27e6c1 | /VisualBox.cpp | 7f4c29ff4c7b0deb3857798b954f38fef4213255 | []
| no_license | fragoulis/gpm-sem1-spacegame | c600f300046c054f7ab3cbf7193ccaad1503ca09 | 85bdfb5b62e2964588f41d03a295b2431ff9689f | refs/heads/master | 2023-06-09T03:43:53.175249 | 2007-12-13T03:03:30 | 2007-12-13T03:03:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,349 | cpp | #include "gl/glee.h"
#include "VisualBox.h"
#include "Texture.h"
#include "Object.h"
namespace tlib
{
OCVisualBox::OCVisualBox()
{}
OCVisualBox::OCVisualBox( const Vector3f& vBBox ):
m_vHalfDim(vBBox)
{
generate();
}
// ------------------------------------------------------------------------
void OCVisualBox::init( const Vector3f& vBBox )
{
m_vHalfDim = vBBox;
generate();
}
void OCVisualBox::texCoord( int iTextures, float x, float y ) const
{
if( !iTextures ) return;
if( iTextures == 1 )
glTexCoord2f( x, y );
else {
for( int i=0; i<iTextures; ++i ) {
glMultiTexCoord2f( GL_TEXTURE0+i, x, y );
}
}
}
// ------------------------------------------------------------------------
void OCVisualBox::buildObject() const
{
// See if the owner has any textures
int iTextures = 0;
IOCTexture *cTex = 0;
if( m_oOwner )
{
cTex = (IOCTexture*)m_oOwner->getComponent("texture");
if( cTex ) {
iTextures = (int)cTex->getNumOfTextures();
}
}
glBegin(GL_QUADS);
{
// front face
glNormal3f( 0.0f, 0.0f, 1.0f );
texCoord( iTextures, 0.0f, 0.0f ); glVertex3f( -m_vHalfDim.x(), -m_vHalfDim.y(), m_vHalfDim.z() );
glNormal3f( 0.0f, 0.0f, 1.0f );
texCoord( iTextures, 1.0f, 0.0f ); glVertex3f( m_vHalfDim.x(), -m_vHalfDim.y(), m_vHalfDim.z() );
glNormal3f( 0.0f, 0.0f, 1.0f );
texCoord( iTextures, 1.0f, 1.0f ); glVertex3f( m_vHalfDim.x(), m_vHalfDim.y(), m_vHalfDim.z() );
glNormal3f( 0.0f, 0.0f, 1.0f );
texCoord( iTextures, 0.0f, 1.0f ); glVertex3f( -m_vHalfDim.x(), m_vHalfDim.y(), m_vHalfDim.z() );
// back face
glNormal3f( 0.0f, 0.0f, -1.0f );
texCoord( iTextures, 1.0f, 0.0f ); glVertex3f( -m_vHalfDim.x(), -m_vHalfDim.y(), -m_vHalfDim.z() );
glNormal3f( 0.0f, 0.0f, -1.0f );
texCoord( iTextures, 1.0f, 1.0f ); glVertex3f( -m_vHalfDim.x(), m_vHalfDim.y(), -m_vHalfDim.z() );
glNormal3f( 0.0f, 0.0f, -1.0f );
texCoord( iTextures, 0.0f, 1.0f ); glVertex3f( m_vHalfDim.x(), m_vHalfDim.y(), -m_vHalfDim.z() );
glNormal3f( 0.0f, 0.0f, -1.0f );
texCoord( iTextures, 0.0f, 0.0f ); glVertex3f( m_vHalfDim.x(), -m_vHalfDim.y(), -m_vHalfDim.z() );
// top face
glNormal3f( 0.0f, 1.0f, 0.0f );
texCoord( iTextures, 0.0f, 1.0f ); glVertex3f( -m_vHalfDim.x(), m_vHalfDim.y(), -m_vHalfDim.z() );
glNormal3f( 0.0f, 1.0f, 0.0f );
texCoord( iTextures, 0.0f, 0.0f ); glVertex3f( -m_vHalfDim.x(), m_vHalfDim.y(), m_vHalfDim.z() );
glNormal3f( 0.0f, 1.0f, 0.0f );
texCoord( iTextures, 1.0f, 0.0f ); glVertex3f( m_vHalfDim.x(), m_vHalfDim.y(), m_vHalfDim.z() );
glNormal3f( 0.0f, 1.0f, 0.0f );
texCoord( iTextures, 1.0f, 1.0f ); glVertex3f( m_vHalfDim.x(), m_vHalfDim.y(), -m_vHalfDim.z() );
// bottom face
glNormal3f( 0.0f, -1.0f, 0.0f );
texCoord( iTextures, 1.0f, 1.0f ); glVertex3f( -m_vHalfDim.x(), -m_vHalfDim.y(), -m_vHalfDim.z() );
glNormal3f( 0.0f, -1.0f, 0.0f );
texCoord( iTextures, 0.0f, 1.0f ); glVertex3f( m_vHalfDim.x(), -m_vHalfDim.y(), -m_vHalfDim.z() );
glNormal3f( 0.0f, -1.0f, 0.0f );
texCoord( iTextures, 0.0f, 0.0f ); glVertex3f( m_vHalfDim.x(), -m_vHalfDim.y(), m_vHalfDim.z() );
glNormal3f( 0.0f, -1.0f, 0.0f );
texCoord( iTextures, 1.0f, 0.0f ); glVertex3f( -m_vHalfDim.x(), -m_vHalfDim.y(), m_vHalfDim.z() );
// right face
glNormal3f( 1.0f, 0.0f, 0.0f );
texCoord( iTextures, 1.0f, 0.0f ); glVertex3f( m_vHalfDim.x(), -m_vHalfDim.y(), -m_vHalfDim.z() );
glNormal3f( 1.0f, 0.0f, 0.0f );
texCoord( iTextures, 1.0f, 1.0f ); glVertex3f( m_vHalfDim.x(), m_vHalfDim.y(), -m_vHalfDim.z() );
glNormal3f( 1.0f, 0.0f, 0.0f );
texCoord( iTextures, 0.0f, 1.0f ); glVertex3f( m_vHalfDim.x(), m_vHalfDim.y(), m_vHalfDim.z() );
glNormal3f( 1.0f, 0.0f, 0.0f );
texCoord( iTextures, 0.0f, 0.0f ); glVertex3f( m_vHalfDim.x(), -m_vHalfDim.y(), m_vHalfDim.z() );
// left face
glNormal3f( -1.0f, 0.0f, 0.0f );
texCoord( iTextures, 0.0f, 0.0f ); glVertex3f( -m_vHalfDim.x(), -m_vHalfDim.y(), -m_vHalfDim.z() );
glNormal3f( -1.0f, 0.0f, 0.0f );
texCoord( iTextures, 1.0f, 0.0f ); glVertex3f( -m_vHalfDim.x(), -m_vHalfDim.y(), m_vHalfDim.z() );
glNormal3f( -1.0f, 0.0f, 0.0f );
texCoord( iTextures, 1.0f, 1.0f ); glVertex3f( -m_vHalfDim.x(), m_vHalfDim.y(), m_vHalfDim.z() );
glNormal3f( -1.0f, 0.0f, 0.0f );
texCoord( iTextures, 0.0f, 1.0f ); glVertex3f( -m_vHalfDim.x(), m_vHalfDim.y(), -m_vHalfDim.z() );
}
glEnd();
} // end buildObject()
} // end of namespace tlib | [
"john.fragkoulis@201bd241-053d-0410-948a-418211174e54"
]
| [
[
[
1,
117
]
]
]
|
ebbce57abfa54efa44d980979484169b5ec27f79 | a92598d0a8a2e92b424915d2944212f2f13e7506 | /PtRPG/libs/cocos2dx/platform/CCImage.cpp | f762c0d7a7955c227697508ef1d1f60e6032f353 | [
"MIT"
]
| permissive | peteo/RPG_Learn | 0cc4facd639bd01d837ac56cf37a07fe22c59211 | 325fd1802b14e055732278f3d2d33a9577608c39 | refs/heads/master | 2021-01-23T11:07:05.050645 | 2011-12-12T08:47:27 | 2011-12-12T08:47:27 | 2,299,148 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 17,004 | cpp | /****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCImage.h"
#include "CCCommon.h"
#include "CCStdC.h"
#include "CCFileUtils.h"
#include "png.h"
#include <string>
#include <ctype.h>
#if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS)
// on ios, we should use platform/ios/CCImage_ios.mm instead
#define QGLOBAL_H // defined for wophone
#include "jpeglib.h"
#undef QGLOBAL_H
#define CC_RGB_PREMULTIPLY_APLHA(vr, vg, vb, va) \
(unsigned)(((unsigned)((unsigned char)(vr) * ((unsigned char)(va) + 1)) >> 8) | \
((unsigned)((unsigned char)(vg) * ((unsigned char)(va) + 1) >> 8) << 8) | \
((unsigned)((unsigned char)(vb) * ((unsigned char)(va) + 1) >> 8) << 16) | \
((unsigned)(unsigned char)(va) << 24))
typedef struct
{
unsigned char* data;
int size;
int offset;
}tImageSource;
static void pngReadCallback(png_structp png_ptr, png_bytep data, png_size_t length)
{
tImageSource* isource = (tImageSource*)png_get_io_ptr(png_ptr);
if((int)(isource->offset + length) <= isource->size)
{
memcpy(data, isource->data+isource->offset, length);
isource->offset += length;
}
else
{
png_error(png_ptr, "pngReaderCallback failed");
}
}
NS_CC_BEGIN;
//////////////////////////////////////////////////////////////////////////
// Impliment CCImage
//////////////////////////////////////////////////////////////////////////
CCImage::CCImage()
: m_nWidth(0)
, m_nHeight(0)
, m_nBitsPerComponent(0)
, m_pData(0)
, m_bHasAlpha(false)
, m_bPreMulti(false)
{
}
CCImage::~CCImage()
{
CC_SAFE_DELETE_ARRAY(m_pData);
}
bool CCImage::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFmtPng*/)
{
CC_UNUSED_PARAM(eImgFmt);
CCFileData data(CCFileUtils::fullPathFromRelativePath(strPath), "rb");
return initWithImageData(data.getBuffer(), data.getSize(), eImgFmt);
}
bool CCImage::initWithImageData(void * pData,
int nDataLen,
EImageFormat eFmt/* = eSrcFmtPng*/,
int nWidth/* = 0*/,
int nHeight/* = 0*/,
int nBitsPerComponent/* = 8*/)
{
bool bRet = false;
do
{
CC_BREAK_IF(! pData || nDataLen <= 0);
if (kFmtPng == eFmt)
{
bRet = _initWithPngData(pData, nDataLen);
break;
}
else if (kFmtJpg == eFmt)
{
bRet = _initWithJpgData(pData, nDataLen);
break;
}
else if (kFmtRawData == eFmt)
{
bRet = _initWithRawData(pData, nDataLen, nWidth, nHeight, nBitsPerComponent);
break;
}
} while (0);
return bRet;
}
bool CCImage::_initWithJpgData(void * data, int nSize)
{
/* these are standard libjpeg structures for reading(decompression) */
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
/* libjpeg data structure for storing one row, that is, scanline of an image */
JSAMPROW row_pointer[1] = {0};
unsigned long location = 0;
unsigned int i = 0;
bool bRet = false;
do
{
/* here we set up the standard libjpeg error handler */
cinfo.err = jpeg_std_error( &jerr );
/* setup decompression process and source, then read JPEG header */
jpeg_create_decompress( &cinfo );
/* this makes the library read from infile */
jpeg_mem_src( &cinfo, (unsigned char *) data, nSize );
/* reading the image header which contains image information */
jpeg_read_header( &cinfo, true );
// we only support RGB or grayscale
if (cinfo.jpeg_color_space != JCS_RGB)
{
if (cinfo.jpeg_color_space == JCS_GRAYSCALE || cinfo.jpeg_color_space == JCS_YCbCr)
{
cinfo.out_color_space = JCS_RGB;
}
}
else
{
break;
}
/* Start decompression jpeg here */
jpeg_start_decompress( &cinfo );
/* init image info */
m_nWidth = (short)(cinfo.image_width);
m_nHeight = (short)(cinfo.image_height);
m_bHasAlpha = false;
m_bPreMulti = false;
m_nBitsPerComponent = 8;
row_pointer[0] = new unsigned char[cinfo.output_width*cinfo.output_components];
CC_BREAK_IF(! row_pointer[0]);
m_pData = new unsigned char[cinfo.output_width*cinfo.output_height*cinfo.output_components];
CC_BREAK_IF(! m_pData);
/* now actually read the jpeg into the raw buffer */
/* read one scan line at a time */
while( cinfo.output_scanline < cinfo.image_height )
{
jpeg_read_scanlines( &cinfo, row_pointer, 1 );
for( i=0; i<cinfo.image_width*cinfo.num_components;i++)
m_pData[location++] = row_pointer[0][i];
}
jpeg_finish_decompress( &cinfo );
jpeg_destroy_decompress( &cinfo );
/* wrap up decompression, destroy objects, free pointers and close open files */
bRet = true;
} while (0);
CC_SAFE_DELETE_ARRAY(row_pointer[0]);
return bRet;
}
bool CCImage::_initWithPngData(void * pData, int nDatalen)
{
bool bRet = false;
png_byte header[8] = {0};
png_structp png_ptr = 0;
png_infop info_ptr = 0;
unsigned char * pImateData = 0;
do
{
// png header len is 8 bytes
CC_BREAK_IF(nDatalen < 8);
// check the data is png or not
memcpy(header, pData, 8);
CC_BREAK_IF(png_sig_cmp(header, 0, 8));
// init png_struct
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
CC_BREAK_IF(! png_ptr);
// init png_info
info_ptr = png_create_info_struct(png_ptr);
CC_BREAK_IF(!info_ptr || setjmp(png_jmpbuf(png_ptr)));
// set the read call back function
tImageSource imageSource;
imageSource.data = (unsigned char*)pData;
imageSource.size = nDatalen;
imageSource.offset = 0;
png_set_read_fn(png_ptr, &imageSource, pngReadCallback);
// read png
// PNG_TRANSFORM_EXPAND: perform set_expand()
// PNG_TRANSFORM_PACKING: expand 1, 2 and 4-bit samples to bytes
// PNG_TRANSFORM_STRIP_16: strip 16-bit samples to 8 bits
// PNG_TRANSFORM_GRAY_TO_RGB: expand grayscale samples to RGB (or GA to RGBA)
png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_EXPAND | PNG_TRANSFORM_PACKING
| PNG_TRANSFORM_STRIP_16 | PNG_TRANSFORM_GRAY_TO_RGB, 0);
int color_type = 0;
png_uint_32 nWidth = 0;
png_uint_32 nHeight = 0;
int nBitsPerComponent = 0;
png_get_IHDR(png_ptr, info_ptr, &nWidth, &nHeight, &nBitsPerComponent, &color_type, 0, 0, 0);
// init image info
m_bPreMulti = true;
m_bHasAlpha = ( info_ptr->color_type & PNG_COLOR_MASK_ALPHA ) ? true : false;
// allocate memory and read data
int bytesPerComponent = 3;
if (m_bHasAlpha)
{
bytesPerComponent = 4;
}
pImateData = new unsigned char[nHeight * nWidth * bytesPerComponent];
CC_BREAK_IF(! pImateData);
png_bytep * rowPointers = png_get_rows(png_ptr, info_ptr);
// copy data to image info
int bytesPerRow = nWidth * bytesPerComponent;
if(m_bHasAlpha)
{
unsigned int *tmp = (unsigned int *)pImateData;
for(unsigned int i = 0; i < nHeight; i++)
{
for(int j = 0; j < bytesPerRow; j += 4)
{
*tmp++ = CC_RGB_PREMULTIPLY_APLHA( rowPointers[i][j], rowPointers[i][j + 1],
rowPointers[i][j + 2], rowPointers[i][j + 3] );
}
}
}
else
{
for (unsigned int j = 0; j < nHeight; ++j)
{
memcpy(pImateData + j * bytesPerRow, rowPointers[j], bytesPerRow);
}
}
m_nBitsPerComponent = nBitsPerComponent;
m_nHeight = (short)nHeight;
m_nWidth = (short)nWidth;
m_pData = pImateData;
pImateData = 0;
bRet = true;
} while (0);
CC_SAFE_DELETE_ARRAY(pImateData);
if (png_ptr)
{
png_destroy_read_struct(&png_ptr, (info_ptr) ? &info_ptr : 0, 0);
}
return bRet;
}
bool CCImage::_initWithRawData(void * pData, int nDatalen, int nWidth, int nHeight, int nBitsPerComponent)
{
bool bRet = false;
do
{
CC_BREAK_IF(0 == nWidth || 0 == nHeight);
m_nBitsPerComponent = nBitsPerComponent;
m_nHeight = (short)nHeight;
m_nWidth = (short)nWidth;
m_bHasAlpha = true;
// only RGBA8888 surported
int nBytesPerComponent = 4;
int nSize = nHeight * nWidth * nBytesPerComponent;
m_pData = new unsigned char[nSize];
CC_BREAK_IF(! m_pData);
memcpy(m_pData, pData, nSize);
bRet = true;
} while (0);
return bRet;
}
bool CCImage::saveToFile(const char *pszFilePath, bool bIsToRGB)
{
bool bRet = false;
do
{
CC_BREAK_IF(NULL == pszFilePath);
std::string strFilePath(pszFilePath);
CC_BREAK_IF(strFilePath.size() <= 4);
std::string strLowerCasePath(strFilePath);
for (unsigned int i = 0; i < strLowerCasePath.length(); ++i)
{
strLowerCasePath[i] = tolower(strFilePath[i]);
}
if (std::string::npos != strLowerCasePath.find(".png"))
{
CC_BREAK_IF(!_saveImageToPNG(pszFilePath, bIsToRGB));
}
else if (std::string::npos != strLowerCasePath.find(".jpg"))
{
CC_BREAK_IF(!_saveImageToJPG(pszFilePath));
}
else
{
break;
}
bRet = true;
} while (0);
return bRet;
}
bool CCImage::_saveImageToPNG(const char * pszFilePath, bool bIsToRGB)
{
bool bRet = false;
do
{
CC_BREAK_IF(NULL == pszFilePath);
FILE *fp;
png_structp png_ptr;
png_infop info_ptr;
png_colorp palette;
png_bytep *row_pointers;
fp = fopen(pszFilePath, "wb");
CC_BREAK_IF(NULL == fp);
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (NULL == png_ptr)
{
fclose(fp);
break;
}
info_ptr = png_create_info_struct(png_ptr);
if (NULL == info_ptr)
{
fclose(fp);
png_destroy_write_struct(&png_ptr, NULL);
break;
}
if (setjmp(png_jmpbuf(png_ptr)))
{
fclose(fp);
png_destroy_write_struct(&png_ptr, &info_ptr);
break;
}
png_init_io(png_ptr, fp);
if (!bIsToRGB && m_bHasAlpha)
{
png_set_IHDR(png_ptr, info_ptr, m_nWidth, m_nHeight, 8, PNG_COLOR_TYPE_RGB_ALPHA,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
}
else
{
png_set_IHDR(png_ptr, info_ptr, m_nWidth, m_nHeight, 8, PNG_COLOR_TYPE_RGB,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
}
palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH * sizeof (png_color));
png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH);
png_write_info(png_ptr, info_ptr);
png_set_packing(png_ptr);
row_pointers = (png_bytep *)malloc(m_nHeight * sizeof(png_bytep));
if(row_pointers == NULL)
{
fclose(fp);
png_destroy_write_struct(&png_ptr, &info_ptr);
break;
}
if (!m_bHasAlpha)
{
for (int i = 0; i < (int)m_nHeight; i++)
{
row_pointers[i] = (png_bytep)m_pData + i * m_nWidth * 3;
}
png_write_image(png_ptr, row_pointers);
free(row_pointers);
row_pointers = NULL;
}
else
{
if (bIsToRGB)
{
unsigned char *pTempData = new unsigned char[m_nWidth * m_nHeight * 3];
if (NULL == pTempData)
{
fclose(fp);
png_destroy_write_struct(&png_ptr, &info_ptr);
break;
}
for (int i = 0; i < m_nHeight; ++i)
{
for (int j = 0; j < m_nWidth; ++j)
{
pTempData[(i * m_nWidth + j) * 3] = m_pData[(i * m_nWidth + j) * 4];
pTempData[(i * m_nWidth + j) * 3 + 1] = m_pData[(i * m_nWidth + j) * 4 + 1];
pTempData[(i * m_nWidth + j) * 3 + 2] = m_pData[(i * m_nWidth + j) * 4 + 2];
}
}
for (int i = 0; i < (int)m_nHeight; i++)
{
row_pointers[i] = (png_bytep)pTempData + i * m_nWidth * 3;
}
png_write_image(png_ptr, row_pointers);
free(row_pointers);
row_pointers = NULL;
CC_SAFE_DELETE_ARRAY(pTempData);
}
else
{
for (int i = 0; i < (int)m_nHeight; i++)
{
row_pointers[i] = (png_bytep)m_pData + i * m_nWidth * 4;
}
png_write_image(png_ptr, row_pointers);
free(row_pointers);
row_pointers = NULL;
}
}
png_write_end(png_ptr, info_ptr);
png_free(png_ptr, palette);
palette = NULL;
png_destroy_write_struct(&png_ptr, &info_ptr);
fclose(fp);
bRet = true;
} while (0);
return bRet;
}
bool CCImage::_saveImageToJPG(const char * pszFilePath)
{
bool bRet = false;
do
{
CC_BREAK_IF(NULL == pszFilePath);
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
FILE * outfile; /* target file */
JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */
int row_stride; /* physical row width in image buffer */
cinfo.err = jpeg_std_error(&jerr);
/* Now we can initialize the JPEG compression object. */
jpeg_create_compress(&cinfo);
CC_BREAK_IF((outfile = fopen(pszFilePath, "wb")) == NULL);
jpeg_stdio_dest(&cinfo, outfile);
cinfo.image_width = m_nWidth; /* image width and height, in pixels */
cinfo.image_height = m_nHeight;
cinfo.input_components = 3; /* # of color components per pixel */
cinfo.in_color_space = JCS_RGB; /* colorspace of input image */
jpeg_set_defaults(&cinfo);
jpeg_start_compress(&cinfo, TRUE);
row_stride = m_nWidth * 3; /* JSAMPLEs per row in image_buffer */
if (m_bHasAlpha)
{
unsigned char *pTempData = new unsigned char[m_nWidth * m_nHeight * 3];
if (NULL == pTempData)
{
jpeg_finish_compress(&cinfo);
jpeg_destroy_compress(&cinfo);
fclose(outfile);
break;
}
for (int i = 0; i < m_nHeight; ++i)
{
for (int j = 0; j < m_nWidth; ++j)
{
pTempData[(i * m_nWidth + j) * 3] = m_pData[(i * m_nWidth + j) * 4];
pTempData[(i * m_nWidth + j) * 3 + 1] = m_pData[(i * m_nWidth + j) * 4 + 1];
pTempData[(i * m_nWidth + j) * 3 + 2] = m_pData[(i * m_nWidth + j) * 4 + 2];
}
}
while (cinfo.next_scanline < cinfo.image_height) {
row_pointer[0] = & pTempData[cinfo.next_scanline * row_stride];
(void) jpeg_write_scanlines(&cinfo, row_pointer, 1);
}
CC_SAFE_DELETE_ARRAY(pTempData);
}
else
{
while (cinfo.next_scanline < cinfo.image_height) {
row_pointer[0] = & m_pData[cinfo.next_scanline * row_stride];
(void) jpeg_write_scanlines(&cinfo, row_pointer, 1);
}
}
jpeg_finish_compress(&cinfo);
fclose(outfile);
jpeg_destroy_compress(&cinfo);
bRet = true;
} while (0);
return bRet;
}
NS_CC_END;
#endif // (CC_TARGET_PLATFORM != TARGET_OS_IPHONE)
/* ios/CCImage_ios.mm uses "mm" as the extension,
so we cannot inclue it in this CCImage.cpp.
It makes a little difference on ios */
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
#include "win32/CCImage_win32.cpp"
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WOPHONE)
#include "wophone/CCImage_wophone.cpp"
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#include "android/CCImage_android.cpp"
#endif
| [
"[email protected]"
]
| [
[
[
1,
595
]
]
]
|
5e3e15841c56ddd1c6cf4c4497933cfada1c6a93 | 2e5fd1fc05c0d3b28f64abc99f358145c3ddd658 | /deps/quickfix/src/.NET/Exceptions.h | 3b2a2a4639b251e0eb4cc6eacdab9c25ad1bebd8 | [
"BSD-2-Clause"
]
| permissive | indraj/fixfeed | 9365c51e2b622eaff4ce5fac5b86bea86415c1e4 | 5ea71aab502c459da61862eaea2b78859b0c3ab3 | refs/heads/master | 2020-12-25T10:41:39.427032 | 2011-02-15T13:38:34 | 2011-02-15T20:50:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,498 | h | /* -*- C++ -*- */
/****************************************************************************
** Copyright (c) quickfixengine.org All rights reserved.
**
** This file is part of the QuickFIX FIX Engine
**
** This file may be distributed under the terms of the quickfixengine.org
** license as defined by quickfixengine.org and appearing in the file
** LICENSE included in the packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.quickfixengine.org/LICENSE for licensing information.
**
** Contact [email protected] if any conditions of this licensing are
** not clear to you.
**
****************************************************************************/
#pragma once
using namespace System;
using namespace System::IO;
#include "quickfix_net.h"
#include "quickfix/exceptions.h"
namespace QuickFix
{
public __gc class FieldNotFound : public Exception
{
public:
FieldNotFound( int f ) : field( f ) {}
int field;
};
public __gc class MessageParseError : public Exception {};
public __gc class FieldConvertError : public Exception
{
public:
FieldConvertError( String* what ) : Exception( what ) {}
};
public __gc class NoTagValue : public Exception
{
public:
NoTagValue( int f ) : field( f ) {}
int field;
};
public __gc class IncorrectTagValue : public Exception
{
public:
IncorrectTagValue( int f ) : field( f ) {}
int field;
};
public __gc class IncorrectDataFormat : public Exception
{
public:
IncorrectDataFormat( int f ) : field( f ) {}
int field;
};
public __gc class ConfigError : public Exception
{
public:
ConfigError( String* what ) : Exception( what ) {}
};
public __gc class RuntimeError : public Exception
{
public:
RuntimeError( String* what ) : Exception( what ) {}
};
public __gc class InvalidMessage : public Exception
{
public:
InvalidMessage( String* what ) : Exception( what ) {}
};
public __gc class DataDictionaryNotFound : public Exception
{
public:
DataDictionaryNotFound( String* version, String* what ) : Exception( what ) {}
String* version;
};
public __gc class SessionNotFound : public Exception {};
public __gc class DoNotSend : public Exception {};
public __gc class RejectLogon : public Exception {};
public __gc class UnsupportedMessageType : public Exception {};
}
| [
"[email protected]"
]
| [
[
[
1,
99
]
]
]
|
ee19120c906523826f7b56ae3cb36855b813870c | e7c45d18fa1e4285e5227e5984e07c47f8867d1d | /Scada/ScdIODB/StdAfx.h | bbd8bf74d86445f1dcbe490e5f199c7f53283909 | []
| no_license | abcweizhuo/Test3 | 0f3379e528a543c0d43aad09489b2444a2e0f86d | 128a4edcf9a93d36a45e5585b70dee75e4502db4 | refs/heads/master | 2021-01-17T01:59:39.357645 | 2008-08-20T00:00:29 | 2008-08-20T00:00:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,764 | h | //**************************************************************************
//
// Copyright (c) FactorySoft, INC. 1996-1998, All Rights Reserved
//
//**************************************************************************
//
// Filename : Stdafx.h
// $Author : Jim Hansen
//
// Subsystem :
//
// Description: Precompiled header
//
//
//**************************************************************************
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#define NOIME
#define NOKANJI
#define NOTAPE
#define NOSOUND
#define NOSERVICE
#define NOIMAGE
//#ifdef _DEBUG
//#define _ATL_DEBUG_INTERFACES
//#define _ATL_DEBUG_REFCOUNT
//#define _ATL_DEBUG_QI
//#endif
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxcview.h>
#include <afxcmn.h> // MFC support for Windows 95 Common Controls
#include <afxcoll.h> // MFC collections
#include <afxtempl.h> // MFC template collections
#include <afxole.h>
#include <afxadv.h> // CSharedFile
#include <stdlib.h> // only for rand()
#include <afxdisp.h>
#define HICKITITEM DWORD
#define HICKITTOPIC DWORD
#define ENG_LCID MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),SORT_DEFAULT)
#include "resource.h"
#include "Modbus.h"
#include "Doc.h"
// OPC
#define OPC_ATL_INCLUDED
#define _ATL_STATIC_REGISTRY
#include <atlbase.h>
//You may derive a class from CComModule and use it if you want to override
#define WM_OPCLOCKUNLOCK WM_USER + 50
#define OPC_LOCK 0
#define OPC_UNLOCK 1
//You may derive a class from CComModule and use it if you want to override
//something, but do not change the name of _Module
// ATL can increment/decrement MFC's lock count
class CAtlGlobalModule : public CComModule
{
public:
};
extern CAtlGlobalModule _Module;
#include <atlcom.h>
#include <statreg.h>
#include "OPCServer.h"
extern CRITICAL_SECTION uiCS; // protect access to current device ptr, etc.
extern CRITICAL_SECTION tagCS; // protect access to tag values with this
#define TRACE_MSG { \
TCHAR msg[MAX_PATH]; \
FormatMessage( FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, \
NULL, \
GetLastError(), \
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), \
msg, MAX_PATH, NULL ); \
TRACE(msg); \
TRACE(_T("\n")); }
#define WM_POLLCLOSE WM_USER+1
#define WM_ADDDEVICE WM_USER+2
#define WM_UPDATETAGS WM_USER+3
#define WM_POLLUPDATE WM_USER+4
//*******************************************************************
| [
"[email protected]"
]
| [
[
[
1,
97
]
]
]
|
08f3c0065666115c5b70fe5caba6646383315c9c | 78fb44a7f01825c19d61e9eaaa3e558ce80dcdf5 | /guidriverMyGUIOgre/include/MyGUI_OgreRenderManager.h | 5bfc97dd0180477ed9b4b608dc125a9995f82952 | []
| no_license | LiberatorUSA/GUCE | a2d193e78d91657ccc4eab50fab06de31bc38021 | a4d6aa5421f8799cedc7c9f7dc496df4327ac37f | refs/heads/master | 2021-01-02T08:14:08.541536 | 2011-09-08T03:00:46 | 2011-09-08T03:00:46 | 41,840,441 | 0 | 0 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 3,319 | h | /*!
@file
@author Albert Semenov
@date 04/2008
@module
*/
#ifndef __MYGUI_OGRE_RENDER_MANAGER_H__
#define __MYGUI_OGRE_RENDER_MANAGER_H__
#include "MyGUI_Prerequest.h"
#include "MyGUI_Instance.h"
#include "MyGUI_RenderFormat.h"
#include "MyGUI_IVertexBuffer.h"
#include "MyGUI_RenderManager.h"
#include <Ogre.h>
#include "MyGUI_LastHeader.h"
namespace MyGUI
{
class OgreRenderManager :
public RenderManager,
public IRenderTarget,
public Ogre::WindowEventListener,
public Ogre::RenderQueueListener,
public Ogre::RenderSystem::Listener
{
MYGUI_INSTANCE_HEADER(OgreRenderManager)
public:
void initialise(Ogre::RenderWindow* _window, Ogre::SceneManager* _scene);
void shutdown();
virtual const IntSize& getViewSize() const { return mViewSize; }
virtual VertexColourType getVertexFormat() { return mVertexFormat; }
virtual IVertexBuffer* createVertexBuffer();
virtual void destroyVertexBuffer(IVertexBuffer* _buffer);
virtual ITexture* createTexture(const std::string& _name);
virtual void destroyTexture(ITexture* _texture);
virtual ITexture* getTexture(const std::string& _name);
virtual bool isFormatSupported(PixelFormat _format, TextureUsage _usage);
virtual void begin();
virtual void end();
virtual void doRender(IVertexBuffer* _buffer, ITexture* _texture, size_t _count);
virtual const RenderTargetInfo& getInfo() { return mInfo; }
void setRenderSystem(Ogre::RenderSystem* _render);
void setRenderWindow(Ogre::RenderWindow* _window);
/** Set scene manager where MyGUI will be rendered */
void setSceneManager(Ogre::SceneManager* _scene);
/** Get GUI viewport index */
size_t getActiveViewport() { return mActiveViewport; }
/** Set GUI viewport index */
void setActiveViewport(size_t _num);
Ogre::RenderWindow * getRenderWindow() { return mWindow; }
#if MYGUI_DEBUG_MODE == 1
virtual bool checkTexture(ITexture* _texture);
#endif
private:
virtual void renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& skipThisInvocation);
virtual void renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation);
virtual void windowResized(Ogre::RenderWindow* _window);
// восстанавливаем буферы
virtual void eventOccurred(const Ogre::String& eventName, const Ogre::NameValuePairList* parameters);
void destroyAllResources();
void updateRenderInfo();
private:
// флаг для обновления всех и вся
bool mUpdate;
IntSize mViewSize;
Ogre::SceneManager* mSceneManager;
VertexColourType mVertexFormat;
// окно, на которое мы подписываемся для изменения размеров
Ogre::RenderWindow* mWindow;
// вьюпорт, с которым работает система
size_t mActiveViewport;
Ogre::RenderSystem* mRenderSystem;
Ogre::TextureUnitState::UVWAddressingMode mTextureAddressMode;
Ogre::LayerBlendModeEx mColorBlendMode, mAlphaBlendMode;
RenderTargetInfo mInfo;
typedef std::map<std::string, ITexture*> MapTexture;
MapTexture mTextures;
};
} // namespace MyGUI
#endif // __MYGUI_OGRE_RENDER_MANAGER_H__
| [
"[email protected]"
]
| [
[
[
1,
115
]
]
]
|
e5aff13f1aa21c3c360137fad862aa8239ca231c | 611fc0940b78862ca89de79a8bbeab991f5f471a | /src/Collision/CollisionSet.cpp | f1fcbc437841efe8cbb1a82d5afd163f5b860ffc | []
| no_license | LakeIshikawa/splstage2 | df1d8f59319a4e8d9375b9d3379c3548bc520f44 | b4bf7caadf940773a977edd0de8edc610cd2f736 | refs/heads/master | 2021-01-10T21:16:45.430981 | 2010-01-29T08:57:34 | 2010-01-29T08:57:34 | 37,068,575 | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 778 | cpp | #include ".\collisionset.h"
CollisionSet::CollisionSet(void)
{
// リスト初期化
for(int i=0; i<MAX_FRAMES; i++)
aFrames[i] = NULL;
mIndex = 0;
}
CollisionSet::~CollisionSet(void)
{
for each( Collision* frame in aFrames ){
delete frame;
}
}
/*
Collisionフレームを追加する
*/
void CollisionSet::AddFrame(int rBango, Collision *pFrame)
{
aFrames[rBango] = pFrame;
}
/*
指定されたフレームを設定する
*/
void CollisionSet::SetFrame(int rBango)
{
mIndex = rBango;
}
/*
フレームをゲット
*/
Collision* CollisionSet::GetFrame(int rBango)
{
return aFrames[rBango];
}
/*
現在使用中のフレームを取得
*/
Collision* CollisionSet::GetCurFrame()
{
return aFrames[mIndex];
} | [
"lakeishikawa@c9935178-01ba-11df-8f7b-bfe16de6f99b"
]
| [
[
[
1,
50
]
]
]
|
fed82ca70cc5c4286cecb0de892a14273c9f3052 | 3bfe835203f793ee00bdf261c26992b1efea69ed | /fall08/cs460/cloth/cloth/Input.h | b46b3b645bd1c42d4d91fc6321ce6137bcc7674d | []
| no_license | yxrkt/DigiPen | 0bdc1ed3ee06e308b4942a0cf9de70831c65a3d3 | e1bb773d15f63c88ab60798f74b2e424bcc80981 | refs/heads/master | 2020-06-04T20:16:05.727685 | 2009-11-18T00:26:56 | 2009-11-18T00:26:56 | 814,145 | 1 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 1,216 | h | #pragma once
#include <windows.h>
#include <d3dx9.h>
#define INPUT Input::Instance()
#define LEFT_BUTTON 0
#define RIGHT_BUTTON 1
#define MIDDLE_BUTTON 2
#define STATE_UP 0
#define STATE_DOWN 1
#define STATE_DBLCLK 2
#define NUM_KEYBOARD_KEYS 256
#define NUM_MOUSE_BUTTONS 3
class Input
{
public:
static Input *Instance( void );
void Initialize( void );
void Update( void );
bool IsKeyHit( int key ) const;
bool IsKeyReleased( int key ) const;
bool IsKeyHeld( int key ) const;
bool IsMouseHit( int button ) const;
bool IsMouseDblClk( int button ) const;
bool IsMouseReleased( int button ) const;
bool IsMouseHeld( int button ) const;
const D3DXVECTOR3 &GetMousePos( void ) const;
LRESULT HandleMessage( UINT msg, WPARAM wParam, LPARAM lparam );
private:
byte m_prevKeyState[NUM_KEYBOARD_KEYS];
byte m_curKeyState[NUM_KEYBOARD_KEYS];
byte m_prevMouseState[NUM_MOUSE_BUTTONS];
byte m_curMouseState[NUM_MOUSE_BUTTONS];
D3DXVECTOR3 m_mousePos;
private:
Input( void );
Input( const Input &rhs );
void operator =( const Input &rhs );
~Input( void );
};
| [
"[email protected]"
]
| [
[
[
1,
53
]
]
]
|
6a3aebce680e0ec4cd53dfa5851519504dc07eb6 | a84b013cd995870071589cefe0ab060ff3105f35 | /webdriver/branches/chrome/chrome/src/cpp/include/v8/src/variables.h | b82ab6310b37e2e46a5c874b0f33d991fd734bbd | [
"Apache-2.0"
]
| permissive | vdt/selenium | 137bcad58b7184690b8785859d77da0cd9f745a0 | 30e5e122b068aadf31bcd010d00a58afd8075217 | refs/heads/master | 2020-12-27T21:35:06.461381 | 2009-08-18T15:56:32 | 2009-08-18T15:56:32 | 13,650,409 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,226 | h | // Copyright 2006-2008 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef V8_VARIABLES_H_
#define V8_VARIABLES_H_
#include "zone.h"
namespace v8 { namespace internal {
class UseCount BASE_EMBEDDED {
public:
UseCount();
// Inform the node of a "use". The weight can be used to indicate
// heavier use, for instance if the variable is accessed inside a loop.
void RecordRead(int weight);
void RecordWrite(int weight);
void RecordAccess(int weight); // records a read & write
void RecordUses(UseCount* uses);
int nreads() const { return nreads_; }
int nwrites() const { return nwrites_; }
int nuses() const { return nreads_ + nwrites_; }
bool is_read() const { return nreads() > 0; }
bool is_written() const { return nwrites() > 0; }
bool is_used() const { return nuses() > 0; }
#ifdef DEBUG
void Print();
#endif
private:
int nreads_;
int nwrites_;
};
// Variables and AST expression nodes can track their "type" to enable
// optimizations and removal of redundant checks when generating code.
class StaticType BASE_EMBEDDED {
public:
enum Kind {
UNKNOWN,
LIKELY_SMI
};
StaticType() : kind_(UNKNOWN) {}
bool Is(Kind kind) const { return kind_ == kind; }
bool IsKnown() const { return !Is(UNKNOWN); }
bool IsUnknown() const { return Is(UNKNOWN); }
bool IsLikelySmi() const { return Is(LIKELY_SMI); }
void CopyFrom(StaticType* other) {
kind_ = other->kind_;
}
static const char* Type2String(StaticType* type);
// LIKELY_SMI accessors
void SetAsLikelySmi() {
kind_ = LIKELY_SMI;
}
void SetAsLikelySmiIfUnknown() {
if (IsUnknown()) {
SetAsLikelySmi();
}
}
private:
Kind kind_;
DISALLOW_COPY_AND_ASSIGN(StaticType);
};
// The AST refers to variables via VariableProxies - placeholders for the actual
// variables. Variables themselves are never directly referred to from the AST,
// they are maintained by scopes, and referred to from VariableProxies and Slots
// after binding and variable allocation.
class Variable: public ZoneObject {
public:
enum Mode {
// User declared variables:
VAR, // declared via 'var', and 'function' declarations
CONST, // declared via 'const' declarations
// Variables introduced by the compiler:
DYNAMIC, // always require dynamic lookup (we don't know
// the declaration)
DYNAMIC_GLOBAL, // requires dynamic lookup, but we know that the
// variable is global unless it has been shadowed
// by an eval-introduced variable
DYNAMIC_LOCAL, // requires dynamic lookup, but we know that the
// variable is local and where it is unless it
// has been shadowed by an eval-introduced
// variable
INTERNAL, // like VAR, but not user-visible (may or may not
// be in a context)
TEMPORARY // temporary variables (not user-visible), never
// in a context
};
// Printing support
static const char* Mode2String(Mode mode);
// Type testing & conversion
Property* AsProperty();
Variable* AsVariable();
bool IsValidLeftHandSide() { return is_valid_LHS_; }
// The source code for an eval() call may refer to a variable that is
// in an outer scope about which we don't know anything (it may not
// be the global scope). scope() is NULL in that case. Currently the
// scope is only used to follow the context chain length.
Scope* scope() const { return scope_; }
// If this assertion fails it means that some code has tried to
// treat the special this variable as an ordinary variable with
// the name "this".
Handle<String> name() const { return name_; }
Mode mode() const { return mode_; }
bool is_accessed_from_inner_scope() const {
return is_accessed_from_inner_scope_;
}
UseCount* var_uses() { return &var_uses_; }
UseCount* obj_uses() { return &obj_uses_; }
bool IsVariable(Handle<String> n) {
return !is_this() && name().is_identical_to(n);
}
bool is_dynamic() const {
return (mode_ == DYNAMIC ||
mode_ == DYNAMIC_GLOBAL ||
mode_ == DYNAMIC_LOCAL);
}
bool is_global() const;
bool is_this() const { return is_this_; }
Variable* local_if_not_shadowed() const {
ASSERT(mode_ == DYNAMIC_LOCAL && local_if_not_shadowed_ != NULL);
return local_if_not_shadowed_;
}
void set_local_if_not_shadowed(Variable* local) {
local_if_not_shadowed_ = local;
}
Expression* rewrite() const { return rewrite_; }
Slot* slot() const;
StaticType* type() { return &type_; }
private:
Variable(Scope* scope, Handle<String> name, Mode mode, bool is_valid_LHS,
bool is_this);
Scope* scope_;
Handle<String> name_;
Mode mode_;
bool is_valid_LHS_;
bool is_this_;
Variable* local_if_not_shadowed_;
// Usage info.
bool is_accessed_from_inner_scope_; // set by variable resolver
UseCount var_uses_; // uses of the variable value
UseCount obj_uses_; // uses of the object the variable points to
// Static type information
StaticType type_;
// Code generation.
// rewrite_ is usually a Slot or a Property, but maybe any expression.
Expression* rewrite_;
friend class VariableProxy;
friend class Scope;
friend class LocalsMap;
friend class AstBuildingParser;
};
} } // namespace v8::internal
#endif // V8_VARIABLES_H_
| [
"noel.gordon@07704840-8298-11de-bf8c-fd130f914ac9"
]
| [
[
[
1,
223
]
]
]
|
eb27b9a8d7cd5878e910e080a1f160c64073d35d | ea12fed4c32e9c7992956419eb3e2bace91f063a | /zombie/code/zombie/nluaserver/src/lua/ldo.cc | 474b0c149d878488fab8658d0c6a6ed4e4c8aeff | []
| no_license | ugozapad/TheZombieEngine | 832492930df28c28cd349673f79f3609b1fe7190 | 8e8c3e6225c2ed93e07287356def9fbdeacf3d6a | refs/heads/master | 2020-04-30T11:35:36.258363 | 2011-02-24T14:18:43 | 2011-02-24T14:18:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,067 | cc | /*
** $Id: ldo.cc,v 1.2 2004/03/26 00:39:30 enlight Exp $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
#include <setjmp.h>
#include <stdlib.h>
#include <string.h>
#define ldo_c
#include "lua/lua.h"
#include "lua/ldebug.h"
#include "lua/ldo.h"
#include "lua/lfunc.h"
#include "lua/lgc.h"
#include "lua/lmem.h"
#include "lua/lobject.h"
#include "lua/lopcodes.h"
#include "lua/lparser.h"
#include "lua/lstate.h"
#include "lua/lstring.h"
#include "lua/ltable.h"
#include "lua/ltm.h"
#include "lua/lundump.h"
#include "lua/lvm.h"
#include "lua/lzio.h"
/*
** {======================================================
** Error-recovery functions (based on long jumps)
** =======================================================
*/
/* chain list of long jump buffers */
struct lua_longjmp {
struct lua_longjmp *previous;
jmp_buf b;
volatile int status; /* error code */
};
static void seterrorobj (lua_State *L, int errcode, StkId oldtop) {
switch (errcode) {
case LUA_ERRMEM: {
setsvalue2s(oldtop, luaS_new(L, MEMERRMSG));
break;
}
case LUA_ERRERR: {
setsvalue2s(oldtop, luaS_new(L, "error in error handling"));
break;
}
case LUA_ERRSYNTAX:
case LUA_ERRRUN: {
setobjs2s(oldtop, L->top - 1); /* error message on current top */
break;
}
}
L->top = oldtop + 1;
}
void luaD_throw (lua_State *L, int errcode) {
if (L->errorJmp) {
L->errorJmp->status = errcode;
longjmp(L->errorJmp->b, 1);
}
else {
G(L)->panic(L);
exit(EXIT_FAILURE);
}
}
int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
struct lua_longjmp lj;
lj.status = 0;
lj.previous = L->errorJmp; /* chain new error handler */
L->errorJmp = &lj;
if (setjmp(lj.b) == 0)
(*f)(L, ud);
L->errorJmp = lj.previous; /* restore old error handler */
return lj.status;
}
static void restore_stack_limit (lua_State *L) {
L->stack_last = L->stack+L->stacksize-1;
if (L->size_ci > LUA_MAXCALLS) { /* there was an overflow? */
int inuse = (int)(L->ci - L->base_ci);
if (inuse + 1 < LUA_MAXCALLS) /* can `undo' overflow? */
luaD_reallocCI(L, LUA_MAXCALLS);
}
}
/* }====================================================== */
static void correctstack (lua_State *L, TObject *oldstack) {
CallInfo *ci;
GCObject *up;
L->top = (L->top - oldstack) + L->stack;
for (up = L->openupval; up != NULL; up = up->gch.next)
gcotouv(up)->v = (gcotouv(up)->v - oldstack) + L->stack;
for (ci = L->base_ci; ci <= L->ci; ci++) {
ci->top = (ci->top - oldstack) + L->stack;
ci->base = (ci->base - oldstack) + L->stack;
}
L->base = L->ci->base;
}
void luaD_reallocstack (lua_State *L, int newsize) {
TObject *oldstack = L->stack;
luaM_reallocvector(L, L->stack, L->stacksize, newsize, TObject);
L->stacksize = newsize;
L->stack_last = L->stack+newsize-1-EXTRA_STACK;
correctstack(L, oldstack);
}
void luaD_reallocCI (lua_State *L, int newsize) {
CallInfo *oldci = L->base_ci;
luaM_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo);
L->size_ci = cast(unsigned short, newsize);
L->ci = (L->ci - oldci) + L->base_ci;
L->end_ci = L->base_ci + L->size_ci;
}
void luaD_growstack (lua_State *L, int n) {
if (n <= L->stacksize) /* double size is enough? */
luaD_reallocstack(L, 2*L->stacksize);
else
luaD_reallocstack(L, L->stacksize + n + EXTRA_STACK);
}
static void luaD_growCI (lua_State *L) {
if (L->size_ci > LUA_MAXCALLS) /* overflow while handling overflow? */
luaD_throw(L, LUA_ERRERR);
else {
luaD_reallocCI(L, 2*L->size_ci);
if (L->size_ci > LUA_MAXCALLS)
luaG_runerror(L, "stack overflow");
}
}
void luaD_callhook (lua_State *L, int event, int line) {
lua_Hook hook = L->hook;
if (hook && L->allowhook) {
ptrdiff_t top = savestack(L, L->top);
ptrdiff_t ci_top = savestack(L, L->ci->top);
lua_Debug ar;
ar.event = event;
ar.currentline = line;
if (event == LUA_HOOKTAILRET)
ar.i_ci = 0; /* tail call; no debug information about it */
else
ar.i_ci = (int)(L->ci - L->base_ci);
luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
L->ci->top = L->top + LUA_MINSTACK;
L->allowhook = 0; /* cannot call hooks inside a hook */
lua_unlock(L);
(*hook)(L, &ar);
lua_lock(L);
lua_assert(!L->allowhook);
L->allowhook = 1;
L->ci->top = restorestack(L, ci_top);
L->top = restorestack(L, top);
}
}
static void adjust_varargs (lua_State *L, int nfixargs, StkId base) {
int i;
Table *htab;
TObject nname;
int actual = (int)(L->top - base); /* actual number of arguments */
if (actual < nfixargs) {
luaD_checkstack(L, nfixargs - actual);
for (; actual < nfixargs; ++actual)
setnilvalue(L->top++);
}
actual -= nfixargs; /* number of extra arguments */
htab = luaH_new(L, actual, 1); /* create `arg' table */
for (i=0; i<actual; i++) /* put extra arguments into `arg' table */
setobj2n(luaH_setnum(L, htab, i+1), L->top - actual + i);
/* store counter in field `n' */
setsvalue(&nname, luaS_newliteral(L, "n"));
setnvalue(luaH_set(L, htab, &nname), cast(lua_Number, actual));
L->top -= actual; /* remove extra elements from the stack */
sethvalue(L->top, htab);
incr_top(L);
}
static StkId tryfuncTM (lua_State *L, StkId func) {
const TObject *tm = luaT_gettmbyobj(L, func, TM_CALL);
StkId p;
ptrdiff_t funcr = savestack(L, func);
if (!ttisfunction(tm))
luaG_typeerror(L, func, "call");
/* Open a hole inside the stack at `func' */
for (p = L->top; p > func; p--) setobjs2s(p, p-1);
incr_top(L);
func = restorestack(L, funcr); /* previous call may change stack */
setobj2s(func, tm); /* tag method is the new function to be called */
return func;
}
StkId luaD_precall (lua_State *L, StkId func) {
LClosure *cl;
ptrdiff_t funcr = savestack(L, func);
if (!ttisfunction(func)) /* `func' is not a function? */
func = tryfuncTM(L, func); /* check the `function' tag method */
if (L->ci + 1 == L->end_ci) luaD_growCI(L);
else condhardstacktests(luaD_reallocCI(L, L->size_ci));
cl = &clvalue(func)->l;
if (!cl->isC) { /* Lua function? prepare its call */
CallInfo *ci;
Proto *p = cl->p;
if (p->is_vararg) /* varargs? */
adjust_varargs(L, p->numparams, func+1);
luaD_checkstack(L, p->maxstacksize);
ci = ++L->ci; /* now `enter' new function */
L->base = L->ci->base = restorestack(L, funcr) + 1;
ci->top = L->base + p->maxstacksize;
ci->u.l.savedpc = p->code; /* starting point */
ci->u.l.tailcalls = 0;
ci->state = CI_SAVEDPC;
while (L->top < ci->top)
setnilvalue(L->top++);
L->top = ci->top;
return NULL;
}
else { /* if is a C function, call it */
CallInfo *ci;
int n;
luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
ci = ++L->ci; /* now `enter' new function */
L->base = L->ci->base = restorestack(L, funcr) + 1;
ci->top = L->top + LUA_MINSTACK;
ci->state = CI_C; /* a C function */
if (L->hookmask & LUA_MASKCALL)
luaD_callhook(L, LUA_HOOKCALL, -1);
lua_unlock(L);
#ifdef LUA_COMPATUPVALUES
lua_pushupvalues(L);
#endif
n = (*clvalue(L->base - 1)->c.f)(L); /* do the actual call */
lua_lock(L);
return L->top - n;
}
}
static StkId callrethooks (lua_State *L, StkId firstResult) {
ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */
luaD_callhook(L, LUA_HOOKRET, -1);
if (!(L->ci->state & CI_C)) { /* Lua function? */
while (L->ci->u.l.tailcalls--) /* call hook for eventual tail calls */
luaD_callhook(L, LUA_HOOKTAILRET, -1);
}
return restorestack(L, fr);
}
void luaD_poscall (lua_State *L, int wanted, StkId firstResult) {
StkId res;
if (L->hookmask & LUA_MASKRET)
firstResult = callrethooks(L, firstResult);
res = L->base - 1; /* res == final position of 1st result */
L->ci--;
L->base = L->ci->base; /* restore base */
/* move results to correct place */
while (wanted != 0 && firstResult < L->top) {
setobjs2s(res++, firstResult++);
wanted--;
}
while (wanted-- > 0)
setnilvalue(res++);
L->top = res;
}
/*
** Call a function (C or Lua). The function to be called is at *func.
** The arguments are on the stack, right after the function.
** When returns, all the results are on the stack, starting at the original
** function position.
*/
void luaD_call (lua_State *L, StkId func, int nResults) {
StkId firstResult;
lua_assert(!(L->ci->state & CI_CALLING));
if (++L->nCcalls >= LUA_MAXCCALLS) {
if (L->nCcalls == LUA_MAXCCALLS)
luaG_runerror(L, "C stack overflow");
else if (L->nCcalls >= (LUA_MAXCCALLS + (LUA_MAXCCALLS>>3)))
luaD_throw(L, LUA_ERRERR); /* error while handing stack error */
}
firstResult = luaD_precall(L, func);
if (firstResult == NULL) /* is a Lua function? */
firstResult = luaV_execute(L); /* call it */
luaD_poscall(L, nResults, firstResult);
L->nCcalls--;
luaC_checkGC(L);
}
static void resume (lua_State *L, void *ud) {
StkId firstResult;
int nargs = *cast(int *, ud);
CallInfo *ci = L->ci;
if (ci == L->base_ci) { /* no activation record? */
lua_assert(nargs < L->top - L->base);
luaD_precall(L, L->top - (nargs + 1)); /* start coroutine */
}
else { /* inside a yield */
lua_assert(ci->state & CI_YIELD);
if (ci->state & CI_C) { /* `common' yield? */
/* finish interrupted execution of `OP_CALL' */
int nresults;
lua_assert((ci-1)->state & CI_SAVEDPC);
lua_assert(GET_OPCODE(*((ci-1)->u.l.savedpc - 1)) == OP_CALL ||
GET_OPCODE(*((ci-1)->u.l.savedpc - 1)) == OP_TAILCALL);
nresults = GETARG_C(*((ci-1)->u.l.savedpc - 1)) - 1;
luaD_poscall(L, nresults, L->top - nargs); /* complete it */
if (nresults >= 0) L->top = L->ci->top;
}
else { /* yielded inside a hook: just continue its execution */
ci->state &= ~CI_YIELD;
}
}
firstResult = luaV_execute(L);
if (firstResult != NULL) /* return? */
luaD_poscall(L, LUA_MULTRET, firstResult); /* finalize this coroutine */
}
static int resume_error (lua_State *L, const char *msg) {
L->top = L->ci->base;
setsvalue2s(L->top, luaS_new(L, msg));
incr_top(L);
lua_unlock(L);
return LUA_ERRRUN;
}
LUA_API int lua_resume (lua_State *L, int nargs) {
int status;
lu_byte old_allowhooks;
lua_lock(L);
if (L->ci == L->base_ci) {
if (nargs >= L->top - L->base)
return resume_error(L, "cannot resume dead coroutine");
}
else if (!(L->ci->state & CI_YIELD)) /* not inside a yield? */
return resume_error(L, "cannot resume non-suspended coroutine");
old_allowhooks = L->allowhook;
lua_assert(L->errfunc == 0 && L->nCcalls == 0);
status = luaD_rawrunprotected(L, resume, &nargs);
if (status != 0) { /* error? */
L->ci = L->base_ci; /* go back to initial level */
L->base = L->ci->base;
L->nCcalls = 0;
luaF_close(L, L->base); /* close eventual pending closures */
seterrorobj(L, status, L->base);
L->allowhook = old_allowhooks;
restore_stack_limit(L);
}
lua_unlock(L);
return status;
}
LUA_API int lua_yield (lua_State *L, int nresults) {
CallInfo *ci;
lua_lock(L);
ci = L->ci;
if (L->nCcalls > 0)
luaG_runerror(L, "attempt to yield across metamethod/C-call boundary");
if (ci->state & CI_C) { /* usual yield */
if ((ci-1)->state & CI_C)
luaG_runerror(L, "cannot yield a C function");
if (L->top - nresults > L->base) { /* is there garbage in the stack? */
int i;
for (i=0; i<nresults; i++) /* move down results */
setobjs2s(L->base + i, L->top - nresults + i);
L->top = L->base + nresults;
}
} /* else it's an yield inside a hook: nothing to do */
ci->state |= CI_YIELD;
lua_unlock(L);
return -1;
}
int luaD_pcall (lua_State *L, Pfunc func, void *u,
ptrdiff_t old_top, ptrdiff_t ef) {
int status;
unsigned short oldnCcalls = L->nCcalls;
ptrdiff_t old_ci = saveci(L, L->ci);
lu_byte old_allowhooks = L->allowhook;
ptrdiff_t old_errfunc = L->errfunc;
L->errfunc = ef;
status = luaD_rawrunprotected(L, func, u);
if (status != 0) { /* an error occurred? */
StkId oldtop = restorestack(L, old_top);
luaF_close(L, oldtop); /* close eventual pending closures */
seterrorobj(L, status, oldtop);
L->nCcalls = oldnCcalls;
L->ci = restoreci(L, old_ci);
L->base = L->ci->base;
L->allowhook = old_allowhooks;
restore_stack_limit(L);
}
L->errfunc = old_errfunc;
return status;
}
/*
** Execute a protected parser.
*/
struct SParser { /* data to `f_parser' */
ZIO *z;
Mbuffer buff; /* buffer to be used by the scanner */
int bin;
};
static void f_parser (lua_State *L, void *ud) {
struct SParser *p;
Proto *tf;
Closure *cl;
luaC_checkGC(L);
p = cast(struct SParser *, ud);
tf = p->bin ? luaU_undump(L, p->z, &p->buff) : luaY_parser(L, p->z, &p->buff);
cl = luaF_newLclosure(L, 0, gt(L));
cl->l.p = tf;
setclvalue(L->top, cl);
incr_top(L);
}
int luaD_protectedparser (lua_State *L, ZIO *z, int bin) {
struct SParser p;
int status;
ptrdiff_t oldtopr = savestack(L, L->top); /* save current top */
p.z = z; p.bin = bin;
luaZ_initbuffer(L, &p.buff);
status = luaD_rawrunprotected(L, f_parser, &p);
luaZ_freebuffer(L, &p.buff);
if (status != 0) { /* error? */
StkId oldtop = restorestack(L, oldtopr);
seterrorobj(L, status, oldtop);
}
return status;
}
| [
"magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91"
]
| [
[
[
1,
471
]
]
]
|
8633862452e364d0cec75dfb3bbb2920c0115727 | 33f59b1ba6b12c2dd3080b24830331c37bba9fe2 | /Graphic/Renderer/D3D9Texture.cpp | 76f27ac0657e32682592e7e3c57ead305b8b5d96 | []
| no_license | daleaddink/flagship3d | 4835c223fe1b6429c12e325770c14679c42ae3c6 | 6cce5b1ff7e7a2d5d0df7aa0594a70d795c7979a | refs/heads/master | 2021-01-15T16:29:12.196094 | 2009-11-01T10:18:11 | 2009-11-01T10:18:11 | 37,734,654 | 1 | 0 | null | null | null | null | GB18030 | C++ | false | false | 4,005 | cpp | #include "D3D9Texture.h"
#include "D3D9RenderWindow.h"
namespace Flagship
{
extern HINSTANCE g_hInstance;
D3D9Texture::D3D9Texture()
{
m_pD3D9Texture = NULL;
m_iClassType = Base::Texture_General;
}
D3D9Texture::~D3D9Texture()
{
SAFE_RELEASE( m_pD3D9Texture );
}
LPDIRECT3DTEXTURE9 D3D9Texture::GetImpliment()
{
return m_pD3D9Texture;
}
bool D3D9Texture::CreateFromMemory()
{
// 获取D3D9设备指针
LPDIRECT3DDEVICE9 pD3D9Device = ( ( D3D9RenderWindow * ) RenderWindow::GetActiveRenderWindow() )->GetDevice();
// 创建D3D9贴图对象
HRESULT hr = D3DXCreateTextureFromFileInMemory( pD3D9Device, m_kFileBuffer.GetPointer(), m_kFileBuffer.GetSize(), &m_pD3D9Texture );
if ( FAILED( hr ) )
{
char szLog[10240];
char szFile[256];
wcstombs( szFile, m_szPathName.c_str(), 256 );
sprintf( szLog, "D3D9Texture::Cache() Fail! File:%s", szFile );
LogManager::GetSingleton()->WriteLog( szLog );
return false;
}
return true;
}
bool D3D9Texture::CreateDynamic( UINT uiWidth, UINT uiHeight, DWORD dwFormat )
{
// 获取D3D9设备指针
LPDIRECT3DDEVICE9 pD3D9Device = ( ( D3D9RenderWindow * ) RenderWindow::GetActiveRenderWindow() )->GetDevice();
// 创建D3D9贴图对象
HRESULT hr = D3DXCreateTexture( pD3D9Device, uiWidth, uiHeight, 1, D3DUSAGE_DYNAMIC, (D3DFORMAT) dwFormat, D3DPOOL_DEFAULT, &m_pD3D9Texture );
if ( FAILED( hr ) )
{
char szLog[10240];
sprintf( szLog, "D3D9Texture::CreateDynamic() Fail! Format:%d", (int)dwFormat );
LogManager::GetSingleton()->WriteLog( szLog );
return false;
}
return true;
}
bool D3D9Texture::CreateRenderTarget( UINT uiWidth, UINT uiHeight, DWORD dwFormat )
{
// 获取D3D9设备指针
LPDIRECT3DDEVICE9 pD3D9Device = ( ( D3D9RenderWindow * ) RenderWindow::GetActiveRenderWindow() )->GetDevice();
// 创建D3D9贴图对象
HRESULT hr = D3DXCreateTexture( pD3D9Device, uiWidth, uiHeight, 1, D3DUSAGE_RENDERTARGET, (D3DFORMAT) dwFormat, D3DPOOL_DEFAULT, &m_pD3D9Texture );
if ( FAILED( hr ) )
{
char szLog[10240];
sprintf( szLog, "D3D9Texture::CreateRenderTexture() Fail! Format:%d", (int)dwFormat );
LogManager::GetSingleton()->WriteLog( szLog );
return false;
}
return true;
}
bool D3D9Texture::CreateDepthStencil( UINT uiWidth, UINT uiHeight, DWORD dwFormat )
{
// 获取D3D9设备指针
LPDIRECT3DDEVICE9 pD3D9Device = ( ( D3D9RenderWindow * ) RenderWindow::GetActiveRenderWindow() )->GetDevice();
// 创建D3D9贴图对象
HRESULT hr = D3DXCreateTexture( pD3D9Device, uiWidth, uiHeight, 1, D3DUSAGE_DEPTHSTENCIL, (D3DFORMAT) dwFormat, D3DPOOL_DEFAULT, &m_pD3D9Texture );
if ( FAILED( hr ) )
{
char szLog[10240];
sprintf( szLog, "D3D9Texture::CreateDepthStencil() Fail! Format:%d", (int)dwFormat );
LogManager::GetSingleton()->WriteLog( szLog );
return false;
}
return true;
}
bool D3D9Texture::ClearTexture()
{
// 获取D3D9设备指针
LPDIRECT3DDEVICE9 pD3D9Device = ( ( D3D9RenderWindow * ) RenderWindow::GetActiveRenderWindow() )->GetDevice();
LPDIRECT3DSURFACE9 pSurface = NULL;
m_pD3D9Texture->GetSurfaceLevel( 0, &pSurface );
pD3D9Device->ColorFill( pSurface, NULL, D3DCOLOR_ARGB(0, 0, 0, 0) );
SAFE_RELEASE( pSurface );
return true;
}
bool D3D9Texture::Lock( int& rPitch, void ** ppData )
{
D3DLOCKED_RECT rect;
HRESULT hr = m_pD3D9Texture->LockRect( 0, &rect, NULL, D3DLOCK_DISCARD );
if ( FAILED( hr ) )
{
char szLog[10240];
sprintf( szLog, "D3D9Texture::Lock() Fail!" );
LogManager::GetSingleton()->WriteLog( szLog );
return false;
}
rPitch = rect.Pitch;
* ppData = rect.pBits;
return true;
}
void D3D9Texture::UnLock()
{
m_pD3D9Texture->UnlockRect( 0 );
}
void D3D9Texture::UnCache()
{
Texture::UnCache();
SAFE_RELEASE( m_pD3D9Texture );
}
} | [
"yf.flagship@e79fdf7c-a9d8-11de-b950-3d5b5f4ea0aa"
]
| [
[
[
1,
145
]
]
]
|
4f829828f41e9a651928f5c3ff525e978a05adda | aca65a1eb785ebe6d6e0e862f3b49931923da90b | /DTI Visualization/DicomImageSet.h | 5574faf81c92110692aa32984de94cb9df8718da | []
| no_license | vcpudding/DTI-Visualization-Hypergraph | d5126a0123707a2b1399a73751aa9bec88c1e25c | 23da494ba4291450cdece4bda421853ec2beedfc | refs/heads/master | 2020-06-05T09:47:30.924373 | 2011-12-29T13:13:44 | 2011-12-29T13:13:44 | 3,026,931 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,209 | h | #pragma once
#include <QDate>
#include <QDir>
#include <QProgressDialog>
#include <QStringList>
#include <QTextStream>
#include <QTreeWidget>
#include "DicomImage.h"
#include "XMLHelper.h"
using namespace XMLHelper;
namespace DicomImageSet
{
//int readDicomImages (QStringList orderedFileList);
static const char * DATASET_FILE_NAME = "dicom_dataset.xml";
int parseFolder (QString folderName);
QStringList getAllFiles (const QString &folderName);
int insertFileItem (IXMLDOMDocument *pDom, IXMLDOMNode * pRoot, const QString &folderName, const QString &fileName);
IXMLDOMNode * findParentNode (IXMLDOMDocument *pXMLDom, IXMLDOMNode * pRoot, const char * patientsName, const char * patientsId, int acquisitionDate, const char * protocol, int acquisitionNumber);
int readDatasetFile (const QString &datasetFileName, QTreeWidget * treeWidget);
int insertDTIFileItem (const QString &datasetFolderName, const QString &queryString, const QString &dtiFileName);
QString getDTIFileName (const QString &datasetFolderName, const QString &queryString);
QStringList getOrderedDcmFiles (const QString &datasetFileName, const QString &queryString);
}
| [
"[email protected]"
]
| [
[
[
1,
26
]
]
]
|
0f2298207774f5f9536bbb54b50f3c77afaf5825 | 5a05acb4caae7d8eb6ab4731dcda528e2696b093 | /GameEngine/Gfx/Ogl/OglHWVertexBuffer.hpp | ce79da0fc43d438974ae06945cd7c57957d0e339 | []
| no_license | andreparker/spiralengine | aea8b22491aaae4c14f1cdb20f5407a4fb725922 | 36a4942045f49a7255004ec968b188f8088758f4 | refs/heads/master | 2021-01-22T12:12:39.066832 | 2010-05-07T00:02:31 | 2010-05-07T00:02:31 | 33,547,546 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 480 | hpp | /*!
*/
#ifndef OGL_HW_VERTEX_BUFFER_HPP
#define OGL_HW_VERTEX_BUFFER_HPP
#include "../VertexBuffer.hpp"
namespace Spiral
{
class OglHWVertexBuffer : public VertexBuffer
{
public:
OglHWVertexBuffer();
private:
virtual OglHWVertexBuffer* DoClone()const;
virtual void DoBind();
virtual void DoUnBind();
virtual bool DoCreate( const VertexFormat& format, boost::int32_t elementSize, boost::int32_t vertexCount, bool bManaged );
};
}
#endif | [
"DreLnBrown@e933ee44-1dc6-11de-9e56-bf19dc6c588e"
]
| [
[
[
1,
25
]
]
]
|
e157f5d9e5a9ee3eeebfe5ac6494df12e0c6baa8 | be2e23022d2eadb59a3ac3932180a1d9c9dee9c2 | /GameServer/MapGroupKernel/SynManager.h | ec4573d509642cba32f6be08fb9bd4b1e28163b7 | []
| no_license | cronoszeu/revresyksgpr | 78fa60d375718ef789042c452cca1c77c8fa098e | 5a8f637e78f7d9e3e52acdd7abee63404de27e78 | refs/heads/master | 2020-04-16T17:33:10.793895 | 2010-06-16T12:52:45 | 2010-06-16T12:52:45 | 35,539,807 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 2,328 | h |
#pragma once
#include "protocol.h"
#include "GameObjSet.h"
#include "Syndicate.h"
typedef IGameObjSet<CSyndicate> ISynSet;
typedef CGameObjSet<CSyndicate> CSynSet;
class ISynMngModify
{
public:
virtual OBJID CreateSyndicate(const CreateSyndicateInfo* pInfo) PURE_VIRTUAL_FUNCTION_0
virtual bool DestroySyndicate(OBJID idSyn, OBJID idTarget = ID_NONE) PURE_VIRTUAL_FUNCTION_0
virtual bool CombineSyndicate(OBJID idSyn, OBJID idTarget) PURE_VIRTUAL_FUNCTION_0
virtual void SetMapSynID(OBJID idMap, OBJID idSyn) PURE_VIRTUAL_FUNCTION
};
class CSynManager : ISynMngModify
{
protected:
virtual ~CSynManager();
public:
CSynManager(PROCESS_ID idProcess);
ULONG Release() { delete this; return 0; }
bool Create();
CSyndicate* QuerySyndicate(OBJID idSyn) { if(idSyn==ID_NONE) return NULL; return m_setSyn->GetObj(idSyn); }
CSynSet* QuerySynSet() { ASSERT(m_setSyn); return m_setSyn; }
ISynMngModify* QueryModify() { return &m_obj; }
ISynMngModify* QuerySynchro() { return (ISynMngModify*)this; }
CSyndicate* QuerySynByName(LPCTSTR szSyn);
bool FindNextSyn(int& nIter); // order by amount, return false: no more syn
OBJID GetMapSynID(OBJID idMap) { if(idMap==WHITE_SYN_MAP_ID) return m_idWhiteSyn; if(idMap==BLACK_SYN_MAP_ID) return m_idBlackSyn; return ID_NONE; }
protected:
OBJID CreateSyndicate(const CreateSyndicateInfo* pInfo);
bool DestroySyndicate(OBJID idSyn, OBJID idTarget = ID_NONE);
bool CombineSyndicate(OBJID idSyn, OBJID idTarget);
void SetMapSynID(OBJID idMap, OBJID idSyn) { if(idMap==WHITE_SYN_MAP_ID) m_idWhiteSyn=idSyn; else if(idMap==BLACK_SYN_MAP_ID) m_idBlackSyn=idSyn; }
protected:
CSynSet* m_setSyn;
OBJID m_idWhiteSyn;
OBJID m_idBlackSyn;
protected: // ctrl
PROCESS_ID m_idProcess;
public:
MYHEAP_DECLARATION(s_heap)
protected:
class XSynMngModify : public ISynMngModify
{
public:
OBJID CreateSyndicate(const CreateSyndicateInfo* pInfo);
bool DestroySyndicate(OBJID idSyn, OBJID idTarget = ID_NONE);
bool CombineSyndicate(OBJID idSyn, OBJID idTarget);
void SetMapSynID(OBJID idMap, OBJID idSyn);
protected:
CSynManager* This() { return m_pOwner; }
CSynManager* m_pOwner;
friend class CSynManager;
} m_obj;
friend class CSynManager::XSynMngModify;
};
| [
"rpgsky.com@cc92e6ba-efcf-11de-bf31-4dec8810c1c1"
]
| [
[
[
1,
71
]
]
]
|
36d6fe7613959bb4f82a30fcbcd6436da6c11090 | d95f4f8156106e5010e4dddfb2799605fabcd1d1 | /src/DebuggerThread.cpp | 34456dd1c0f04bdbcaf7b92617966c43d6a0438a | [
"MIT"
]
| permissive | lockie/Cracker | 1afe91511a769e537871c1e1cad6c54b7c018044 | 48fc4f8323fcbc9193e100d936646da2fd1b191b | refs/heads/master | 2021-01-12T08:40:10.565997 | 2006-07-20T16:57:11 | 2006-07-20T16:57:11 | 76,653,044 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,138 | cpp | //---------------------------------------------------------------------------
#include <vcl.h>
#include <sysutils.hpp>
#include "fLog.h"
#include "CrackerEngine.h"
#include "DebuggerThread.h"
//---------------------------------------------------------------------------
// Important: Methods and properties of objects in VCL can only be
// used in a method called using Synchronize, for example:
//
// Synchronize(UpdateCaption);
//
// where UpdateCaption could look like:
//
// void __fastcall TDebuggerThread::UpdateCaption()
// {
// Form1->Caption = "Updated in a thread";
// }
//---------------------------------------------------------------------------
__fastcall TDebuggerThread::TDebuggerThread(const AnsiString* AppName,
char* Params, const char* CurrDir) : TThread(false) {
FreeOnTerminate = false;
OnTerminate = Stop;
Priority = tpHigher;
appName = AppName;
if( Params ) {
params = new char[strlen(Params)+2];
strcpy(params, Params);
} else params = NULL;
if( CurrDir ) {
currDir = new char[strlen(CurrDir)+2];
strcpy(currDir, CurrDir);
} else currDir = NULL;
StartupInfo = new STARTUPINFO;
ProcessInfo = new PROCESS_INFORMATION;
ZeroMemory( StartupInfo, sizeof(STARTUPINFO) );
StartupInfo->cb = sizeof(STARTUPINFO);
ZeroMemory( ProcessInfo, sizeof(PROCESS_INFORMATION) );
DebugEvent = new DEBUG_EVENT;
ZeroMemory(DebugEvent, sizeof(DEBUG_EVENT));
};
//---------------------------------------------------------------------------
__fastcall TDebuggerThread::~TDebuggerThread() {
TerminateProcess(ProcessInfo->hProcess, 0);
};
//---------------------------------------------------------------------------
void __fastcall TDebuggerThread::Execute()
{
//---- Place thread code here ----
bRunning = CreateProcessA(
appName->c_str(),
params,
NULL,
NULL,
false,
/*CREATE_SUSPENDED | */ DEBUG_ONLY_THIS_PROCESS,
NULL,
currDir,
StartupInfo,
ProcessInfo );
CloseHandle(ProcessInfo->hProcess);
CloseHandle(ProcessInfo->hThread);
if( !bRunning ) Trace("Unable to start new process! Error code %d", GetLastError());
while( !Terminated && bRunning && WaitForDebugEvent(DebugEvent, INFINITE) ) {
DWORD dwCont = CrackerEngine->OnDebugEvent(DebugEvent);
if( DebugEvent->dwDebugEventCode == EXIT_PROCESS_DEBUG_EVENT ) break;
if( Terminated ) break;
ContinueDebugEvent(DebugEvent->dwProcessId, DebugEvent->dwThreadId, dwCont);
};
CrackerEngine->Stopped();
};
//---------------------------------------------------------------------------
void __fastcall TDebuggerThread::Stop(TObject* Sender) { // OnTerminate handler
CloseHandle(ProcessInfo->hProcess);
CloseHandle(ProcessInfo->hThread);
delete ProcessInfo; ProcessInfo = NULL;
delete StartupInfo; StartupInfo = NULL;
delete DebugEvent; DebugEvent = NULL;
CrackerEngine->DebuggerThread = NULL;
};
| [
"[email protected]"
]
| [
[
[
1,
101
]
]
]
|
d75a2bc6ce9f28e3b356a324a6fa3532fbe91898 | 6dac9369d44799e368d866638433fbd17873dcf7 | /src/branches/06112002/src/arch/Win32/Win32ModuleDB.cpp | 88db0603432b6e90ce98608760433320561e0a2b | []
| no_license | christhomas/fusionengine | 286b33f2c6a7df785398ffbe7eea1c367e512b8d | 95422685027bb19986ba64c612049faa5899690e | refs/heads/master | 2020-04-05T22:52:07.491706 | 2006-10-24T11:21:28 | 2006-10-24T11:21:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,173 | cpp | #include <Win32/Win32ModuleDB.h>
#include <Win32/Win32Module.h>
#include <cstdio>
/** Win32 ModuleDB Constructor
*
* Sets all internal data to zero/NULL
*/
Win32ModuleDB::Win32ModuleDB()
{
m_nummodules = 0;
m_numsearchpaths = 0;
m_module = NULL;
m_searchpath = NULL;
}
/** Win32 ModuleDB Deconstructor
*
* Operation:
* -# Deletes all DLL Modules and unloads them
* -# Deletes all search paths
*/
Win32ModuleDB::~Win32ModuleDB()
{
int a;
for(a=0;a<m_nummodules;a++) delete m_module[a];
for(a=0;a<m_numsearchpaths;a++) delete m_searchpath[a];
delete[] m_module;
delete[] m_searchpath;
}
/** Retrieves a DLL Module
*
* @param name The filename of the DLL Module being searched for
*
* @returns A IModule pointer or NULL is the module is not found
*/
IModule * Win32ModuleDB::GetModule(char *name)
{
for(int a=0;a<m_nummodules;a++){
if(strcmp(m_module[a]->GetFilename(), name) == 0) return m_module[a];
}
return NULL;
}
/** Adds a searchpath to the ModuleDB
*
* @param path The path to add to the search list
*
* Operation:
* -# Allocate a new array of searchpath string pointers, increasing the size by one
* -# Copy all the old searchpath pointers to the new array
* -# Delete the old searchpath array
* -# Reset the searchpath array pointer to the new array
* -# Allocate a new searchpath string
* -# Copy the new searchpath to the array
* -# Increase the number of searchpaths by one
*/
void Win32ModuleDB::AddPath(char *path){
char **temp = new char *[m_numsearchpaths+1];
for(int a=0;a<m_numsearchpaths;a++) temp[a] = m_searchpath[a];
delete[] m_searchpath;
m_searchpath = temp;
m_searchpath[m_numsearchpaths] = new char[strlen(path)+1];
strcpy(m_searchpath[m_numsearchpaths],path);
m_numsearchpaths++;
}
/** Adds a module to the database
*
* @param module An IModule pointer
*
* Operation:
* -# Allocate a new array of module pointers, increasing the size by one
* -# Copy all the old module pointers to the new array
* -# Delete the old module array
* -# Reset the module array pointer to the new array
* -# Assign the extra pointer to the module paramter passed into the method
* -# Increase the number of modules by one
*/
void Win32ModuleDB::AddModule(IModule *module)
{
IModule **temp = new IModule *[m_nummodules+1];
for(int a=0;a<m_nummodules;a++) temp[a] = m_module[a];
delete[] m_module;
m_module = temp;
m_module[m_nummodules] = module;
m_nummodules++;
}
/** Loads a DLL Module
*
* @param name The filename of the Module to load
*
* @returns A IModule pointer or NULL if not found
*
* Operation:
* -# Test whether the filename is valid
* -# Attempt to retrieve a pointer to that module, test whether it's already loaded or not
* -# If not loaded, loop through all the searchpaths, attempting to load the DLL Module at each path
* -# Allocate a new Win32Module object
* -# Create a absolute path to the DLL Module based on the current searchpath and the DLL Module filename
* -# Attempt to load the DLL Module
* -# If the attempt was successful, add the module to the Database and clear up, then return
* -# clear up all temporary memory and try the next searchpath
*/
IModule * Win32ModuleDB::LoadModule(char *name){
Win32Module *m = NULL;
if(name!=NULL){
m = (Win32Module *)GetModule(name);
if(m==NULL){
for(int a=0;a<m_numsearchpaths;a++){
char *path = m_searchpath[a];
m = new Win32Module(name,path,NULL);
char *filename = new char[strlen(path) + strlen("/") + strlen(name) + 1];
sprintf(filename,"%s/%s",path,name);
if(m->Load(filename) != NULL){
AddModule(m);
delete[] filename;
return m;
}
delete[] filename;
delete m;
}
}else{
return m;
}
}
return NULL;
}
/** Unloads a DLL module
*
* @param name The filename of the DLL Module to unload
*
* @returns Boolean true or false, depending on whether the DLL Module successfully unloaded or not
*
* Operation:
* -# Loop through the loaded modules, testing the filename against the one being searched for
* -# If match is found, attempt to remove that module from the database
* -# Create a new temporary module array, with one less element
* -# Loop through all the loaded DLL modules, if the module being copied is the one being deleted, skip it
* -# Copy each module pointer for all those that are not being removed
* -# Delete the module being unloaded
* -# Delete the module array
* -# Reassign the module array pointer to the temporary array
* -# Reduce the number of modules in the database
*/
bool Win32ModuleDB::UnloadModule(char *name)
{
int a,b,c;
for(a=0;a<m_nummodules;a++){
if(strcmp(name,m_module[a]->GetFilename()) == 0){
IModule **temp = new IModule *[m_nummodules-1];
for(b=0,c=0;b<m_nummodules;b++){
if(b == a) continue;
temp[c++] = m_module[b];
}
delete m_module[a];
delete[] m_module;
m_module = temp;
m_nummodules--;
return true;
}
}
return false;
}
/** Unloads all the DLL modules from the database
*
* Operation:
* -# Constantly requests to unload the first DLL module in the array
* -# When the array is empty, then all the DLL Modules are released
*/
void Win32ModuleDB::UnloadAll(void)
{
while(m_nummodules > 0){
UnloadModule(m_module[0]->GetFilename());
}
}
/** Retrieve a function pointer from a DLL Module
*
* @param name The filename of the DLL Module
* @param func The name of the function requested
*
* @returns A Function pointer to the correct DLL function or NULL if not found
*
* Operation:
* -# Attempt to load the DLL Module
* -# If successful, Attempt to retrieve a function pointer from that module
*/
void * Win32ModuleDB::GetFunction(char *name,char *func){
Win32Module *m;
if((m = (Win32Module *)LoadModule(name)) == NULL) return NULL;
return (void *)GetProcAddress((HINSTANCE)m->GetHandle(),TEXT(func));
}
| [
"chris_a_thomas@1bf15c89-c11e-0410-aefd-b6ca7aeaabe7"
]
| [
[
[
1,
232
]
]
]
|
56dc4c37294a15bc084bd3030515d1bef3aa3ea0 | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/mw/classicui/uifw/apps/bctestlauncher/src/bctestlauncherview.cpp | b061c34ef83a2d8b66328849f8176e06a987b67b | []
| no_license | SymbianSource/oss.FCL.sftools.ana.compatanamdw | a6a8abf9ef7ad71021d43b7f2b2076b504d4445e | 1169475bbf82ebb763de36686d144336fcf9d93b | refs/heads/master | 2020-12-24T12:29:44.646072 | 2010-11-11T14:03:20 | 2010-11-11T14:03:20 | 72,994,432 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,158 | cpp | /*
* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: Implementation of application view class.
*
*/
#include <avkon.hrh>
#include <aknviewappui.h>
#include <akntabgrp.h>
#include <aknnavide.h>
#include <e32std.h>
#include <e32base.h>
#include <eiktxlbm.h>
#include <akndef.h>
#include <centralrepository.h>
#include <aknlistquerydialog.h>
#include <bctestlauncher.rsg>
#include "bctestlauncherview.h"
#include "bctestlaunchercontainer.h"
#include "bctestrunner.h"
#include "bctestapplication.h"
#include "streamlogger.h"
// ============================ LOCAL FUNCTIONS ==============================
namespace BCTest
{
inline static CEikMenuPaneItem::SData& BuildItem(
const TDesC& aName, const TInt aID )
{
static CEikMenuPaneItem::SData item;
item.iCommandId = aID;
item.iText = aName;
item.iFlags= EEikMenuItemSymbolOn;
item.iCascadeId = 0;
return item;
}
}
// ============================ MEMBER FUNCTIONS =============================
// ---------------------------------------------------------------------------
// CBCTestLauncherView::CBCTestLauncherView()
// C++ default constructor can NOT contain any code, that
// might leave.
// ---------------------------------------------------------------------------
//
CBCTestLauncherView::CBCTestLauncherView( RArray<CBCTestApplication*>* aList )
: iContainer( NULL ), iSelectApps( aList )
{
}
// ---------------------------------------------------------------------------
// CBCTestLauncherView::ConstructL
// Symbian 2nd phase constructor can leave.
// ---------------------------------------------------------------------------
//
void CBCTestLauncherView::ConstructL()
{
BaseConstructL( R_BCTESTLAUNCHER_VIEW );
//construct the app list menu
}
// ---------------------------------------------------------------------------
// CBCTestLauncherView::~CBCTestLauncherView
// Destructor.
// ---------------------------------------------------------------------------
//
CBCTestLauncherView::~CBCTestLauncherView()
{
if ( iContainer )
{
AppUi()->RemoveFromStack( iContainer );
}
delete iContainer;
}
// ---------------------------------------------------------------------------
// TUid CAknAtPbarView::Id()
// returns view Id.
// ---------------------------------------------------------------------------
//
TUid CBCTestLauncherView::Id() const
{
return KViewId;
}
// ---------------------------------------------------------------------------
// CAknAtPbarView::HandleCommandL( TInt aCommand )
// handles commands.
// ---------------------------------------------------------------------------
//
void CBCTestLauncherView::HandleCommandL( TInt aCommand )
{
switch ( aCommand )
{
case EAknCmdExit:
case EAknSoftkeyBack:
case EEikCmdExit:
AppUi()->HandleCommandL( EEikCmdExit );
return; // this can never be reached
case ESdkVersion:
iContainer->SetSdkVersion();
return; // this can never be reached
}
TInt number = aCommand - EBCTestLauncherStart;
if( number >= 0 && number < ( *iSelectApps ).Count() )
{
Reset();
( *iSelectApps )[number]->Select();
}
AppUi()->HandleCommandL( aCommand );
}
// ---------------------------------------------------------------------------
// CAknAtPbarView::HandleClientRectChange()
//
// ---------------------------------------------------------------------------
void CBCTestLauncherView::HandleClientRectChange()
{
if ( iContainer )
{
iContainer->SetRect( ClientRect() );
}
}
// ---------------------------------------------------------------------------
// CBCTestLauncherView::DoActivateL(...)
//
// ---------------------------------------------------------------------------
void CBCTestLauncherView::DoActivateL(
const TVwsViewId& /*aPrevViewId*/, TUid /*aCustomMessageId*/,
const TDesC8& /*aCustomMessage*/ )
{
iContainer = new( ELeave ) CBCTestLauncherContainer;
iContainer->SetMopParent( this );
iContainer->ConstructL( ClientRect() );
AppUi()->AddToStackL( *this, iContainer, ECoeStackPriorityDefault );
}
// ---------------------------------------------------------------------------
// CBCTestLauncherView::DoDeactivate()
//
// ---------------------------------------------------------------------------
void CBCTestLauncherView::DoDeactivate()
{
if ( iContainer )
{
AppUi()->RemoveFromStack( iContainer );
}
delete iContainer;
iContainer = NULL;
}
// ---------------------------------------------------------------------------
// CBCTestLauncherView::RunSelectionL()
//
// ---------------------------------------------------------------------------
TBool CBCTestLauncherView::SelectL()
{
_LIT( KPrefix, "1\t" );
CListBoxView::CSelectionIndexArray* indexArray =
new( ELeave )CArrayFixFlat<TInt>( ( *iSelectApps ).Count() );
CleanupStack::PushL( indexArray );
CAknListQueryDialog* dlg =
new( ELeave ) CAknListQueryDialog( indexArray );
dlg->PrepareLC(R_BCTESTLAUNCHER_MULTI_SELECTION_QUERY);
CDesCArray* items = static_cast<CDesCArray*>( static_cast<
CTextListBoxModel*>( dlg->ListBox()->Model() )->ItemTextArray() );
items->Reset();
for( TInt i = 0; i < ( *iSelectApps ).Count(); ++i )
{
TBuf<KNameLength> text( KPrefix );
text += ( *iSelectApps )[i]->Name();
items->AppendL( text );
}
TBool res = EFalse;
if ( dlg->RunLD() )
{
Reset();
for (TInt i = 0; i < indexArray->Count(); ++i)
{
( *iSelectApps )[ indexArray->At( i ) ]->Select();
}
res = ETrue;
}
CleanupStack::PopAndDestroy(); // indexArray
return res;
}
void CBCTestLauncherView::Reset()
{
for( TInt i = 0; i < ( *iSelectApps ).Count(); ++i )
{
( *iSelectApps )[i]->Select( EFalse );
}
}
// ---------------------------------------------------------------------------
// CBCTestLauncherView::DynInitMenuPaneL()
//
// ---------------------------------------------------------------------------
//
void CBCTestLauncherView::DynInitMenuPaneL(
TInt aResourceId, CEikMenuPane* aMenuPane )
{
if( R_BCTESTLAUNCHER_SEPARATE_TESTS == aResourceId )
{
for( TInt i = 0; i < ( *iSelectApps ).Count(); ++i )
{
aMenuPane->AddMenuItemL(
BCTest::BuildItem( ( *iSelectApps )[i]->Name(),
EBCTestLauncherStart + i ) );
}
}
}
| [
"none@none"
]
| [
[
[
1,
239
]
]
]
|
8c026a6ebfeaeec8b1c63178dc4df564d941f1f3 | b5ad65ebe6a1148716115e1faab31b5f0de1b493 | /src/AranDx9/VideoManDx9.cpp | 4a48946b3702e664d50826f4a23cff8898638d88 | []
| no_license | gasbank/aran | 4360e3536185dcc0b364d8de84b34ae3a5f0855c | 01908cd36612379ade220cc09783bc7366c80961 | refs/heads/master | 2021-05-01T01:16:19.815088 | 2011-03-01T05:21:38 | 2011-03-01T05:21:38 | 1,051,010 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 48,196 | cpp | #include "AranDx9PCH.h"
#include "VideoManDx9.h"
#include "ArnMath.h"
#include "Animation.h"
#include "ArnAnimationController.h"
#include "ArnMesh.h"
#include "RenderLayer.h"
#include "ArnSkinInfo.h"
#include "ArnMaterial.h"
#include "ArnTexture.h"
#include "ArnIpo.h"
#include "InputMan.h"
#include "AranDx9.h"
#include "ModelReader.h"
VideoManDx9::VideoManDx9()
: VideoMan()
, pDrawingModel(0)
, lpD3DDevice(0)
{
testFloatArray.resize(2000);
ZeroMemory(this->szClassName, sizeof(this->szClassName));
}
HRESULT
VideoManDx9::InitWindow( TCHAR* szClassName, void* msgProc, int width, int height )
{
setScreenSize(width, height);
setCloseNow(FALSE);
setClassName(szClassName);
this->wndClass.style = CS_CLASSDC;
this->wndClass.lpfnWndProc = (WNDPROC)msgProc;
this->wndClass.cbClsExtra = 0;
this->wndClass.cbWndExtra = 0;
this->wndClass.hInstance = GetModuleHandle(0);
this->wndClass.hIcon = 0;
this->wndClass.hCursor = LoadCursor(0, IDC_ARROW);
this->wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
this->wndClass.lpszClassName = getClassName();
this->wndClass.lpszMenuName = 0;
if (!RegisterClass(&(this->wndClass)))
{
return E_FAIL;
}
int screenResX = GetSystemMetrics(SM_CXFULLSCREEN);
int screenResY = GetSystemMetrics(SM_CYFULLSCREEN);
int windowPosX = screenResX / 2 - getScreenWidth() / 2;
int windowPosY = screenResY / 2 - getScreenHeight() / 2;
//DWORD windowStyle = 0; //WS_BORDER | WS_SYSMENU;
this->hWnd = CreateWindow(getClassName(), getClassName(), WS_POPUPWINDOW, windowPosX, windowPosY, getScreenWidth(), getScreenHeight(), 0, 0, this->wndClass.hInstance, 0);
if (!this->hWnd)
{
return E_FAIL;
}
// Init loading window and show it immediately
int loadingWndWidth = 400;
int loadingWndHeight = 100;
windowPosX = screenResX / 2 - loadingWndWidth / 2;
windowPosY = screenResY / 2 - loadingWndHeight / 2;
/*INITCOMMONCONTROLSEX InitCtrlEx;
InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
InitCtrlEx.dwICC = ICC_PROGRESS_CLASS;
InitCommonControlsEx(&InitCtrlEx);*/
//this->hLoadingWnd = CreateWindowEx(WS_EX_DLGMODALFRAME, this->szClassName, _T("Loading"), WS_BORDER, windowPosX, windowPosY, loadingWndWidth, loadingWndHeight, 0, 0, this->wndClass.hInstance, 0);
//HWND tempHwnd = CreateWindowEx(0, PROGRESS_CLASS, 0, WS_CHILD | WS_VISIBLE, 20, 20, 200, 50, this->hLoadingWnd, 0, 0, 0);
//ShowWindow(tempHwnd, SW_SHOW);
//this->hLoadingWnd = CreateDialog(this->wndClass.hInstance, MAKEINTRESOURCE(IDD_LOADING_DIALOG), this->hWnd, reinterpret_cast<DLGPROC>(LoadingDialogProc));
//DialogBox(this->wndClass.hInstance, MAKEINTRESOURCE(IDD_LOADING_DIALOG), this->hWnd, reinterpret_cast<DLGPROC>(this->LoadingDialogProc));
return S_OK;
}
HRESULT
VideoManDx9::InitD3D(BOOL isMultiThreaded)
{
this->lpD3D = Direct3DCreate9(D3D_SDK_VERSION);
if (this->lpD3D == 0)
{
return E_FAIL;
}
D3DCAPS9 caps;
this->lpD3D->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &caps);
int vp = 0;
if (caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT)
{
vp = D3DCREATE_HARDWARE_VERTEXPROCESSING;
}
else
{
vp = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
}
// for debugging (PIX?)
//vp = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferWidth = getScreenWidth();
d3dpp.BackBufferHeight = getScreenHeight();
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dpp.hDeviceWindow = this->hWnd;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
d3dpp.Flags = 0;
d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
d3dpp.Windowed = TRUE;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; //D3DFMT_UNKNOWN;
HRESULT hr;
DWORD createFlags = vp;
if (isMultiThreaded == TRUE)
{
createFlags |= D3DCREATE_MULTITHREADED;
}
//
// Conditions to utilize PIX tool to debug shader;
// 1. D3DCREATE_MULTITHREADED flag
// 2. D3D Retail DLL
// 3. 'Disable D3DX Analysis' in PIX should be checked
//
createFlags |= D3DCREATE_MULTITHREADED;
hr = this->lpD3D->CreateDevice(
D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, this->hWnd, createFlags, &d3dpp, &this->lpD3DDevice);
return hr;
}
HRESULT
VideoManDx9::Show()
{
//
// Show the main window before and remove loading window after.
//
ShowCursor( TRUE );
ShowWindow( this->hWnd, SW_SHOWDEFAULT );
UpdateWindow( this->hWnd );
DestroyWindow( this->hLoadingWnd );
return S_OK;
}
int
VideoManDx9::Draw()
{
VideoMan::Draw();
if (this->lpD3DDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(10, 45, 70), 1.0f, 0) != D3D_OK)
{
MessageBox(0, _T("Clear() error"), _T("Error"), MB_OK | MB_ICONERROR);
return -2;
}
HRESULT hr = this->lpD3DDevice->BeginScene();
if (FAILED(hr))
{
std::cout << "BeginScene() failed" << std::endl;
return -1;
}
foreach(RenderLayer* layer, getRenderLayers())
{
if (layer->getVisible())
{
layer->render();
layer->update(getTime(), getElapsedTime());
}
}
this->lpAnimationController->AdvanceTime( 0.1f, 0 );
this->lpD3DDevice->EndScene();
// reset rotation
if (this->GetInputMan()->IsRClicked())
{
resetModelArcBallRotation();
}
if (this->GetInputMan()->IsDragging() == FALSE)
{
if (this->GetInputMan()->IsClicked())
{
//OutputDebugString(_T("Drag Start"));
this->GetInputMan()->SetDragging(TRUE);
updateModelArcBallRotation();
}
}
else
{
if (this->GetInputMan()->IsClicked())
{
//OutputDebugString(_T("Dragging...\n"));
Point2Int downPos = this->GetInputMan()->GetMouseDownPos();
Point2Int curPos = this->GetInputMan()->GetMouseCurPos();
Point2Int diffPos;
diffPos.x = downPos.x - curPos.x;
diffPos.y = downPos.y - curPos.y;
ArnQuat quat;
ArnVec3 pV;
pV.x = (float)diffPos.y;
pV.y = (float)diffPos.x;
pV.z = 0.0f;
float angle = sqrtf((float)(diffPos.x*diffPos.x + diffPos.y*diffPos.y));
ArnQuaternionRotationAxis(&quat, &pV, D3DXToRadian(angle));
ArnMatrix mRot;
ArnMatrixRotationQuaternion(&mRot, &quat);
setModelArcBallRotation(ArnMatrixMultiply(*getModelArcBallRotationLast(), mRot));
}
else
{
//OutputDebugString(_T("Drag End"));
this->GetInputMan()->SetDragging(FALSE);
}
}
if (this->isCloseNow() == FALSE)
{
hr = this->lpD3DDevice->Present(0, 0, 0, 0);
if (FAILED(hr))
{
std::cout << "Present() failed" << std::endl;
return -2;
}
}
return 0;
}
HRESULT
VideoManDx9::InitLight_Internal()
{
this->lpD3DDevice->SetLight(0, (CONST D3DLIGHT9 *)&getDefaultLight());
//this->lpD3DDevice->SetLight(0, &this->pointLight);
this->lpD3DDevice->LightEnable(0, TRUE);
return S_OK;
}
HRESULT
VideoManDx9::InitShader()
{
return S_OK;
}
HRESULT
VideoManDx9::InitAnimationController()
{
return S_OK;
}
HRESULT
VideoManDx9::InitMainCamera()
{
return S_OK;
}
HRESULT
VideoManDx9::InitMaterial()
{
return S_OK;
}
HRESULT
VideoManDx9::InitFont()
{
return S_OK;
}
HRESULT
VideoManDx9::InitModels()
{
return S_OK;
}
HRESULT
VideoManDx9::InitLight()
{
return S_OK;
}
void
VideoManDx9::ChangeInTestVB(D3DCOLOR color)
{
HRESULT hr = this->lpTestVB->Lock(0, 0, &this->pVBVertices, 0);
if (FAILED(hr))
{
MessageBox(0, _T("Error at Lock()"), _T("Error"), MB_OK);
return;
}
MY_COLOR_VERTEX* data = (MY_COLOR_VERTEX*)this->pVBVertices;
data[0].color = color;
this->lpTestVB->Unlock();
}
HRESULT
VideoManDx9::StartMainLoop()
{
VideoMan::StartMainLoop();
// TRUE is default when one or more light are set
this->lpD3DDevice->SetRenderState(D3DRS_LIGHTING, TRUE);
//this->lpD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
this->lpD3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_PHONG);
// set default ambient color when there is no light
this->lpD3DDevice->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(100, 100, 100));
this->lpD3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE);
// TRUE is default
//this->lpD3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE);
//ShowWindow(this->hWnd, SW_SHOW);
MSG msg;
do
{
if (this->isRendering() == FALSE)
{
if (GetMessage(&msg, 0, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
//std::cout << ".";
}
else
{
if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
if (this->isCloseNow() != TRUE)
{
if (this->Draw() < 0) // error occurred
return E_FAIL;
}
//this->pInputMan->ProcessKeyboardInput();
}
if (this->isCloseNow())
{
break;
}
} while (msg.message != WM_QUIT);
return S_OK;
}
void
VideoManDx9::DrawAtEditor( BOOL isReady, BOOL isRunning )
{
this->setOkayToDestruct(!isReady || !isRunning);
if (!isReady || !isRunning)
{
return;
}
// TODO: Keyframed Animation
// follow the current frame number
//this->drawCount++;
this->lpD3DDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(80, 80, 80), 1.0f, 0);
this->lpD3DDevice->BeginScene();
// Drawing Job Here
//////////////////////////////////////////////////////////////////////////
// World - View - Projection
//////////////////////////////////////////////////////////////////////////
resetWorldMatrix();
this->lpD3DDevice->SetTransform(D3DTS_WORLD, ArnMatrixGetConstDxPtr(getWorldMatrix()));
//this->SetCamera(0.0f, 0.0f, -50.0f);
ArnMatrix view;
ArnMatrixLookAtLH(
&view,
&getMainCamera()->eye, // the camera position
&getMainCamera()->at, // the look-at position
&getMainCamera()->up // the up direction
);
setViewMatrix(view);
this->lpD3DDevice->SetTransform(D3DTS_VIEW, ArnMatrixGetConstDxPtr(getViewMatrix()));
ArnMatrix proj;
ArnMatrixPerspectiveFovLH(
&proj,
D3DXToRadian(45),
(float)getScreenWidth() / (float)getScreenHeight(),
getMainCamera()->nearClip,
getMainCamera()->farClip
);
setProjectionMatrix(proj);
this->lpD3DDevice->SetTransform(D3DTS_PROJECTION, ArnMatrixGetConstDxPtr(getProjectionMatrix()));
ArnMatrix matTranslation, matScaling;
if (this->pDrawingModel == 0)
{
// Sample model displaying
ArnMatrixTranslation(&matTranslation, 0.0f, 0.0f, 10.0f);
ArnMatrixScaling(&matScaling, 0.1f, 0.1f, 0.1f);
ArnMatrix xform = ArnMatrixMultiply(matScaling, matTranslation);
this->RenderModel(this->mrMan, &xform);
}
else
{
ArnMatrixTranslation(&matTranslation, 0.0f, 0.0f, 10.0f);
ArnMatrixScaling(&matScaling, 1.0f, 1.0f, 1.0f);
ArnMatrix xform = ArnMatrixMultiply(matScaling, matTranslation);
this->RenderModel(this->pDrawingModel, &xform);
this->pDrawingModel->AdvanceTime( 0.1f );
}
//this->RenderModel(&this->mrMan, &(matScaling * matTranslation));
//this->RenderModel(&this->mr1);
this->lpAnimationController->AdvanceTime(0.1f, 0);
this->lpD3DDevice->EndScene();
this->lpD3DDevice->Present(0, 0, 0, 0);
}
HRESULT
VideoManDx9::RenderModel(const ModelReader* pMR, const ArnMatrix* worldTransformMatrix /* = 0 */)
{
if (!pMR || !pMR->IsInitialized())
return E_FAIL;
EXPORT_VERSION ev = pMR->GetExportVersion();
if (ev == EV_ARN10 || ev == EV_ARN11)
{
return RenderModel1(pMR, worldTransformMatrix);
}
else if (ev == EV_ARN20)
{
return RenderModel2(pMR, worldTransformMatrix);
}
return E_FAIL;
}
HRESULT
VideoManDx9::InitTestVertexBuffer()
{
MY_COLOR_VERTEX data[] = {
/*{ 2.5f, -3.0f, 0.0f, D3DCOLOR_XRGB(0, 0, 255), },
{ -2.5f, -3.0f, 0.0f, D3DCOLOR_XRGB(255, 0, 0), },
{ 0.0f, 3.0f, 0.0f, D3DCOLOR_XRGB(0, 255, 0), },
{ -2.5f, 3.0f, 0.0f, D3DCOLOR_XRGB(0, 255, 255), },*/
{ -1.0f, 1.0f, 0.0f, D3DCOLOR_XRGB(0, 0, 255), },
{ 1.0f, 1.0f, 0.0f, D3DCOLOR_XRGB(0, 255, 0), },
{ -1.0f, -1.0f, 0.0f, D3DCOLOR_XRGB(255, 0, 0), },
{ 1.0f, 1.0f, 0.0f, D3DCOLOR_XRGB(255, 255, 255), },
{ 1.0f, -1.0f, 0.0f, D3DCOLOR_XRGB(255, 0, 255), },
{ -1.0f, -1.0f, 0.0f, D3DCOLOR_XRGB(0, 255, 255), },
};
//int dataSize = sizeof(MY_COLOR_VERTEX)*6;
int w = 399;
int h = 399;
MY_COLOR_VERTEX* dynamicData = new MY_COLOR_VERTEX[6*w*h]; // total 699*699 tiles
int dynamicDataSize = sizeof(MY_COLOR_VERTEX)*6*w*h;
int i, j, k;
for (i = -(w+1)/2+1; i < (w+1)/2; i++)
{
for (j = -(h+1)/2+1; j < (h+1)/2; j++)
{
for (k = 0; k < 6; k++)
{
int index = k + (j+(h+1)/2-1)*6 + (i+(w+1)/2-1)*h*6;
MY_COLOR_VERTEX* v = &dynamicData[index];
v->x = data[k].x + (2.0f*i);
v->y = data[k].y + (2.0f*j);
v->z = data[k].z;
v->color = data[k].color;
}
}
}
HRESULT hr = this->lpD3DDevice->CreateVertexBuffer(dynamicDataSize, D3DUSAGE_WRITEONLY, this->MY_COLOR_VERTEX_FVF, D3DPOOL_MANAGED, &this->lpTestVB, 0);
if (FAILED(hr))
{
MessageBox(0, _T("Error at CreateVertexBuffer()"), _T("Error"), MB_OK);
return hr;
}
hr = this->lpTestVB->Lock(0, 0, &this->pVBVertices, 0);
if (FAILED(hr))
{
MessageBox(0, _T("Error at Lock()"), _T("Error"), MB_OK);
return hr;
}
memcpy(this->pVBVertices, dynamicData, dynamicDataSize);
this->lpTestVB->Unlock();
hr = this->lpD3DDevice->CreateVertexBuffer(dynamicDataSize, D3DUSAGE_WRITEONLY, this->MY_COLOR_VERTEX_FVF, D3DPOOL_MANAGED, &this->lpTestVB2, 0);
if (FAILED(hr))
{
MessageBox(0, _T("Error at CreateVertexBuffer()"), _T("Error"), MB_OK);
return hr;
}
hr = this->lpTestVB2->Lock(0, 0, &this->pVBVertices, 0);
if (FAILED(hr))
{
MessageBox(0, _T("Error at Lock()"), _T("Error"), MB_OK);
return hr;
}
memcpy(this->pVBVertices, dynamicData, dynamicDataSize);
this->lpTestVB2->Unlock();
delete [] dynamicData;
dynamicData = 0;
return hr;
}
HRESULT
VideoManDx9::InitBoxVertexBuffer()
{
ARN_VDD data[] = {
{ ArnVec3(-1.0f, 1.0f, -1.0f), ArnVec3(0.0f, 0.0f, -1.0f), D3DCOLOR_XRGB(255, 255, 255), { 0.0f, 0.0f, } },
{ ArnVec3( 1.0f, 1.0f, -1.0f), ArnVec3(0.0f, 0.0f, -1.0f), D3DCOLOR_XRGB(255, 255, 255), { 1.0f, 0.0f, } },
{ ArnVec3(-1.0f, -1.0f, -1.0f), ArnVec3(0.0f, 0.0f, -1.0f), D3DCOLOR_XRGB(255, 255, 255), { 0.0f, 1.0f, } },
{ ArnVec3( 1.0f, 1.0f, -1.0f), ArnVec3(0.0f, 0.0f, -1.0f), D3DCOLOR_XRGB( 50, 50, 50), { 1.0f, 0.0f, } },
{ ArnVec3( 1.0f, -1.0f, -1.0f), ArnVec3(0.0f, 0.0f, -1.0f), D3DCOLOR_XRGB( 50, 50, 50), { 1.0f, 1.0f, } },
{ ArnVec3(-1.0f, -1.0f, -1.0f), ArnVec3(0.0f, 0.0f, -1.0f), D3DCOLOR_XRGB( 50, 50, 50), { 0.0f, 1.0f, } },
{ ArnVec3(-1.0f, -1.0f, 1.0f), ArnVec3(0.0f, 0.0f, 1.0f), D3DCOLOR_XRGB(255, 0, 0), { 0.0f, 1.0f, } },
{ ArnVec3( 1.0f, 1.0f, 1.0f), ArnVec3(0.0f, 0.0f, 1.0f), D3DCOLOR_XRGB( 0, 255, 0), { 1.0f, 0.0f, } },
{ ArnVec3(-1.0f, 1.0f, 1.0f), ArnVec3(0.0f, 0.0f, 1.0f), D3DCOLOR_XRGB( 0, 0, 255), { 0.0f, 0.0f, } },
{ ArnVec3(-1.0f, -1.0f, 1.0f), ArnVec3(0.0f, 0.0f, 1.0f), D3DCOLOR_XRGB( 0, 255, 255), { 0.0f, 1.0f, } },
{ ArnVec3( 1.0f, -1.0f, 1.0f), ArnVec3(0.0f, 0.0f, 1.0f), D3DCOLOR_XRGB(255, 0, 255), { 1.0f, 1.0f, } },
{ ArnVec3( 1.0f, 1.0f, 1.0f), ArnVec3(0.0f, 0.0f, 1.0f), D3DCOLOR_XRGB(255, 255, 255), { 1.0f, 0.0f, } },
{ ArnVec3( 1.0f, 1.0f, -1.0f), ArnVec3(1.0f, 0.0f, 0.0f), D3DCOLOR_XRGB(200, 10, 10), { 0.0f, 0.0f, } },
{ ArnVec3( 1.0f, 1.0f, 1.0f), ArnVec3(1.0f, 0.0f, 0.0f), D3DCOLOR_XRGB(100, 100, 100), { 1.0f, 0.0f, } },
{ ArnVec3( 1.0f, -1.0f, -1.0f), ArnVec3(1.0f, 0.0f, 0.0f), D3DCOLOR_XRGB(100, 100, 100), { 0.0f, 1.0f, } },
{ ArnVec3( 1.0f, 1.0f, 1.0f), ArnVec3(1.0f, 0.0f, 0.0f), D3DCOLOR_XRGB(100, 100, 100), { 0.0f, 0.0f, } },
{ ArnVec3( 1.0f, -1.0f, 1.0f), ArnVec3(1.0f, 0.0f, 0.0f), D3DCOLOR_XRGB(100, 100, 100), { 1.0f, 0.0f, } },
{ ArnVec3( 1.0f, -1.0f, -1.0f), ArnVec3(1.0f, 0.0f, 0.0f), D3DCOLOR_XRGB(100, 100, 100), { 0.0f, 1.0f, } },
{ ArnVec3(-1.0f, -1.0f, -1.0f), ArnVec3(-1.0f, 0.0f, 0.0f), D3DCOLOR_XRGB( 0, 0, 200), { 0.0f, 1.0f, } },
{ ArnVec3(-1.0f, 1.0f, 1.0f), ArnVec3(-1.0f, 0.0f, 0.0f), D3DCOLOR_XRGB( 0, 0, 200), { 1.0f, 1.0f, } },
{ ArnVec3(-1.0f, 1.0f, -1.0f), ArnVec3(-1.0f, 0.0f, 0.0f), D3DCOLOR_XRGB( 0, 0, 200), { 1.0f, 0.0f, } },
{ ArnVec3(-1.0f, -1.0f, -1.0f), ArnVec3(-1.0f, 0.0f, 0.0f), D3DCOLOR_XRGB( 0, 0, 255), { 0.0f, 1.0f, } },
{ ArnVec3(-1.0f, -1.0f, 1.0f), ArnVec3(-1.0f, 0.0f, 0.0f), D3DCOLOR_XRGB( 0, 0, 255), { 1.0f, 1.0f, } },
{ ArnVec3(-1.0f, 1.0f, 1.0f), ArnVec3(-1.0f, 0.0f, 0.0f), D3DCOLOR_XRGB( 0, 0, 255), { 1.0f, 0.0f, } },
{ ArnVec3(-1.0f, 1.0f, 1.0f), ArnVec3( 0.0f, 1.0f, 0.0f), D3DCOLOR_XRGB(200, 200, 200), { 0.0f, 0.0f, } },
{ ArnVec3( 1.0f, 1.0f, 1.0f), ArnVec3( 0.0f, 1.0f, 0.0f), D3DCOLOR_XRGB(200, 200, 200), { 1.0f, 0.0f, } },
{ ArnVec3(-1.0f, 1.0f, -1.0f), ArnVec3( 0.0f, 1.0f, 0.0f), D3DCOLOR_XRGB(200, 200, 200), { 0.0f, 1.0f, } },
{ ArnVec3( 1.0f, 1.0f, 1.0f), ArnVec3( 0.0f, 1.0f, 0.0f), D3DCOLOR_XRGB(200, 200, 200), { 0.0f, 0.0f, } },
{ ArnVec3( 1.0f, 1.0f, -1.0f), ArnVec3( 0.0f, 1.0f, 0.0f), D3DCOLOR_XRGB(200, 200, 200), { 1.0f, 0.0f, } },
{ ArnVec3(-1.0f, 1.0f, -1.0f), ArnVec3( 0.0f, 1.0f, 0.0f), D3DCOLOR_XRGB(200, 200, 200), { 0.0f, 1.0f, } },
{ ArnVec3(-1.0f, -1.0f, -1.0f), ArnVec3( 0.0f, -1.0f, 0.0f), D3DCOLOR_XRGB(200, 200, 200), { 0.0f, 0.0f, } },
{ ArnVec3( 1.0f, -1.0f, 1.0f), ArnVec3( 0.0f, -1.0f, 0.0f), D3DCOLOR_XRGB(200, 200, 200), { 1.0f, 1.0f, } },
{ ArnVec3(-1.0f, -1.0f, 1.0f), ArnVec3( 0.0f, -1.0f, 0.0f), D3DCOLOR_XRGB(200, 200, 200), { 0.0f, 1.0f, } },
{ ArnVec3(-1.0f, -1.0f, -1.0f), ArnVec3( 0.0f, -1.0f, 0.0f), D3DCOLOR_XRGB(255, 255, 0), { 0.0f, 0.0f, } },
{ ArnVec3( 1.0f, -1.0f, -1.0f), ArnVec3( 0.0f, -1.0f, 0.0f), D3DCOLOR_XRGB(255, 255, 0), { 1.0f, 0.0f, } },
{ ArnVec3( 1.0f, -1.0f, 1.0f), ArnVec3( 0.0f, -1.0f, 0.0f), D3DCOLOR_XRGB(200, 200, 200), { 1.0f, 1.0f, } },
};
int dataSize = sizeof(ARN_VDD) * 12 * 3;
HRESULT hr = this->lpD3DDevice->CreateVertexBuffer(dataSize, D3DUSAGE_WRITEONLY, ARN_VDD::ARN_VDD_FVF, D3DPOOL_MANAGED, &this->lpBoxVB, 0);
if (FAILED(hr))
{
MessageBox(0, _T("Error at CreateVertexBuffer()"), _T("Error"), MB_OK);
return hr;
}
hr = this->lpBoxVB->Lock(0, 0, &this->pVBVertices, 0);
if (FAILED(hr))
{
MessageBox(0, _T("Error at Lock()"), _T("Error"), MB_OK);
return hr;
}
memcpy(this->pVBVertices, data, dataSize);
this->lpBoxVB->Unlock();
return hr;
}
HRESULT
VideoManDx9::InitModelsAtEditor()
{
//
// This is called when the Engine is used by editor module
//
//this->mr1.Initialize( this->lpD3DDevice, ARN_VDD::ARN_VDD_FVF, this->hLoadingWnd, _T("box1.arn"), this->lpAnimationController );
//this->mrMan.Initialize( this->lpD3DDevice, ARN_VDD::ARN_VDD_FVF, this->hLoadingWnd, _T("man.arn"), this->lpAnimationController );
return S_OK;
}
HRESULT
VideoManDx9::InitTexture()
{
HRESULT hr = E_FAIL;
/*hr = ArnCreateTextureFromFile(this, "tex1.png", &this->lpTex1);
if (hr != D3D_OK)
{
hr = ArnCreateTextureFromFile(this, "..\\Aran\\tex1.png", &this->lpTex1);
if (hr != D3D_OK)
{
return -1;
}
}*/
return hr;
}
HRESULT
VideoManDx9::TurnModelLightOn(ModelReader *pMR, ArnMatrix* worldTransformMatrix)
{
int i;
int modelLightCount = pMR->GetLightCount();
for (i = 0; i < modelLightCount; i++)
{
ArnLightData& light = pMR->GetLight(i);
//light.Phi = D3DXToRadian(100.0f);
//light.Theta = D3DXToRadian(20.0f);
light.Falloff = 1.0f;
light.Ambient.r = light.Diffuse.r / 2;
light.Ambient.g = light.Diffuse.g / 2;
light.Ambient.b = light.Diffuse.b / 2;
light.Ambient.a = light.Diffuse.a / 2;
//light.Position.z = -20.0f;
if (worldTransformMatrix != 0)
{
ArnVec3 lightDir(light.Direction); // original
ArnVec4 lightPosition, lightDirection; // transformed
ArnVec3 scaling, translation;
ArnQuat rotation;
ArnMatrixDecompose(&scaling, &rotation, &translation, worldTransformMatrix);
lightPosition.x = light.Position.x + translation.x;
lightPosition.y = light.Position.y + translation.y;
lightPosition.z = light.Position.z + translation.z;
//D3DXVec3Transform(&lightPosition, &lightPos, worldTransformMatrix);
ArnMatrix matRot;
ArnMatrixRotationQuaternion(&matRot, &rotation);
ArnVec3Transform(&lightDirection, &lightDir, &matRot);
light.Position.x = lightPosition.x;
light.Position.y = lightPosition.y;
light.Position.z = lightPosition.z;
light.Direction.x = lightDirection.x;
light.Direction.y = lightDirection.y;
light.Direction.z = lightDirection.z;
}
this->lpD3DDevice->SetLight(getTotalLightCount(), (CONST D3DLIGHT9 *)&light);
this->lpD3DDevice->LightEnable(getTotalLightCount(), TRUE);
setTotalLightCount( getTotalLightCount() + 1 );
}
return S_OK;
}
HRESULT
VideoManDx9::RenderModel1(const ModelReader *pMR, const ArnMatrix* worldTransformMatrix) const
{
//
// SHOULD BE CALLED BETWEEN BeginScene() & EndScene()
//
HRESULT hr = S_OK;
if (pMR->GetExportVersion() != EV_ARN10 && pMR->GetExportVersion() != EV_ARN11)
{
MessageBox(0, _T("RenderModel() call corrupted."), _T("Error"), MB_OK | MB_ICONERROR);
return E_FAIL;
}
int i, j, vertexOffset = 0;
int meshCount = pMR->GetNotIndMeshCount();
this->lpD3DDevice->SetFVF(pMR->GetFVF());
this->lpD3DDevice->SetStreamSource(0, (IDirect3DVertexBuffer9*)pMR->GetVB(), 0, sizeof(ARN_VDD));
// An ARN model is stored with 'front view' aspect.
// 'Top view' aspect is preferable to make consistent x- and y-axis orientation
// between 3ds Max and Aran Rendering window.
// To make this work, we define -90 degree x-axis rotation transform matrix.
ArnMatrix matRotX90;
ArnMatrixRotationX(&matRotX90, D3DXToRadian(-90.0f));
ArnMatrix matFinalTransform;
for (i = 0; i < meshCount; i++)
{
// TODO: keyframed animation
const ArnMatrix* pAnimMat = pMR->GetAnimMatControlledByAC(i);
matFinalTransform = ArnMatrixMultiply(*pAnimMat, matRotX90);
if (worldTransformMatrix != 0)
{
matFinalTransform = ArnMatrixMultiply(matFinalTransform, *worldTransformMatrix);
}
this->lpD3DDevice->SetTransform(D3DTS_WORLD, ArnMatrixGetConstDxPtr(matFinalTransform));
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// get the number of materials of this mesh
int materialCount = pMR->GetMaterialCount(i);
int materialOffset = 0;
// find for material offset of this mesh (accumulation)
for (j = 0; j < i; j++)
{
materialOffset += pMR->GetMaterialCount(j);
}
// draw primitives with material and texture
const ArnMaterialData* matRef = 0;
LPDIRECT3DTEXTURE9 texRef = 0;
if (materialCount > 0)
{
for (j = 0; j < materialCount; j++)
{
// get the real material(w/ texture) offset
int ref = materialOffset + j;
if (ref < 0)
{
const ArnMaterialData& mtrlData = getDefaultMaterial();
matRef = &mtrlData;
texRef = 0;
}
else
{
matRef = pMR->GetMaterial(ref);
// if there is texture information...
if (pMR->GetTexture(ref) != 0)
{
// ..set it
texRef = (LPDIRECT3DTEXTURE9)pMR->GetTexture(ref);
}
else
{
texRef = 0;
}
}
this->lpD3DDevice->SetMaterial((CONST D3DMATERIAL9 *)matRef);
this->lpD3DDevice->SetTexture(0, texRef);
//
// calculate current mesh's face(triangle) count
//
// i; current mesh index
// j; current mesh's current material index
//
int faceStartOffset = pMR->GetMaterialReferenceFast(i, j);
int faceCount = -1;
if (j == pMR->GetMaterialCount(i) - 1)
{
// if this material is last one...
faceCount = pMR->GetFaceCount(i) - pMR->GetMaterialReferenceFast(i, j);
}
else
{
// ...or not
faceCount = pMR->GetMaterialReferenceFast(i, j+1) - faceStartOffset;
}
this->lpD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST, vertexOffset + faceStartOffset*3, faceCount);
}
}
else if (materialCount == 0) // use default material and texture when there is no material defined explicitly
{
matRef = &getDefaultMaterial();
this->lpD3DDevice->SetMaterial((CONST D3DMATERIAL9 *)matRef);
this->lpD3DDevice->SetTexture(0, 0);
int faceStartOffset = pMR->GetMaterialReferenceFast(i, 0); // ..Fast
int faceCount = pMR->GetFaceCount(i) - pMR->GetMaterialReferenceFast(i, 0); //..Fast this material is last one, always.
this->lpD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST, vertexOffset + faceStartOffset*3, faceCount);
}
else
{
// critical error! materialCount < 0!!!
MessageBox(0, _T("materialCount < 0 error."), _T("Error"), MB_OK);
return E_FAIL;
}
// increase vertex data offset by current mesh's vertices count
vertexOffset += pMR->GetFaceCount(i) * 3;
}
return hr;
}
HRESULT
VideoManDx9::RenderModel2(const ModelReader *pMR, const ArnMatrix* worldTransformMatrix)
{
if (pMR->GetExportVersion() != EV_ARN20)
{
MessageBox(0, _T("RenderModel2() call corrupted."), _T("Error"), MB_OK | MB_ICONERROR);
return E_FAIL;
}
int i, j, k;
int meshCount = pMR->GetIndMeshCount();
int accum = 0;
std::vector<int> skinnedMeshTextureIndex;
// An ARN model is stored with 'front view' aspect.
// 'Top view' aspect is preferable to make consistent x- and y-axis orientation
// between 3ds Max and Aran Rendering window.
// To make this work, we define -90 degree x-axis rotation transform matrix.
ArnMatrix matRotX90;
ArnMatrixRotationX(&matRotX90, D3DXToRadian(-90.0f));
ArnMatrix matGeneralMeshFinalTransform;
for (i = 0; i < meshCount; i++)
{
int matCount = pMR->GetMaterialCount(i);
if (pMR->GetSkeletonIndexByMeshIndex(i) < 0)
{
// General mesh case
const ArnMatrix* pAnimMat = pMR->GetAnimMatControlledByAC(i);
matGeneralMeshFinalTransform = ArnMatrixMultiply(*pAnimMat, matRotX90);
if (worldTransformMatrix != 0)
{
matGeneralMeshFinalTransform = ArnMatrixMultiply(matGeneralMeshFinalTransform, *worldTransformMatrix);
}
this->lpD3DDevice->SetTransform(D3DTS_WORLD, ArnMatrixGetConstDxPtr(matGeneralMeshFinalTransform));
for (j = 0; j < matCount; j++)
{
const ArnMaterialData* matPointer = pMR->GetMaterial(j + accum);
this->lpD3DDevice->SetMaterial((CONST D3DMATERIAL9 *)matPointer);
LPDIRECT3DTEXTURE9 texPointer = (LPDIRECT3DTEXTURE9)pMR->GetTexture(j + accum);
this->lpD3DDevice->SetTexture(0, texPointer);
LPD3DXMESH mp = (LPD3DXMESH)pMR->GetMeshPointer(i);
mp->DrawSubset(j);
}
}
else
{
// Skinned mesh case
// vertex transform will be applied via vertex shader (see below)
skinnedMeshTextureIndex.push_back(accum);
}
accum += matCount;
}
//////////////////////////////////////////////////////////////////////////
// Skinned Mesh Rendering
//////////////////////////////////////////////////////////////////////////
//D3DXMATRIX* offsetTemp = 0;
ArnMatrix offset, offsetInverse;
const ArnMatrix* combinedTemp = 0;
static ArnMatrix finalTransforms[128];
ZeroMemory(finalTransforms, sizeof(finalTransforms));
D3DXHANDLE hTech = this->lpEffectSkinning->GetTechniqueByName("VertexBlendingTech");
//***D3DXHANDLE hWorldViewProj = this->lpEffectSkinning->GetParameterByName(0, "WorldViewProj");
//***D3DXHANDLE hFinalTransforms = this->lpEffectSkinning->GetParameterByName(0, "FinalTransforms");
//D3DXHANDLE hTex = this->lpEffectSkinning->GetParameterByName(0, "Tex");
D3DXHANDLE hNumVertInflu = this->lpEffectSkinning->GetParameterByName(0, "NumVertInfluences");
D3DXHANDLE hTestFloatArray = this->lpEffectSkinning->GetParameterByName(0, "TestFloatArray");
ArnMatrix matWorldViewProj = ArnMatrixMultiply(getWorldMatrix(), getViewMatrix(), getProjectionMatrix());
int numVertInfluences = 3;
V_OKAY( this->lpEffectSkinning->SetInt( hNumVertInflu, numVertInfluences ) );
//***V_OKAY( this->lpEffectSkinning->SetMatrix( hWorldViewProj, ArnMatrixGetConstDxPtr(matWorldViewProj) ) );
V_OKAY( this->lpEffectSkinning->SetTechnique( hTech ) );
UINT numPasses;
this->lpEffectSkinning->Begin(&numPasses, 0);
size_t boneCount;
for (i = 0; i < (int)numPasses; i++)
{
for (j = 0; j < (int)pMR->GetSkeletonNodeSize(); j++)
{
//int associatedMeshIndex = pMR->GetMeshIndexBySkeletonIndex(j);
//pMR->UpdateBoneCombinedMatrixByMeshIndex(associatedMeshIndex);
boneCount = pMR->GetSkeletonNodePointer(j)->bones.size();
for(k = 0; k < (int)boneCount; k++)
{
const char* boneName = pMR->GetSkeletonNodePointer(j)->bones[k].nameFixed.c_str();
//combinedTemp = pMR->GetCombinedMatrixByBoneName(boneName); // hierarchically computed at runtime
combinedTemp = pMR->GetTransformationMatrixByBoneName(boneName); // precomputed transforms
offset = pMR->GetSkeletonNodePointer(j)->bones[k].offsetMatrix;
ArnMatrixInverse(&offsetInverse, 0, &offset);
finalTransforms[k] = ArnMatrixMultiply(offsetInverse, *combinedTemp, matRotX90);
if (worldTransformMatrix != 0)
{
finalTransforms[k] = ArnMatrixMultiply(finalTransforms[k], *worldTransformMatrix);
}
}
//***this->lpEffectSkinning->SetMatrixArray(hFinalTransforms, ArnMatrixGetConstDxPtr(finalTransforms[0]), (UINT)boneCount);
this->lpEffectSkinning->SetFloatArray(hTestFloatArray, &testFloatArray[0], 2000);
this->lpEffectSkinning->BeginPass(i);
this->lpEffectSkinning->CommitChanges();
LPDIRECT3DTEXTURE9 texPointer = (LPDIRECT3DTEXTURE9)pMR->GetTexture(skinnedMeshTextureIndex[j]);
this->lpD3DDevice->SetTexture(0, texPointer);
LPD3DXMESH smp = (LPD3DXMESH)pMR->GetSkinnedMeshPointer(j);
smp->DrawSubset(0); // TODO: Multiple subset in skinned mesh
this->lpEffectSkinning->EndPass();
}
}
this->lpEffectSkinning->End();
return S_OK;
}
// TODO: Contains memory leak at this method
//
// rotationKeys = new D3DXKEY_QUATERNION[4];
// translationKeys = new D3DXKEY_VECTOR3[3];
// scaleKeys = new D3DXKEY_VECTOR3[4];
HRESULT
VideoManDx9::InitCustomMesh()
{
HRESULT hr = 0;
hr = ArnCreateMeshFVF(12, 24, MY_CUSTOM_MESH_VERTEX::MY_CUSTOM_MESH_VERTEX_FVF, lpD3DDevice, &this->lpCustomMesh);
if (FAILED(hr))
{
MessageBox(0, _T("Custom Mesh creation failed."), _T("Error"), MB_OK | MB_ICONERROR);
return E_FAIL;
}
MY_CUSTOM_MESH_VERTEX* v = 0;
this->lpCustomMesh->LockVertexBuffer(0, (void**)&v);
// fill in the front face MY_CUSTOM_MESH_VERTEX data
v[0] = MY_CUSTOM_MESH_VERTEX(-1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f);
v[1] = MY_CUSTOM_MESH_VERTEX(-1.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f);
v[2] = MY_CUSTOM_MESH_VERTEX( 1.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 1.0f, 1.0f);
v[3] = MY_CUSTOM_MESH_VERTEX( 1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f);
// fill in the back face MY_CUSTOM_MESH_VERTEX data
v[4] = MY_CUSTOM_MESH_VERTEX(-1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
v[5] = MY_CUSTOM_MESH_VERTEX( 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f);
v[6] = MY_CUSTOM_MESH_VERTEX( 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f);
v[7] = MY_CUSTOM_MESH_VERTEX(-1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f);
// fill in the top face MY_CUSTOM_MESH_VERTEX data
v[8] = MY_CUSTOM_MESH_VERTEX(-1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f);
v[9] = MY_CUSTOM_MESH_VERTEX(-1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f);
v[10] = MY_CUSTOM_MESH_VERTEX( 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f);
v[11] = MY_CUSTOM_MESH_VERTEX( 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f);
// fill in the bottom face MY_CUSTOM_MESH_VERTEX data
v[12] = MY_CUSTOM_MESH_VERTEX(-1.0f, -1.0f, -1.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f);
v[13] = MY_CUSTOM_MESH_VERTEX( 1.0f, -1.0f, -1.0f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f);
v[14] = MY_CUSTOM_MESH_VERTEX( 1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f, 1.0f, 1.0f);
v[15] = MY_CUSTOM_MESH_VERTEX(-1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f);
// fill in the left face MY_CUSTOM_MESH_VERTEX data
v[16] = MY_CUSTOM_MESH_VERTEX(-1.0f, -1.0f, 1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f);
v[17] = MY_CUSTOM_MESH_VERTEX(-1.0f, 1.0f, 1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f);
v[18] = MY_CUSTOM_MESH_VERTEX(-1.0f, 1.0f, -1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f);
v[19] = MY_CUSTOM_MESH_VERTEX(-1.0f, -1.0f, -1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f);
// fill in the right face MY_CUSTOM_MESH_VERTEX data
v[20] = MY_CUSTOM_MESH_VERTEX( 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f);
v[21] = MY_CUSTOM_MESH_VERTEX( 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f);
v[22] = MY_CUSTOM_MESH_VERTEX( 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f);
v[23] = MY_CUSTOM_MESH_VERTEX( 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f);
this->lpCustomMesh->UnlockVertexBuffer();
WORD* ind = 0;
this->lpCustomMesh->LockIndexBuffer(0, (void**)&ind);
// fill in the front face index data
ind[0] = 0; ind[1] = 1; ind[2] = 2;
ind[3] = 0; ind[4] = 2; ind[5] = 3;
// fill in the back face index data
ind[6] = 4; ind[7] = 5; ind[8] = 6;
ind[9] = 4; ind[10] = 6; ind[11] = 7;
// fill in the top face index data
ind[12] = 8; ind[13] = 9; ind[14] = 10;
ind[15] = 8; ind[16] = 10; ind[17] = 11;
// fill in the bottom face index data
ind[18] = 12; ind[19] = 13; ind[20] = 14;
ind[21] = 12; ind[22] = 14; ind[23] = 15;
// fill in the left face index data
ind[24] = 16; ind[25] = 17; ind[26] = 18;
ind[27] = 16; ind[28] = 18; ind[29] = 19;
// fill in the right face index data
ind[30] = 20; ind[31] = 21; ind[32] = 22;
ind[33] = 20; ind[34] = 22; ind[35] = 23;
this->lpCustomMesh->UnlockIndexBuffer();
DWORD* attributeBuffer = 0;
this->lpCustomMesh->LockAttributeBuffer(0, &attributeBuffer);
int i;
attributeBuffer[ 0] = 1;
attributeBuffer[ 1] = 0;
attributeBuffer[ 2] = 1;
attributeBuffer[ 3] = 0;
attributeBuffer[ 4] = 0;
attributeBuffer[ 5] = 1;
attributeBuffer[ 6] = 0;
attributeBuffer[ 7] = 1;
attributeBuffer[ 8] = 2;
attributeBuffer[ 9] = 2;
attributeBuffer[10] = 1;
attributeBuffer[11] = 1;
this->lpCustomMesh->UnlockAttributeBuffer();
/*hr = this->lpCustomMesh->OptimizeInplace(D3DXMESHOPT_ATTRSORT | D3DXMESHOPT_COMPACT | D3DXMESHOPT_VERTEXCACHE, &adjacencyBuffer[0], &newAdjBuffer[0], 0, 0);
if (hr != D3D_OK)
{
MessageBox(0, _T("OptimizeInplace() error"), _T("Error"), MB_OK | MB_ICONERROR);
return E_FAIL;
}*/
//delete [] adjacencyBuffer;
//adjacencyBuffer = 0;
//ZeroMemory(&this->meshContainer, sizeof(D3DXMESHCONTAINER));
//this->meshContainer.MeshData.pMesh = this->lpCustomMesh;
//this->meshContainer.MeshData.Type = D3DXMESHTYPE_MESH;
//
//this->meshContainer.Name = "Simple Box";
//this->meshContainer.NumMaterials = 3;
//this->meshContainer.pAdjacency = adjacencyBuffer;
//this->meshContainer.pEffects = 0;
//this->meshContainer.pMaterials = this->rgbMaterial;
//this->meshContainer.pNextMeshContainer = 0;
//this->meshContainer.pSkinInfo =
this->frame1.Name = "Custom Bone 1";
this->frame1.pFrameFirstChild = &this->frame2;
this->frame1.pFrameSibling = 0;
this->frame1.pMeshContainer = 0; //&this->meshContainer;
D3DXMatrixIdentity(&this->frame1.TransformationMatrix);
this->frame2.Name = "Custom Bone 2";
this->frame2.pFrameFirstChild = 0;
this->frame2.pFrameSibling = 0;
this->frame2.pMeshContainer = 0;
D3DXMatrixIdentity(&this->frame2.TransformationMatrix);
//D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1;
//MessageBox(0, _T("About to call D3DXCreateSkinInfoFVF()"), _T("Notice"), MB_OK);
if (FAILED(ArnCreateSkinInfoFVF(24, MY_CUSTOM_MESH_VERTEX::MY_CUSTOM_MESH_VERTEX_FVF, 2, &this->lpSkinInfo)))
{
MessageBox(0, _T("ArnCreateSkinInfoFVF() failed."), _T("Error"), MB_OK | MB_ICONERROR);
return E_FAIL;
}
ArnMatrix boneMat1, boneMat2;
ArnMatrixIdentity(&boneMat1);
ArnMatrixIdentity(&boneMat2);
V_OKAY(this->lpSkinInfo->SetBoneName(0, "Custom Bone 1"));
V_OKAY(this->lpSkinInfo->SetBoneName(1, "Custom Bone 2"));
V_OKAY(this->lpSkinInfo->SetBoneOffsetMatrix(0, &boneMat1));
V_OKAY(this->lpSkinInfo->SetBoneOffsetMatrix(1, &boneMat2));
DWORD* bone1Vertices = 0;
DWORD* bone2Vertices = 0;
float* bone1Weights = 0;
float* bone2Weights = 0;
try
{
bone1Vertices = new DWORD[24];
bone2Vertices = new DWORD[12];
bone1Weights = new float[24];
bone2Weights = new float[12];
}
catch (...)
{
SAFE_DELETE_ARRAY(bone1Vertices);
SAFE_DELETE_ARRAY(bone2Vertices);
SAFE_DELETE_ARRAY(bone1Weights);
SAFE_DELETE_ARRAY(bone2Weights);
throw new std::runtime_error("Memory allocation failure");
}
for (i = 0; i < 24; i++)
{
bone1Vertices[i] = i;
if (i >= 12)
bone1Weights[i] = 0.5f;
else
bone1Weights[i] = 1.0f;
}
for (i = 0; i < 12; i++)
{
bone2Vertices[i] = i+12;
bone2Weights[i] = 0.5f;
}
V_OKAY(this->lpSkinInfo->SetBoneInfluence(0, 24, bone1Vertices, bone1Weights));
V_OKAY(this->lpSkinInfo->SetBoneInfluence(1, 12, bone2Vertices, bone2Weights));
DWORD maxVertexInfluence, numBoneCombinations;
LPD3DXBUFFER boneCombinations;
//int customMeshVerticesCount = this->lpCustomMesh->GetNumVertices();
D3DVERTEXELEMENT9 tempDeclMesh[MAX_FVF_DECL_SIZE];
ZeroMemory(tempDeclMesh, sizeof(tempDeclMesh));
this->lpCustomMesh->GetDeclaration(tempDeclMesh);
D3DVERTEXELEMENT9 tempDeclSkin[MAX_FVF_DECL_SIZE];
ZeroMemory(tempDeclSkin, sizeof(tempDeclSkin));
//this->lpSkinInfo->GetDeclaration(tempDeclSkin);
//this->lpSkinInfo->SetDeclaration(tempDeclMesh);
std::vector<DWORD> adjacencyBuffer, newAdjBuffer;
int adjSize = this->lpCustomMesh->GetNumFaces() * 3;
adjacencyBuffer.resize(adjSize);
newAdjBuffer.resize(adjSize);
//DWORD* adjacencyBuffer = new DWORD[this->lpCustomMesh->GetNumFaces() * 3];
if (this->lpCustomMesh->GenerateAdjacency(0.001f, &adjacencyBuffer[0]) != D3D_OK)
{
MessageBox(0, _T("GenerateAdjacency() error."), _T("Error"), MB_OK | MB_ICONERROR);
}
//D3DPERF_BeginEvent(0xff00ffff, _T("Convert call"));
//MessageBox(0, _T("About to call ConvertToIndexedBlenedMesh()"), _T("Notice"), MB_OK);
hr = this->lpSkinInfo->ConvertToIndexedBlendedMesh(
this->lpCustomMesh,
0,
2,
&adjacencyBuffer[0],
&newAdjBuffer[0],
0,
0,
&maxVertexInfluence,
&numBoneCombinations,
&boneCombinations,
&this->lpCustomSkinnedMesh
);
if (hr != D3D_OK)
{
char errorNumber[64];
_itoa_s(hr, errorNumber, 10);
MessageBoxA(0, "ConvertToIndexedBlenedMesh() Failed", errorNumber, MB_OK | MB_ICONERROR);
return E_FAIL;
}
//MessageBox(0, _T("ConvertToIndexedBlenedMesh() Success"), _T("Notice"), MB_OK);
//D3DPERF_EndEvent();
D3DVERTEXELEMENT9 declaration[MAX_FVF_DECL_SIZE];
ZeroMemory(&declaration, sizeof(declaration));
this->lpCustomSkinnedMesh->GetDeclaration(declaration);
//D3DXBONECOMBINATION* bcp0 = (D3DXBONECOMBINATION*)boneCombinations->GetBufferPointer();
//D3DXBONECOMBINATION* bcp1 = bcp0+1;
//D3DXBONECOMBINATION* bcp2 = bcp0+2;
for (i = 0; i < (int)this->lpSkinInfo->GetNumBones(); i++)
{
// const char* boneName = this->lpSkinInfo->GetBoneName(i);
i++;
i--;
}
boneCombinations->Release();
boneCombinations = 0;
//DWORD skinnedMeshFVF = this->lpCustomSkinnedMesh->GetFVF();
DWORD animIndex = 0;
ArnVec3 scale;
ArnVec3 translation;
ArnQuat rotation;
//ArnVec3 vecOutScale, vecOutTranslation;
ArnQuat qOut;
ARNKEY_QUATERNION* rotationKeys = 0;
ARNKEY_VECTOR3* translationKeys = 0;
ARNKEY_VECTOR3* scaleKeys = 0;
V_OKAY(ArnCreateKeyframedAnimationSet("Custom Snake Animation", 1, ARNPLAY_LOOP, 2, 0, 0, &this->lpDefaultAnimationSet));
try
{
rotationKeys = new ARNKEY_QUATERNION[4];
translationKeys = new ARNKEY_VECTOR3[3];
scaleKeys = new ARNKEY_VECTOR3[4];
}
catch (std::bad_alloc& ba)
{
SAFE_DELETE_ARRAY(rotationKeys);
SAFE_DELETE_ARRAY(translationKeys);
SAFE_DELETE_ARRAY(scaleKeys);
throw ba;
}
rotationKeys[0].Time = 1.0f;
ArnQuaternionRotationAxis(&rotationKeys[0].Value, &ArnConsts::ARNVEC3_X, D3DXToRadian(10));
rotationKeys[1].Time = 2.0f;
ArnQuaternionRotationAxis(&rotationKeys[1].Value, &ArnConsts::ARNVEC3_Y, D3DXToRadian(90));
rotationKeys[2].Time = 3.0f;
ArnQuaternionRotationAxis(&rotationKeys[2].Value, &ArnConsts::ARNVEC3_Z, D3DXToRadian(120));
rotationKeys[3].Time = 4.0f;
ArnQuaternionRotationAxis(&rotationKeys[3].Value, &ArnConsts::ARNVEC3_X, D3DXToRadian(10));
translationKeys[0].Time = 1.0f;
translationKeys[0].Value = CreateArnVec3(1.0f, 1.0f, 1.0f);
translationKeys[1].Time = 2.0f;
translationKeys[1].Value = CreateArnVec3(1.0f, 0.0f, 1.0f);
translationKeys[2].Time = 4.0f;
translationKeys[2].Value = CreateArnVec3(0.0f, 1.0f, 5.0f);
scaleKeys[0].Time = 0.0f;
scaleKeys[0].Value = CreateArnVec3(1.0f, 1.0f, 1.0f);
scaleKeys[1].Time = 2.0f;
scaleKeys[1].Value = CreateArnVec3(0.3f, 0.3f, 1.0f);
scaleKeys[2].Time = 3.5f;
scaleKeys[2].Value = CreateArnVec3(1.0f, 10.0f, 1.0f);
scaleKeys[3].Time = 4.0f;
scaleKeys[3].Value = CreateArnVec3(100.0f, 100.0f, 500.0f);
V_OKAY(this->lpDefaultAnimationSet->RegisterAnimationSRTKeys("Custom Bone 1", 0, 4, 3, 0, rotationKeys, translationKeys, &animIndex));
V_OKAY(this->lpDefaultAnimationSet->RegisterAnimationSRTKeys("Custom Bone 2", 4, 0, 0, scaleKeys, 0, 0, &animIndex));
DOUBLE time;
for (time = 0.0f; time < 150.0f; time += 0.1f)
{
DOUBLE periodicPosition = this->lpDefaultAnimationSet->GetPeriodicPosition(time);
V_OKAY(this->lpDefaultAnimationSet->GetSRT(periodicPosition, 0, &scale, &rotation, &translation));
}
//
// TODO: Animation Set testing
//
//V_OKAY(this->lpAnimationController->RegisterAnimationSet(this->lpDefaultAnimationSet));
//
//// Set animation set to track
//LPD3DXANIMATIONSET lpAnimSet = 0;
//V_OKAY(this->lpAnimationController->GetAnimationSet(0, &lpAnimSet));
//V_OKAY(this->lpAnimationController->SetTrackAnimationSet(0, lpAnimSet));
//V_OKAY(this->lpAnimationController->SetTrackEnable(0, TRUE));
//V_OKAY(this->lpAnimationController->SetTrackWeight(0, 1.0f));
//V_OKAY(this->lpAnimationController->SetTrackSpeed(0, 1.0f));
//V_OKAY(this->lpAnimationController->SetTrackPosition(0, 0.0f));
//V_OKAY(this->lpAnimationController->ResetTime());
//V_OKAY(this->lpAnimationController->SetTrackEnable(0, FALSE));
//SAFE_RELEASE(lpAnimSet);
//D3DXFrameRegisterNamedMatrices(&this->frame1, this->lpAnimationController);
//V_OKAY(this->lpAnimationController->AdvanceTime(0.1f, 0));
hr = S_OK;
return hr;
}
void
VideoManDx9::setWorldViewProjection( const ArnMatrix& matWorld, const ArnMatrix& matView, const ArnMatrix& matProj )
{
setWorldMatrix(matWorld);
setViewMatrix(matView);
setProjectionMatrix(matProj);
this->lpD3DDevice->SetTransform(D3DTS_WORLD, ArnMatrixGetConstDxPtr(getWorldMatrix()));
this->lpD3DDevice->SetTransform(D3DTS_VIEW, ArnMatrixGetConstDxPtr(getViewMatrix()));
this->lpD3DDevice->SetTransform(D3DTS_PROJECTION, ArnMatrixGetConstDxPtr(getProjectionMatrix()));
}
template<typename T1, typename T2> void CopyColorValue(T1& t1, const T2& t2)
{
t1.r = t2.r;
t1.g = t2.g;
t1.b = t2.b;
t1.a = t2.a;
}
template<typename T1, typename T2> void CopyMaterialData(T1& t1, const T2& t2)
{
CopyColorValue(t1.Diffuse, t2.Diffuse);
CopyColorValue(t1.Ambient, t2.Ambient);
CopyColorValue(t1.Specular, t2.Specular);
CopyColorValue(t1.Emissive, t2.Emissive);
t1.Power = t2.Power;
}
void
VideoManDx9::renderSingleMesh( ArnMesh* mesh, const ArnMatrix& globalXform /*= DX_CONSTS::D3DXMAT_IDENTITY*/ )
{
if (mesh->isVisible())
{
unsigned int j;
ArnMatrix zinvert;
ArnMatrixIdentity(&zinvert);
zinvert.m[2][2] = -1; // Z-index
ArnMatrix finalXform = ArnMatrixMultiply(mesh->getAutoLocalXform().transpose(), globalXform);
finalXform = finalXform * zinvert;
GetDev()->SetTransform(D3DTS_WORLD, ArnMatrixGetConstDxPtr(finalXform));
unsigned int subsetCount = mesh->getMeshData().materialCount;
for (j = 0; j < subsetCount; ++j)
{
CONST D3DMATERIAL9 *mtrl = (CONST D3DMATERIAL9 *)mesh->getMaterial(j);
if (mtrl)
{
GetDev()->SetMaterial(mtrl);
ArnMaterial* matNode = mesh->getMaterialNode(j);
ArnTexture* texture = matNode->getD3DTexture(0);
if (texture)
{
// TODO: Texture in DX9
//GetDev()->SetTexture(0, texture->getDxTexture());
}
}
else
{
const char *mtrlName = mesh->getMaterialReferenceName(j);
assert(mtrlName && strlen(mtrlName));
const ArnNode* mtrlNode = mesh->getSceneRoot()->getConstNodeByName( mtrlName );
const ArnMaterial* mtrl2 = dynamic_cast<const ArnMaterial*>(mtrlNode);
assert(mtrl2);
const ArnMaterialData &amd = mtrl2->getD3DMaterialData();
D3DMATERIAL9 m;
CopyMaterialData(m, amd);
GetDev()->SetMaterial(&m);
if (mtrl2->getTextureCount())
{
const ArnTexture* tex = mtrl2->getFirstTexture();
const ArnRenderableObject* renderable = tex->getRenderableObject();
assert(renderable);
// 'Rendering texture' has meaning of 'binding texture'
renderable->render(false);
}
else
{
GetDev()->SetTexture(0, 0);
}
}
// TODO: Mesh render in DX9
assert (mesh->getRenderableObject ());
mesh->getRenderableObject ()->render (0);
}
}
}
void
VideoManDx9::setReshapeCallback( void reshape(int, int) )
{
ARN_THROW_NOT_IMPLEMENTED_ERROR
}
void
VideoManDx9::setKeyboardCallback(void keyboardCB(unsigned char, int, int))
{
ARN_THROW_NOT_IMPLEMENTED_ERROR
}
void
VideoManDx9::clearFrameBuffer()
{
ARN_THROW_NOT_IMPLEMENTED_ERROR
}
void
VideoManDx9::swapFrameBuffer()
{
ARN_THROW_NOT_IMPLEMENTED_ERROR
}
void
VideoManDx9::setupViewMatrix() const
{
ARN_THROW_NOT_IMPLEMENTED_ERROR
}
void
VideoManDx9::SetDrawingModelAtEditor(ModelReader* pMR)
{
this->pDrawingModel = pMR;
}
void VideoManDx9::setLight( int lightId, const ArnLight* light )
{
ARN_THROW_NOT_IMPLEMENTED_ERROR
}
void VideoManDx9::setClearColor_Internal()
{
ARN_THROW_NOT_IMPLEMENTED_ERROR
}
void
VideoManDx9::setClassName(TCHAR* szClassName)
{
_tcscpy(this->szClassName, szClassName);
}
void VideoManDx9::setupProjectionMatrix() const
{
}
void VideoManDx9::setMouseCallback( void mouseCB(int, int, int, int) )
{
ARN_THROW_NOT_IMPLEMENTED_ERROR
}
//////////////////////////////////////////////////////////////////////////
HRESULT
ArnIntersectDx9( LPD3DXMESH pMesh, const ArnVec3* pRayPos, const ArnVec3* pRayDir, bool* pHit, DWORD* pFaceIndex, FLOAT* pU, FLOAT* pV, FLOAT* pDist, ArnGenericBuffer* ppAllHits, DWORD* pCountOfHits )
{
assert(ppAllHits == 0);
//
// TODO: Is exhaustive collision test by ray testing too slow???
//
/*
BOOL hit;
D3DXIntersect(pMesh, pRayPos->getConstDxPtr(), pRayDir->getConstDxPtr(), &hit, pFaceIndex, pU, pV, pDist, 0, pCountOfHits);
*pHit = hit ? true : false;
*/
*pHit = false;
return S_OK;
}
InputMan*
VideoManDx9::GetInputMan()
{
return this->pInputMan;
}
void
VideoManDx9::AttachInputMan(InputMan* inputMan)
{
this->pInputMan = inputMan;
}
| [
"[email protected]"
]
| [
[
[
1,
1536
]
]
]
|
2bea3b51f2e71ec8187f559199185d5607047223 | c5534a6df16a89e0ae8f53bcd49a6417e8d44409 | /trunk/nGENE Proj/DeviceRenderDX9.cpp | cc9c491d93b3448d15c27fbbe0f792f12a644f9e | []
| no_license | svn2github/ngene | b2cddacf7ec035aa681d5b8989feab3383dac012 | 61850134a354816161859fe86c2907c8e73dc113 | refs/heads/master | 2023-09-03T12:34:18.944872 | 2011-07-27T19:26:04 | 2011-07-27T19:26:04 | 78,163,390 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,445 | cpp | /*
---------------------------------------------------------------------------
This source file is part of nGENE Tech.
Copyright (c) 2006- Wojciech Toman
This program is free software.
File: DeviceRenderDX9.cpp
Version: 0.11
---------------------------------------------------------------------------
*/
#include "PrecompiledHeaders.h"
#include "DeviceRenderDX9.h"
#include "DX9Mapping.h"
namespace nGENE
{
// Initialize static members
TypeInfo DeviceRenderDX9::Type(L"DeviceRenderDX9", &DeviceRender::Type);
DeviceRenderDX9::DeviceRenderDX9(IDirect3D9* _d3d,
D3DPRESENT_PARAMETERS& _params,
HWND _hwnd,
PROCESSING_TYPE _type,
bool _profile,
bool _multiThreaded):
m_pD3DDev(NULL),
DeviceRender(_type),
m_Params(_params),
m_pD3D(_d3d),
m_hWnd(_hwnd),
m_bProfile(_profile),
m_bMultiThreaded(_multiThreaded)
{
init();
}
//----------------------------------------------------------------------
DeviceRenderDX9::~DeviceRenderDX9()
{
cleanup();
}
//----------------------------------------------------------------------
void DeviceRenderDX9::init()
{
// Determine DirectX vertex processing method, based on the
// nGENE's one.
dword create = 0;
switch(m_Processing)
{
case PROCESSING_SOFTWARE: create = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
break;
case PROCESSING_MIXED : create = D3DCREATE_MIXED_VERTEXPROCESSING;
break;
case PROCESSING_HARDWARE: create = D3DCREATE_HARDWARE_VERTEXPROCESSING;
break;
case PROCESSING_HARDWARE_PURE: create = D3DCREATE_PUREDEVICE;
break;
default:
Log::log(LET_WARNING, L"nGENE", __WFILE__, __WFUNCTION__, __LINE__,
L"Unknown vertex processing type. Defaulting to mixed.");
create = D3DCREATE_MIXED_VERTEXPROCESSING;
break;
}
// Set multi-threading flag
if(m_bMultiThreaded)
create |= D3DCREATE_MULTITHREADED;
uint adapter = D3DADAPTER_DEFAULT;
D3DDEVTYPE devType = D3DDEVTYPE_HAL;
if(m_bProfile)
{
// Look for PerfHUD
for(uint i = 0; i < m_pD3D->GetAdapterCount(); ++i)
{
D3DADAPTER_IDENTIFIER9 adapterID;
HRESULT result;
result = m_pD3D->GetAdapterIdentifier(i, 0, &adapterID);
if(strstr(adapterID.Description, "PerfHUD") != 0)
{
adapter = i;
devType = D3DDEVTYPE_REF;
break;
}
}
}
// Create device
m_hWnd = (m_hWnd ? m_hWnd : Engine::getSingleton().getTopLevelWndHandle());
HRESULT hr = 0;
if(FAILED(hr = m_pD3D->CreateDevice(adapter,
devType,
m_hWnd,
create,
&m_Params,
&m_pD3DDev)))
{
Log::log(LET_FATAL_ERROR, L"nGENE", __WFILE__, __WFUNCTION__, __LINE__,
L"Creating 3D Device failed: %ls",
DX9Mapping::getDXErrorDescription(hr).c_str());
return;
}
// Store caps to avoid calling this method again
if(FAILED(hr = m_pD3D->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &m_DeviceCaps)))
{
Log::log(LET_FATAL_ERROR, L"nGENE", __WFILE__, __WFUNCTION__, __LINE__,
L"DirectX 9c device caps could not be retrieved: %ls",
DX9Mapping::getDXErrorDescription(hr).c_str());
return;
}
}
//----------------------------------------------------------------------
void DeviceRenderDX9::cleanup()
{
NGENE_RELEASE(m_pD3DDev);
m_pD3D = NULL;
}
//----------------------------------------------------------------------
void DeviceRenderDX9::onDeviceLost()
{
HRESULT res = m_pD3DDev->TestCooperativeLevel();
if(res == D3DERR_DEVICELOST)
{
// Device is lost and could not be reset... so let's wait a while
if(!m_bIsLost)
{
m_bIsLost = true;
Renderer::getSingleton().cleanupDefaultResources();
// Handle event
DeviceEvent evt;
evt.type = DET_LOST;
ListenerRegistry <DeviceEvent>::handleEvent(evt);
Log::log(LET_WARNING, L"nGENE", __WFILE__, __WFUNCTION__,
__LINE__, L"Rendering device lost");
}
Sleep(100);
return;
}
else if(res == D3DERR_DEVICENOTRESET)
{
// Device is lost but we can reset it now
m_bIsLost = false;
HRESULT hr = 0;
// Reset the device itself
if(FAILED(hr = m_pD3DDev->Reset(&m_Params)))
{
Log::log(LET_ERROR, L"nGENE", __WFILE__, __WFUNCTION__,
__LINE__, DX9Mapping::getDXErrorDescription(hr).c_str());
return;
}
// Handle event
DeviceEvent evt;
evt.type = DET_RESET;
ListenerRegistry <DeviceEvent>::handleEvent(evt);
// We have to manually reset frustum as it is not DirectX resource
Engine::getSingleton().resetCameraAndFrustum();
Renderer::getSingleton().resetRenderStates();
Log::log(LET_EVENT, L"nGENE", __WFILE__, __WFUNCTION__,
__LINE__, L"Rendering device successfully restored");
}
}
//----------------------------------------------------------------------
bool DeviceRenderDX9::testCapabilities(nGENE_CAPABILITIES _caps, void* _param)
{
// Find the cap
switch(_caps)
{
case CAPS_MAX_ANISOTROPY: memcpy(_param, &m_DeviceCaps.MaxAnisotropy, sizeof(dword));
break;
case CAPS_MIN_ANISOTROPY: memset(_param, (m_DeviceCaps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC ? true : false),
sizeof(bool));
break;
case CAPS_MAG_ANISOTROPY: memset(_param, (m_DeviceCaps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC ? true : false),
sizeof(bool));
break;
case CAPS_MAX_CLIPPLANES: memcpy(_param, &m_DeviceCaps.MaxUserClipPlanes, sizeof(dword));
break;
case CAPS_MAX_INDICES_COUNT: memcpy(_param, &m_DeviceCaps.MaxVertexIndex, sizeof(dword));
break;
case CAPS_MAX_PRIMITIVES_COUNT: memcpy(_param, &m_DeviceCaps.MaxPrimitiveCount, sizeof(dword));
break;
case CAPS_MAX_LIGHTS: memcpy(_param, &m_DeviceCaps.MaxActiveLights, sizeof(dword));
break;
case CAPS_MAX_RTS: memcpy(_param, &m_DeviceCaps.NumSimultaneousRTs, sizeof(dword));
break;
case CAPS_MAX_TEXTURE_HEIGHT: memcpy(_param, &m_DeviceCaps.MaxTextureHeight, sizeof(dword));
break;
case CAPS_MAX_TEXTURE_WIDTH: memcpy(_param, &m_DeviceCaps.MaxTextureWidth, sizeof(dword));
break;
case CAPS_VERTEX_SHADER: strcpy((char*)_param, D3DXGetVertexShaderProfile(m_pD3DDev));
break;
case CAPS_GEOMETRY_SHADER:strcpy((char*)_param, "no support");
break;
case CAPS_PIXEL_SHADER: strcpy((char*)_param, D3DXGetPixelShaderProfile(m_pD3DDev));
break;
default:
// Cap does not exist
Log::log(LET_WARNING, L"nGENE", __WFILE__, __WFUNCTION__, __LINE__,
L"Unknown or unused device cap: %d", static_cast<int>(_caps));
break;
}
return true;
}
//----------------------------------------------------------------------
void DeviceRenderDX9::reset(D3DPRESENT_PARAMETERS* _params)
{
m_Params = *_params;
m_pD3DDev->Reset(&m_Params);
}
//----------------------------------------------------------------------
void DeviceRenderDX9::beginRender()
{
m_pD3DDev->BeginScene();
}
//----------------------------------------------------------------------
void DeviceRenderDX9::endRender()
{
m_pD3DDev->EndScene();
m_pD3DDev->Present(NULL, NULL, NULL, NULL);
}
//----------------------------------------------------------------------
}
| [
"Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57"
]
| [
[
[
1,
254
]
]
]
|
268ab58c3b8f28e9cf370cf1e62334080eac670b | d5f5a6b9fb6885b72bec1ee733ba73abcc1c21b8 | /TrayIcon.h | b42b61ca27ab201a32f5c3e2934f97321660c481 | []
| no_license | congchenutd/mailchecker | 8e99e080e670a8a1a97fab757955a9d8e7250296 | fbfd2dc5b9b03b1e7887e5864cfdd9cd90fbdf50 | refs/heads/master | 2021-01-18T14:05:07.857597 | 2011-03-07T23:54:11 | 2011-03-07T23:54:11 | 32,358,817 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 897 | h | #ifndef TRAYICON_H
#define TRAYICON_H
#include <QSystemTrayIcon>
#include <QTimer>
#include <QSet>
class MailCheckerDlg;
class QAction;
class Connection;
class NotificationWindow;
class TrayIcon : public QSystemTrayIcon
{
Q_OBJECT
public:
TrayIcon(QObject* parent = 0);
private slots:
void onTrayActivated(QSystemTrayIcon::ActivationReason reason);
void onCheckAll();
void onTellMeAgain();
void onOpenApp();
void onCheckDone();
void onNewMailCountChanged(int count);
void onUpdateAnimation();
private:
void alert();
void setHasNewMail(bool has);
private:
MailCheckerDlg* dlg;
QAction* actionCheck;
QAction* actionTellMeAgain;
QAction* actionApplication;
QAction* actionSettings;
QAction* actionExit;
QTimer timer;
QTimer animationTimer;
NotificationWindow* notification;
QSet<Connection*> threads;
};
#endif // TRAYICON_H
| [
"congchenutd@11d43eb3-d973-da56-5163-f7c915874638"
]
| [
[
[
1,
46
]
]
]
|
dc27cb2b85f17742f7ee801028b89e0fdfd5480c | b47e38256ce41d17fa8cbc7cbb46f8c4394b1e79 | /BQhistory.h | 34324fbc8362ef667b24228377c3d519ba8a4870 | []
| no_license | timothyha/ppc-bq | b54162c6e117d6df9849054e75bc7da06d630c1a | 144c3a00bd130fc34831f530e2c7207edaa8ee7e | refs/heads/master | 2020-05-16T14:25:31.426285 | 2010-09-04T06:03:47 | 2010-09-04T06:03:47 | 32,114,289 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 989 | h | #include <afx.h>
#include <atlstr.h>
class BQposition{
public:
char* moduleShortName;
int bookAbsIndex;
int chapter;
int scroll;
CString path;
int isSet;
BQposition(){
isSet = false;
};
void set(const char*mod, int bk, int ch, int scr){
if(isSet){
delete moduleShortName;
}
moduleShortName = new char[(strlen(mod)+1)*sizeof(char)];
strcpy(moduleShortName, mod);
bookAbsIndex = bk;
chapter = ch;
scroll = scr;
isSet = true;
};
~BQposition(){
if(isSet)
delete moduleShortName;
};
};
class BQhistory{
public:
int count;
int allocated;
int position;
int limit;
BQposition**list;
public:
BQhistory(){
count = 0;
allocated = 0;
position = -1;
limit=100;
};
~BQhistory(){
for(int i=0;i<count;i++)
delete list[i];
delete list;
};
int load(CString file);
int save(int depth);
int back(void);
int forward(void);
int insert(const char*mod, int bk, int ch, int scr);
};
| [
"nuh.ubf@e3e9064e-3af0-11de-9146-fdf1833cc731"
]
| [
[
[
1,
55
]
]
]
|
f50e5786438f4e2efc33b2dde0ea25c4abe073a9 | ab41c2c63e554350ca5b93e41d7321ca127d8d3a | /glm/core/type_vec3.inl | d0360e751e169ad85b965189af74065a4c624e26 | []
| no_license | burner/e3rt | 2dc3bac2b7face3b1606ee1430e7ecfd4523bf2e | 775470cc9b912a8c1199dd1069d7e7d4fc997a52 | refs/heads/master | 2021-01-11T08:08:00.665300 | 2010-04-26T11:42:42 | 2010-04-26T11:42:42 | 337,021 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,763 | inl | ///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2008-08-22
// Updated : 2008-09-09
// Licence : This source is under MIT License
// File : glm/core/type_tvec3.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm
{
namespace detail
{
template <typename valType>
typename tvec3<valType>::size_type tvec3<valType>::value_size()
{
return typename tvec3<valType>::size_type(3);
}
template <typename valType>
bool tvec3<valType>::is_vector()
{
return true;
}
//////////////////////////////////////
// Accesses
template <typename valType>
inline valType& tvec3<valType>::operator[](typename tvec3<valType>::size_type i)
{
assert( i >= typename tvec3<valType>::size_type(0) &&
i < tvec3<valType>::value_size());
return (&x)[i];
}
template <typename valType>
inline valType const & tvec3<valType>::operator[](typename tvec3<valType>::size_type i) const
{
assert( i >= typename tvec3<valType>::size_type(0) &&
i < tvec3<valType>::value_size());
return (&x)[i];
}
//////////////////////////////////////
// Implicit basic constructors
template <typename valType>
inline tvec3<valType>::tvec3() :
x(valType(0)),
y(valType(0)),
z(valType(0))
{}
template <typename valType>
inline tvec3<valType>::tvec3(const tvec3<valType>& v) :
x(v.x),
y(v.y),
z(v.z)
{}
//////////////////////////////////////
// Explicit basic constructors
template <typename valType>
inline tvec3<valType>::tvec3(valType s) :
x(s),
y(s),
z(s)
{}
template <typename valType>
inline tvec3<valType>::tvec3(valType s0, valType s1, valType s2) :
x(s0),
y(s1),
z(s2)
{}
//////////////////////////////////////
// Swizzle constructors
template <typename valType>
inline tvec3<valType>::tvec3(const tref3<valType>& r) :
x(r.x),
y(r.y),
z(r.z)
{}
//////////////////////////////////////
// Convertion scalar constructors
template <typename valType>
template <typename U>
inline tvec3<valType>::tvec3(U x) :
x(valType(x)),
y(valType(x)),
z(valType(x))
{}
template <typename valType>
template <typename A, typename B, typename C>
inline tvec3<valType>::tvec3(A x, B y, C z) :
x(valType(x)),
y(valType(y)),
z(valType(z))
{}
//////////////////////////////////////
// Convertion vector constructors
template <typename valType>
template <typename A, typename B>
inline tvec3<valType>::tvec3(const tvec2<A>& v, B s) :
x(valType(v.x)),
y(valType(v.y)),
z(valType(s))
{}
template <typename valType>
template <typename A, typename B>
inline tvec3<valType>::tvec3(A s, const tvec2<B>& v) :
x(valType(s)),
y(valType(v.x)),
z(valType(v.y))
{}
template <typename valType>
template <typename U>
inline tvec3<valType>::tvec3(const tvec3<U>& v) :
x(valType(v.x)),
y(valType(v.y)),
z(valType(v.z))
{}
template <typename valType>
template <typename U>
inline tvec3<valType>::tvec3(const tvec4<U>& v) :
x(valType(v.x)),
y(valType(v.y)),
z(valType(v.z))
{}
//////////////////////////////////////
// Unary arithmetic operators
template <typename valType>
inline tvec3<valType>& tvec3<valType>::operator= (const tvec3<valType>& v)
{
this->x = v.x;
this->y = v.y;
this->z = v.z;
return *this;
}
template <typename valType>
inline tvec3<valType>& tvec3<valType>::operator+=(valType const & s)
{
this->x += s;
this->y += s;
this->z += s;
return *this;
}
template <typename valType>
inline tvec3<valType>& tvec3<valType>::operator+=(const tvec3<valType>& v)
{
this->x += v.x;
this->y += v.y;
this->z += v.z;
return *this;
}
template <typename valType>
inline tvec3<valType>& tvec3<valType>::operator-=(valType const & s)
{
this->x -= s;
this->y -= s;
this->z -= s;
return *this;
}
template <typename valType>
inline tvec3<valType>& tvec3<valType>::operator-=(const tvec3<valType>& v)
{
this->x -= v.x;
this->y -= v.y;
this->z -= v.z;
return *this;
}
template <typename valType>
inline tvec3<valType>& tvec3<valType>::operator*=(valType const & s)
{
this->x *= s;
this->y *= s;
this->z *= s;
return *this;
}
template <typename valType>
inline tvec3<valType>& tvec3<valType>::operator*=(const tvec3<valType>& v)
{
this->x *= v.x;
this->y *= v.y;
this->z *= v.z;
return *this;
}
template <typename valType>
inline tvec3<valType>& tvec3<valType>::operator/=(valType const & s)
{
this->x /= s;
this->y /= s;
this->z /= s;
return *this;
}
template <typename valType>
inline tvec3<valType>& tvec3<valType>::operator/=(const tvec3<valType>& v)
{
this->x /= v.x;
this->y /= v.y;
this->z /= v.z;
return *this;
}
template <typename valType>
inline tvec3<valType>& tvec3<valType>::operator++()
{
++this->x;
++this->y;
++this->z;
return *this;
}
template <typename valType>
inline tvec3<valType>& tvec3<valType>::operator--()
{
--this->x;
--this->y;
--this->z;
return *this;
}
//////////////////////////////////////
// Unary bit operators
template <typename valType>
inline tvec3<valType>& tvec3<valType>::operator%=(valType const & s)
{
this->x %= s;
this->y %= s;
this->z %= s;
return *this;
}
template <typename valType>
inline tvec3<valType>& tvec3<valType>::operator%=(const tvec3<valType>& v)
{
this->x %= v.x;
this->y %= v.y;
this->z %= v.z;
return *this;
}
template <typename valType>
inline tvec3<valType>& tvec3<valType>::operator&=(valType const & s)
{
this->x &= s;
this->y &= s;
this->z &= s;
return *this;
}
template <typename valType>
inline tvec3<valType>& tvec3<valType>::operator&=(const tvec3<valType>& v)
{
this->x &= v.x;
this->y &= v.y;
this->z &= v.z;
return *this;
}
template <typename valType>
inline tvec3<valType>& tvec3<valType>::operator|=(valType const & s)
{
this->x |= s;
this->y |= s;
this->z |= s;
return *this;
}
template <typename valType>
inline tvec3<valType>& tvec3<valType>::operator|=(const tvec3<valType>& v)
{
this->x |= v.x;
this->y |= v.y;
this->z |= v.z;
return *this;
}
template <typename valType>
inline tvec3<valType>& tvec3<valType>::operator^=(valType const & s)
{
this->x ^= s;
this->y ^= s;
this->z ^= s;
return *this;
}
template <typename valType>
inline tvec3<valType>& tvec3<valType>::operator^=(const tvec3<valType>& v)
{
this->x ^= v.x;
this->y ^= v.y;
this->z ^= v.z;
return *this;
}
template <typename valType>
inline tvec3<valType>& tvec3<valType>::operator<<=(valType const & s)
{
this->x <<= s;
this->y <<= s;
this->z <<= s;
return *this;
}
template <typename valType>
inline tvec3<valType>& tvec3<valType>::operator<<=(const tvec3<valType>& v)
{
this->x <<= v.x;
this->y <<= v.y;
this->z <<= v.z;
return *this;
}
template <typename valType>
inline tvec3<valType>& tvec3<valType>::operator>>=(valType const & s)
{
this->x >>= s;
this->y >>= s;
this->z >>= s;
return *this;
}
template <typename valType>
inline tvec3<valType>& tvec3<valType>::operator>>=(const tvec3<valType>& v)
{
this->x >>= v.x;
this->y >>= v.y;
this->z >>= v.z;
return *this;
}
//////////////////////////////////////
// Swizzle operators
template <typename valType>
inline valType tvec3<valType>::swizzle(comp x) const
{
return (*this)[x];
}
template <typename valType>
inline tvec2<valType> tvec3<valType>::swizzle(comp x, comp y) const
{
return tvec2<valType>(
(*this)[x],
(*this)[y]);
}
template <typename valType>
inline tvec3<valType> tvec3<valType>::swizzle(comp x, comp y, comp z) const
{
return tvec3<valType>(
(*this)[x],
(*this)[y],
(*this)[z]);
}
template <typename valType>
inline tvec4<valType> tvec3<valType>::swizzle(comp x, comp y, comp z, comp w) const
{
return tvec4<valType>(
(*this)[x],
(*this)[y],
(*this)[z],
(*this)[w]);
}
template <typename valType>
inline tref3<valType> tvec3<valType>::swizzle(comp x, comp y, comp z)
{
return tref3<valType>(
(*this)[x],
(*this)[y],
(*this)[z]);
}
//////////////////////////////////////
// Binary arithmetic operators
template <typename T>
inline tvec3<T> operator+ (const tvec3<T>& v, T const & s)
{
return tvec3<T>(
v.x + s,
v.y + s,
v.z + s);
}
template <typename T>
inline tvec3<T> operator+ (T const & s, const tvec3<T>& v)
{
return tvec3<T>(
s + v.x,
s + v.y,
s + v.z);
}
template <typename T>
inline tvec3<T> operator+ (const tvec3<T>& v1, const tvec3<T>& v2)
{
return tvec3<T>(
v1.x + v2.x,
v1.y + v2.y,
v1.z + v2.z);
}
//operator-
template <typename T>
inline tvec3<T> operator- (const tvec3<T>& v, T const & s)
{
return tvec3<T>(
v.x - s,
v.y - s,
v.z - s);
}
template <typename T>
inline tvec3<T> operator- (T const & s, const tvec3<T>& v)
{
return tvec3<T>(
s - v.x,
s - v.y,
s - v.z);
}
template <typename T>
inline tvec3<T> operator- (const tvec3<T>& v1, const tvec3<T>& v2)
{
return tvec3<T>(
v1.x - v2.x,
v1.y - v2.y,
v1.z - v2.z);
}
//operator*
template <typename T>
inline tvec3<T> operator* (const tvec3<T>& v, T const & s)
{
return tvec3<T>(
v.x * s,
v.y * s,
v.z * s);
}
template <typename T>
inline tvec3<T> operator* (T const & s, const tvec3<T>& v)
{
return tvec3<T>(
s * v.x,
s * v.y,
s * v.z);
}
template <typename T>
inline tvec3<T> operator* (const tvec3<T>& v1, const tvec3<T> & v2)
{
return tvec3<T>(
v1.x * v2.x,
v1.y * v2.y,
v1.z * v2.z);
}
//operator/
template <typename T>
inline tvec3<T> operator/ (const tvec3<T>& v, T const & s)
{
return tvec3<T>(
v.x / s,
v.y / s,
v.z / s);
}
template <typename T>
inline tvec3<T> operator/ (T const & s, const tvec3<T>& v)
{
return tvec3<T>(
s / v.x,
s / v.y,
s / v.z);
}
template <typename T>
inline tvec3<T> operator/ (const tvec3<T>& v1, const tvec3<T>& v2)
{
return tvec3<T>(
v1.x / v2.x,
v1.y / v2.y,
v1.z / v2.z);
}
// Unary constant operators
template <typename T>
inline tvec3<T> operator- (const tvec3<T>& v)
{
return tvec3<T>(
-v.x,
-v.y,
-v.z);
}
template <typename T>
inline tvec3<T> operator++ (const tvec3<T>& v, int)
{
return tvec3<T>(
v.x + T(1),
v.y + T(1),
v.z + T(1));
}
template <typename T>
inline tvec3<T> operator-- (const tvec3<T>& v, int)
{
return tvec3<T>(
v.x - T(1),
v.y - T(1),
v.z - T(1));
}
//////////////////////////////////////
// Binary bit operators
template <typename T>
inline tvec3<T> operator% (const tvec3<T>& v, T const & s)
{
return tvec3<T>(
v.x % s,
v.y % s,
v.z % s);
}
template <typename T>
inline tvec3<T> operator% (T const & s, const tvec3<T>& v)
{
return tvec3<T>(
s % v.x,
s % v.y,
s % v.z);
}
template <typename T>
inline tvec3<T> operator% (const tvec3<T>& v1, const tvec3<T>& v2)
{
return tvec3<T>(
v1.x % v2.x,
v1.y % v2.y,
v1.z % v2.z);
}
template <typename T>
inline tvec3<T> operator& (const tvec3<T>& v, T const & s)
{
return tvec3<T>(
v.x & s,
v.y & s,
v.z & s);
}
template <typename T>
inline tvec3<T> operator& (T const & s, const tvec3<T>& v)
{
return tvec3<T>(
s & v.x,
s & v.y,
s & v.z);
}
template <typename T>
inline tvec3<T> operator& (const tvec3<T>& v1, const tvec3<T>& v2)
{
return tvec3<T>(
v1.x & v2.x,
v1.y & v2.y,
v1.z & v2.z);
}
template <typename T>
inline tvec3<T> operator| (const tvec3<T>& v, T const & s)
{
return tvec3<T>(
v.x | s,
v.y | s,
v.z | s);
}
template <typename T>
inline tvec3<T> operator| (T const & s, const tvec3<T>& v)
{
return tvec3<T>(
s | v.x,
s | v.y,
s | v.z);
}
template <typename T>
inline tvec3<T> operator| (const tvec3<T>& v1, const tvec3<T>& v2)
{
return tvec3<T>(
v1.x | v2.x,
v1.y | v2.y,
v1.z | v2.z);
}
template <typename T>
inline tvec3<T> operator^ (const tvec3<T>& v, T const & s)
{
return tvec3<T>(
v.x ^ s,
v.y ^ s,
v.z ^ s);
}
template <typename T>
inline tvec3<T> operator^ (T const & s, const tvec3<T>& v)
{
return tvec3<T>(
s ^ v.x,
s ^ v.y,
s ^ v.z);
}
template <typename T>
inline tvec3<T> operator^ (const tvec3<T>& v1, const tvec3<T>& v2)
{
return tvec3<T>(
v1.x ^ v2.x,
v1.y ^ v2.y,
v1.z ^ v2.z);
}
template <typename T>
inline tvec3<T> operator<< (const tvec3<T>& v, T const & s)
{
return tvec3<T>(
v.x << s,
v.y << s,
v.z << s);
}
template <typename T>
inline tvec3<T> operator<< (T const & s, const tvec3<T>& v)
{
return tvec3<T>(
s << v.x,
s << v.y,
s << v.z);
}
template <typename T>
inline tvec3<T> operator<< (const tvec3<T>& v1, const tvec3<T>& v2)
{
return tvec3<T>(
v1.x << v2.x,
v1.y << v2.y,
v1.z << v2.z);
}
template <typename T>
inline tvec3<T> operator>> (const tvec3<T>& v, T const & s)
{
return tvec3<T>(
v.x >> s,
v.y >> s,
v.z >> s);
}
template <typename T>
inline tvec3<T> operator>> (T const & s, const tvec3<T>& v)
{
return tvec3<T>(
s >> v.x,
s >> v.y,
s >> v.z);
}
template <typename T>
inline tvec3<T> operator>> (const tvec3<T>& v1, const tvec3<T>& v2)
{
return tvec3<T>(
v1.x >> v2.x,
v1.y >> v2.y,
v1.z >> v2.z);
}
template <typename T>
inline tvec3<T> operator~ (const tvec3<T>& v)
{
return tvec3<T>(
~v.x,
~v.y,
~v.z);
}
//////////////////////////////////////
// tref definition
template <typename T>
tref3<T>::tref3(T& x, T& y, T& z) :
x(x),
y(y),
z(z)
{}
template <typename T>
tref3<T>::tref3(const tref3<T>& r) :
x(r.x),
y(r.y),
z(r.z)
{}
template <typename T>
tref3<T>::tref3(const tvec3<T>& v) :
x(v.x),
y(v.y),
z(v.z)
{}
template <typename T>
tref3<T>& tref3<T>::operator= (const tref3<T>& r)
{
x = r.x;
y = r.y;
z = r.z;
return *this;
}
template <typename T>
tref3<T>& tref3<T>::operator= (const tvec3<T>& v)
{
x = v.x;
y = v.y;
z = v.z;
return *this;
}
}//namespace detail
}//namespace glm
| [
"[email protected]"
]
| [
[
[
1,
762
]
]
]
|
217f38757812c6f53228797d7e62d5f4fc5faea0 | 5e72c94a4ea92b1037217e31a66e9bfee67f71dd | /older/tptest5/src/TestPanel.h | dad7ddaa9d95dfaf59bd805eb4e78e961f150665 | []
| no_license | stein1/bbk | 1070d2c145e43af02a6df14b6d06d9e8ed85fc8a | 2380fc7a2f5bcc9cb2b54f61e38411468e1a1aa8 | refs/heads/master | 2021-01-17T23:57:37.689787 | 2011-05-04T14:50:01 | 2011-05-04T14:50:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 842 | h | #pragma once
#include "main.h"
class TestPanel : public wxPanel
{
public:
TestPanel(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
~TestPanel(void);
virtual bool ExecuteTest(void) = 0;
void PostTest(bool abort = false, bool hidewindow = false);
void PreStartTest(void);
void OnStartTest( wxCommandEvent& event );
void SetSBToolTip( wxString label );
void GetListColumn( wxListCtrl *list, int index, int icol, wxString &out );
void CopyToClipboard( wxString &text );
void GetListAsText( wxListCtrl *list, wxString &text );
void OnResultListKeyDown(wxListEvent& event);
virtual void RefreshSettingsList(void) = 0;
protected:
wxButton *m_StartButton;
wxBoxSizer *m_SizerMain;
wxListCtrl *m_ListResult;
wxListCtrl *m_ListSettings;
};
| [
"[email protected]"
]
| [
[
[
1,
28
]
]
]
|
5e8d57773a544edd04d8f15b0d4960089c32be9b | e82b022f6278b217b0aaa0ad47fccec84ba028c3 | /madivs/madivs/gearcmdw.cpp | 459029fb74c6b1d10b8ef6392198f53a95e0b828 | []
| no_license | BackupTheBerlios/worldspace | 000a42ceaa49f536e619c7c3ed1d254c8507283a | dc22f6971968f0d210f1c72ad4fa1b5bbd83c929 | refs/heads/master | 2021-01-01T16:26:03.508426 | 2008-02-14T22:43:18 | 2008-02-14T22:43:18 | 40,072,255 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,607 | cpp | //=======================================================================
//@V@:Note: This file generated by vgen V1.04 (10:25:37 22 Jun 1998).
// gearcmdw.cpp: Source for gearCmdWindow class
//=======================================================================
#include <v/vnotice.h> // for vNoticeDialog
#include <v/vkeys.h> // to map keysi
#include <v/vutil.h>
#include <v/vfilesel.h>
#include "gearcmdw.h" // our header
#include "globales.h"
#include "plugins.h"
static char *filter[]={
"*","md2",0};
plugin_info *plugins;
extern modelo *model;
// Start defines for the main window with 100
//@V@:BeginIDs
enum {
m_FirstCmd = 100, // Dummy Command
cmdAuxTimer, // AuxTimer
blkLast // Last item
};
//@V@:EndIDs
//@V@:BeginPulldownMenu FileMenu
static vMenu FileMenu[] =
{
{"&Importar...", M_Open, isSens, notChk, noKeyLbl, noKey, noSub},
{"&Exportar", M_SaveAs, isSens, notChk, noKeyLbl, noKey, noSub},
{"&Importar textura...", M_Open_T, isSens, notChk, noKeyLbl, noKey, noSub},
{"-", M_Line, notSens, notChk, noKeyLbl, noKey, noSub},
{"E&xit", M_Exit, isSens, notChk, noKeyLbl, noKey, noSub},
{NULL}
};
//@V@:EndPulldownMenu
//@V@:BeginPulldownMenu EditMenu
static vMenu VerMenu[] =
{
{"&Wireframe", M_T_Wire, isSens, notChk, noKeyLbl, noKey, noSub},
{"&Textura", M_T_Tex, isSens, notChk, noKeyLbl, noKey, noSub},
{NULL}
};
//@V@:EndPulldownMenu
//@V@:BeginMenu StandardMenu
static vMenu StandardMenu[] =
{
{"&Fichero", M_Ficheros, isSens, notUsed, notUsed, noKey, &FileMenu[0]},
{"&Ver", M_Ver, isSens, notUsed, notUsed, noKey, &VerMenu[0]},
{NULL}
};
//@V@:EndMenu
//@V@:BeginCmdPane ToolBar
static CommandObject ToolBar[] =
{
{C_Button,M_Exit,0,"Salir",NoList,CA_None,isSens,NoFrame,0,0},
{C_Button,M_T_Wire,0,"Wireframe",NoList,CA_None,isSens,NoFrame,0,0},
{C_Button,M_T_Tex,0,"Textura",NoList,CA_None,isSens,NoFrame,0,0},
{C_EndOfList,0,0,0,0,CA_None,0,0,0}
};
//@V@:EndCmdPane
//====================>>> gearAuxTimer::TimerTick <<<====================
void gearAuxTimer::TimerTick()
{
cmdw->WindowCommand(cmdAuxTimer, cmdAuxTimer, C_Button); // update clock
}
//====================>>> gearCmdWindow::gearCmdWindow <<<====================
gearCmdWindow::gearCmdWindow(char* name, int width, int height) :
vCmdWindow(name, width, height)
{
UserDebug1(Constructor,"gearCmdWindow::gearCmdWindow(%s) Constructor\n",name)
// The Menu Bar
gearMenu = new vMenuPane(StandardMenu);
AddPane(gearMenu);
// The Command Pane
gearCmdPane = new vCommandPane(ToolBar);
AddPane(gearCmdPane);
// The Canvas
gearCanvas = new gearOGLCanvasPane;
AddPane(gearCanvas);
_auxTimer = new gearAuxTimer(this); // create aux timer
_auxTimer->TimerSet(30); // 30 ms second intervals
// Associated dialogs
buscar_plugins("plugins",plugins);
// Show Window
ShowWindow();
WindowCommand(cmdAuxTimer,cmdAuxTimer,C_Button); // update clock
}
//====================>>> gearCmdWindow::~gearCmdWindow <<<====================
gearCmdWindow::~gearCmdWindow()
{
UserDebug(Destructor,"gearCmdWindow::~gearCmdWindow() destructor\n")
// Now put a delete for each new in the constructor.
delete gearMenu;
delete gearCanvas;
delete gearCmdPane;
_auxTimer->TimerStop(); // end it
delete _auxTimer; // free it
}
//====================>>> gearCmdWindow::KeyIn <<<====================
void gearCmdWindow::KeyIn(vKey keysym, unsigned int shift)
{
vBeep();
vCmdWindow::KeyIn(keysym, shift);
}
//====================>>> gearCmdWindow::WindowCommand <<<====================
void gearCmdWindow::WindowCommand(ItemVal id, ItemVal val, CmdType cType)
{
// Default: route menu and toolbar commands here
UserDebug1(CmdEvents,"gearCmdWindow:WindowCommand(%d)\n",id)
switch (id)
{
//@V@:Case M_Open
case M_Open:
{
char fich_imp[1024]="";
vFileSelect importar(this);
int indice=0;
importar.FileSelect("Importar fichero...",fich_imp,1023,extensiones,indice);
printf("%d->%s\n",indice,fich_imp);
importar_modelo(indice,fich_imp);
break;
} //@V@:EndCase
//@V@:Case M_Save
case M_Save:
{
vNoticeDialog note(this);
note.Notice("Save");
break;
} //@V@:EndCase
//@V@:Case M_SaveAs
case M_SaveAs:
{
vNoticeDialog note(this);
note.Notice("Save As");
break;
} //@V@:EndCase
//@V@:Case M_CloseFile
case M_CloseFile:
{
vNoticeDialog note(this);
note.Notice("Close File");
break;
} //@V@:EndCase
//@V@:Case M_Exit
case M_Exit:
{
theApp->Exit();
break;
} //@V@:EndCase
//@V@:Case M_Cut
case M_Cut:
{
vNoticeDialog note(this);
note.Notice("Cut");
break;
} //@V@:EndCase
//@V@:Case M_Copy
case M_Copy:
{
vNoticeDialog note(this);
note.Notice("Copy");
break;
} //@V@:EndCase
//@V@:Case M_Paste
case M_Paste:
{
vNoticeDialog note(this);
note.Notice("Paste");
break;
} //@V@:EndCase
//@V@:Case auxTimer
case cmdAuxTimer: // Event from aux timer
{
gearCanvas->TimerAnimate();
break;
} //@V@:EndCase
default: // route unhandled commands up
{
vCmdWindow::WindowCommand(id, val, cType);
break;
}
}
}
| [
"neuralgya"
]
| [
[
[
1,
227
]
]
]
|
12d2a182eb254bcf07c08a3963f7a23070013fd2 | 8d3bc2c1c82dee5806c4503dd0fd32908c78a3a9 | /samples/entity/property.h | 1b239925c4bb2f1e6c3d2744491b31b6d5343940 | []
| no_license | ryzom/werewolf2 | 2645d169381294788bab9a152c4071061063a152 | a868205216973cf4d1c7d2a96f65f88360177b69 | refs/heads/master | 2020-03-22T20:08:32.123283 | 2010-03-05T21:43:32 | 2010-03-05T21:43:32 | 140,575,749 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,901 | h | #ifndef WW_PROPERTY_H
#define WW_PROPERTY_H
#include <string>
#include <nel/misc/smart_ptr.h>
#include "iproperty.h"
template<class T>
class PropertyData : public NLMISC::CRefCount {
public:
T value;
std::string name;
bool dirty;
//CL_Signal_v2<const T&, const T&> valueChanged;
};
template<class T>
class Property : public IProperty {
public:
Property() { }
Property(const Property ©) : data(copy.data) { }
Property(const std::string &name) : data(new PropertyData<T>()) {
data->name = name;
data->dirty = false;
}
virtual ~Property() { }
void Set(const T& value) {
if(data->value != value) {
T oldValue = data->value;
data->value = value;
data->dirty = true;
//data->valueChanged.invoke(oldValue, value);
}
}
const T& Get() const { return data->value; }
virtual const std::string &GetName() const { return data->name; }
virtual bool IsNull() const { return data == NULL; }
virtual bool IsDirty() const { return data->dirty; }
virtual void ClearDirty() { data->dirty = false; }
//virtual std::string ToString() const { return TypeSerializer::ToString(data->value); }
//virtual void SetFromString(const T_String &value) { TypeSerializer::FromString(value, data->value); }
//virtual int GetTypeId() const { return TypeSerializer::GetTypeId(data->value); }
//CL_Signal_v2<const T&, const T&> &ValueChanged() { return data->valueChanged; }
Property<T> operator= (const Property<T>& rhs);
Property<T> operator= (const T& rhs);
Property<T> operator+= (const Property<T>& rhs);
Property<T> operator+= (const T& rhs);
Property<T> operator-= (const Property<T>& rhs);
Property<T> operator-= (const T& rhs);
bool operator== (const Property<T>& rhs);
bool operator== (const T& rhs);
bool operator!= (const Property<T>& rhs);
bool operator!= (const T& rhs);
bool operator> (const Property<T>& rhs);
bool operator> (const T& rhs);
bool operator< (const Property<T>& rhs);
bool operator< (const T& rhs);
operator T() const { return data->value; }
private:
NLMISC::CSmartPtr< PropertyData<T> > data;
};
template<class T>
inline Property<T> Property<T>::operator =(const Property<T> &rhs) {
data = rhs.data;
return *this;
}
template<class T>
inline Property<T> Property<T>::operator =(const T &rhs) {
Set(rhs);
return *this;
}
template<class T>
inline Property<T> Property<T>::operator +=(const Property<T> &rhs) {
Set(data->value + rhs.data->value);
return *this;
}
template<class T>
inline Property<T> Property<T>::operator +=(const T &rhs) {
Set(data->value + rhs);
return *this;
}
template<class T>
inline Property<T> Property<T>::operator -=(const Property<T> &rhs) {
Set(data->value - rhs.data->value);
return *this;
}
template<class T>
inline Property<T> Property<T>::operator -=(const T &rhs) {
Set(data->value - rhs);
return *this;
}
template<class T>
inline bool Property<T>::operator ==(const Property<T> &rhs) {
return data == rhs.data;
}
template<class T>
inline bool Property<T>::operator ==(const T &rhs) {
return (data->value == rhs);
}
template<class T>
inline bool Property<T>::operator !=(const Property<T> &rhs) {
return data != rhs.data;
}
template<class T>
inline bool Property<T>::operator !=(const T &rhs) {
return (data->value != rhs);
}
template<class T>
inline bool Property<T>::operator >(const Property<T> &rhs) {
return (data->value > rhs.data->value);
}
template<class T>
inline bool Property<T>::operator >(const T &rhs) {
return (data->value > rhs);
}
template<class T>
inline bool Property<T>::operator <(const Property<T> &rhs) {
return (data->value < rhs.data->value);
}
template<class T>
inline bool Property<T>::operator <(const T &rhs) {
return (data->value < rhs);
}
#endif // WW_PROPERTY_H | [
"[email protected]"
]
| [
[
[
1,
162
]
]
]
|
ff1594fe791a4105c57a6a0de1fc3f3c4517d031 | f8b364974573f652d7916c3a830e1d8773751277 | /emulator/allegrex/instructions/SVQ.h | 629489148e89851f4dba30d252f48d3144aa7616 | []
| no_license | lemmore22/pspe4all | 7a234aece25340c99f49eac280780e08e4f8ef49 | 77ad0acf0fcb7eda137fdfcb1e93a36428badfd0 | refs/heads/master | 2021-01-10T08:39:45.222505 | 2009-08-02T11:58:07 | 2009-08-02T11:58:07 | 55,047,469 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,028 | h | template< > struct AllegrexInstructionTemplate< 0xf8000000, 0xfc000002 > : AllegrexInstructionUnknown
{
static AllegrexInstructionTemplate &self()
{
static AllegrexInstructionTemplate insn;
return insn;
}
static AllegrexInstruction *get_instance()
{
return &AllegrexInstructionTemplate::self();
}
virtual AllegrexInstruction *instruction(u32 opcode)
{
return this;
}
virtual char const *opcode_name()
{
return "SVQ";
}
virtual void interpret(Processor &processor, u32 opcode);
virtual void disassemble(u32 address, u32 opcode, char *opcode_name, char *operands, char *comment);
protected:
AllegrexInstructionTemplate() {}
};
typedef AllegrexInstructionTemplate< 0xf8000000, 0xfc000002 >
AllegrexInstruction_SVQ;
namespace Allegrex
{
extern AllegrexInstruction_SVQ &SVQ;
}
#ifdef IMPLEMENT_INSTRUCTION
AllegrexInstruction_SVQ &Allegrex::SVQ =
AllegrexInstruction_SVQ::self();
#endif
| [
"[email protected]"
]
| [
[
[
1,
41
]
]
]
|
f5870d0612d870ec313ade6cde1eb5800fe271d5 | f55665c5faa3d79d0d6fe91fcfeb8daa5adf84d0 | /GameSDK/SLB/src/ClassInfo.cpp | dd2473e9518f8d994330558bf32ad86e7ba83c82 | []
| no_license | lxinhcn/starworld | 79ed06ca49d4064307ae73156574932d6185dbab | 86eb0fb8bd268994454b0cfe6419ffef3fc0fc80 | refs/heads/master | 2021-01-10T07:43:51.858394 | 2010-09-15T02:38:48 | 2010-09-15T02:38:48 | 47,859,019 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 14,631 | cpp | /*
SLB - Simple Lua Binder
Copyright (C) 2007 Jose L. Hidalgo Valiño (PpluX)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Jose L. Hidalgo (www.pplux.com)
[email protected]
*/
#include <SLB/ClassInfo.hpp>
#include <SLB/Manager.hpp>
#include <SLB/Hybrid.hpp>
#include <SLB/Debug.hpp>
#include <SLB/util.hpp>
namespace SLB {
ClassInfo::ClassInfo(const std::type_info &ti) :
Namespace(true),
_typeid(0),
_name(""),
_instanceFactory(0),
_isHybrid(false)
{
SLB_DEBUG_CALL;
_typeid = &ti;
Manager::getInstance().addClass(this);
_name = _typeid->name();
}
ClassInfo::~ClassInfo()
{
SLB_DEBUG_CALL;
delete _instanceFactory;
}
void ClassInfo::setName(const std::string& name)
{
SLB_DEBUG_CALL;
// rename first in the manager...
Manager::getInstance().rename(this, name);
_name = name;
}
void ClassInfo::getMembers( std::list< const char* >& l, bool baseClass )
{
Table* t = dynamic_cast< Table* >( get( std::string( "__members" ) ) );
if( t )
{
t->getElements( l );
}
if( baseClass )
{
for(BaseClassMap::const_iterator b = _baseClasses.begin(); b != _baseClasses.end(); ++b )
{
((ClassInfo*)b->second.get())->getMembers( l, baseClass );
}
}
}
void ClassInfo::setInstanceFactory( InstanceFactory *factory)
{
SLB_DEBUG_CALL;
delete _instanceFactory; // delete old..
_instanceFactory = factory;
}
void ClassInfo::setConstructor( FuncCall *constructor )
{
SLB_DEBUG_CALL;
_constructor = constructor;
}
void ClassInfo::setClass__index( FuncCall *func )
{
SLB_DEBUG_CALL;
SLB_DEBUG(2, "ClassInfo(%p) '%s' set Class __index -> %p", this, _name.c_str(), func);
_meta__index[0] = func;
}
void ClassInfo::setClass__newindex( FuncCall *func )
{
SLB_DEBUG_CALL;
SLB_DEBUG(2, "ClassInfo(%p) '%s' set Class __newindex -> %p", this, _name.c_str(), func);
_meta__newindex[0] = func;
}
void ClassInfo::setObject__index( FuncCall *func )
{
SLB_DEBUG_CALL;
SLB_DEBUG(2, "ClassInfo(%p) '%s' set Object __index -> %p", this, _name.c_str(), func);
_meta__index[1] = func;
}
void ClassInfo::setObject__newindex( FuncCall *func )
{
SLB_DEBUG_CALL;
SLB_DEBUG(2, "ClassInfo(%p) '%s' set Object __newindex -> %p", this, _name.c_str(), func);
_meta__newindex[1] = func;
}
void ClassInfo::pushImplementation(lua_State *L)
{
Table::pushImplementation(L);
lua_getmetatable(L, -1);
lua_pushstring(L, "__objects");
lua_newtable(L);
lua_rawset(L, -3);
lua_pushstring(L, "__class_ptr");
lua_pushlightuserdata(L, (void*)this);
lua_rawset(L, -3);
lua_pop(L,1); // remove metatable
}
void ClassInfo::pushInstance(lua_State *L, InstanceBase *instance)
{
SLB_DEBUG_CALL;
int top = lua_gettop(L);
if (instance == 0)
{
SLB_DEBUG(7, "Push(%s) Invalid!!", _name.c_str());
lua_pushnil(L);
return;
}
InstanceBase **obj = reinterpret_cast<InstanceBase**>
(lua_newuserdata(L, sizeof(InstanceBase*))); // top+1
*obj = instance;
SLB_DEBUG(7, "Push(%s) InstanceHandler(%p) -> ptr(%p) const_ptr(%p)",
_name.c_str(), instance, instance->get_ptr(), instance->get_const_ptr());
// get metatable (class table's metatable)
push(L); // (table) top+2
lua_getmetatable(L,-1);
lua_replace(L,-2);
lua_pushvalue(L,-1);
lua_setmetatable(L, top+1);
// keep a copy
if (instance->keepCopyAsCache())
{
lua_getfield(L, top+2, "__objects");
lua_pushlightuserdata(L, const_cast<void*>(instance->get_const_ptr()) );
lua_pushvalue(L,top+1);
lua_rawset(L, -3);
}
lua_settop(L, top+1);
}
void *ClassInfo::get_ptr(lua_State *L, int pos) const
{
SLB_DEBUG_CALL;
pos = L_abs_index(L,pos);
void *obj = 0;
InstanceBase *i = getInstance(L, pos);
if (i)
{
ClassInfo *i_ci = i->getClass();
assert("Invalid ClassInfo" && (i_ci != 0));
obj = Manager::getInstance().convert(
i_ci->getTypeid(),
getTypeid(),
i->get_ptr()
);
}
SLB_DEBUG(7, "Class(%s) get_ptr at %d -> %p", _name.c_str(), pos, obj);
return obj;
}
const void* ClassInfo::get_const_ptr(lua_State *L, int pos) const
{
SLB_DEBUG_CALL;
pos = L_abs_index(L,pos);
const void *obj = 0;
InstanceBase *i = getInstance(L, pos);
if (i)
{
ClassInfo *i_ci = i->getClass();
assert("Invalid ClassInfo" && (i_ci != 0));
obj = Manager::getInstance().convert(
i_ci->getTypeid(),
getTypeid(),
i->get_const_ptr() );
}
SLB_DEBUG(7, "Class(%s) get_const_ptr -> %p", _name.c_str(), obj);
return obj;
}
InstanceBase* ClassInfo::getInstance(lua_State *L, int pos) const
{
SLB_DEBUG_CALL;
SLB_DEBUG(10, "L=%p; Pos = %i (abs = %i)",L, pos, L_abs_index(L,pos) );
pos = L_abs_index(L,pos);
InstanceBase *instance = 0;
int top = lua_gettop(L);
if (lua_getmetatable(L, pos))
{
lua_getfield(L, -1, "__class_ptr");
if (!lua_isnil(L,-1))
{
void *obj = lua_touserdata(L, pos);
if (obj == 0)
{
luaL_error(L,
"Expected object of type %s at #%d",
_name.c_str(), pos);
}
instance = *reinterpret_cast<InstanceBase**>(obj);
}
}
lua_settop(L, top);
SLB_DEBUG(10, "Instance(%p) -> %p (%s)",
instance,
instance? instance->get_const_ptr() : 0,
instance? (instance->get_const_ptr() ? "const" : "non_const") : "nil");
return instance;
}
void ClassInfo::push_ref(lua_State *L, void *ref )
{
SLB_DEBUG_CALL;
if (_instanceFactory)
{
if (ref)
{
pushInstance(L, _instanceFactory->create_ref(ref) );
SLB_DEBUG(7, "Class(%s) push_ref -> %p", _name.c_str(), ref);
}
else
{
luaL_error(L, "Can not push a NULL reference of class %s", _name.c_str());
}
}
else
{
luaL_error(L, "Unknown class %s (push_reference)", _name.c_str());
}
}
void ClassInfo::push_ptr(lua_State *L, void *ptr, bool fromConstructor)
{
SLB_DEBUG_CALL;
if (_instanceFactory)
{
pushInstance(L, _instanceFactory->create_ptr(ptr, fromConstructor) );
SLB_DEBUG(7, "Class(%s) push_ptr (from_Constructor %d) -> %p", _name.c_str(), fromConstructor, ptr);
// if is Hybrid and fromConstructor
if (_isHybrid && fromConstructor)
{
int top = lua_gettop(L);
//suppose that this state will hold the Object..
HybridBase *hb = SLB::get<HybridBase*>(L,top);
if (!hb) assert("Invalid push of hybrid object" && false);
if (!hb->isAttached()) hb->attach(L);
// check... just in case
assert("Invalid lua stack..." && (top == lua_gettop(L)));
}
}
else
{
luaL_error(L, "Can not push a ptr of class %s", _name.c_str());
}
}
void ClassInfo::push_const_ptr(lua_State *L, const void *const_ptr)
{
SLB_DEBUG_CALL;
if (_instanceFactory)
{
pushInstance(L, _instanceFactory->create_const_ptr(const_ptr) );
SLB_DEBUG(7, "Class(%s) push const_ptr -> %p", _name.c_str(), const_ptr);
}
else
{
luaL_error(L, "Can not push a const_ptr of class %s", _name.c_str());
}
}
void ClassInfo::push_copy(lua_State *L, const void *ptr)
{
SLB_DEBUG_CALL;
if (_instanceFactory)
{
if (ptr)
{
pushInstance(L, _instanceFactory->create_copy(ptr) );
SLB_DEBUG(7, "Class(%s) push copy -> %p", _name.c_str(), ptr);
}
else
{
luaL_error(L, "Can not push copy from NULL of class %s", _name.c_str());
}
}
else
{
luaL_error(L, "Can not push a copy of class %s", _name.c_str());
}
}
int ClassInfo::__index(lua_State *L)
{
SLB_DEBUG_CALL;
int result = Table::__index(L); // default implementation
if ( result < 1 )
{
// type == 0 -> class __index
// type == 1 -> object __index
int type = lua_istable(L,1)? 0 : 1;
SLB_DEBUG(4, "Called ClassInfo(%p) '%s' __index %s", this, _name.c_str(), type? "OBJECT" : "CLASS");
// if looking for a class method, using an string...
if (lua_isstring(L,2))
{
const char *key = lua_tostring(L,2);
Object *obj = 0;
if( lua_gettop(L) >= 2 )
{
std::string key( "__members::" );
key = key + lua_tostring(L,2) + "::__get";
Object* member = get( key );
if( member )
{
member->push(L);
lua_insert(L,1);
lua_remove(L,3);
lua_call(L,lua_gettop(L)-1, LUA_MULTRET);
result = lua_gettop(L);
}
}
for(BaseClassMap::iterator i = _baseClasses.begin(); obj == 0L && i != _baseClasses.end(); ++i)
{
obj = ((Table*)(i->second.get()))->get(key);
if (obj)
{
obj->push(L);
result = 1;
break;
}
else
{
std::string get_key( "__members::" );
get_key = get_key + key + "::__get";
Object* member = ((Table*)(i->second.get()))->get( get_key );
if( member )
{
member->push(L);
lua_insert(L,1);
lua_remove(L,3);
lua_call(L,lua_gettop(L)-1, LUA_MULTRET);
result = lua_gettop(L);
break;
}
}
}
}
if (result < 1) // still not found...
{
if (_meta__index[type].valid())
{
// 1 - func to call
_meta__index[type]->push(L);
lua_insert(L,1);
// 2 - object/table
// 3 - key
SLB_DEBUG_STACK(8,L, "Class(%s) __index {%s} metamethod -> %p",
_name.c_str(), type? "OBJECT" : "CLASS", (void*)_meta__index[type].get() );
assert("Error in number of stack elements" && lua_gettop(L) == 3);
lua_call(L,lua_gettop(L)-1, LUA_MULTRET);
result = lua_gettop(L);
}
else
{
SLB_DEBUG(4, "ClassInfo(%p) '%s' doesn't have __index[%s] implementation.",
this, _name.c_str(), type? "OBJECT" : "CLASS");
}
}
}
return result;
}
int ClassInfo::__newindex(lua_State *L)
{
SLB_DEBUG_CALL;
// 0 = class __index
// 1 = object __index
int type = lua_istable(L,1)? 0 : 1;
SLB_DEBUG(4, "Called ClassInfo(%p) '%s' __newindex %s", this, _name.c_str(), type? "OBJECT" : "CLASS");
if (_meta__newindex[type].valid())
{
// 1 - func to call
_meta__newindex[type]->push(L);
lua_insert(L,1);
// 2 - object
// 3 - key/table
// 4 - value
SLB_DEBUG_STACK(8,L, "Class(%s) __index {%s} metamethod -> %p",
_name.c_str(), type? "OBJECT" :"CLASS", (void*)_meta__newindex[type].get() );
assert("Error in number of stack elements" && lua_gettop(L) == 4);
lua_call(L,lua_gettop(L)-1, LUA_MULTRET);
return lua_gettop(L);
}
else
{
SLB_DEBUG(4, "ClassInfo(%p) '%s' doesn't have __newindex[%s] implementation.",
this, _name.c_str(), type? "OBJECT" : "CLASS");
}
std::string key( "__members::" );
if( lua_gettop(L) != 3 ) return 0;
key = key + lua_tostring(L,2) + "::__set";
Object* member = get( key );
if( member )
{
member->push(L); // f
lua_insert(L,1);
lua_remove(L,3);
lua_call(L,lua_gettop(L)-1, LUA_MULTRET);
return lua_gettop(L);
}
else
{
for(BaseClassMap::iterator i = _baseClasses.begin(); i != _baseClasses.end(); ++i)
{
Object* member = ((Table*)(i->second.get()))->get( key );
if( member )
{
member->push(L);
lua_insert(L,1);
lua_remove(L,3);
lua_call(L,lua_gettop(L)-1, LUA_MULTRET);
return lua_gettop(L);
}
}
}
return Table::__newindex(L);
}
int ClassInfo::__garbageCollector(lua_State *L)
{
InstanceBase* instance =
*reinterpret_cast<InstanceBase**>(lua_touserdata(L, 1));
delete instance;
return 0;
}
int ClassInfo::__call(lua_State *L)
{
SLB_DEBUG_CALL;
if ( _constructor.valid() )
{
_constructor->push(L);
lua_replace(L, 1); // remove ClassInfo table
lua_call(L, lua_gettop(L)-1 , LUA_MULTRET);
return lua_gettop(L);
}
else
{
luaL_error(L,
"ClassInfo '%s' is abstract ( or doesn't have a constructor ) ", _name.c_str());
}
return 0;
}
int ClassInfo::__tostring(lua_State *L)
{
SLB_DEBUG_CALL;
int top = lua_gettop(L);
lua_pushfstring(L, "Class(%s) [%s]", _name.c_str(), getInfo().c_str());
;
for(BaseClassMap::iterator i = _baseClasses.begin(); i != _baseClasses.end(); ++i)
{
lua_pushfstring(L, "\n\tinherits from %s (%p)",i->second->getName().c_str(), (Object*) i->second.get());
}
for(Elements::iterator i = _elements.begin(); i != _elements.end(); ++i)
{
Object *obj = i->second.get();
FuncCall *fc = dynamic_cast<FuncCall*>(obj);
if (fc)
{
lua_pushfstring(L, "\n\tfunction (%s) [%s]",i->first.c_str(), obj->getInfo().c_str() );
for (size_t i = 0; i < fc->getNumArguments(); ++i)
{
lua_pushfstring(L, "\n\t\t[%d] (%s) [%s]",i,
fc->getArgType(i)->name(),
fc->getArgComment(i).c_str()
);
}
//TODO, print return type
}
else
{
lua_pushfstring(L, "\n\t%s -> %p [%s] [%s]",i->first.c_str(), obj, typeid(*obj).name(), obj->getInfo().c_str() );
}
}
lua_concat(L, lua_gettop(L) - top);
return 1;
}
bool ClassInfo::isSubClassOf( const ClassInfo *base, ConverList *s, bool bBaseToDerived )
{
SLB_DEBUG_CALL;
if( base == NULL ) return false;
if (base == this) return true;
// BaseClassMap::iterator i = _baseClasses.find( base->getTypeid() );
BaseClassMap::iterator i = _baseClasses.begin();
while( i != _baseClasses.end() )
{
if( i->second->isSubClassOf( base, s, bBaseToDerived ) )
{
if( s )
s->push_back(
bBaseToDerived?
std::make_pair( i->second->getTypeid(), getTypeid() ):
std::make_pair( getTypeid(), i->second->getTypeid() )
);
return true;
}
++i;
}
//return (i != _baseClasses.end());
return false;
}
}
| [
"albertclass@a94d7126-06ea-11de-b17c-0f1ef23b492c"
]
| [
[
[
1,
554
]
]
]
|
b6bdc07f2dc6789c71dc146125f34f629b6d240f | 1d2705c9be9ee0f974c224eb794f2f8a9e9a3d50 | /tracking_control/tracking_control.h | 62a6cddaf3dbe354210fa89a6f1fde20448714fe | []
| no_license | llvllrbreeze/alcorapp | dfe2551f36d346d73d998f59d602c5de46ef60f7 | 3ad24edd52c19f0896228f55539aa8bbbb011aac | refs/heads/master | 2021-01-10T07:36:01.058011 | 2008-12-16T12:51:50 | 2008-12-16T12:51:50 | 47,865,136 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,820 | h | /////////////////////////////////////////////////////////////////////////////
// Name: tracking_control.h
// Purpose:
// Author: Andrea Carbone
// Modified by:
// Created: 05/03/2007 23:15:00
// RCS-ID:
// Copyright: Alcor
// Licence:
/////////////////////////////////////////////////////////////////////////////
#ifndef _TRACKING_CONTROL_H_
#define _TRACKING_CONTROL_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "tracking_control.h"
#endif
/*!
* Includes
*/
//#define WIN_LEAN_AND_MEAN
////@begin includes
#include "wx/image.h"
#include "tracking_control_frame.h"
////@end includes
/*!
* Forward declarations
*/
////@begin forward declarations
////@end forward declarations
/*!
* Control identifiers
*/
////@begin control identifiers
////@end control identifiers
/*!
* tracking_control_app class declaration
*/
class tracking_control_app: public wxApp
{
DECLARE_CLASS( tracking_control_app )
DECLARE_EVENT_TABLE()
public:
/// Constructor
tracking_control_app();
/// Initialises member variables
void Init();
/// Initialises the application
virtual bool OnInit();
/// Called on exit
virtual int OnExit();
////@begin tracking_control_app event handler declarations
////@end tracking_control_app event handler declarations
////@begin tracking_control_app member function declarations
////@end tracking_control_app member function declarations
////@begin tracking_control_app member variables
////@end tracking_control_app member variables
};
/*!
* Application instance declaration
*/
////@begin declare app
DECLARE_APP(tracking_control_app)
////@end declare app
#endif
// _TRACKING_CONTROL_H_
| [
"andrea.carbone@1ffd000b-a628-0410-9a29-793f135cad17"
]
| [
[
[
1,
87
]
]
]
|
25b79c171acf95501bbc4a68b6c91ff1d30f14cf | 1bc0a9b0d931f0f4b4cb5a700fe5f7c60a28663d | /avltree.h | eb4cfcbc94bdc5ef1c837b8afd02fc477722872c | []
| no_license | huangyingw/AVLTree | 0c5b6643ba3785cc538f568b8f661f63a24f98e0 | 6e19318f906540a1180c80416bc8b0dc39c859d7 | refs/heads/master | 2016-08-08T12:36:35.075412 | 2010-04-08T07:16:23 | 2010-04-08T07:16:23 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 12,067 | h | #include<iostream>
using namespace std;
#include "/media/myproject/git/c_c++/linux/data_structure/cirQueue/CirQueue.h"
class AVLNode
{
public:
int data;
AVLNode *left,*right;
int balance;
int height;//AVL结点的高度
AVLNode():left(NULL),right(NULL),balance(0){}
AVLNode(int d,AVLNode *l=NULL,AVLNode *r=NULL):data(d),left(l),right(r),balance(0),height(0){}
};
class AVLTree
{
public:
int RefValue;//插入结束的标志
AVLNode *root;//根结点的指针
int Height(AVLNode *t)const;
AVLTree():root(NULL){}
AVLTree(int Ref):RefValue(Ref),root(NULL){}
int Insert(AVLNode* &tree, int x,int & taller);//插入
int PrintAVLHor(AVLNode*current,ostream&out);//打印出BST的视图
void SetHeight(AVLNode* ptr,int height);//设置当前节点的所有子节点的高度
void RotateLeft(AVLNode * &Tree, AVLNode * NewTree);//右子树比左子树高:对以Tree为根的AVL树做左单旋转,旋转后新根在NewTree
void LeftBalance(AVLNode * &Tree, int & taller);//左平衡化
void RightBalance(AVLNode * &Tree, int & taller);//右平衡化
int Insert(int x){int taller;return Insert(root,x,taller);}
void Remove(AVLNode* &tree, int x,int & shorter);//在以tree为根的AVL树中删除元素x,如果删除成功,shorter返回1,否则返回0
void RightAdjust_Del(AVLNode *&Tree, int &shorter);
void LeftAdjust_Del(AVLNode *&Tree, int &shorter);
void RotateRight(AVLNode *&Tree,AVLNode* NewTree);
void Remove_Ex(AVLNode *&r, const int &x, int &inc);
AVLNode* Min(AVLNode* ptr);
friend istream& operator>>(istream& in,AVLTree & Tree);
friend ostream& operator>>(ostream& out,const AVLTree & Tree);
};
void AVLTree::RotateLeft(AVLNode * &Tree, AVLNode * NewTree)//右子树比左子树高:对以Tree为根的AVL树做左单旋转,旋转后新根在NewTree
{
Tree->right=NewTree->left;
NewTree->left=Tree;
Tree=NewTree;
}
void AVLTree::LeftBalance(AVLNode* &Tree, int &taller)
{
AVLNode *left_child=Tree->left;
switch(left_child->balance)//判断左子树的平衡因子
{
case -1://左高,修改平衡因子
{
Tree->balance = 0;
left_child->balance = 0;
RotateRight(Tree,Tree->left);//做右单旋转
SetHeight(Tree,Tree->right->height);
taller=0;
break;
}
case 0://没有发生不平衡
{
cout<<"LeftBalance error: Tree already balanced. \n";
break;
}
case 1://右高,取左子树的右子树
{
AVLNode *right_child=left_child->right;
switch(right_child->balance)//判断该右子树的平衡因子
{
case -1:
{
Tree->balance=1;
left_child->balance=0;
break;
}
case 0:
{
Tree->balance=left_child->balance=0;
break;
}
case 1:
{
Tree->balance=0;
left_child->balance=-1;
break;
}
}//调整旋转后各结点的平衡因子
right_child->balance=0;
RotateLeft(Tree->left,left_child->right);//左单旋转
SetHeight(Tree->left,Tree->left->height);
RotateRight(Tree,Tree->left);//右单旋转
SetHeight(Tree,Tree->right->height);
taller=0;
}
}
}
void AVLTree::SetHeight(AVLNode* ptr,int height)//设置当前节点的所有子节点的高度,
{
if(NULL!=ptr)
{
ptr->height=height;
if(NULL!=ptr->left)
{
SetHeight(ptr->left,ptr->height+1);
}
if(NULL!=ptr->right)
{
SetHeight(ptr->right,ptr->height+1);
}
}
}
void AVLTree::RightBalance(AVLNode* &Tree, int &taller)
{
AVLNode *rightsub=Tree->right,*leftsub;
switch(rightsub->balance)
{
case 1:
{
Tree->balance=rightsub->balance=0;
RotateLeft(Tree,Tree->right);
SetHeight(Tree,Tree->left->height);
taller=0;
break;
}
case 0:
{
cout<<"RightBalance error: Tree already balanced. \n";
break;
}
case -1:
{
leftsub=rightsub->left;
switch(leftsub->balance)
{
case 1:
{
Tree->balance=-1;
leftsub->balance=0;
break;
}
case 0:
{
Tree->balance=rightsub->balance=0;
break;
}
case -1:
{
Tree->balance=0;
rightsub->balance=1;
break;
}
}
leftsub->balance=0;
RotateRight(Tree->right,rightsub->left);
SetHeight(Tree->right,rightsub->height);
RotateLeft(Tree,Tree->right);
SetHeight(Tree,Tree->left->height);
taller=0;
}
}
}
int AVLTree::Insert(AVLNode* &tree, int x,int & taller)//在以tree为根的AVL树中插入新元素x,如果插入成功,taller返回1,否则返回0。
{
int success;
if(tree==NULL)//原为空树,或某结点的空链域
{
tree=new AVLNode(x);//创建新结点并插入
success=(tree!=NULL)?1:0;//成功标志:存储分配成功为1
if(success)
taller=1;
}
else if(x<tree->data)//判断是向左插入还是向右插入
{
success=Insert(tree->left,x,taller);//插入到左子树
if(taller)//插入成功
{
SetHeight(tree,tree->height);
switch(tree->balance)//判断平衡因子
{
case -1://原左子树高,不平衡,调整
{
LeftBalance(tree,taller);
break;
}
case 0://原两子树等高,仅改平衡因子
{
tree->balance=-1;
break;
}
case 1://原右子树高,仅改平衡因子
{
tree->balance=0;
taller=0;
break;
}
}
}
}
else if(x>tree->data)
{
success=Insert(tree->right,x,taller);//插入到右子树
if(taller)//插入成功
{
SetHeight(tree,tree->height);
switch(tree->balance)//判断平衡因子
{
case -1://原左子树高,仅改平衡因子
{
tree->balance=0;
taller=0;
break;
}
case 0://原两子树等高,仅改平衡因子
{
tree->balance=1;
break;
}
case 1://原右子树高,不平衡,调整
{
RightBalance(tree,taller);
break;
}
}
}
}
return success;//向上层传送插入成功信息,此变量在此函数中没用,不过,这是传递信息的一种好方法,应该学习,所以没删除
}
AVLNode* AVLTree::Min(AVLNode* ptr)//在ptr中搜寻最小结点
{
if(NULL!=ptr)
{
if(NULL!=ptr->left)
{
Min(ptr->left);
}
else
{
return ptr;
}
}
}
void AVLTree::Remove(AVLNode* &tree, int x,int & shorter)//在以tree为根的AVL树中删除元素x,如果删除成功,shorter返回1,否则返回0。
{
if(tree == NULL)
{
shorter = 0;
return;
}
if(tree->data<x)//往右子树删除
{
Remove(tree->right,x,shorter);
if (shorter == 0) return;
switch ( tree->balance )
{
case 0:
{
tree->balance = -1;
shorter=0;
break;
}
case 1:
{
tree->balance = 0;
shorter = 1;
break;
}
case -1:
{
LeftAdjust_Del(tree, shorter);
break;
}
}
}
else if ( tree->data > x )//往左子树删除
{
Remove(tree->left, x, shorter);
if ( shorter == 0 ) return;
switch ( tree->balance )
{
case 0:
tree->balance = 1;
shorter = 0;
break;
case -1:
tree->balance = 0;
shorter = 1;
break;
case 1:
RightAdjust_Del(tree, shorter);
break;
}
}
else
{
if (tree->left && tree->right)
{
int data = Min(tree->right)->data;
Remove(tree->right, data, shorter);
tree->data = data;
if (shorter == 0) return;
switch (tree->balance)
{
case 0:
{
tree->balance = -1;
shorter=0;
break;
}
case 1:
{
tree->balance = 0;
shorter = 1;
break;
}
case -1:
{
LeftAdjust_Del(tree, shorter);
break;
}
}
return;
}
AVLNode *tmp =tree ;
tree = tree->left!=0?tree->left:tree->right;
delete tmp;
shorter = 1;
return;
}
}
void AVLTree::RotateRight(AVLNode *&Tree,AVLNode* NewTree)
{
Tree->left=NewTree->right;
NewTree->right=Tree;
Tree=NewTree;
}
void AVLTree::LeftAdjust_Del(AVLNode *&Tree, int &shorter)
{
AVLNode *left_child = Tree->left;
switch ( left_child->balance )
{
case -1:
{
Tree->balance = 0;
left_child->balance = 0;
RotateRight(Tree, Tree->left);
SetHeight(Tree,Tree->left->height);
shorter = 1;
break;
}
case 0:
{
Tree->balance = -1;
left_child->balance = 1;
RotateRight(Tree, left_child);
SetHeight(Tree,Tree->right->height);
shorter = 0;
break;
}
case 1:
{
AVLNode *right_child = left_child->right;
switch (right_child->balance )
{
case 0:
{
Tree->balance = 0;
left_child->balance = 0;
right_child->balance = 0;
shorter = 1;
break;
}
case 1:
{
Tree->balance = -1;
left_child->balance = 0;
right_child->balance = 0;
shorter = 1;
break;
}
case -1:
{
Tree->balance = 0;
left_child->balance = 1;
right_child->balance = 0;
shorter = 1;
break;
}
}
RotateLeft(left_child, left_child->right);
SetHeight(left_child,left_child->right->height);
RotateRight(Tree, left_child);
break;
}
}
}
void AVLTree::RightAdjust_Del(AVLNode *&Tree, int &shorter)
{
AVLNode *right_child = Tree->right;
switch (right_child->balance)
{
case 0:
{
right_child->balance = -1;
Tree->balance = 1;
shorter = 0;
RotateLeft(Tree, right_child);
SetHeight(Tree,Tree->left->height);
break;
}
case 1:
{
right_child->balance = 0;
Tree->balance = 0;
shorter = 1;
RotateLeft(Tree, right_child);
SetHeight(Tree,Tree->left->height);
break;
}
case -1:
{
AVLNode *left_child = right_child->left;
switch (left_child->balance)
{
case 0:
{
Tree->balance = 0;
right_child->balance = 0;
left_child->balance = 0;
shorter = 1;
break;
}
case 1:
{
Tree->balance = -1;
right_child->balance = 0;
left_child->balance = 0;
shorter = 1;
break;
}
case -1:
{
Tree->balance = 0;
right_child->balance = 1;
left_child->balance = 0;
shorter = 1;
break;
}
RotateRight(right_child, left_child);
SetHeight(right_child,Tree->right->height);
RotateLeft(Tree, right_child);
break;
}
}
}
}
int AVLTree::PrintAVLHor(AVLNode*current,ostream&out)//打印出BST的视图
{
int currentHeight=0;
CirQueue<AVLNode*> Q;
Q.InitQueue();
if(NULL!=current)
{
Q.EnQueue(current);
while(!Q.QueueEmpty())
{
current=Q.DeQueue();
if(currentHeight<current->height)
{
currentHeight=current->height;
out<<endl;
}
out<<current->data<<",";
if(NULL!=current->left)
{
Q.EnQueue(current->left);
}
if(NULL!=current->right)
{
Q.EnQueue(current->right);
}
}
}
cout<<endl<<endl;
return 0;
}
| [
"[email protected]"
]
| [
[
[
1,
511
]
]
]
|
a2f8a643ad7b818cd9ae500014c06b582d534cda | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/boost/test/results_reporter.hpp | c1c38ae54b9246923471edac098e00b8b9ce2023 | [
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | willrebuild/flyffsf | e5911fb412221e00a20a6867fd00c55afca593c7 | d38cc11790480d617b38bb5fc50729d676aef80d | refs/heads/master | 2021-01-19T20:27:35.200154 | 2011-02-10T12:34:43 | 2011-02-10T12:34:43 | 32,710,780 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,785 | hpp | // (C) Copyright Gennadiy Rozental 2001-2005.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/test for the library home page.
//
// File : $RCSfile: results_reporter.hpp,v $
//
// Version : $Revision: 1.2 $
//
// Description : defines class unit_test_result that is responsible for
// gathering test results and presenting this information to end-user
// ***************************************************************************
#ifndef BOOST_TEST_RESULTS_REPORTER_HPP_021205GER
#define BOOST_TEST_RESULTS_REPORTER_HPP_021205GER
// Boost.Test
#include <boost/test/detail/global_typedef.hpp>
#include <boost/test/detail/fwd_decl.hpp>
// STL
#include <iosfwd> // for std::ostream&
#include <boost/test/detail/suppress_warnings.hpp>
//____________________________________________________________________________//
namespace boost {
namespace unit_test {
namespace results_reporter {
// ************************************************************************** //
// ************** formatter interface ************** //
// ************************************************************************** //
class BOOST_TEST_DECL format {
public:
// Destructor
virtual ~format() {}
virtual void results_report_start( std::ostream& ostr ) = 0;
virtual void results_report_finish( std::ostream& ostr ) = 0;
virtual void test_unit_report_start( test_unit const&, std::ostream& ostr ) = 0;
virtual void test_unit_report_finish( test_unit const&, std::ostream& ostr ) = 0;
virtual void do_confirmation_report( test_unit const&, std::ostream& ostr ) = 0;
};
// ************************************************************************** //
// ************** report configuration ************** //
// ************************************************************************** //
BOOST_TEST_DECL void set_level( report_level );
BOOST_TEST_DECL void set_stream( std::ostream& );
BOOST_TEST_DECL void set_format( output_format );
BOOST_TEST_DECL void set_format( results_reporter::format* );
// ************************************************************************** //
// ************** report initiation ************** //
// ************************************************************************** //
BOOST_TEST_DECL void make_report( report_level l = INV_REPORT_LEVEL, test_unit_id = INV_TEST_UNIT_ID );
inline void confirmation_report( test_unit_id id = INV_TEST_UNIT_ID )
{ make_report( CONFIRMATION_REPORT, id ); }
inline void short_report( test_unit_id id = INV_TEST_UNIT_ID )
{ make_report( SHORT_REPORT, id ); }
inline void detailed_report( test_unit_id id = INV_TEST_UNIT_ID )
{ make_report( DETAILED_REPORT, id ); }
} // namespace results_reporter
} // namespace unit_test
} // namespace boost
//____________________________________________________________________________//
#include <boost/test/detail/enable_warnings.hpp>
// ***************************************************************************
// Revision History :
//
// $Log: results_reporter.hpp,v $
// Revision 1.2 2005/12/14 05:13:18 rogeeff
// dll support introduced
//
// Revision 1.1 2005/02/20 08:27:06 rogeeff
// This a major update for Boost.Test framework. See release docs for complete list of fixes/updates
//
// ***************************************************************************
#endif // BOOST_TEST_RESULTS_REPORTER_HPP_021205GER
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
98
]
]
]
|
a27665a2364cfa7eff2088d33afd48cb4e30473a | 854ee643a4e4d0b7a202fce237ee76b6930315ec | /arcemu_svn/src/arcemu-world/BattlegroundHandler.cpp | 266b9b772f493eb991fd3fe53650e88d26371648 | []
| no_license | miklasiak/projekt | df37fa82cf2d4a91c2073f41609bec8b2f23cf66 | 064402da950555bf88609e98b7256d4dc0af248a | refs/heads/master | 2021-01-01T19:29:49.778109 | 2008-11-10T17:14:14 | 2008-11-10T17:14:14 | 34,016,391 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,156 | cpp | /*
* ArcEmu MMORPG Server
* Copyright (C) 2005-2007 Ascent Team <http://www.ascentemu.com/>
* Copyright (C) 2008 <http://www.ArcEmu.org/>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "StdAfx.h"
void WorldSession::HandleBattlefieldPortOpcode(WorldPacket &recv_data)
{
uint16 mapinfo, unk;
uint8 action;
uint32 bgtype;
if(!_player->IsInWorld()) return;
recv_data >> unk >> bgtype >> mapinfo >> action;
if(action == 0)
{
BattlegroundManager.RemovePlayerFromQueues(_player);
}
else
{
/* Usually the fields in the packet would've been used to check what instance we're porting into, however since we're not
* doing "queue multiple battleground types at once" we can just use our cached pointer in the player class. - Burlex
*/
if(_player->m_pendingBattleground)
_player->m_pendingBattleground->PortPlayer(_player);
}
}
void WorldSession::HandleBattlefieldStatusOpcode(WorldPacket &recv_data)
{
/* This is done based on whether we are queued, inside, or not in a battleground.
*/
if(_player->m_pendingBattleground) // Ready to port
BattlegroundManager.SendBattlefieldStatus(_player, 2, _player->m_pendingBattleground->GetType(), _player->m_pendingBattleground->GetId(), 120000, 0, _player->m_pendingBattleground->Rated());
else if(_player->m_bg) // Inside a bg
BattlegroundManager.SendBattlefieldStatus(_player, 3, _player->m_bg->GetType(), _player->m_bg->GetId(), (uint32)UNIXTIME - _player->m_bg->GetStartTime(), _player->GetMapId(), _player->m_bg->Rated());
else // None
BattlegroundManager.SendBattlefieldStatus(_player, 0, 0, 0, 0, 0, 0);
}
void WorldSession::HandleBattlefieldListOpcode(WorldPacket &recv_data)
{
uint64 guid;
recv_data >> guid;
CHECK_INWORLD_RETURN;
Creature * pCreature = _player->GetMapMgr()->GetCreature( GET_LOWGUID_PART(guid) );
if( pCreature == NULL )
return;
SendBattlegroundList( pCreature, 0 );
}
void WorldSession::SendBattlegroundList(Creature* pCreature, uint32 mapid)
{
if(!pCreature)
return;
/* we should have a bg id selection here. */
uint32 t = BATTLEGROUND_WARSUNG_GULCH;
if (mapid == 0)
{
if(pCreature->GetCreatureInfo())
{
if(strstr(pCreature->GetCreatureInfo()->SubName, "Arena") != NULL)
t = BATTLEGROUND_ARENA_2V2;
else if(strstr(pCreature->GetCreatureInfo()->SubName, "Arathi") != NULL)
t = BATTLEGROUND_ARATHI_BASIN;
else if(strstr(pCreature->GetCreatureInfo()->SubName, "Eye of the Storm") != NULL)
t = BATTLEGROUND_EYE_OF_THE_STORM;
else if(strstr(pCreature->GetCreatureInfo()->SubName, "Warsong") != NULL)
t = BATTLEGROUND_WARSUNG_GULCH;
}
}
else
t = mapid;
BattlegroundManager.HandleBattlegroundListPacket(this, t);
}
void WorldSession::HandleBattleMasterHelloOpcode(WorldPacket &recv_data)
{
CHECK_PACKET_SIZE(recv_data, 8);
if( !_player->IsInWorld() )
return;
uint64 guid;
recv_data >> guid;
sLog.outDebug("Received CMSG_BATTLEMASTER_HELLO from " I64FMT, guid);
Creature * bm = _player->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid));
if(!bm)
return;
if(!bm->HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BATTLEFIELDPERSON )) // Not a Battlemaster
return;
SendBattlegroundList(bm, 0);
}
void WorldSession::HandleLeaveBattlefieldOpcode(WorldPacket &recv_data)
{
if(_player->m_bg && _player->IsInWorld())
_player->m_bg->RemovePlayer(_player, false);
}
void WorldSession::HandleAreaSpiritHealerQueryOpcode(WorldPacket &recv_data)
{
if(!_player->IsInWorld() || !_player->m_bg) return;
uint64 guid;
recv_data >> guid;
Creature * psg = _player->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid));
if(psg == NULL)
return;
uint32 restime = _player->m_bg->GetLastResurrect() + 30;
if((uint32)UNIXTIME > restime)
restime = 1000;
else
restime = (restime - (uint32)UNIXTIME) * 1000;
WorldPacket data(SMSG_AREA_SPIRIT_HEALER_TIME, 12);
data << guid << restime;
SendPacket(&data);
}
void WorldSession::HandleAreaSpiritHealerQueueOpcode(WorldPacket &recv_data)
{
if(!_player->IsInWorld() || !_player->m_bg) return;
uint64 guid;
recv_data >> guid;
Creature * psg = _player->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid));
if(psg == NULL)
return;
_player->m_bg->QueuePlayerForResurrect(_player, psg);
_player->CastSpell(_player,2584,true);
}
void WorldSession::HandleBattlegroundPlayerPositionsOpcode(WorldPacket &recv_data)
{
/* This packet doesn't appear to be used anymore...
* - Burlex
*/
}
void WorldSession::HandleBattleMasterJoinOpcode(WorldPacket &recv_data)
{
CHECK_INWORLD_RETURN
if(_player->HasAura(BG_DESERTER))
{
WorldPacket data(SMSG_GROUP_JOINED_BATTLEGROUND, 4);
data << (uint32) 0xFFFFFFFE;
_player->GetSession()->SendPacket(&data);
return;
}
if(_player->GetGroup() && _player->GetGroup()->m_isqueued)
{
SystemMessage("You are in a group that is already queued for a battleground or inside a battleground. Leave this first.");
return;
}
/* are we already in a queue? */
if(_player->m_bgIsQueued)
BattlegroundManager.RemovePlayerFromQueues(_player);
if(_player->IsInWorld())
BattlegroundManager.HandleBattlegroundJoin(this, recv_data);
}
void WorldSession::HandleArenaJoinOpcode(WorldPacket &recv_data)
{
CHECK_INWORLD_RETURN
if(_player->GetGroup() && _player->GetGroup()->m_isqueued)
{
SystemMessage("You are in a group that is already queued for a battleground or inside a battleground. Leave this first.");
return;
}
/* are we already in a queue? */
if(_player->m_bgIsQueued)
BattlegroundManager.RemovePlayerFromQueues(_player);
uint32 bgtype=0;
uint64 guid;
uint8 arenacategory;
uint8 as_group;
uint8 rated_match;
recv_data >> guid >> arenacategory >> as_group >> rated_match;
switch(arenacategory)
{
case 0: // 2v2
bgtype = BATTLEGROUND_ARENA_2V2;
break;
case 1: // 3v3
bgtype = BATTLEGROUND_ARENA_3V3;
break;
case 2: // 5v5
bgtype = BATTLEGROUND_ARENA_5V5;
break;
}
if(bgtype != 0)
BattlegroundManager.HandleArenaJoin(this, bgtype, as_group, rated_match);
}
void WorldSession::HandleInspectHonorStatsOpcode( WorldPacket &recv_data )
{
CHECK_PACKET_SIZE( recv_data, 8 );
CHECK_INWORLD_RETURN
uint64 guid;
recv_data >> guid;
if( _player == NULL )
{
sLog.outError( "HandleInspectHonorStatsOpcode : _player was null" );
return;
}
if( _player->GetMapMgr() == NULL )
{
sLog.outError( "HandleInspectHonorStatsOpcode : _player map mgr was null" );
return;
}
if( _player->GetMapMgr()->GetPlayer( (uint32)guid ) == NULL )
{
sLog.outError( "HandleInspectHonorStatsOpcode : guid was null" );
return;
}
Player* player = _player->GetMapMgr()->GetPlayer( (uint32)guid );
WorldPacket data( MSG_INSPECT_HONOR_STATS, 13 );
data << player->GetGUID() << (uint8)player->GetUInt32Value( PLAYER_FIELD_HONOR_CURRENCY );
data << player->GetUInt32Value( PLAYER_FIELD_KILLS );
data << player->GetUInt32Value( PLAYER_FIELD_TODAY_CONTRIBUTION );
data << player->GetUInt32Value( PLAYER_FIELD_YESTERDAY_CONTRIBUTION );
data << player->GetUInt32Value( PLAYER_FIELD_LIFETIME_HONORBALE_KILLS );
SendPacket( &data );
}
void WorldSession::HandleInspectArenaStatsOpcode( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE( recv_data, 8 );
CHECK_INWORLD_RETURN
uint64 guid;
recv_data >> guid;
Player* player = _player->GetMapMgr()->GetPlayer( (uint32)guid );
if( player == NULL )
{
sLog.outError( "HandleInspectHonorStatsOpcode : guid was null" );
return;
}
uint32 id;
for( uint8 i = 0; i < 3; i++ )
{
id = player->GetUInt32Value( PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + ( i * 6 ) );
if( id > 0 )
{
ArenaTeam* team = objmgr.GetArenaTeamById( id );
if( team != NULL )
{
WorldPacket data( MSG_INSPECT_ARENA_STATS, 8 + 1 + 4 * 5 );
data << player->GetGUID();
data << team->m_type;
data << team->m_id;
data << team->m_stat_rating;
data << team->m_stat_gamesplayedweek;
data << team->m_stat_gameswonweek;
data << team->m_stat_gamesplayedseason;
SendPacket( &data );
}
}
}
}
void WorldSession::HandlePVPLogDataOpcode(WorldPacket &recv_data)
{
CHECK_INWORLD_RETURN
if(_player->m_bg)
_player->m_bg->SendPVPData(_player);
}
| [
"[email protected]@3074cc92-8d2b-11dd-8ab4-67102e0efeef",
"[email protected]@3074cc92-8d2b-11dd-8ab4-67102e0efeef"
]
| [
[
[
1,
1
],
[
5,
77
],
[
79,
80
],
[
82,
82
],
[
84,
84
],
[
86,
86
],
[
88,
88
],
[
91,
100
],
[
118,
121
],
[
124,
169
],
[
179,
294
],
[
296,
317
]
],
[
[
2,
4
],
[
78,
78
],
[
81,
81
],
[
83,
83
],
[
85,
85
],
[
87,
87
],
[
89,
90
],
[
101,
117
],
[
122,
123
],
[
170,
178
],
[
295,
295
],
[
318,
319
]
]
]
|
7d92f4638b045e22aa433e23653b07f21207ce07 | b6e0e894be10de33532969a67b9e278753d392f9 | /infoquerydialog.h | b4672586dc4f3e53a1e476668bfa0e27061caca6 | []
| no_license | faellsa/teachersmanagement | 4f9ef70ec91b1237d45cd2b7c71afdd2bc183e0e | 15f79a11eadac2e6c811fe27fbf727faa27d32c3 | refs/heads/master | 2020-05-16T19:01:29.339150 | 2011-05-21T09:46:30 | 2011-05-21T09:46:30 | 32,401,290 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,278 | h | #ifndef INFOQUERYDIALOG_H
#define INFOQUERYDIALOG_H
#include "childdialogbase.h"
#include <QSqlQueryModel>
#include <QAction>
#include "teachersinfotable.h"
namespace Ui {
class InfoQueryDialog;
}
class InfoQueryDialog : public ChildDialogBase
{
Q_OBJECT
public:
explicit InfoQueryDialog(QDialog *parent = 0);
~InfoQueryDialog();
private:
Ui::InfoQueryDialog *ui;
QSqlQueryModel* m_Model;
QAction* m_DeleteAction;
QAction* m_EditAction;
QList <QAction*> m_Actions;
TeacherInfo *m_TeacherInfo;
QString m_PersonnelNo;
static const int attributeNum = 33;
void setupWidgets();
void setupSignals();
void setTeachersInfo(TeacherInfo &teacherInfo);
private slots:
void showConditionWidget(QString conditionType);
void onQueryButton();
void onDeleteAction();
void onDetailAction();
void showPersonalInfoPage();
void showPoliticalInfoPage();
void showWorkInfoPage();
void showPersonalExperiencePage();
void showRemarkPage();
void onOkButton();
void onExportExcel();
//void onShowDetail(Qt::CheckState checkeState);
void isShowDetail(int checkeState);
void onPoliticsStatus(QString politicsStatus);
void onGraduateTrain(QString graduateTrain);
};
#endif // INFOQUERYDIALOG_H
| [
"lefthand0702@69ecbcbb-dc20-fe55-c2b8-cdc3f9c2dbdb"
]
| [
[
[
1,
58
]
]
]
|
d83d1cfb18f3cc7263fa3c70fae9763358887b4c | d9a78f212155bb978f5ac27d30eb0489bca87c3f | /PB/src/PbFt/GeneratedFiles/Debug/moc_ftlobby_a.cpp | dce20ba3c0b83890f3d0c056cf5155a9a91980c2 | []
| no_license | marchon/pokerbridge | 1ed4a6a521f8644dcd0b6ec66a1ac46879b8473c | 97d42ef318bf08f3bc0c0cb1d95bd31eb2a3a8a9 | refs/heads/master | 2021-01-10T07:15:26.496252 | 2010-05-17T20:01:29 | 2010-05-17T20:01:29 | 36,398,892 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,617 | cpp | /****************************************************************************
** Meta object code from reading C++ file 'ftlobby_a.h'
**
** Created: Thu 25. Mar 16:20:36 2010
** by: The Qt Meta Object Compiler version 61 (Qt 4.5.2)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "stdafx.h"
#include "..\..\ftlobby_a.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'ftlobby_a.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 61
#error "This file was generated using the moc from 4.5.2. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_FTLobbyAdaptor[] = {
// content:
2, // revision
0, // classname
0, 0, // classinfo
2, 12, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
// signals: signature, parameters, type, tag, flags
19, 16, 15, 15, 0x05,
// slots: signature, parameters, type, tag, flags
42, 15, 15, 15, 0x09,
0 // eod
};
static const char qt_meta_stringdata_FTLobbyAdaptor[] = {
"FTLobbyAdaptor\0\0ev\0pongEvent(QVariantMap)\0"
"ping()\0"
};
const QMetaObject FTLobbyAdaptor::staticMetaObject = {
{ &RpcAdaptor::staticMetaObject, qt_meta_stringdata_FTLobbyAdaptor,
qt_meta_data_FTLobbyAdaptor, 0 }
};
const QMetaObject *FTLobbyAdaptor::metaObject() const
{
return &staticMetaObject;
}
void *FTLobbyAdaptor::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_FTLobbyAdaptor))
return static_cast<void*>(const_cast< FTLobbyAdaptor*>(this));
return RpcAdaptor::qt_metacast(_clname);
}
int FTLobbyAdaptor::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = RpcAdaptor::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: pongEvent((*reinterpret_cast< QVariantMap(*)>(_a[1]))); break;
case 1: ping(); break;
default: ;
}
_id -= 2;
}
return _id;
}
// SIGNAL 0
void FTLobbyAdaptor::pongEvent(QVariantMap _t1)
{
void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
QMetaObject::activate(this, &staticMetaObject, 0, _a);
}
QT_END_MOC_NAMESPACE
| [
"mikhail.mitkevich@a5377438-2eb2-11df-b28a-19025b8c0740"
]
| [
[
[
1,
86
]
]
]
|
4cf756993d4f2cd15d7ea7299c0fa8ca82c6b3d9 | 1775576281b8c24b5ce36b8685bc2c6919b35770 | /trunk/args_edit.cpp | 0196cf9bebfc3bc49d5576108857c9d633bed83d | []
| no_license | BackupTheBerlios/gtkslade-svn | 933a1268545eaa62087f387c057548e03497b412 | 03890e3ba1735efbcccaf7ea7609d393670699c1 | refs/heads/master | 2016-09-06T18:35:25.336234 | 2006-01-01T11:05:50 | 2006-01-01T11:05:50 | 40,615,146 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,865 | cpp |
#include "main.h"
#include "args.h"
GtkWidget* arg_labels[5];
GtkWidget* arg_entrys[5];
BYTE arg_value_dialog_val = 0;
vector<string> aedit_arg_types;
BYTE* aedit_args = NULL;
bool* aedit_args_consistent = NULL;
extern GtkWidget *editor_window;
void aedit_arg_value_radio_selected(GtkWidget *widget, gpointer data)
{
int val = (int)data;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
arg_value_dialog_val = val;
}
void aedit_arg_flag_cbox_toggled(GtkWidget *widget, gpointer data)
{
int val = (int)data;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
arg_value_dialog_val |= val;
else
arg_value_dialog_val = (arg_value_dialog_val & ~val);
}
int open_arg_value_dialog(int val, argtype_t *at)
{
arg_value_dialog_val = val;
GtkWidget *dialog = gtk_dialog_new_with_buttons("Edit Arg",
GTK_WINDOW(editor_window),
GTK_DIALOG_MODAL,
GTK_STOCK_OK,
GTK_RESPONSE_ACCEPT,
GTK_STOCK_CANCEL,
GTK_RESPONSE_REJECT,
NULL);
GtkWidget *main_vbox = gtk_vbox_new(false, 0);
GtkWidget *values_frame = gtk_frame_new("Values");
gtk_container_set_border_width(GTK_CONTAINER(values_frame), 4);
gtk_box_pack_start(GTK_BOX(main_vbox), values_frame, false, false, 0);
GtkWidget *values_hbox = gtk_hbox_new(false, 0);
gtk_container_add(GTK_CONTAINER(values_frame), values_hbox);
GtkWidget *values_vbox = gtk_vbox_new(false, 0);
gtk_container_set_border_width(GTK_CONTAINER(values_vbox), 4);
gtk_box_pack_start(GTK_BOX(values_hbox), values_vbox, false, false, 0);
GtkWidget *flags_frame = gtk_frame_new("Flags");
gtk_container_set_border_width(GTK_CONTAINER(flags_frame), 4);
GtkWidget *flags_vbox = gtk_vbox_new(false, 0);
gtk_container_set_border_width(GTK_CONTAINER(flags_vbox), 4);
gtk_container_add(GTK_CONTAINER(flags_frame), flags_vbox);
if (at->has_flags)
gtk_box_pack_start(GTK_BOX(main_vbox), flags_frame, false, false, 0);
int rows = 0;
GtkWidget *radgroup = gtk_radio_button_new(NULL);
for (int a = 0; a < at->values.size(); a++)
{
if (!at->values[a].flag)
{
GtkWidget *button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(radgroup), at->values[a].name.c_str());
g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(aedit_arg_value_radio_selected), (gpointer)at->values[a].value);
if (at->values[a].value == val)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), true);
gtk_box_pack_start(GTK_BOX(values_vbox), button, false, false, 0);
rows++;
if (rows == 15)
{
values_vbox = gtk_vbox_new(false, 0);
gtk_container_set_border_width(GTK_CONTAINER(values_vbox), 4);
gtk_box_pack_start(GTK_BOX(values_hbox), values_vbox, false, false, 0);
rows = 0;
}
}
else
{
GtkWidget *button = gtk_check_button_new_with_label(at->values[a].name.c_str());
g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(aedit_arg_flag_cbox_toggled), (gpointer)at->values[a].value);
if (at->values[a].value & val)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), true);
gtk_box_pack_start(GTK_BOX(flags_vbox), button, false, false, 0);
}
}
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), main_vbox);
gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ON_PARENT);
gtk_window_set_default_size(GTK_WINDOW(dialog), 300, -1);
gtk_widget_show_all(dialog);
int response = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
if (response == GTK_RESPONSE_ACCEPT)
return arg_value_dialog_val;
else
return val;
}
void arg_entry_changed(GtkEditable *editable, gpointer data)
{
GtkEntry* entry = (GtkEntry*)editable;
int arg = (int)data;
argtype_t* arg_type = get_arg_type(aedit_arg_types[arg]);
string text = gtk_entry_get_text(entry);
if (text != "")
{
aedit_args[arg] = atoi(text.c_str());
aedit_args_consistent[arg] = true;
}
else
aedit_args_consistent[arg] = false;
if (arg_type)
{
string val_name = arg_type->get_name(atoi(gtk_entry_get_text(entry)));
gtk_label_set_text(GTK_LABEL(arg_labels[arg]), val_name.c_str());
gtk_misc_set_alignment(GTK_MISC(arg_labels[arg]), 0.0, 0.5);
}
}
void aedit_change_button_click(GtkWidget *widget, gpointer data)
{
int arg = (int)data;
argtype_t* at = get_arg_type(aedit_arg_types[arg]);
if (at)
{
int val = open_arg_value_dialog(aedit_args[arg], at);
gtk_entry_set_text(GTK_ENTRY(arg_entrys[arg]), parse_string("%d", val).c_str());
}
}
GtkWidget* get_args_editor(BYTE* args, string* argnames, string* argtypes, bool* consistent)
{
GtkWidget *vbox = gtk_vbox_new(true, 0);
gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
aedit_arg_types.clear();
aedit_args = args;
aedit_args_consistent = consistent;
for (int a = 0; a < 5; a++)
{
aedit_arg_types.push_back(argtypes[a]);
GtkWidget *hbox = gtk_hbox_new(false, 0);
// Labels
GtkWidget *label = gtk_label_new(parse_string("%s:", argnames[a].c_str()).c_str());
gtk_box_pack_start(GTK_BOX(hbox), label, false, false, 0);
// Label
arg_labels[a] = gtk_label_new(NULL);
gtk_box_pack_start(GTK_BOX(hbox), arg_labels[a], true, true, 4);
// Entry
arg_entrys[a] = gtk_entry_new();
gtk_widget_set_size_request(GTK_WIDGET(arg_entrys[a]), 32, -1);
g_signal_connect(G_OBJECT(arg_entrys[a]), "changed", G_CALLBACK(arg_entry_changed), (gpointer)a);
gtk_box_pack_start(GTK_BOX(hbox), arg_entrys[a], false, false, 4);
if (consistent[a])
gtk_entry_set_text(GTK_ENTRY(arg_entrys[a]), parse_string("%d", args[a]).c_str());
// Button
GtkWidget *button = gtk_button_new_with_label("Change");
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(aedit_change_button_click), (gpointer)a);
gtk_box_pack_start(GTK_BOX(hbox), button, false, false, 4);
gtk_box_pack_start(GTK_BOX(vbox), hbox, false, false, 0);
}
return vbox;
}
void open_args_edit(BYTE* args, string* argnames, string* argtypes, bool* consistent)
{
GtkWidget *dialog = gtk_dialog_new_with_buttons("Edit Args",
GTK_WINDOW(editor_window),
GTK_DIALOG_MODAL,
GTK_STOCK_OK,
GTK_RESPONSE_ACCEPT,
GTK_STOCK_CANCEL,
GTK_RESPONSE_REJECT,
NULL);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), get_args_editor(args, argnames, argtypes, consistent));
gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ON_PARENT);
gtk_window_set_default_size(GTK_WINDOW(dialog), 300, -1);
gtk_widget_show_all(dialog);
int response = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
gtk_window_present(GTK_WINDOW(editor_window));
}
| [
"veilofsorrow@0f6d0948-3201-0410-bbe6-95a89488c5be"
]
| [
[
[
1,
211
]
]
]
|
043dbca9fe2490e6873bb94b6bd379bb3aad911e | 41f818d13a1d29305763aea93709ed0682e047d4 | /Conf/DefaultOptions.cpp | 0a14f4bc37a011f35de9df2e41ff817bdb6192ca | []
| no_license | lucasb-eyer/roadrage | bb760e4705f09a7965085bd56409c2a1e3fbfc5a | bb9b470f4a686b632d1e700aa4dc8dea4a3a11c0 | refs/heads/master | 2020-05-17T15:25:45.068260 | 2010-12-01T13:23:55 | 2010-12-01T13:23:55 | 42,473,106 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 257 | cpp | #include "DefaultOptions.h"
using namespace RoadRage;
DefaultOptions::DefaultOptions()
{
}
DefaultOptions::~DefaultOptions()
{
}
void DefaultOptions::add(const std::string& name, const std::string& value)
{
m_defOpt[name] = value;
}
| [
"[email protected]"
]
| [
[
[
1,
16
]
]
]
|
67cd75fc2de65687382b47e76ab9e764fe4d2cfd | a84b143f40d9e945b3ee81a2e4522706a381ca85 | /PGR2project/common/timer.cpp | 1c14fd9c7af4396589df1cd1516aa19e9ab64e47 | []
| no_license | kucerad/natureal | ed076b87001104d2817ade8f64a34e1571f53fc8 | afa143975c54d406334dc1ee7af3f8ee26008334 | refs/heads/master | 2021-01-01T05:38:08.139120 | 2011-09-06T07:00:36 | 2011-09-06T07:00:36 | 35,802,274 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,170 | cpp | // ===================================================================
// $Id$
//
// timer.cpp
// Timing for running process
//
// Licence: the use and distribution of this file is severely limited, please
// see the file 'doc/Licence.txt'. Any non-authorized use can be prosecuted under
// International Law. For further questions, please, e-mail to [email protected]
// or mail to Vlastimil Havran, Pohodli 27, 57001 Litomysl, the Czech Republic.
// REPLACEMENT_STRING
//
// Initial coding by Vlastimil Havran, 1998.
// Windows time measuring added by Jaroslav Krivanek, October 2003.
// GOLEM headers
#include "timer.h"
// ------------------------------------------------------
// Use ftime instead of time, see > man ftime
#define _USE_FTIME_CALL
// standard headers
#include <ctime>
#ifdef __UNIX__
#include <sys/time.h>
#include <sys/resource.h>
#ifdef _USE_FTIME_CALL
#include <sys/timeb.h>
#endif // _USE_FTIME_CALL
#endif // __UNIX__
#ifdef _MSC_VER
#include <windows.h>
#include <sys/types.h>
#include <sys/timeb.h>
#endif // _MSC_VER
// Staic variable
bool
CTimer::initTimingCalled = false;
// The following are not static's in the CTimer class to prevent
// #including <windows.h> into the "timer.h" header.
#ifdef _MSC_VER
/// true if the performance timer works under windows
static BOOL hasHRTimer;
/// frequency of the performance timer under windows
static LARGE_INTEGER hrFreq;
#endif // MSC_VER
void
CTimer::_initTiming()
{
#ifdef _MSC_VER
hasHRTimer = QueryPerformanceFrequency(&hrFreq);
#endif
initTimingCalled = true;
}
void
CTimer::Reset()
{
// Real times in seconds
#ifdef _USE_FTIME_CALL
timeb beg;
ftime(&beg);
lastRealTime = (double)(beg.time + 0.001 * beg.millitm);
#else // _USE_FTIME_CALL
time_t beg;
time(&beg);
lastRealTime = (double)beg;
#endif // _USE_FTIME_CALL
lastUserTime = 0.0;
lastSystemTime = 0.0;
realTime = 0.0;
userTime = 0.0;
systemTime = 0.0;
countStop = 0;
running = false;
#ifdef __UNIX__
// Timing in OS UNIX
begrusage.ru_utime.tv_usec = begrusage.ru_utime.tv_sec =
begrusage.ru_stime.tv_usec = begrusage.ru_stime.tv_sec = 0L;
endrusage = begrusage;
#endif // __UNIX__
}
void
CTimer::_start() const
{
if (running)
return; // timer is already running
// Measure the real time
#ifdef _USE_FTIME_CALL
timeb beg;
ftime(&beg);
lastRealTime = (double)(beg.time + 0.001 * beg.millitm);
#else // _USE_FTIME_CALL
time_t beg;
time(&beg);
lastRealTime = (double)beg;
#endif // _USE_FTIME_CALL
// Measure the real and system time
#ifdef __UNIX__
// Measure under UNIX
struct rusage begrusage;
getrusage(RUSAGE_SELF, &begrusage);
lastUserTime = (double)begrusage.ru_utime.tv_sec +
1e-6 * begrusage.ru_utime.tv_usec;
lastSystemTime = (double)begrusage.ru_stime.tv_sec +
1e-6 * begrusage.ru_stime.tv_usec;
#endif // __UNIX__
#ifdef _MSC_VER
// Mesure under Windows
if (hasHRTimer) {
LARGE_INTEGER counter;
QueryPerformanceCounter(&counter);
lastUserTime = (double)counter.QuadPart / (double)hrFreq.QuadPart;
lastSystemTime = 0;
}
else {
static struct _timeb mtime;
_ftime(&mtime);
lastUserTime = (double)mtime.time + 1e-3 * mtime.millitm;
lastSystemTime = 0;
}
#endif
// Begin trace.
running = true;
}
void
CTimer::_stop() const
{
if (!running)
return; // timer is not running
// Begin trace.
#ifdef _USE_FTIME_CALL
timeb end;
ftime(&end);
realTime += (double)(end.time + 0.001 * end.millitm) - lastRealTime;
#else // _USE_FTIME_CALL
time_t end;
time(&end);
realTime += (double)end - lastRealTime;
#endif // _USE_FTIME_CALL
#ifdef __UNIX__
// timing in unix OS
getrusage(RUSAGE_SELF, &endrusage);
userTime += (double)endrusage.ru_utime.tv_sec +
1e-6 * endrusage.ru_utime.tv_usec -
lastUserTime;
systemTime += (double)endrusage.ru_stime.tv_sec +
1e-6 * endrusage.ru_stime.tv_usec -
lastSystemTime;
#endif // __UNIX__
#ifdef _MSC_VER
// Mesure under Windows
if (hasHRTimer) {
LARGE_INTEGER counter;
QueryPerformanceCounter(&counter);
userTime += (double)counter.QuadPart / (double)hrFreq.QuadPart -
lastUserTime;
systemTime = 0;
}
else {
static struct _timeb mtime;
_ftime(&mtime);
userTime += (double)mtime.time + 1e-3 * mtime.millitm -
lastUserTime;
systemTime = 0;
}
#endif
running = false;
countStop++;
}
// returns the real time measured by timer in seconds
double
CTimer::RealTime() const
{
if (running) {
_stop();
_start();
}
return realTime;
}
// returns the user time measured by timer in seconds
double
CTimer::UserTime() const
{
if (running) {
_stop();
_start();
}
return userTime;
}
// returns the user+system time measured by timer in seconds
double
CTimer::SystemTime() const
{
if (running) {
_stop();
_start();
}
return systemTime;
}
| [
"kucera.ad@2c66c73b-3297-93fb-03e7-aeb916e281bd"
]
| [
[
[
1,
229
]
]
]
|
47c2b30046c3f9121a115f942c56cc933d56efee | 061348a6be0e0e602d4a5b3e0af28e9eee2d257f | /Examples/Tutorial/UserInterface/37InternalWindow.cpp | 35fa5d612b28146c06adedc91a11bee55c18a896 | []
| no_license | passthefist/OpenSGToolbox | 4a76b8e6b87245685619bdc3a0fa737e61a57291 | d836853d6e0647628a7dd7bb7a729726750c6d28 | refs/heads/master | 2023-06-09T22:44:20.711657 | 2010-07-26T00:43:13 | 2010-07-26T00:43:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,841 | cpp | // OpenSG Tutorial Example: Creating a Button Component
//
// This tutorial explains how to edit the basic features of
// a Button and a ToggleButtoncreated in the OSG User
// Interface library.
//
// Includes: Button PreferredSize, MaximumSize, MinimumSize, Font,
// Text,and adding a Button to a Scene. Also note that clicking
// the Button causes it to appear pressed
// General OpenSG configuration, needed everywhere
#include "OSGConfig.h"
// Methods to create simple geometry: boxes, spheres, tori etc.
#include "OSGSimpleGeometry.h"
// A little helper to simplify scene management and interaction
#include "OSGSimpleSceneManager.h"
#include "OSGNode.h"
#include "OSGGroup.h"
#include "OSGViewport.h"
// The general scene file loading handler
#include "OSGSceneFileHandler.h"
// Input
#include "OSGWindowUtils.h"
// UserInterface Headers
#include "OSGUIForeground.h"
#include "OSGUIDrawingSurface.h"
#include "OSGInternalWindow.h"
#include "OSGGraphics2D.h"
#include "OSGLookAndFeelManager.h"
// Activate the OpenSG namespace
OSG_USING_NAMESPACE
// The SimpleSceneManager to manage simple applications
SimpleSceneManager *mgr;
WindowEventProducerRefPtr TutorialWindow;
void display(void);
void reshape(Vec2f Size);
// 01 Button Headers
#include "OSGButton.h"
#include "OSGToggleButton.h"
#include "OSGUIFont.h"
#include "OSGColorLayer.h"
#include "OSGFlowLayout.h"
// Create a class to allow for the use of the Escape
// key to exit
class TutorialKeyListener : public KeyListener
{
public:
virtual void keyPressed(const KeyEventUnrecPtr e)
{
if(e->getKey() == KeyEvent::KEY_Q && e->getModifiers() & KeyEvent::KEY_MODIFIER_COMMAND)
{
TutorialWindow->closeWindow();
}
}
virtual void keyReleased(const KeyEventUnrecPtr e)
{
}
virtual void keyTyped(const KeyEventUnrecPtr e)
{
}
};
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
TutorialWindow->setDisplayCallback(display);
TutorialWindow->setReshapeCallback(reshape);
TutorialKeyListener TheKeyListener;
TutorialWindow->addKeyListener(&TheKeyListener);
// Make Torus Node (creates Torus in background of scene)
NodeRefPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
// Make Main Scene Node and add the Torus
NodeRefPtr scene = OSG::Node::create();
scene->setCore(OSG::Group::create());
scene->addChild(TorusGeometryNode);
// Create the Graphics
GraphicsRefPtr TutorialGraphics = OSG::Graphics2D::create();
// Initialize the LookAndFeelManager to enable default settings
LookAndFeelManager::the()->getLookAndFeel()->init();
/******************************************************
Create an Button Component and
a simple Font.
See 17Label_Font for more
information about Fonts.
******************************************************/
ButtonRefPtr ExampleButton = OSG::Button::create();
UIFontRefPtr ExampleFont = OSG::UIFont::create();
ExampleFont->setSize(16);
ExampleButton->setMinSize(Vec2f(50, 25));
ExampleButton->setMaxSize(Vec2f(200, 100));
ExampleButton->setPreferredSize(Vec2f(100, 50));
ExampleButton->setToolTipText("Button 1 ToolTip");
ExampleButton->setText("Button 1");
ExampleButton->setFont(ExampleFont);
ExampleButton->setTextColor(Color4f(1.0, 0.0, 0.0, 1.0));
ExampleButton->setRolloverTextColor(Color4f(1.0, 0.0, 1.0, 1.0));
ExampleButton->setActiveTextColor(Color4f(1.0, 0.0, 0.0, 1.0));
ExampleButton->setAlignment(Vec2f(1.0,0.0));
/******************************************************
Create a ToggleButton and determine its
characteristics. ToggleButton inherits
off of Button, so all characteristsics
used above can be used with ToggleButtons
as well.
The only difference is that when pressed,
ToggleButton remains pressed until pressed
again.
-setSelected(bool): Determine whether the
ToggleButton is Selected (true) or
deselected (false).
******************************************************/
ToggleButtonRefPtr ExampleToggleButton = OSG::ToggleButton::create();
ExampleToggleButton->setSelected(false);
ExampleToggleButton->setText("ToggleMe");
ExampleToggleButton->setToolTipText("Toggle Button ToolTip");
// Create Background to be used with the MainInternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
// Create The Internal Window
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
// Assign the Button to the MainInternalWindow so it will be displayed
// when the view is rendered.
MainInternalWindow->pushToChildren(ExampleButton);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setPosition(Pnt2f(50,50));
MainInternalWindow->setPreferredSize(Vec2f(300,300));
MainInternalWindow->setTitle(std::string("Internal Window 1"));
// Create The Internal Window
InternalWindowRefPtr MainInternalWindow2 = OSG::InternalWindow::create();
LayoutRefPtr MainInternalWindowLayout2 = OSG::FlowLayout::create();
// Assign the Button to the MainInternalWindow so it will be displayed
// when the view is rendered.
MainInternalWindow2->pushToChildren(ExampleToggleButton);
MainInternalWindow2->setLayout(MainInternalWindowLayout2);
MainInternalWindow2->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow2->setPosition(Pnt2f(150,150));
MainInternalWindow2->setPreferredSize(Vec2f(300,300));
MainInternalWindow2->setTitle(std::string("Internal Window 2"));
MainInternalWindow2->setIconable(false);
MainInternalWindow2->setAllwaysOnTop(true);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow2);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
mgr->setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
// Show the whole Scene
mgr->showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"37InternalWindow");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
// Callback functions
// Redraw the window
void display(void)
{
mgr->redraw();
}
// React to size changes
void reshape(Vec2f Size)
{
mgr->resize(Size.x(), Size.y());
}
| [
"[email protected]"
]
| [
[
[
1,
241
]
]
]
|
149000d60755a9333691ee5db38d3cdec2d9574a | 2e613efc5a3b330f440a2d90bb758dafbdf8f6b1 | /include/rtlinearscalex.h | 02d96db1d236f382be507cba79e78e3dbc428d5d | []
| no_license | zhaoweisonake/qfplot | 4a76d446aebfddce4bf8a51c709a815f35ca76d2 | e30d851261f3987a42319ff98def23771adb24bd | refs/heads/master | 2021-01-18T12:31:07.049737 | 2010-05-17T09:29:11 | 2010-05-17T09:29:11 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,070 | h | #ifndef RTLINEARSCALEX_H
#define RTLINEARSCALEX_H
#include "linearscalex.h"
//PLOTTER_IMPORT has hi prority them PLOTTER_EXPORT
#if defined(Q_WS_WIN)
# if !defined(PLOTTER_EXPORT) && !defined(PLOTTER_IMPORT)
# define PLOTTER_EXPORT
# elif defined(PLOTTER_IMPORT)
# if defined(PLOTTER_EXPORT)
# undef PLOTTER_EXPORT
# endif
# define PLOTTER_EXPORT __declspec(dllimport)
# elif defined(PLOTTER_EXPORT)
# undef PLOTTER_EXPORT
# define PLOTTER_EXPORT __declspec(dllexport)
# endif
#else
# define PLOTTER_EXPORT
#endif
/**
* Class LinearScaleX
*
*/
class PLOTTER_EXPORT RTLinearScaleX : public LinearScaleX
{
public:
//Must be called after change time on a plotter.
virtual void setRefPoint( double val, double pos, double d );
virtual int real2plot (double value)const;
virtual double plot2real (double value)const;
protected:
//Max value on a plotter.
double currentVal;
//Corresponded position of the currentVal.
double currentX;
};
#endif //RTLINEARSCALEX_H
| [
"akhokhlov@localhost"
]
| [
[
[
1,
44
]
]
]
|
827f868fba4823eb4681eab32e57d039d61ce6e8 | a296df442777ae1e63188cbdf5bcd2ca0adedf3f | /2372/2372/Item.h | 984ff9caae03bdf8dbcee7efcebaa175be0ed8b5 | []
| no_license | piyushv94/jpcap-scanner | 39b4d710166c12a2fe695d9ec222da7b36787443 | 8fbf4214586e4f07f1b3ec4819f9a3c7451bd679 | refs/heads/master | 2021-01-10T06:15:32.064675 | 2011-11-26T20:23:55 | 2011-11-26T20:23:55 | 44,114,378 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 333 | h | #ifndef _myItem
#define _myItem
#include<iostream>
using std::ostream;
class Item{
friend ostream& operator<<(ostream &_os,const Item& _i);
public:
int x;
int y;
Item(int _x=0,int _y=0);
int getX()const;
int getY()const;
virtual ostream& printOut(ostream& os,const Item& i) const;
void unitTest();
};
#endif | [
"[email protected]"
]
| [
[
[
1,
17
]
]
]
|
f7382ec2e665628de39d83049ccbd848096badf3 | c5534a6df16a89e0ae8f53bcd49a6417e8d44409 | /trunk/nGENE Framework/SettingsWindowWin32.cpp | 97e6a9e2327b8f78d4d7d8b8c8ca0fff56b17cf7 | []
| no_license | svn2github/ngene | b2cddacf7ec035aa681d5b8989feab3383dac012 | 61850134a354816161859fe86c2907c8e73dc113 | refs/heads/master | 2023-09-03T12:34:18.944872 | 2011-07-27T19:26:04 | 2011-07-27T19:26:04 | 78,163,390 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,411 | cpp | /*
---------------------------------------------------------------------------
This source file is part of nGENE Tech.
Copyright (c) 2006- Wojciech Toman
This program is free software.
File: SettingsWindowWin32.cpp
Version: 0.10
---------------------------------------------------------------------------
*/
#define NOMINMAX
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif
#include <windows.h>
#include "PrecompiledHeaders.h"
#include "Resource.h"
#include "SettingsWindowWin32.h"
#include "FuncSplit.h"
#include "RendererEnumerator.h"
namespace nGENE
{
namespace Application
{
bool DisplayModesComparator(SDisplayMode* _mode1, SDisplayMode* _mode2)
{
if(_mode1->width == _mode2->width)
return (_mode1->height < _mode2->height);
else
return (_mode1->width < _mode2->width);
}
SettingsWindowWin32::SettingsWindowWin32()
{
}
//----------------------------------------------------------------------
SettingsWindowWin32::~SettingsWindowWin32()
{
}
//----------------------------------------------------------------------
bool SettingsWindowWin32::createWindow()
{
// Retrieve display modes
DEVMODE mode;
dword counter = 0;
while(EnumDisplaySettings(NULL, counter++, &mode))
{
SDisplayMode displayMode;
displayMode.width = mode.dmPelsWidth;
displayMode.height = mode.dmPelsHeight;
stringstream buffer;
buffer << displayMode.width << "x" << displayMode.height;
m_DisplayModes[buffer.str()] = displayMode;
}
HINSTANCE hInstance = static_cast<HINSTANCE>(GetModuleHandle(NULL));
int i = DialogBox(hInstance, MAKEINTRESOURCE(IDD_DLG_CONFIG), NULL, DlgProc);
// Cancel clicked, so we have to exit
if(!i)
return false;
// Error occured, so log it
if(i == -1)
{
int winError = GetLastError();
wchar_t* errDesc = new wchar_t[255];
FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
winError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
static_cast<LPWSTR>(errDesc),
255,
NULL);
Log::log(LET_ERROR, L"Application", __WFILE__, __WFUNCTION__, __LINE__,
errDesc);
return false;
}
return true;
}
//----------------------------------------------------------------------
void SettingsWindowWin32::showWindow(bool value)
{
}
//----------------------------------------------------------------------
BOOL SettingsWindowWin32::DlgProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lParam)
{
HWND hwndItem;
int sel;
char data[10];
HashTable <string, SDisplayMode>::iterator iter;
HashTable <string, SDisplayMode> table = SettingsWindowWin32::getSingleton().getDisplayModes();
vector <SDisplayMode*> modes;
for(iter = table.begin(); iter != table.end(); ++iter)
modes.push_back(&iter->second);
std::sort(modes.begin(), modes.end(), DisplayModesComparator);
switch(nMsg)
{
case WM_INITDIALOG:
{
// Initialize combo box
hwndItem = GetDlgItem(hDlg, IDC_CBO_RENDERSYSTEM);
vector <wstring> vRenderers = RendererEnumerator::getSingleton().getNamesList();
for(uint i = 0; i < vRenderers.size(); ++i)
{
string stName(vRenderers[i].begin(), vRenderers[i].end());
SendMessage(hwndItem, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(stName.c_str()));
}
SendMessage(hwndItem, CB_SETCURSEL, static_cast<WPARAM>(0), 0);
// Initialize combo box
hwndItem = GetDlgItem(hDlg, IDC_CBO_SOUNDSYSTEM);
SendMessage(hwndItem, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>("FMOD"));
SendMessage(hwndItem, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>("No sound"));
SendMessage(hwndItem, CB_SETCURSEL, static_cast<WPARAM>(0), 0);
// Initialize list box
hwndItem = GetDlgItem(hDlg, IDC_LST_MODE);
for(uint i = 0; i < modes.size(); ++i)
{
char line[12];
sprintf(line, "%dx%d", modes[i]->width, modes[i]->height);
SendMessage(hwndItem, LB_ADDSTRING, 0, reinterpret_cast<LPARAM>(line));
}
SendMessage(hwndItem, LB_SELECTSTRING, 0, reinterpret_cast<LPARAM>("800x600"));
// Set default display mode to windowed
hwndItem = GetDlgItem(hDlg, IDC_CHB_WINDOWED);
SendMessage(hwndItem, BM_SETCHECK, static_cast<WPARAM>(TRUE), 0);
// Set default number of target windows to 1
hwndItem = GetDlgItem(hDlg, IDC_TXT_WNDS);
SendMessage(hwndItem, WM_SETTEXT, 0, reinterpret_cast<LPARAM>("1"));
// Enable VSync by default
hwndItem = GetDlgItem(hDlg, IDC_CHB_VSYNC);
SendMessage(hwndItem, BM_SETCHECK, static_cast<WPARAM>(TRUE), 0);
// Set startup size and position of the window
int x, y, screenWidth, screenHeight;
RECT rcDlg;
GetWindowRect(hDlg, &rcDlg);
screenWidth = GetSystemMetrics(SM_CXFULLSCREEN);
screenHeight = GetSystemMetrics(SM_CYFULLSCREEN);
x = (screenWidth >> 1) - ((rcDlg.right - rcDlg.left) >> 1);
y = (screenHeight>> 1) - ((rcDlg.bottom - rcDlg.top) >> 1);
MoveWindow(hDlg, x, y, (rcDlg.right - rcDlg.left),
(rcDlg.bottom - rcDlg.top), TRUE);
}
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_CBO_RENDERSYSTEM:
hwndItem = GetDlgItem(hDlg, IDC_CBO_RENDERSYSTEM);
if(HIWORD(wParam) == CBN_SELCHANGE)
{
sel = SendMessage(hwndItem, CB_GETCURSEL, 0, 0);
if(sel != -1)
{
char temp[16];
SendMessage(hwndItem, CB_GETLBTEXT, static_cast<WORD>(sel), LPARAM(temp));
string selected = temp;
wstring stRenderer(selected.begin(), selected.end());
SettingsWindowWin32::getSingleton().getEngineInfo().renderer = stRenderer;
}
}
return TRUE;
case IDC_CBO_SOUNDSYSTEM:
hwndItem = GetDlgItem(hDlg, IDC_CBO_SOUNDSYSTEM);
sel = SendMessage(hwndItem, CB_GETCOUNT, 0, 0);
if(HIWORD(wParam) == CBN_SELCHANGE)
{
sel = SendMessage(hwndItem, CB_GETCURSEL, 0, 0);
if(sel != -1)
{
// Set rendering API
if(sel == 0)
SettingsWindowWin32::getSingleton().getEngineInfo().soundLibrary = L"FMOD";
else if(sel == 1)
SettingsWindowWin32::getSingleton().getEngineInfo().soundLibrary = L"";
}
}
return TRUE;
case IDC_LST_MODE:
hwndItem = GetDlgItem(hDlg, IDC_LST_MODE);
if(HIWORD(wParam) == LBN_SELCHANGE)
{
sel = SendMessage(hwndItem, LB_GETCURSEL, 0, 0);
if(sel != -1)
{
char temp[10];
SendMessage(hwndItem, LB_GETTEXT, static_cast<WORD>(sel), LPARAM(temp));
string selected = temp;
vector <string> vecValues;
FuncSplit <string> tokenizer;
tokenizer(selected, vecValues, "x");
SettingsWindowWin32::getSingleton().getEngineInfo().DisplayMode.width = atoi(vecValues[0].c_str());
SettingsWindowWin32::getSingleton().getEngineInfo().DisplayMode.height = atoi(vecValues[1].c_str());
}
}
return TRUE;
case IDC_CHB_WINDOWED:
if(IsDlgButtonChecked(hDlg, IDC_CHB_WINDOWED))
{
hwndItem = GetDlgItem(hDlg, IDC_TXT_WNDS);
SendMessage(hwndItem, WM_ENABLE, static_cast<WPARAM>(TRUE), 0);
SettingsWindowWin32::getSingleton().getEngineInfo().DisplayMode.windowed = true;
}
else
{
hwndItem = GetDlgItem(hDlg, IDC_TXT_WNDS);
SendMessage(hwndItem, WM_ENABLE, static_cast<WPARAM>(FALSE), 0);
SettingsWindowWin32::getSingleton().getEngineInfo().DisplayMode.windowed = false;
}
return TRUE;
case IDC_CHB_VSYNC:
if(IsDlgButtonChecked(hDlg, IDC_CHB_VSYNC))
{
SettingsWindowWin32::getSingleton().getEngineInfo().DisplayMode.vsync = true;
}
else
{
SettingsWindowWin32::getSingleton().getEngineInfo().DisplayMode.vsync = false;
}
return TRUE;
case ID_OK:
hwndItem = GetDlgItem(hDlg, IDC_TXT_WNDS);
SendMessage(hwndItem, WM_GETTEXT, 10, reinterpret_cast<LPARAM>(data));
SettingsWindowWin32::getSingleton().getEngineInfo().renderWindowsNum = atoi(data);
EndDialog(hDlg, 1);
return TRUE;
case ID_CANCEL:
EndDialog(hDlg, 0);
return FALSE;
}
}
return FALSE;
}
//----------------------------------------------------------------------
}
} | [
"Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57"
]
| [
[
[
1,
278
]
]
]
|
7748a7af0188701054ec0005ce4094444b168324 | 45229380094a0c2b603616e7505cbdc4d89dfaee | /HMMCLR/stdafx.h | da029fbfd1fab30ad0ec5bf16ea84586fc5f5422 | []
| no_license | xcud/msrds | a71000cc096723272e5ada7229426dee5100406c | 04764859c88f5c36a757dbffc105309a27cd9c4d | refs/heads/master | 2021-01-10T01:19:35.834296 | 2011-11-04T09:26:01 | 2011-11-04T09:26:01 | 45,697,313 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 441 | h | // stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
#pragma once
// TODO: reference additional headers your program requires here
#pragma unmanaged
#include <cv.h>
//#include <cxtypes.h>
#include <highgui.h>
#include <cvcam.h>
#include <vector>
#pragma managed
using namespace System::Runtime::InteropServices; | [
"perpet99@cc61708c-8d4c-0410-8fce-b5b73d66a671"
]
| [
[
[
1,
20
]
]
]
|
02e8858f5f07ee58d4b87a806e8d0542f0619e9a | a84b013cd995870071589cefe0ab060ff3105f35 | /webdriver/branches/jsapi/third_party/gecko-1.9.0.11/win32/include/nsIDOMHTMLQuoteElement.h | 9155322634046567bcf162e0f30ded9a23538980 | [
"Apache-2.0"
]
| permissive | vdt/selenium | 137bcad58b7184690b8785859d77da0cd9f745a0 | 30e5e122b068aadf31bcd010d00a58afd8075217 | refs/heads/master | 2020-12-27T21:35:06.461381 | 2009-08-18T15:56:32 | 2009-08-18T15:56:32 | 13,650,409 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,346 | h | /*
* DO NOT EDIT. THIS FILE IS GENERATED FROM e:/xr19rel/WINNT_5.2_Depend/mozilla/dom/public/idl/html/nsIDOMHTMLQuoteElement.idl
*/
#ifndef __gen_nsIDOMHTMLQuoteElement_h__
#define __gen_nsIDOMHTMLQuoteElement_h__
#ifndef __gen_nsIDOMHTMLElement_h__
#include "nsIDOMHTMLElement.h"
#endif
/* For IDL files that don't want to include root IDL files. */
#ifndef NS_NO_VTABLE
#define NS_NO_VTABLE
#endif
/* starting interface: nsIDOMHTMLQuoteElement */
#define NS_IDOMHTMLQUOTEELEMENT_IID_STR "a6cf90a3-15b3-11d2-932e-00805f8add32"
#define NS_IDOMHTMLQUOTEELEMENT_IID \
{0xa6cf90a3, 0x15b3, 0x11d2, \
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 }}
/**
* The nsIDOMHTMLQuoteElement interface is the interface to a [X]HTML
* q element.
*
* For more information on this interface please see
* http://www.w3.org/TR/DOM-Level-2-HTML/
*
* @status FROZEN
*/
class NS_NO_VTABLE NS_SCRIPTABLE nsIDOMHTMLQuoteElement : public nsIDOMHTMLElement {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOMHTMLQUOTEELEMENT_IID)
/* attribute DOMString cite; */
NS_SCRIPTABLE NS_IMETHOD GetCite(nsAString & aCite) = 0;
NS_SCRIPTABLE NS_IMETHOD SetCite(const nsAString & aCite) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMHTMLQuoteElement, NS_IDOMHTMLQUOTEELEMENT_IID)
/* Use this macro when declaring classes that implement this interface. */
#define NS_DECL_NSIDOMHTMLQUOTEELEMENT \
NS_SCRIPTABLE NS_IMETHOD GetCite(nsAString & aCite); \
NS_SCRIPTABLE NS_IMETHOD SetCite(const nsAString & aCite);
/* Use this macro to declare functions that forward the behavior of this interface to another object. */
#define NS_FORWARD_NSIDOMHTMLQUOTEELEMENT(_to) \
NS_SCRIPTABLE NS_IMETHOD GetCite(nsAString & aCite) { return _to GetCite(aCite); } \
NS_SCRIPTABLE NS_IMETHOD SetCite(const nsAString & aCite) { return _to SetCite(aCite); }
/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
#define NS_FORWARD_SAFE_NSIDOMHTMLQUOTEELEMENT(_to) \
NS_SCRIPTABLE NS_IMETHOD GetCite(nsAString & aCite) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetCite(aCite); } \
NS_SCRIPTABLE NS_IMETHOD SetCite(const nsAString & aCite) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetCite(aCite); }
#if 0
/* Use the code below as a template for the implementation class for this interface. */
/* Header file */
class nsDOMHTMLQuoteElement : public nsIDOMHTMLQuoteElement
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMHTMLQUOTEELEMENT
nsDOMHTMLQuoteElement();
private:
~nsDOMHTMLQuoteElement();
protected:
/* additional members */
};
/* Implementation file */
NS_IMPL_ISUPPORTS1(nsDOMHTMLQuoteElement, nsIDOMHTMLQuoteElement)
nsDOMHTMLQuoteElement::nsDOMHTMLQuoteElement()
{
/* member initializers and constructor code */
}
nsDOMHTMLQuoteElement::~nsDOMHTMLQuoteElement()
{
/* destructor code */
}
/* attribute DOMString cite; */
NS_IMETHODIMP nsDOMHTMLQuoteElement::GetCite(nsAString & aCite)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsDOMHTMLQuoteElement::SetCite(const nsAString & aCite)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* End of implementation class template. */
#endif
#endif /* __gen_nsIDOMHTMLQuoteElement_h__ */
| [
"simon.m.stewart@07704840-8298-11de-bf8c-fd130f914ac9"
]
| [
[
[
1,
108
]
]
]
|
c53e9e7ccc45e14d2d6744604a04db50e152af4d | 2dbbca065b62a24f47aeb7ec5cd7a4fd82083dd4 | /OUAN/OUAN/Src/Game/GameObject/GameObjectBridge.h | 1538ddd641ec1e356c2fce9deecf9797df5760dc | []
| no_license | juanjmostazo/once-upon-a-night | 9651dc4dcebef80f0475e2e61865193ad61edaaa | f8d5d3a62952c45093a94c8b073cbb70f8146a53 | refs/heads/master | 2020-05-28T05:45:17.386664 | 2010-10-06T12:49:50 | 2010-10-06T12:49:50 | 38,101,059 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 5,020 | h | #ifndef GameObjectBridgeH_H
#define GameObjectBridgeH_H
#include "GameObject.h"
#include "../../Graphics/RenderComponent/RenderComponentEntity.h"
#include "../../Graphics/RenderComponent/RenderComponentInitial.h"
#include "../../Graphics/RenderComponent/RenderComponentPositional.h"
#include "../../Physics/PhysicsComponent/PhysicsComponentComplexConvex.h"
#include "../../Logic/LogicComponent/LogicComponent.h"
namespace OUAN
{
const std::string BRIDGE_ANIM_IDLE="idle";
const std::string BRIDGE_ANIM_ROLL="roll";
const std::string BRIDGE_ANIM_ROLL_IDLE="roll_idle";
const std::string BRIDGE_ANIM_UNROLL="unroll";
/// Class to hold terrain information
class GameObjectBridge : public GameObject, public boost::enable_shared_from_this<GameObjectBridge>
{
private:
/// Visual information
RenderComponentEntityPtr mRenderComponentEntity;
/// Position information
RenderComponentInitialPtr mRenderComponentInitial;
RenderComponentPositionalPtr mRenderComponentPositional;
/// Physics information
//PhysicsComponentComplexConvexPtr mPhysicsComponentComplexConvex;
/// Logic component: it'll represent the 'brains' of the game object
/// containing information on its current state, its life and health(if applicable),
/// or the world(s) the object belongs to
LogicComponentPtr mLogicComponent;
//TODO: think what happens when world changes with the rendercomponent
public:
//Constructor
GameObjectBridge(const std::string& name);
//Destructor
~GameObjectBridge();
/// Return render component entity
/// @return render component entity
RenderComponentEntityPtr getRenderComponentEntity() const;
/// Set logic component
void setLogicComponent(LogicComponentPtr logicComponent);
/// return logic component
LogicComponentPtr getLogicComponent();
bool isWorthUpdatingPhysicsComponents();
/// Set render component
/// @param pRenderComponentEntity
void setRenderComponentEntity(RenderComponentEntityPtr pRenderComponentEntity);
/// Set positional component
/// @param pRenderComponentPositional the component containing the positional information
void setRenderComponentPositional(RenderComponentPositionalPtr pRenderComponentPositional);
void setVisible(bool visible);
Ogre::Vector3 getLastPositionDifference();
/// Set initial component
void setRenderComponentInitial(RenderComponentInitialPtr pRenderComponentInitial);
/// Return positional component
/// @return positional component
RenderComponentPositionalPtr getRenderComponentPositional() const;
/// Return initial component
/// @return initial component
RenderComponentInitialPtr getRenderComponentInitial() const;
/// Set Particle Systems
void setRenderComponentParticleSystemChangeWorld(RenderComponentParticleSystemPtr mRenderComponentParticleSystemChangeWorld);
/// Get Particle Systems
RenderComponentParticleSystemPtr getRenderComponentParticleSystemChangeWorld() const;
/// Set physics component
//void setPhysicsComponentComplexConvex(PhysicsComponentComplexConvexPtr pPhysicsComponentComplexConvex);
/// Get physics component
//PhysicsComponentComplexConvexPtr getPhysicsComponentComplexConvex() const;
/// React to a world change to the one given as a parameter
/// @param world world to change to
void changeToWorld(int newWorld, double perc);
void changeWorldFinished(int newWorld);
void changeWorldStarted(int newWorld);
/// Reset object
virtual void reset();
bool hasPositionalComponent() const;
RenderComponentPositionalPtr getPositionalComponent() const;
bool hasPhysicsComponent() const;
//PhysicsComponentPtr getPhysicsComponent() const;
bool hasRenderComponentEntity() const;
RenderComponentEntityPtr getEntityComponent() const;
/// Process collision event
/// @param gameObject which has collision with
void processCollision(GameObjectPtr pGameObject, Ogre::Vector3 pNormal);
/// Process collision event
/// @param gameObject which has collision with
void processEnterTrigger(GameObjectPtr pGameObject);
/// Process collision event
/// @param gameObject which has collision with
void processExitTrigger(GameObjectPtr pGameObject);
void update(double elapsedSeconds);
bool hasLogicComponent() const;
LogicComponentPtr getLogicComponent() const;
};
class TGameObjectBridgeParameters: public TGameObjectParameters
{
public:
TGameObjectBridgeParameters();
~TGameObjectBridgeParameters();
///Parameters specific to an Ogre Entity
TRenderComponentEntityParameters tRenderComponentEntityParameters;
///Positional parameters
TRenderComponentPositionalParameters tRenderComponentPositionalParameters;
///Physics parameters
TPhysicsComponentComplexConvexParameters tPhysicsComponentComplexConvexParameters;
///Logic parameters
TLogicComponentParameters tLogicComponentParameters;
};
}
#endif | [
"wyern1@1610d384-d83c-11de-a027-019ae363d039",
"juanj.mostazo@1610d384-d83c-11de-a027-019ae363d039"
]
| [
[
[
1,
27
],
[
29,
74
],
[
81,
81
],
[
83,
84
],
[
86,
99
],
[
101,
145
]
],
[
[
28,
28
],
[
75,
80
],
[
82,
82
],
[
85,
85
],
[
100,
100
]
]
]
|
a2680653a4103912d4864d77e8cfadec0cdb63a1 | b5ad65ebe6a1148716115e1faab31b5f0de1b493 | /src/Aran/ArnBinaryChunk.cpp | 5ec812d486911d4f26ac9b8bfbeb4296b95e0e16 | []
| no_license | gasbank/aran | 4360e3536185dcc0b364d8de84b34ae3a5f0855c | 01908cd36612379ade220cc09783bc7366c80961 | refs/heads/master | 2021-05-01T01:16:19.815088 | 2011-03-01T05:21:38 | 2011-03-01T05:21:38 | 1,051,010 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,181 | cpp | #include "AranPCH.h"
#include "ArnBinaryChunk.h"
#include "zlib.h"
// Copied and modified from zpipe.c example of zlib
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
# include <fcntl.h>
# include <io.h>
# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
#else
# define SET_BINARY_MODE(file)
#endif
#define CHUNK 16384
int inf(FILE *source, char *dest)
{
int ret;
unsigned have;
z_stream strm;
unsigned char in[CHUNK];
unsigned char out[CHUNK];
unsigned destOffset = 0;
/* allocate inflate state */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = 0;
strm.next_in = Z_NULL;
ret = inflateInit(&strm);
if (ret != Z_OK)
return ret;
/* decompress until deflate stream ends or end of file */
do {
strm.avail_in = fread(in, 1, CHUNK, source);
if (ferror(source)) {
(void)inflateEnd(&strm);
return Z_ERRNO;
}
if (strm.avail_in == 0)
break;
strm.next_in = in;
/* run inflate() on input until output buffer not full */
do {
strm.avail_out = CHUNK;
strm.next_out = out;
ret = inflate(&strm, Z_NO_FLUSH);
assert(ret != Z_STREAM_ERROR); /* state not clobbered */
switch (ret) {
case Z_NEED_DICT:
ret = Z_DATA_ERROR; /* and fall through */
case Z_DATA_ERROR:
case Z_MEM_ERROR:
(void)inflateEnd(&strm);
return ret;
}
have = CHUNK - strm.avail_out;
memcpy(dest + destOffset, out, have);
destOffset += have;
} while (strm.avail_out == 0);
/* done when inflate() says it's done */
} while (ret != Z_STREAM_END);
/* clean up and return */
(void)inflateEnd(&strm);
return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
}
/* report a zlib or i/o error */
void zerr(int ret)
{
fputs("zpipe: ", stderr);
switch (ret) {
case Z_ERRNO:
if (ferror(stdin))
fputs("error reading stdin\n", stderr);
if (ferror(stdout))
fputs("error writing stdout\n", stderr);
break;
case Z_STREAM_ERROR:
fputs("invalid compression level\n", stderr);
break;
case Z_DATA_ERROR:
fputs("invalid or incomplete deflate data\n", stderr);
break;
case Z_MEM_ERROR:
fputs("out of memory\n", stderr);
break;
case Z_VERSION_ERROR:
fputs("zlib version mismatch!\n", stderr);
}
}
//////////////////////////////////////////////////////////////////////////
ArnBinaryChunk::ArnBinaryChunk()
: ArnObject(NDT_RT_BINARYCHUNK)
, m_recordDef()
, m_data()
, m_deallocateData(true)
, m_recordCount(0)
, m_recordSize(0)
{
}
ArnBinaryChunk::~ArnBinaryChunk()
{
if (m_deallocateData)
delete [] m_data;
}
ArnBinaryChunk*
ArnBinaryChunk::createFrom(const char* fileName, bool zlibCompressed, unsigned int uncompressedSize)
{
FILE* f = fopen(fileName, "rb");
ArnBinaryChunk* ret = 0;
if (f)
{
if (zlibCompressed == false)
{
fseek(f, 0, SEEK_END);
size_t fileSize = ftell(f);
assert(fileSize == uncompressedSize);
if (fileSize)
{
ret = new ArnBinaryChunk();
char* data = new char[fileSize]; // Since ret->m_data type is 'const char*', we use temporary variable named 'data'.
ret->m_deallocateData = true;
fseek(f, 0, SEEK_SET);
fread(data, 1, fileSize, f);
fclose(f);
ret->m_data = data;
ret->m_recordSize = fileSize;
ret->m_recordCount = 1;
}
}
else // zlib compressed binary file
{
ret = new ArnBinaryChunk();
char* data = new char[uncompressedSize]; // Since ret->m_data type is 'const char*', we use temporary variable named 'data'.
int zret;
if ((zret = inf(f, data)) != Z_OK)
{
zerr(zret);
delete [] data;
throw MyError(MEE_FILE_ACCESS_ERROR);
}
ret->m_data = data;
ret->m_deallocateData = true;
ret->m_recordSize = uncompressedSize;
ret->m_recordCount = 1;
}
fclose(f);
}
else
{
throw MyError(MEE_FILE_ACCESS_ERROR);
}
return ret;
}
void
ArnBinaryChunk::addField(const char* type, const char* usage)
{
ArnChunkFieldType acft = ACFT_UNKNOWN;
if (strcmp(type, "float") == 0)
acft = ACFT_FLOAT;
else if (strcmp(type, "float2") == 0)
acft = ACFT_FLOAT2;
else if (strcmp(type, "float3") == 0)
acft = ACFT_FLOAT3;
else if (strcmp(type, "float8") == 0)
acft = ACFT_FLOAT8;
else if (strcmp(type, "int") == 0)
acft = ACFT_INT;
else if (strcmp(type, "int3") == 0)
acft = ACFT_INT3;
else if (strcmp(type, "int4") == 0)
acft = ACFT_INT4;
else
acft = ACFT_UNKNOWN;
assert(acft != ACFT_UNKNOWN);
m_recordDef.push_back(Field(acft, usage, m_recordSize));
m_recordSize += ArnChunkFieldTypeSize[acft];
}
void
ArnBinaryChunk::copyFieldArray(void* target, int targetSize, const char* usage) const
{
const Field* field = 0;
foreach(const Field& f, m_recordDef)
{
if (f.usage.compare(usage) == 0)
{
field = &f;
break;
}
}
assert(field);
const int fieldSize = ArnChunkFieldTypeSize[field->type];
assert(targetSize == fieldSize * m_recordCount); // Clients should provide the exact 'targetSize' for 'target'.
for (int i = 0; i < m_recordCount; ++i)
{
memcpy((void*)((char*)target + fieldSize * i), m_data + m_recordSize * i + field->offset, fieldSize);
}
}
void
ArnBinaryChunk::printFieldArray(const char* usage) const
{
const Field* field = 0;
foreach(const Field& f, m_recordDef)
{
if (f.usage.compare(usage) == 0)
{
field = &f;
break;
}
}
assert(field);
for (int i = 0; i < m_recordCount; ++i)
{
if (field->type == ACFT_FLOAT3)
{
const ArnVec3* vec3 = (const ArnVec3*)(m_data + m_recordSize * i + field->offset);
char buf[128];
ArnVec3GetFormatString(buf, 128, *vec3);
std::cout << buf << std::endl;
}
}
}
unsigned int
ArnBinaryChunk::getRecordCount() const
{
return m_recordCount;
}
unsigned int
ArnBinaryChunk::getRecordSize() const
{
return m_recordSize;
}
const char*
ArnBinaryChunk::getConstRawDataPtr() const
{
return m_data;
}
const char*
ArnBinaryChunk::getRecordAt( int i ) const
{
assert(i < m_recordCount);
return m_data + m_recordSize * i;
}
| [
"[email protected]"
]
| [
[
[
1,
261
]
]
]
|
042fd287be58ba43cc01914c66becf0cd23b0989 | c95a83e1a741b8c0eb810dd018d91060e5872dd8 | /Game/ClientShellDLL/ClientShellShared/GadgetTargetFX.h | 8ff939c66670b3ce519430b003a35cf2c8bf190b | []
| no_license | rickyharis39/nolf2 | ba0b56e2abb076e60d97fc7a2a8ee7be4394266c | 0da0603dc961e73ac734ff365bfbfb8abb9b9b04 | refs/heads/master | 2021-01-01T17:21:00.678517 | 2011-07-23T12:11:19 | 2011-07-23T12:11:19 | 38,495,312 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,451 | h | // ----------------------------------------------------------------------- //
//
// MODULE : GadgetTargetFX.h
//
// PURPOSE : GadgetTargetFX - Definition
//
// (c) 2002 Monolith Productions, Inc. All Rights Reserved
//
// ----------------------------------------------------------------------- //
#ifndef __GADGETTARGET_FX_H__
#define __GADGETTARGET_FX_H__
#include "SpecialFX.h"
#include "GadgetTargetTypes.h"
struct GADGETTARGETCREATESTRUCT : public SFXCREATESTRUCT
{
GADGETTARGETCREATESTRUCT();
GadgetTargetType eType;
bool bSwitchWeapons;
bool bPowerOn;
uint8 nTeamID;
};
inline GADGETTARGETCREATESTRUCT::GADGETTARGETCREATESTRUCT()
{
eType = eINVALID;
bSwitchWeapons = true;
bPowerOn = true;
nTeamID = INVALID_TEAM;
}
class CGadgetTargetFX : public CSpecialFX
{
public :
virtual LTBOOL Init(SFXCREATESTRUCT* psfxCreateStruct);
virtual uint32 GetSFXID() { return SFX_GADGETTARGET_ID; }
virtual GadgetTargetType GetType() const {return m_eType;}
virtual bool SwitchWeapons() const {return m_bSwitchWeapons;}
virtual bool IsPowerOn() const {return m_bPowerOn;}
virtual uint8 GetTeamID() const { return m_nTeamID; }
virtual LTBOOL OnServerMessage(ILTMessage_Read *pMsg);
private :
GadgetTargetType m_eType;
bool m_bSwitchWeapons;
bool m_bPowerOn;
uint8 m_nTeamID;
};
#endif // __GADGETTARGET_FX_H__ | [
"[email protected]"
]
| [
[
[
1,
59
]
]
]
|
3f5c84edaf8834dfb2b448951fa69bcbc515f60e | 0dba4a3016f3ad5aa22b194137a72efbc92ab19e | /albion2/client/csystem.h | 043df441b5fd7a03e8e83961780c37c986595310 | []
| no_license | BackupTheBerlios/albion2 | 11e89586c3a2d93821b6a0d3332c1a7ef1af6abf | bc3d9ba9cf7b8f7579a58bc190a4abb32b30c716 | refs/heads/master | 2020-12-30T10:23:18.448750 | 2007-01-26T23:58:42 | 2007-01-26T23:58:42 | 39,515,887 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,700 | h | /*
* 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 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __CSYSTEM_H__
#define __CSYSTEM_H__
#ifdef WIN32
#include <windows.h>
#endif
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <engine.h>
#include <msg.h>
#include <core.h>
#include <gfx.h>
#include <event.h>
#include <camera.h>
#include <a2emodel.h>
#include <scene.h>
#include <ode.h>
#include <ode_object.h>
#include <light.h>
#include <shader.h>
#include <a2emap.h>
#include <image.h>
#include <net.h>
#include <gui.h>
#include "cmap.h"
using namespace std;
class csystem {
public:
csystem(engine* e, camera* cam, cmap* cm);
~csystem();
bool init_net();
bool connect_client(const char* name, const char* pw);
struct chat_msg {
unsigned int type;
string name;
string msg;
};
vector<chat_msg> chat_msgs;
void add_chat_msg(unsigned int type, char* name, char* msg);
chat_msg* get_msg();
vector<chat_msg> send_msgs;
void send_chat_msg(unsigned int type, char* msg);
chat_msg* get_send_msg();
engine* e;
core* c;
msg* m;
net* n;
gui* agui;
camera* cam;
cmap* cm;
SDL_Surface* sf;
bool done;
bool netinit;
bool new_client;
bool disconnected;
bool logged_in;
char* server;
unsigned short int port;
unsigned short int lis_port;
string client_name;
string client_pw;
unsigned int client_id;
vector<unsigned int> vis_user;
bool move_forward;
bool move_back;
unsigned int move_timer;
struct client {
string name;
unsigned int status;
unsigned int id;
bool get_map;
bool get_pos;
bool get_rot;
unsigned int map;
vertex3 position;
vertex3 rotation;
};
vector<client> clients;
client* get_client(unsigned int id);
enum CONTROL_FLAGS {
CF_LOAD_MAP = 1
};
vector<unsigned int> flags;
void add_flag(unsigned int flag);
unsigned int get_flag();
void run();
};
#endif
| [
"[email protected]"
]
| [
[
[
1,
126
]
]
]
|
dc168666854e8a26a1587cdd97209721d6c69148 | c5ecda551cefa7aaa54b787850b55a2d8fd12387 | /src/UILayer/MainTabWnd.h | 5b2c2096136c0de8d939d4ac51f1045de637d3e7 | []
| no_license | firespeed79/easymule | b2520bfc44977c4e0643064bbc7211c0ce30cf66 | 3f890fa7ed2526c782cfcfabb5aac08c1e70e033 | refs/heads/master | 2021-05-28T20:52:15.983758 | 2007-12-05T09:41:56 | 2007-12-05T09:41:56 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,398 | h | #pragma once
#include "TabWnd.h"
// CMainTabWnd
#include "DlgMainTabResource.h"
#include "DlgMaintabDownload.h"
#include "DlgMainTabShare.h"
#include "DlgMainTabSidePanel.h"
#include "DlgMainTabAdvance.h"
#include "SpeedMeterDlg.h"
#include "Localizee.h"
//#include "StatDlg.h"
class CMainTabWnd : public CTabWnd, public CLocalizee
{
DECLARE_DYNAMIC(CMainTabWnd)
LOCALIZEE_WND_CANLOCALIZE()
public:
CMainTabWnd();
virtual ~CMainTabWnd();
BOOL CreateEx(const RECT& rect, CWnd* pParentWnd, UINT nID);
CDlgMainTabResource m_dlgResource;
CDlgMaintabDownload m_dlgDownload;
CDlgMainTabShare m_dlgShare;
CDlgMainTabAdvance m_dlgAdvance;
CDlgMainTabSidePanel m_dlgSidePanel;
/*CSpeedMeterDlg m_SpeedMeterDlg;*/
enum ETabId
{
TI_RESOURCE,
TI_DOWNLOAD,
TI_SHARE,
TI_ADVANCE,
TI_BN,
TI_MAX
};
POSITION m_aposTabs[TI_MAX];
BOOL IsTabShowed(ETabId eTabId);
void AddTabById(ETabId eTabId);
void RemoveTabById(ETabId eTabId);
void SetActiveTabById(ETabId eTabId){SetActiveTab(m_aposTabs[eTabId]);}
protected:
void Localize();
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
// afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
// afx_msg void OnPaint();
};
| [
"LanceFong@4a627187-453b-0410-a94d-992500ef832d"
]
| [
[
[
1,
62
]
]
]
|
8baa884d1265f24fa9cd9332931ed20bed8a2b4c | b739a332ba929e8c6951c4c686dc7992c4c38f40 | /WonFW/NewMenu/NewMenu.cpp | 699034fe153ce07a8c8b6ec17f84eeaae9563add | []
| no_license | codingman/antiarp | ad8b6400c8efa086197912dc6d534db540333ba0 | 929987e23d5d3b31c9340e377c6455fc7139f610 | refs/heads/master | 2021-12-04T11:13:56.716565 | 2009-04-17T11:50:11 | 2009-04-17T11:50:11 | null | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 329,888 | cpp | //------------------------------------------------------------------------------
// File : NewMenu.cpp
// Version : 1.25
// Date : 25. June 2005
// Author : Bruno Podetti
// Email : [email protected]
// Web : www.podetti.com/NewMenu
// Systems : VC6.0/7.0 and VC7.1 (Run under (Window 98/ME), Windows Nt 2000/XP)
// for all systems it will be the best when you install the latest IE
// it is recommended for CNewToolBar
//
// For bugreport please add following informations
// - The CNewMenu version number (Example CNewMenu 1.16)
// - Operating system Win95 / WinXP and language (English / Japanese / German etc.)
// - Installed service packs
// - Version of internet explorer (important for CNewToolBar)
// - Short description how to reproduce the bug
// - Pictures/Sample are welcome too
// - You can write in English or German to the above email-address.
// - Have my compiled examples the same effect?
//------------------------------------------------------------------------------
//
// Special
// Compiled version with visual studio V7.0/7.1 doesn't run correctly on
// WinNt 4.0 nor Windows 95. For those platforms, you have to compile it with
// visual studio V6.0.
// (It may run with 7.0/7.1, but you must be sure to have all required and newest
// dll from the MFC installed => otherwise menu painting problems)
// Keep in mind you should have installed latest service-packs to the operating-
// system too! (And a new IE because some fixes of common components were made)
//------------------------------------------------------------------------------
//
// ToDo's
// checking GDI-Leaks, are there some more?
// Shade-Drawing, when underground is changing
// Border repainting after menu closing!!!
// Shade painting problems? On Chinese or Japanese systems?
// supporting additional bitmap in menu with ownerdrawn style
//
// 25. June 2005 (Version 1.25)
// added compatibility for new security enhancement in CRT (MFC 8.0)
//
// 16. May 2005 (Version 1.24)
// added tranparency to menu
// added some more information for visualtudio work better with messagemaps
// safer handling of limitted HDC's
// added new function CreateBitmapMask
// - Mark P. Peterson - [email protected] - http://www.RhinoSoft.com/
// corrected background and highlight colors for XP styles. Read comments dated May-05-2005 below for more information
//
// 23. January 2005 (Version 1.23) - Mark P. Peterson - [email protected] - http://www.RhinoSoft.com/
// added another LoadToolbar() function to map a 16 color toolbar to a 256 color bitmap
// created CNewMenuThreadHook class to be instantiated and destroyed in a thread to setup and release the menu hook
// Bruno: Now we subclass only NewMenu (Drawing border etc.)
//
// 11. September 2004 (Version 1.22)
// added helperfunction for forcing compiler to export templatefunction
// better support for Hebrew or Arabic (MFT_RIGHTORDER)
// added new support for multiple monitors
// added some more details to errorhandling of CNewMenu ShowLastError only debug
// Changed AddTheme for compatibility to VisualStudio 2005
//
// 27. June 2004 (Version 1.21)
// colorsheme for office 2003 style changed and more like real office 2003
// enabled keyboardcues in style office 2003
// Old colorscheme from office 2003 is now called STYLE_COLORFUL
//
// 1. May 2004 (Version 1.20)
// additionally drawing for menubar
// added some compatibility issue with wine
// shading window (only test)
// changed the colorscheme with more theme support
// corected the menubar detection
//
// 6. February 2004 (Version 1.19)
// Icy and standard menu: systemmenu now with symbols
// underline enabling and disabling added, thanks to Robin Leatherbarrow
// make it compatible to 64-bit windows, thanks to David Pritchard
// added accelerator support to menu, thanks to Iain Clarke
// Corrected functions names SetXpBlendig/GetXpBlendig to SetXpBlending/GetXpBlending
// removed 3d-look from office 2003 style menu (now like real office 2003 menu)
// Handling of a normal menu-item in menubar changed
//
// 30. November 2003 (Version 1.18)
// minor changes for CNewToolBar
//
// 11. September 2003 Bug Fixes or nice hints from 1.16
// Better handling of menubar brushes (never destroy) Style_XP and STYLE_XP_2003
// Drawing of menuicons on WinNt 4.0 fixed
// spelling & initializing & unused brushes fixed, thanks to John Zegers
//
// 12. July 2003 Bug Fixes or nice hints from 1.15
// Added gradient-Dockbar (CNewDockBar) for office 2003 style
// (you need to define USE_NEW_DOCK_BAR)
// fixed menu checkmarks with bitmaps (Selection-with is not correct on all styles)
// Drawing to a memory-DC minimizing flickering
// with of menu-bar-item without & now better
//
// 22. June 2003 Bug Fixes or nice hints from 1.14
// Shortkey-handling for ModifyODMenu and InsertODMenu
// Change os identifer for OS>5.0 to WinXP
// Color scheme for Office menu changed and updating menubarcolor too
// Gradientcolor for Office 2003 bar
// XP-changing settings Border Style => fixed border painting without restarting
//
// 23. April 2003 Bug Fixes or nice hints from 1.13
// Fixed the window menu with extreme width, thanks to Voy
// Fix bug about shortkey for added menu item with AppendMenu, thanks to Mehdy Bohlool(Zy)
// Measureitem for default item corrected, thanks to LordLiverpool
// New menu style office 2003, but color schema is not tested, changing of menubar color
// on win95 and WinNt is not possible
// Menubardrawing on deactivated app corrected for win95 & WinNt4.0
//
// 23. January 2003 Bug Fixes or nice hints from 1.12
// Fixed SetMenuText, thanks to Eugene Plokhov
// Easier for having an other menu font, but on your own risk ;)
// Added new function SetNewMenuBorderAllMenu for borderhandling off non CNewMenu
//
// 22. December 2002 Bug Fixes or nice hints from 1.11
// Added some new tracing stuffs
// fixed SetMenuText
// XP-Style menu more office style and better handling with less 256 color, thanks to John Zegers
// Close window button disabling under XP with theme fixed
// Menubar color with theme fixed, thanks to Luther Weeks
//
// (9. November) Bug Fixes or nice hints from 1.11b
// Some new function for bleaching bitmaps, thanks to John Zegers
// GetSubMenu(LPCTSTR) , thanks to George Menhorn
// Menu animation under Win 98 fixed
// Borderdrawing a little better also under win 98
// Added new menustyle ICY
//
// (21. August 2002) Bug Fixes or nice hints from 1.10
// Bugfix for Windows NT 4.0 System Bitmaps, thanks to Christoph Weber
//
// (30. July 2002) Bug Fixes or nice hints from 1.03
// Color of checked icons / selection marks more XP-look
// Updating images 16 color by changing systems colors
// Icon drawing with more highlighting and half transparency
// Scroller for large menu correcting (but the overlapping border is not corrected)
// Resource-problem on windows 95/98/ME?, when using too much bitmaps in menus
// changing the kind of storing bitmaps (images list)
// Calculating the size for a menuitem (specially submenuitem) corrected.
// Recentfilelist corrected (Seperator gots a wrong ID number)
//
// (25. June 2002) Bug Fixes or nice hints from 1.02
// Adding removing menu corrected for drawing the shade in menubar
// Draw the menuborder corrected under win 98 at the bottom side
// Highlighting under 98 for menu corrected (Assert), Neville Franks
// Works also on Windows 95
// Changing styles on XP menucolor of the bar now corrected.
//
// (18. June 2002) Bug Fixes or nice hints from 1.01
// Popup menu which has more items than will fit, better
// LoadMenu changed for better languagessuport, SnowCat
// Bordercolor & Drawing of XP-Style-Menu changed to more XP-Look
// Added some functions for setting/reading MenuItemData and MenuData
// Menubar highlighting now supported under 98/ME (NT 4.0 and 95?)
// Font for menutitle can be changed
// Bugs for popupmenu by adding submenu corrected, no autodestroy
//
// (6. June 2002) Bug Fixes or nice hints from 1.00
// Loading Icons from a resource dll expanded (LoadToolBar) Jonathan de Halleux, Belgium.
// Minimized resource leak of User and Gdi objects
// Problem of disabled windows button on 98/Me solved
// Gradient-drawing without Msimg32.dll now supported especially for win 95
// Using solid colors for drawing menu items
// GetSubMenu changed to const
// Added helper function for setting popup-flag for popup menu (centered text)
// Redraw menu bar corrected after canceling popup menu in old style menu
//
// (23. Mai 2002) Bug Fixes and portions of code from previous version supplied by:
// Brent Corkum, Ben Ashley, Girish Bharadwaj, Jean-Edouard Lachand-Robert,
// Robert Edward Caldecott, Kenny Goers, Leonardo Zide, Stefan Kuhr,
// Reiner Jung, Martin Vladic, Kim Yoo Chul, Oz Solomonovich, Tongzhe Cui,
// Stephane Clog, Warren Stevens, Damir Valiulin
//
// You are free to use/modify this code but leave this header intact.
// This class is public domain so you are free to use it any of your
// applications (Freeware, Shareware, Commercial).
// All I ask is that you let me know so that if you have a real winner I can
// brag to my buddies that some of my code is in your app. I also wouldn't
// mind if you sent me a copy of your application since I like to play with
// new stuff.
//------------------------------------------------------------------------------
#include "stdafx.h" // Standard windows header file
#include "NewMenu.h" // CNewMenu class declaration
// Those two following constants should be only defined for tracing.
// Normally they are commented out.
//#define _TRACE_MENU_
//#define _TRACE_MENU_LOGFILE
//#define _NEW_MENU_USER_FONT
// For using an userfont you can set the define. It does not work right in the
// systemmenu nor in the menubar. But when you like to use the new menu only in
// popups then it will work, but it is newer a good idea to set or change the
// menufont.
// I do not support this mode, you use it on your own risk. :)
#ifdef _NEW_MENU_USER_FONT
static LOGFONT MENU_USER_FONT = {20, 0, 0, 0, FW_NORMAL,
0, 0, 0, DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH,_T("Comic Sans MS")};
#endif
#ifdef _TRACE_MENU_
#include "MyTrace.h"
#endif
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
#endif
#ifndef IS_INTRESOURCE
#define IS_INTRESOURCE(hh) (HIWORD(hh)==NULL)
#endif
#define GAP 2
#ifndef COLOR_MENUBAR
#define COLOR_MENUBAR 30
#endif
#ifndef SPI_GETDROPSHADOW
#define SPI_GETDROPSHADOW 0x1024
#endif
#ifndef SPI_GETFLATMENU
#define SPI_GETFLATMENU 0x1022
#endif
#ifndef ODS_NOACCEL
#define ODS_NOACCEL 0x0100
#endif
#ifndef DT_HIDEPREFIX
#define DT_HIDEPREFIX 0x00100000
#endif
#ifndef DT_PREFIXONLY
#define DT_PREFIXONLY 0x00200000
#endif
#ifndef SPI_GETKEYBOARDCUES
#define SPI_GETKEYBOARDCUES 0x100A
#endif
#ifndef _WIN64
#ifdef SetWindowLongPtrA
#undef SetWindowLongPtrA
#endif
inline LONG_PTR SetWindowLongPtrA( HWND hWnd, int nIndex, LONG_PTR dwNewLong )
{
return( ::SetWindowLongA( hWnd, nIndex, LONG( dwNewLong ) ) );
}
#ifdef SetWindowLongPtrW
#undef SetWindowLongPtrW
#endif
inline LONG_PTR SetWindowLongPtrW( HWND hWnd, int nIndex, LONG_PTR dwNewLong )
{
return( ::SetWindowLongW( hWnd, nIndex, LONG( dwNewLong ) ) );
}
#ifdef GetWindowLongPtrA
#undef GetWindowLongPtrA
#endif
inline LONG_PTR GetWindowLongPtrA( HWND hWnd, int nIndex )
{
return( ::GetWindowLongA( hWnd, nIndex ) );
}
#ifdef GetWindowLongPtrW
#undef GetWindowLongPtrW
#endif
inline LONG_PTR GetWindowLongPtrW( HWND hWnd, int nIndex )
{
return( ::GetWindowLongW( hWnd, nIndex ) );
}
#ifndef GWLP_WNDPROC
#define GWLP_WNDPROC (-4)
#endif
#ifndef SetWindowLongPtr
#ifdef UNICODE
#define SetWindowLongPtr SetWindowLongPtrW
#else
#define SetWindowLongPtr SetWindowLongPtrA
#endif // !UNICODE
#endif //SetWindowLongPtr
#ifndef GetWindowLongPtr
#ifdef UNICODE
#define GetWindowLongPtr GetWindowLongPtrW
#else
#define GetWindowLongPtr GetWindowLongPtrA
#endif // !UNICODE
#endif // GetWindowLongPtr
#endif //_WIN64
// Count of menu icons normal gloomed and grayed
#define MENU_ICONS 3
BOOL bHighContrast = FALSE;
BOOL bWine = FALSE;
typedef BOOL (WINAPI* FktGradientFill)( IN HDC, IN PTRIVERTEX, IN ULONG, IN PVOID, IN ULONG, IN ULONG);
typedef BOOL (WINAPI* FktIsThemeActive)();
typedef HRESULT (WINAPI* FktSetWindowTheme)(HWND hwnd, LPCWSTR pszSubAppName, LPCWSTR pszSubIdList);
FktGradientFill pGradientFill = NULL;
FktIsThemeActive pIsThemeActive = NULL;
FktSetWindowTheme pSetWindowTheme = NULL;
BOOL GUILIBDLLEXPORT IsMenuThemeActive()
{
return pIsThemeActive?pIsThemeActive():FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// Helper datatypes
class CToolBarData
{
public:
WORD wVersion;
WORD wWidth;
WORD wHeight;
WORD wItemCount;
//WORD aItems[wItemCount]
WORD* items()
{ return (WORD*)(this+1); }
};
class CNewMenuIconInfo
{
public:
WORD wBitmapID;
WORD wWidth;
WORD wHeight;
WORD* ids(){ return (WORD*)(this+1); }
};
// Helpers for casting
__inline HMENU UIntToHMenu(const unsigned int ui )
{
return( (HMENU)(UINT_PTR)ui );
}
__inline HMENU HWndToHMenu(const HWND hWnd )
{
return( (HMENU)hWnd );
}
__inline HWND HMenuToHWnd(const HMENU hMenu)
{
return( (HWND)hMenu );
}
__inline UINT HWndToUInt(const HWND hWnd )
{
return( (UINT)(UINT_PTR) hWnd);
}
__inline HWND UIntToHWnd(const UINT hWnd )
{
return( (HWND)(UINT_PTR) hWnd);
}
__inline UINT HMenuToUInt(const HMENU hMenu )
{
return( (UINT)(UINT_PTR) hMenu);
}
__inline LONG_PTR LongToPTR(const LONG value )
{
return( LONG_PTR)value;
}
#ifdef _DEBUG
static void ShowLastError(LPCTSTR pErrorTitle=NULL)
{
if(pErrorTitle==NULL)
{
pErrorTitle=_T("Error from Menu");
}
DWORD error = GetLastError();
if(error)
{
LPVOID lpMsgBuf=NULL;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
error,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL );
if(lpMsgBuf)
{
// Display the string.
MessageBox( NULL, (LPCTSTR)lpMsgBuf, pErrorTitle, MB_OK | MB_ICONINFORMATION );
// Free the buffer.
LocalFree( lpMsgBuf );
}
else
{
CString temp;
temp.Format(_T("Error message 0x%lx not found"),error);
// Display the string.
MessageBox( NULL,temp, pErrorTitle, MB_OK | MB_ICONINFORMATION );
}
}
}
#else
#define ShowLastError(sz)
#endif
// this is a bad code! The timer 31 will be restartet, when it was used!!!!
UINT GetSafeTimerID(HWND hWnd, const UINT uiElapse)
{
UINT nNewTimerId = NULL;
if(IsWindow(hWnd))
{ // Try to start with TimerID 31, normaly is used 1, 10, or 100
for(UINT nTimerId=31; nTimerId<100 && nNewTimerId==NULL; nTimerId++)
{ // Try to set a timer each uiElapse ms
nNewTimerId = (UINT)::SetTimer(hWnd,nTimerId,uiElapse,NULL);
}
// Wow you have more than 69 timers!!!
// Try to increase nTimerId<100 to nTimerId<1000;
ASSERT(nNewTimerId);
}
return nNewTimerId;
}
WORD NumBitmapColors(LPBITMAPINFOHEADER lpBitmap)
{
if ( lpBitmap->biClrUsed != 0)
return (WORD)lpBitmap->biClrUsed;
switch (lpBitmap->biBitCount)
{
case 1:
return 2;
case 4:
return 16;
case 8:
return 256;
}
return 0;
}
int NumScreenColors()
{
static int nColors = 0;
if (!nColors)
{
// DC of the desktop
CClientDC myDC(NULL);
nColors = myDC.GetDeviceCaps(NUMCOLORS);
if (nColors == -1)
{
nColors = 64000;
}
}
return nColors;
}
HBITMAP LoadColorBitmap(LPCTSTR lpszResourceName, HMODULE hInst, int* pNumcol)
{
if(hInst==0)
{
hInst = AfxFindResourceHandle(lpszResourceName, RT_BITMAP);
}
HRSRC hRsrc = ::FindResource(hInst,MAKEINTRESOURCE(lpszResourceName),RT_BITMAP);
if (hRsrc == NULL)
return NULL;
// determine how many colors in the bitmap
HGLOBAL hglb;
if ((hglb = LoadResource(hInst, hRsrc)) == NULL)
return NULL;
LPBITMAPINFOHEADER lpBitmap = (LPBITMAPINFOHEADER)LockResource(hglb);
if (lpBitmap == NULL)
return NULL;
WORD numcol = NumBitmapColors(lpBitmap);
if(pNumcol)
{
*pNumcol = numcol;
}
UnlockResource(hglb);
FreeResource(hglb);
return LoadBitmap(hInst,lpszResourceName);
//TODO: check it bpo
//if(numcol!=16)
//{
// return LoadBitmap(hInst,lpszResourceName);
// // (HBITMAP)LoadImage(hInst,lpszResourceName,IMAGE_BITMAP,0,0,LR_DEFAULTCOLOR|LR_CREATEDIBSECTION|LR_SHARED);
//}
//else
//{
// // mapping from color in DIB to system color
// // { RGB_TO_RGBQUAD(0x00, 0x00, 0x00), COLOR_BTNTEXT }, // black
// // { RGB_TO_RGBQUAD(0x80, 0x80, 0x80), COLOR_BTNSHADOW }, // dark gray
// // { RGB_TO_RGBQUAD(0xC0, 0xC0, 0xC0), COLOR_BTNFACE }, // bright gray
// // { RGB_TO_RGBQUAD(0xFF, 0xFF, 0xFF), COLOR_BTNHIGHLIGHT } // white
// return (HBITMAP)AfxLoadSysColorBitmap(hInst,hRsrc,FALSE);
//}
}
HBITMAP CreateBitmapMask(HBITMAP hbmColour, COLORREF crTransparent)
{
HBITMAP hbmMask = NULL;
BITMAP bm = {0};
if(GetObject(hbmColour, sizeof(BITMAP), &bm))
{
hbmMask = CreateBitmap(bm.bmWidth, bm.bmHeight, 1, 1, NULL);
if(hbmMask)
{
// Get some HDCs that are compatible with the display driver
HDC hdcMem = CreateCompatibleDC(0);
HDC hdcMem2 = CreateCompatibleDC(0);
SelectObject(hdcMem, hbmColour);
SelectObject(hdcMem2, hbmMask);
// Set the background colour of the colour image to the colour
// you want to be transparent.
SetBkColor(hdcMem, crTransparent);
// Copy the bits from the colour image to the B+W mask... everything
// with the background colour ends up white while everythig else ends up
// black...Just what we wanted.
BitBlt(hdcMem2, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
// Take our new mask and use it to turn the transparent colour in our
// original colour image to black so the transparency effect will
// work right.
BitBlt(hdcMem, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem2, 0, 0, SRCINVERT);
// Clean up.
DeleteDC(hdcMem);
DeleteDC(hdcMem2);
}
}
return hbmMask;
}
COLORREF MakeGrayAlphablend(CBitmap* pBitmap, int weighting, COLORREF blendcolor)
{
CDC myDC;
// Create a compatible bitmap to the screen
myDC.CreateCompatibleDC(0);
// Select the bitmap into the DC
CBitmap* pOldBitmap = myDC.SelectObject(pBitmap);
BITMAP myInfo = {0};
GetObject((HGDIOBJ)pBitmap->m_hObject,sizeof(myInfo),&myInfo);
for (int nHIndex = 0; nHIndex < myInfo.bmHeight; nHIndex++)
{
for (int nWIndex = 0; nWIndex < myInfo.bmWidth; nWIndex++)
{
COLORREF ref = myDC.GetPixel(nWIndex,nHIndex);
// make it gray
DWORD nAvg = (GetRValue(ref) + GetGValue(ref) + GetBValue(ref))/3;
// Algorithme for alphablending
//dest' = ((weighting * source) + ((255-weighting) * dest)) / 256
DWORD refR = ((weighting * nAvg) + ((255-weighting) * GetRValue(blendcolor))) / 256;
DWORD refG = ((weighting * nAvg) + ((255-weighting) * GetGValue(blendcolor))) / 256;;
DWORD refB = ((weighting * nAvg) + ((255-weighting) * GetBValue(blendcolor))) / 256;;
myDC.SetPixel(nWIndex,nHIndex,RGB(refR,refG,refB));
}
}
COLORREF topLeftColor = myDC.GetPixel(0,0);
myDC.SelectObject(pOldBitmap);
return topLeftColor;
}
class CNewLoadLib
{
public:
HMODULE m_hModule;
void* m_pProg;
CNewLoadLib(LPCTSTR pName,LPCSTR pProgName)
{
m_hModule = LoadLibrary(pName);
m_pProg = m_hModule ? (void*)GetProcAddress (m_hModule,pProgName) : NULL;
}
~CNewLoadLib()
{
if(m_hModule)
{
FreeLibrary(m_hModule);
m_hModule = NULL;
}
}
};
#if(WINVER < 0x0500)
DECLARE_HANDLE(HMONITOR);
typedef struct tagMONITORINFO
{
DWORD cbSize;
RECT rcMonitor;
RECT rcWork;
DWORD dwFlags;
} MONITORINFO, *LPMONITORINFO;
BOOL GetMonitorInfo( HMONITOR hMonitor, LPMONITORINFO lpmi)
{
#ifdef UNICODE
static CNewLoadLib menuInfo(_T("user32.dll"),"GetMonitorInfoW");
#else
static CNewLoadLib menuInfo(_T("user32.dll"),"GetMonitorInfoA");
#endif
if(menuInfo.m_pProg)
{
typedef BOOL (WINAPI* FktGetMonitorInfo)( HMONITOR, LPMONITORINFO);
return ((FktGetMonitorInfo)menuInfo.m_pProg)(hMonitor,lpmi);
}
return FALSE;
}
#define MONITOR_DEFAULTTONULL 0x00000000
#define MONITOR_DEFAULTTOPRIMARY 0x00000001
#define MONITOR_DEFAULTTONEAREST 0x00000002
#define MONITORINFOF_PRIMARY 0x00000001
HMONITOR MonitorFromWindow(
HWND hwnd, // handle to a window
DWORD dwFlags // determine return value
)
{
static CNewLoadLib menuInfo(_T("user32.dll"),"MonitorFromWindow");
if(menuInfo.m_pProg)
{
typedef HMONITOR (WINAPI* FktMonitorFromWindow)( HWND, DWORD);
return ((FktMonitorFromWindow)menuInfo.m_pProg)(hwnd,dwFlags);
}
return NULL;
}
HMONITOR MonitorFromRect(
LPCRECT lprc, // rectangle
DWORD dwFlags // determine return value
)
{
static CNewLoadLib menuInfo(_T("user32.dll"),"MonitorFromRect");
if(menuInfo.m_pProg)
{
typedef HMONITOR (WINAPI* FktMonitorFromRect)( LPCRECT, DWORD);
return ((FktMonitorFromRect)menuInfo.m_pProg)(lprc,dwFlags);
}
return NULL;
}
BOOL GetMenuInfo( HMENU hMenu, LPMENUINFO pInfo)
{
static CNewLoadLib menuInfo(_T("user32.dll"),"GetMenuInfo");
if(menuInfo.m_pProg)
{
typedef BOOL (WINAPI* FktGetMenuInfo)(HMENU, LPMENUINFO);
return ((FktGetMenuInfo)menuInfo.m_pProg)(hMenu,pInfo);
}
return FALSE;
}
BOOL SetMenuInfo( HMENU hMenu, LPCMENUINFO pInfo)
{
static CNewLoadLib menuInfo(_T("user32.dll"),"SetMenuInfo");
if(menuInfo.m_pProg)
{
typedef BOOL (WINAPI* FktSetMenuInfo)(HMENU, LPCMENUINFO);
return ((FktSetMenuInfo)menuInfo.m_pProg)(hMenu,pInfo);
}
return FALSE;
}
DWORD GetLayout(HDC hDC)
{
static CNewLoadLib getLayout(_T("gdi32.dll"),"GetLayout");
if(getLayout.m_pProg)
{
typedef DWORD (WINAPI* FktGetLayout)(HDC);
return ((FktGetLayout)getLayout.m_pProg)(hDC);
}
return NULL;
}
DWORD SetLayout(HDC hDC, DWORD dwLayout)
{
static CNewLoadLib setLayout(_T("gdi32.dll"),"SetLayout");
if(setLayout.m_pProg)
{
typedef DWORD (WINAPI* FktSetLayout)(HDC,DWORD);
return ((FktSetLayout)setLayout.m_pProg)(hDC,dwLayout);
}
return NULL;
}
#define WS_EX_LAYERED 0x00080000
#define LWA_ALPHA 2 // Use bAlpha to determine the opacity of the layer
BOOL SetLayeredWindowAttributes(HWND hWnd, COLORREF cr, BYTE bAlpha, DWORD dwFlags)
{
static CNewLoadLib setLayout(_T("User32.dll"),"SetLayeredWindowAttributes");
if(setLayout.m_pProg)
{
typedef BOOL (WINAPI *lpfnSetLayeredWindowAttributes) (HWND hWnd, COLORREF cr, BYTE bAlpha, DWORD dwFlags);
return ((lpfnSetLayeredWindowAttributes)setLayout.m_pProg)(hWnd, cr, bAlpha, dwFlags);
}
return false;
}
#endif
void MenuDrawText(HDC hDC ,LPCTSTR lpString,int nCount,LPRECT lpRect,UINT uFormat)
{
if(nCount==-1)
{
nCount = lpString?(int)_tcslen(lpString):0;
}
LOGFONT logfont = {0};
if(!GetObject(GetCurrentObject(hDC, OBJ_FONT),sizeof(logfont),&logfont))
{
logfont.lfOrientation = 0;
}
size_t bufSizeTChar = nCount + 1;
TCHAR* pBuffer = (TCHAR*)_alloca(bufSizeTChar*sizeof(TCHAR));
_tcsncpy_s(pBuffer,bufSizeTChar,lpString,nCount);
pBuffer[nCount] = 0;
UINT oldAlign = GetTextAlign(hDC);
const int nBorder=4;
HGDIOBJ hOldFont = NULL;
CFont TempFont;
TEXTMETRIC textMetric;
if (!GetTextMetrics(hDC, &textMetric))
{
textMetric.tmOverhang = 0;
textMetric.tmAscent = 0;
}
else if ((textMetric.tmPitchAndFamily&(TMPF_VECTOR|TMPF_TRUETYPE))==0 )
{
// we have a bitmapfont it is not possible to rotate
if(logfont.lfOrientation || logfont.lfEscapement)
{
hOldFont = GetCurrentObject(hDC,OBJ_FONT);
_tcscpy_s(logfont.lfFaceName,ARRAY_SIZE(logfont.lfFaceName),_T("Arial"));
// we need a truetype font for rotation
logfont.lfOutPrecision = OUT_TT_ONLY_PRECIS;
// the font will be destroyed at the end by destructor
TempFont.CreateFontIndirect(&logfont);
// we select at the end the old font
SelectObject(hDC,TempFont);
GetTextMetrics(hDC, &textMetric);
}
}
DWORD dwLayout = GetLayout(hDC);
if(dwLayout&LAYOUT_RTL)
{
SetTextAlign (hDC,TA_RIGHT|TA_TOP|TA_UPDATECP);
}
else
{
SetTextAlign (hDC,TA_LEFT|TA_TOP|TA_UPDATECP);
}
CPoint pos(lpRect->left,lpRect->top);
if( (uFormat&DT_VCENTER) &&lpRect)
{
switch(logfont.lfOrientation%3600)
{
default:
case 0:
logfont.lfOrientation = 0;
pos.y = (lpRect->top+lpRect->bottom-textMetric.tmHeight)/2;
if(dwLayout&LAYOUT_RTL)
{
pos.x = lpRect->right - nBorder;
}
else
{
pos.x = lpRect->left + nBorder;
}
break;
case 1800:
case -1800:
logfont.lfOrientation = 1800;
pos.y = (lpRect->top+textMetric.tmHeight +lpRect->bottom)/2;
if(dwLayout&LAYOUT_RTL)
{
pos.x = lpRect->left + nBorder;
}
else
{
pos.x = lpRect->right - nBorder;
}
break;
case 900:
case -2700:
logfont.lfOrientation = 900;
pos.x = (lpRect->left+lpRect->right-textMetric.tmHeight)/2;
pos.y = lpRect->bottom - nBorder;
if(dwLayout&LAYOUT_RTL)
{
pos.y = lpRect->top + nBorder;
}
else
{
pos.y = lpRect->bottom - nBorder;
}
break;
case -900:
case 2700:
logfont.lfOrientation = 2700;
pos.x = (lpRect->left+lpRect->right+textMetric.tmHeight)/2;
if(dwLayout&LAYOUT_RTL)
{
pos.y = lpRect->bottom - nBorder;
}
else
{
pos.y = lpRect->top + nBorder;
}
break;
}
}
CPoint oldPos;
MoveToEx(hDC,pos.x,pos.y,&oldPos);
while(nCount)
{
TCHAR *pTemp =_tcsstr(pBuffer,_T("&"));
if(pTemp)
{
// we found &
if(*(pTemp+1)==_T('&'))
{
// the different is in character unicode and byte works
int nTempCount = DWORD(pTemp-pBuffer)+1;
ExtTextOut(hDC,pos.x,pos.y,ETO_CLIPPED,lpRect,pBuffer,nTempCount,NULL);
nCount -= nTempCount+1;
pBuffer = pTemp+2;
}
else
{
// draw underline the different is in character unicode and byte works
int nTempCount = DWORD(pTemp-pBuffer);
ExtTextOut(hDC,pos.x,pos.y,ETO_CLIPPED,lpRect,pBuffer,nTempCount,NULL);
nCount -= nTempCount+1;
pBuffer = pTemp+1;
if(!(uFormat&DT_HIDEPREFIX) )
{
CSize size;
GetTextExtentPoint(hDC, pTemp+1, 1, &size);
GetCurrentPositionEx(hDC,&pos);
COLORREF oldColor = SetBkColor(hDC, GetTextColor(hDC));
LONG cx = size.cx - textMetric.tmOverhang / 2;
LONG nTop;
CRect rc;
switch(logfont.lfOrientation)
{
case 0:
// Get height of text so that underline is at bottom.
nTop = pos.y + textMetric.tmAscent + 1;
// Draw the underline using the foreground color.
if(dwLayout&LAYOUT_RTL)
{
rc.SetRect(pos.x-cx+2, nTop, pos.x+1, nTop+1);
}
else
{
rc.SetRect(pos.x, nTop, pos.x+cx, nTop+1);
}
ExtTextOut(hDC, pos.x, nTop, ETO_OPAQUE, &rc, _T(""), 0, NULL);
break;
case 1800:
// Get height of text so that underline is at bottom.
nTop = pos.y -(textMetric.tmAscent + 1);
// Draw the underline using the foreground color.
if(dwLayout&LAYOUT_RTL)
{
rc.SetRect(pos.x-1, nTop-1, pos.x+cx-1, nTop);
}
else
{
rc.SetRect(pos.x-cx, nTop-1, pos.x, nTop);
}
ExtTextOut(hDC, pos.x, nTop, ETO_OPAQUE, &rc, _T(""), 0, NULL);
break;
case 900:
// draw up
// Get height of text so that underline is at bottom.
nTop = pos.x + (textMetric.tmAscent + 1);
// Draw the underline using the foreground color.
if(dwLayout&LAYOUT_RTL)
{
rc.SetRect(nTop-1, pos.y, nTop, pos.y+cx-2);
}
else
{
rc.SetRect(nTop, pos.y-cx, nTop+1, pos.y);
}
ExtTextOut(hDC, nTop, pos.y, ETO_OPAQUE, &rc, _T(""), 0, NULL);
break;
case 2700:
// draw down
// Get height of text so that underline is at bottom.
nTop = pos.x -(textMetric.tmAscent + 1);
// Draw the underline using the foreground color.
if(dwLayout&LAYOUT_RTL)
{
rc.SetRect(nTop, pos.y-cx+1 , nTop+1, pos.y);
}
else
{
rc.SetRect(nTop-1, pos.y, nTop, pos.y+cx);
}
ExtTextOut(hDC, nTop, pos.y, ETO_OPAQUE, &rc, _T(""), 0, NULL);
break;
}
SetBkColor(hDC, oldColor);
// corect the actual drawingpoint
MoveToEx(hDC,pos.x,pos.y,NULL);
}
}
}
else
{
// draw the rest of the string
ExtTextOut(hDC,pos.x,pos.y,ETO_CLIPPED,lpRect,pBuffer,nCount,NULL);
break;
}
}
// restore old point
MoveToEx(hDC,oldPos.x,oldPos.y,NULL);
// restore old align
SetTextAlign(hDC,oldAlign);
if(hOldFont!=NULL)
{
SelectObject(hDC,hOldFont);
}
}
CRect GUILIBDLLEXPORT GetScreenRectFromWnd(HWND hWnd)
{
CRect rect;
HMONITOR hMonitor = MonitorFromWindow(hWnd,MONITOR_DEFAULTTONEAREST);
MONITORINFO monitorinfo={0};
monitorinfo.cbSize = sizeof(monitorinfo);
if(hMonitor!=NULL && GetMonitorInfo(hMonitor,&monitorinfo))
{
rect = monitorinfo.rcWork;
}
else
{
rect.SetRect(0,0,GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN));
}
return rect;
}
CRect GUILIBDLLEXPORT GetScreenRectFromRect(LPCRECT pRect)
{
CRect rect;
HMONITOR hMonitor = MonitorFromRect(pRect,MONITOR_DEFAULTTONEAREST);
MONITORINFO monitorinfo={0};
monitorinfo.cbSize = sizeof(monitorinfo);
if(hMonitor!=NULL && GetMonitorInfo(hMonitor,&monitorinfo))
{
rect = monitorinfo.rcWork;
}
else
{
rect.SetRect(0,0,GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN));
}
return rect;
}
BOOL GUILIBDLLEXPORT TrackPopupMenuSpecial(CMenu *pMenu, UINT uFlags, CRect rcTBItem, CWnd *pWndCommand, BOOL bOnSide)
{
CRect rect = GetScreenRectFromRect(rcTBItem);
CPoint CenterPoint = rect.CenterPoint();
CNewMenu* pNewMenu = DYNAMIC_DOWNCAST(CNewMenu,pMenu);
if(bOnSide)
{
if(CenterPoint.x<rcTBItem.right)
{
// menu on the right side of the screen
if(rcTBItem.left<=rect.left){rcTBItem.left=rect.left+1;}
if(rcTBItem.top<rect.top){rcTBItem.top=rect.top;}
if(IsMirroredWnd(pWndCommand->GetSafeHwnd()))
{
return pMenu->TrackPopupMenu(TPM_LEFTBUTTON|uFlags, rcTBItem.left-1, rcTBItem.top+1,pWndCommand,NULL);
}
else
{
return pMenu->TrackPopupMenu(TPM_LEFTBUTTON|TPM_RIGHTALIGN|uFlags, rcTBItem.left-1, rcTBItem.top+1,pWndCommand,NULL);
}
}
else
{
if(rcTBItem.right<=rect.left){rcTBItem.right=rect.left+1;}
if(rcTBItem.top<rect.top){rcTBItem.top=rect.top;}
return pMenu->TrackPopupMenu(TPM_LEFTBUTTON|uFlags, rcTBItem.right-1, rcTBItem.top+1,pWndCommand,NULL);
}
}
else
{
int nMenuHeight = 0;
if(pNewMenu)
{
CSize size = pNewMenu->GetIconSize();
// calculate more or less the height, seperators and titles may be wrong
nMenuHeight = pNewMenu->GetMenuItemCount()*size.cy;
}
bool bMenuAbove = CenterPoint.y<rcTBItem.top;
if(bMenuAbove && nMenuHeight)
{
if((rcTBItem.bottom+nMenuHeight)<rect.bottom)
{
bMenuAbove = false;
}
}
if(bMenuAbove)
{
// bottom of the screen
if(rcTBItem.left<rect.left){rcTBItem.left=rect.left;}
if(rcTBItem.top>rect.bottom){rcTBItem.top=rect.bottom;}
if(IsMirroredWnd(pWndCommand->GetSafeHwnd()))
{
return pMenu->TrackPopupMenu(TPM_LEFTBUTTON|TPM_BOTTOMALIGN|TPM_RIGHTALIGN|uFlags, rcTBItem.left, rcTBItem.top,pWndCommand,rcTBItem);
}
else
{
return pMenu->TrackPopupMenu(TPM_LEFTBUTTON|TPM_BOTTOMALIGN|uFlags, rcTBItem.left, rcTBItem.top,pWndCommand,rcTBItem);
}
}
else
{
// top of the screen
if(rcTBItem.left<rect.left){rcTBItem.left=rect.left;}
if(rcTBItem.bottom<rect.top){rcTBItem.bottom=rect.top;}
if(IsMirroredWnd(pWndCommand->GetSafeHwnd()))
{
return pMenu->TrackPopupMenu(TPM_LEFTBUTTON|TPM_RIGHTALIGN|uFlags, rcTBItem.left, rcTBItem.bottom,pWndCommand,rcTBItem);
}
else
{
return pMenu->TrackPopupMenu(TPM_LEFTBUTTON|uFlags, rcTBItem.left, rcTBItem.bottom,pWndCommand,rcTBItem);
}
}
}
}
class CNewBrushList : public CObList
{
public:
CNewBrushList(){}
~CNewBrushList()
{
while(!IsEmpty())
{
delete RemoveTail();
}
}
};
class CNewBrush : public CBrush
{
public:
UINT m_nMenuDrawMode;
COLORREF m_BarColor;
COLORREF m_BarColor2;
CNewBrush(UINT menuDrawMode, COLORREF barColor, COLORREF barColor2):m_nMenuDrawMode(menuDrawMode),m_BarColor(barColor),m_BarColor2(barColor2)
{
if (g_Shell!=WinNT4 &&
g_Shell!=Win95 &&
(menuDrawMode==CNewMenu::STYLE_XP_2003 || menuDrawMode==CNewMenu::STYLE_COLORFUL))
{
// Get the desktop hDC...
HDC hDcDsk = GetWindowDC(0);
CDC* pDcDsk = CDC::FromHandle(hDcDsk);
CDC clientDC;
clientDC.CreateCompatibleDC(pDcDsk);
CRect rect(0,0,(GetSystemMetrics(SM_CXFULLSCREEN)+16)&~7,20);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(pDcDsk,rect.Width(),rect.Height());
CBitmap* pOldBitmap = clientDC.SelectObject(&bitmap);
int nRight = rect.right;
if(rect.right>700)
{
rect.right = 700;
DrawGradient(&clientDC,rect,barColor,barColor2,TRUE,TRUE);
rect.left = rect.right;
rect.right = nRight;
clientDC.FillSolidRect(rect, barColor2);
}
else
{
DrawGradient(&clientDC,rect,barColor,barColor2,TRUE,TRUE);
}
clientDC.SelectObject(pOldBitmap);
// Release the desktopdc
ReleaseDC(0,hDcDsk);
CreatePatternBrush(&bitmap);
}
else
{
CreateSolidBrush(barColor);
}
}
};
CBrush* GetMenuBarBrush()
{
// The brushes will be destroyed at program-end => Not a memory-leak
static CNewBrushList brushList;
static CNewBrush* lastBrush = NULL;
COLORREF menuBarColor;
COLORREF menuBarColor2; //JUS
UINT nMenuDrawMode = CNewMenu::GetMenuDrawMode();
switch(nMenuDrawMode)
{
case CNewMenu::STYLE_XP_2003 :
case CNewMenu::STYLE_XP_2003_NOBORDER :
{
CNewMenu::GetMenuBarColor2003(menuBarColor, menuBarColor2);
if (NumScreenColors()>=256 && !bHighContrast)
{
nMenuDrawMode = CNewMenu::STYLE_XP_2003;
}
else
{
menuBarColor = menuBarColor2 = GetSysColor(COLOR_3DFACE);
nMenuDrawMode = CNewMenu::STYLE_XP;
}
}
break;
case CNewMenu::STYLE_COLORFUL :
case CNewMenu::STYLE_COLORFUL_NOBORDER :
{
CNewMenu::GetMenuBarColor2003(menuBarColor, menuBarColor2);
if (NumScreenColors()>=256 && !bHighContrast)
{
nMenuDrawMode = CNewMenu::STYLE_COLORFUL;
}
else
{
nMenuDrawMode = CNewMenu::STYLE_XP;
}
}
break;
case CNewMenu::STYLE_XP :
case CNewMenu::STYLE_XP_NOBORDER :
menuBarColor = menuBarColor2 = GetSysColor(COLOR_3DFACE);
nMenuDrawMode = CNewMenu::STYLE_XP;
break;
default:
return NULL;
}
// check if the last brush the one which we want
if(lastBrush!=NULL &&
lastBrush->m_nMenuDrawMode==nMenuDrawMode &&
lastBrush->m_BarColor==menuBarColor &&
lastBrush->m_BarColor2==menuBarColor2)
{
return lastBrush;
}
// Check if the brush is allready created
POSITION pos = brushList.GetHeadPosition();
while (pos)
{
lastBrush = (CNewBrush*)brushList.GetNext(pos);
if(lastBrush!=NULL &&
lastBrush->m_nMenuDrawMode==nMenuDrawMode &&
lastBrush->m_BarColor==menuBarColor &&
lastBrush->m_BarColor2==menuBarColor2)
{
return lastBrush;
}
}
// create a new one and insert into the list
brushList.AddHead(lastBrush = new CNewBrush(nMenuDrawMode,menuBarColor,menuBarColor2));
return lastBrush;
}
void UpdateMenuBarColor(HMENU hMenu)
{
CBrush* pBrush = GetMenuBarBrush();
// for WindowsBlind activating it's better for not to change menubar background
if(!pBrush /* || (pIsThemeActive && pIsThemeActive()) */ )
{
// menubackground hasn't been set
return;
}
MENUINFO menuInfo = {0};
menuInfo.cbSize = sizeof(menuInfo);
menuInfo.hbrBack = *pBrush;
menuInfo.fMask = MIM_BACKGROUND;
// Change color only for CNewMenu and derived classes
if(IsMenu(hMenu) && DYNAMIC_DOWNCAST(CNewMenu,CMenu::FromHandlePermanent(hMenu))!=NULL)
{
SetMenuInfo(hMenu,&menuInfo);
}
CWinApp* pWinApp = AfxGetApp();
// Update menu from template
if(pWinApp)
{
CDocManager* pManager = pWinApp->m_pDocManager;
if(pManager)
{
POSITION pos = pManager->GetFirstDocTemplatePosition();
while(pos)
{
CDocTemplate* pTemplate = pManager->GetNextDocTemplate(pos);
CMultiDocTemplate* pMultiTemplate = DYNAMIC_DOWNCAST(CMultiDocTemplate,pTemplate);
if(pMultiTemplate)
{
// Change color only for CNewMenu and derived classes
if(DYNAMIC_DOWNCAST(CNewMenu,CMenu::FromHandlePermanent(pMultiTemplate->m_hMenuShared))!=NULL)
{
// need for correct menubar color
SetMenuInfo(pMultiTemplate->m_hMenuShared,&menuInfo);
}
}
/* // does not work with embeded menues
if(pTemplate)
{
// Change color only for CNewMenu and derived classes
// need for correct menubar color
if(DYNAMIC_DOWNCAST(CNewMenu,CMenu::FromHandlePermanent(pTemplate->m_hMenuInPlace))!=NULL)
{
// menu & accelerator resources for in-place container
SetMenuInfo(pTemplate->m_hMenuInPlace,&menuInfo);
}
if(DYNAMIC_DOWNCAST(CNewMenu,CMenu::FromHandlePermanent(pTemplate->m_hMenuEmbedding))!=NULL)
{
// menu & accelerator resource for server editing embedding
SetMenuInfo(pTemplate->m_hMenuEmbedding,&menuInfo);
}
if(DYNAMIC_DOWNCAST(CNewMenu,CMenu::FromHandlePermanent(pTemplate->m_hMenuInPlaceServer))!=NULL)
{
// menu & accelerator resource for server editing in-place
SetMenuInfo(pTemplate->m_hMenuInPlaceServer,&menuInfo);
}
}
*/
}
}
}
}
BOOL DrawMenubarItem(CWnd* pWnd,CMenu* pMenu, UINT nItemIndex,UINT nState)
{
CRect itemRect;
if (nItemIndex!=UINT(-1) && GetMenuItemRect(pWnd->m_hWnd,pMenu->m_hMenu, nItemIndex, &itemRect))
{
MENUITEMINFO menuInfo = {0};
menuInfo.cbSize = sizeof(menuInfo);
menuInfo.fMask = MIIM_DATA|MIIM_TYPE|MIIM_ID;
if(pMenu->GetMenuItemInfo(nItemIndex,&menuInfo,TRUE))
{
// Only ownerdrawn were allowed
if(menuInfo.fType&MF_OWNERDRAW)
{
CWindowDC dc(pWnd);
CFont fontMenu;
LOGFONT logFontMenu;
#ifdef _NEW_MENU_USER_FONT
logFontMenu = MENU_USER_FONT;
#else
NONCLIENTMETRICS nm = {0};
nm.cbSize = sizeof (NONCLIENTMETRICS);
VERIFY (SystemParametersInfo(SPI_GETNONCLIENTMETRICS,nm.cbSize,&nm,0));
logFontMenu = nm.lfMenuFont;
#endif
fontMenu.CreateFontIndirect (&logFontMenu);
CFont* pOldFont = dc.SelectObject(&fontMenu);
CRect wndRect;
GetWindowRect(*pWnd,wndRect);
itemRect.OffsetRect(-wndRect.TopLeft());
// Bugfix for wine
if(bWine)
{
if(!(GetWindowLongPtr(*pWnd, GWL_STYLE)&WS_THICKFRAME) )
{
itemRect.OffsetRect(-GetSystemMetrics(SM_CXFIXEDFRAME),
-(GetSystemMetrics(SM_CYMENU)+GetSystemMetrics(SM_CYCAPTION)+GetSystemMetrics(SM_CYFIXEDFRAME)+1));
}
else
{
itemRect.OffsetRect(-GetSystemMetrics(SM_CXFRAME),
-(GetSystemMetrics(SM_CYMENU)+GetSystemMetrics(SM_CYCAPTION)+GetSystemMetrics(SM_CYFRAME)+1));
}
}
DRAWITEMSTRUCT drwItem = {0};
drwItem.CtlType = ODT_MENU;
drwItem.hwndItem = HMenuToHWnd(pMenu->m_hMenu);
drwItem.itemID = menuInfo.wID;
drwItem.itemData = menuInfo.dwItemData;
drwItem.rcItem = itemRect;
drwItem.hDC = dc.m_hDC;
drwItem.itemState = nState;
drwItem.itemAction = ODA_DRAWENTIRE;
ASSERT(menuInfo.dwItemData);
CNewMenu::m_dwLastActiveItem = (DWORD)menuInfo.dwItemData;
CPoint windowOrg;
SetWindowOrgEx(dc.m_hDC,0,0,&windowOrg);
SendMessage(pWnd->GetSafeHwnd(),WM_DRAWITEM,NULL,(LPARAM)&drwItem);
SetWindowOrgEx(dc.m_hDC,windowOrg.x,windowOrg.y,NULL);
dc.SelectObject(pOldFont);
return TRUE;
}
}
}
return FALSE;
}
Win32Type IsShellType()
{
OSVERSIONINFO osvi = {0};
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
DWORD winVer=GetVersion();
if(winVer<0x80000000)
{/*NT */
if(!GetVersionEx(&osvi))
{
ShowLastError(_T("Error from Menu: GetVersionEx NT"));
}
if(osvi.dwMajorVersion==4L)
{
return WinNT4;
}
else if(osvi.dwMajorVersion==5L && osvi.dwMinorVersion==0L)
{
return Win2000;
}
// thanks to John Zegers
else if(osvi.dwMajorVersion>=5L)// && osvi.dwMinorVersion==1L)
{
return WinXP;
}
return WinNT3;
}
else if (LOBYTE(LOWORD(winVer))<4)
{
return Win32s;
}
if(!GetVersionEx(&osvi))
{
ShowLastError(_T("Error from Menu: GetVersionEx"));
}
if(osvi.dwMajorVersion==4L && osvi.dwMinorVersion==10L)
{
return Win98;
}
else if(osvi.dwMajorVersion==4L && osvi.dwMinorVersion==90L)
{
return WinME;
}
return Win95;
}
BOOL IsShadowEnabled()
{
BOOL bEnabled = FALSE;
if(SystemParametersInfo(SPI_GETDROPSHADOW,0,&bEnabled,0))
{
return bEnabled;
}
return FALSE;
}
COLORREF DarkenColorXP(COLORREF color)
{
return RGB( MulDiv(GetRValue(color),7,10),
MulDiv(GetGValue(color),7,10),
MulDiv(GetBValue(color)+55,7,10));
}
// Function splits a color into its RGB components and
// transforms the color using a scale 0..255
COLORREF DarkenColor( long lScale, COLORREF lColor)
{
long red = MulDiv(GetRValue(lColor),(255-lScale),255);
long green = MulDiv(GetGValue(lColor),(255-lScale),255);
long blue = MulDiv(GetBValue(lColor),(255-lScale),255);
return RGB(red, green, blue);
}
COLORREF MixedColor(COLORREF colorA,COLORREF colorB)
{
// ( 86a + 14b ) / 100
int red = MulDiv(86,GetRValue(colorA),100) + MulDiv(14,GetRValue(colorB),100);
int green = MulDiv(86,GetGValue(colorA),100) + MulDiv(14,GetGValue(colorB),100);
int blue = MulDiv(86,GetBValue(colorA),100) + MulDiv(14,GetBValue(colorB),100);
return RGB( min(red,0xff),min(green,0xff), min(blue,0xff));
}
COLORREF MidColor(COLORREF colorA,COLORREF colorB)
{
// (7a + 3b)/10
int red = MulDiv(7,GetRValue(colorA),10) + MulDiv(3,GetRValue(colorB),10);
int green = MulDiv(7,GetGValue(colorA),10) + MulDiv(3,GetGValue(colorB),10);
int blue = MulDiv(7,GetBValue(colorA),10) + MulDiv(3,GetBValue(colorB),10);
return RGB( min(red,0xff),min(green,0xff), min(blue,0xff));
}
COLORREF GrayColor(COLORREF crColor)
{
int Gray = (((int)GetRValue(crColor)) + GetGValue(crColor) + GetBValue(crColor))/3;
return RGB( Gray,Gray,Gray);
}
BOOL IsLightColor(COLORREF crColor)
{
return (((int)GetRValue(crColor)) + GetGValue(crColor) + GetBValue(crColor))>(3*128);
}
COLORREF GetXpHighlightColor()
{
if(bHighContrast)
{
return GetSysColor(COLOR_HIGHLIGHT);
}
if (NumScreenColors() > 256)
{
// May-05-2005 - Mark P. Peterson ([email protected]) - Changed to use "MixedColor1()" instead when not using XP Theme mode.
// It appears that using MidColor() in many non XP Themes cases returns the wrong color, this needs to be much more like the
// highlight color as the user has selected in Windows. If the highlight color is YELLOW, for example, and the COLOR_WINDOW
// value is WHITE, using MidColor() the function returns a dark blue color making the menus too hard to read.
if ((! IsMenuThemeActive()) && (IsLightColor(GetSysColor(COLOR_HIGHLIGHT))))
return MixedColor(GetSysColor(COLOR_WINDOW),GetSysColor(COLOR_HIGHLIGHT));
else
return MidColor(GetSysColor(COLOR_WINDOW),GetSysColor(COLOR_HIGHLIGHT));
// as released by Bruno
// return MidColor(GetSysColor(COLOR_WINDOW),GetSysColor(COLOR_HIGHLIGHT));
}
return GetSysColor(COLOR_WINDOW);
}
// Function splits a color into its RGB components and
// transforms the color using a scale 0..255
COLORREF LightenColor( long lScale, COLORREF lColor)
{
long R = MulDiv(255-GetRValue(lColor),lScale,255)+GetRValue(lColor);
long G = MulDiv(255-GetGValue(lColor),lScale,255)+GetGValue(lColor);
long B = MulDiv(255-GetBValue(lColor),lScale,255)+GetBValue(lColor);
return RGB(R, G, B);
}
COLORREF BleachColor(int Add, COLORREF color)
{
return RGB( min (GetRValue(color)+Add, 255),
min (GetGValue(color)+Add, 255),
min (GetBValue(color)+Add, 255));
}
COLORREF GetAlphaBlendColor(COLORREF blendColor, COLORREF pixelColor,int weighting)
{
if(pixelColor==CLR_NONE)
{
return CLR_NONE;
}
// Algorithme for alphablending
//dest' = ((weighting * source) + ((255-weighting) * dest)) / 256
DWORD refR = ((weighting * GetRValue(pixelColor)) + ((255-weighting) * GetRValue(blendColor))) / 256;
DWORD refG = ((weighting * GetGValue(pixelColor)) + ((255-weighting) * GetGValue(blendColor))) / 256;;
DWORD refB = ((weighting * GetBValue(pixelColor)) + ((255-weighting) * GetBValue(blendColor))) / 256;;
return RGB(refR,refG,refB);
}
void DrawGradient(CDC* pDC,CRect& Rect,
COLORREF StartColor,COLORREF EndColor,
BOOL bHorizontal,BOOL bUseSolid)
{
int Count = pDC->GetDeviceCaps(NUMCOLORS);
if(Count==-1)
bUseSolid = FALSE;
// for running under win95 and WinNt 4.0 without loading Msimg32.dll
if(!bUseSolid && pGradientFill )
{
TRIVERTEX vert[2];
GRADIENT_RECT gRect;
vert [0].y = Rect.top;
vert [0].x = Rect.left;
vert [0].Red = COLOR16(COLOR16(GetRValue(StartColor))<<8);
vert [0].Green = COLOR16(COLOR16(GetGValue(StartColor))<<8);
vert [0].Blue = COLOR16(COLOR16(GetBValue(StartColor))<<8);
vert [0].Alpha = 0x0000;
vert [1].y = Rect.bottom;
vert [1].x = Rect.right;
vert [1].Red = COLOR16(COLOR16(GetRValue(EndColor))<<8);
vert [1].Green = COLOR16(COLOR16(GetGValue(EndColor))<<8);
vert [1].Blue = COLOR16(COLOR16(GetBValue(EndColor))<<8);
vert [1].Alpha = 0x0000;
gRect.UpperLeft = 0;
gRect.LowerRight = 1;
if(bHorizontal)
{
pGradientFill(pDC->m_hDC,vert,2,&gRect,1,GRADIENT_FILL_RECT_H);
}
else
{
pGradientFill(pDC->m_hDC,vert,2,&gRect,1,GRADIENT_FILL_RECT_V);
}
}
else
{
BYTE StartRed = GetRValue(StartColor);
BYTE StartGreen = GetGValue(StartColor);
BYTE StartBlue = GetBValue(StartColor);
BYTE EndRed = GetRValue(EndColor);
BYTE EndGreen = GetGValue(EndColor);
BYTE EndBlue = GetBValue(EndColor);
int n = (bHorizontal)?Rect.Width():Rect.Height();
// only need for the rest, can be optimized
{
if(bUseSolid)
{
// We need a solid brush (can not be doted)
pDC->FillSolidRect(Rect,pDC->GetNearestColor(EndColor));
}
else
{
// We need a brush (can be doted)
CBrush TempBrush(EndColor);
pDC->FillRect(Rect,&TempBrush);
}
}
int dy = 2;
n-=dy;
for(int dn=0;dn<=n;dn+=dy)
{
BYTE ActRed = (BYTE)(MulDiv(int(EndRed) -StartRed, dn,n)+StartRed);
BYTE ActGreen = (BYTE)(MulDiv(int(EndGreen)-StartGreen,dn,n)+StartGreen);
BYTE ActBlue = (BYTE)(MulDiv(int(EndBlue) -StartBlue, dn,n)+StartBlue);
CRect TempRect;
if(bHorizontal)
{
TempRect = CRect(CPoint(Rect.left+dn,Rect.top),CSize(dy,Rect.Height()));
}
else
{
TempRect = CRect(CPoint(Rect.left,Rect.top+dn),CSize(Rect.Width(),dy));
}
if(bUseSolid)
{
pDC->FillSolidRect(TempRect,pDC->GetNearestColor(RGB(ActRed,ActGreen,ActBlue)));
}
else
{
CBrush TempBrush(RGB(ActRed,ActGreen,ActBlue));
pDC->FillRect(TempRect,&TempBrush);
}
}
}
}
/////////////////////////////////////////////////////////////////////////////
// CNewMenuHook important class for subclassing menus!
class CNewMenuHook
{
friend class CNewMenuThreadHook;
public:
class CMenuHookData
{
public:
CMenuHookData(HWND hWnd,BOOL bSpecialWnd)
: m_dwData(bSpecialWnd),m_bDrawBorder(FALSE),m_Point(0,0),
m_hRgn((HRGN)1),m_bDoSubclass(TRUE)
//, m_hRightShade(NULL),m_hBottomShade(NULL),m_TimerID(0)
{
// Safe actual menu
SetMenu(CNewMenuHook::m_hLastMenu);
// Reset for the next menu
CNewMenuHook::m_hLastMenu = NULL;
// Save actual border setting etc.
m_dwStyle = GetWindowLongPtr(hWnd, GWL_STYLE);
m_dwExStyle = GetWindowLongPtr(hWnd, GWL_EXSTYLE);
//if(pSetWindowTheme)pSetWindowTheme(hWnd,L" ",L" ");
}
~CMenuHookData()
{
if(m_hRgn!=(HRGN)1)
{
DeleteObject(m_hRgn);
m_hRgn = (HRGN)1;
}
}
BOOL SetMenu(HMENU hMenu)
{
m_hMenu = hMenu;
if(!CNewMenu::GetNewMenuBorderAllMenu() &&
!DYNAMIC_DOWNCAST(CNewMenu,CMenu::FromHandlePermanent(hMenu)))
{
m_bDoSubclass = FALSE;
}
else
{
m_bDoSubclass = TRUE;
}
// When I change the backgroundcolor the borderdrawing well be wrong (scrollmenu)
//if(IsMenu(hMenu) &&
// CNewMenu::GetMenuDrawMode()==CNewMenu::STYLE_XP ||
// CNewMenu::GetMenuDrawMode()==CNewMenu::STYLE_XP_NOBORDER )
//{
// MENUINFO menuInfo;
// ZeroMemory(&menuInfo,sizeof(menuInfo));
// menuInfo.cbSize = sizeof(menuInfo);
// menuInfo.hbrBack = g_MenuBrush;
// menuInfo.fMask = MIM_BACKGROUND;
// ::SetMenuInfo(hMenu,&menuInfo);
//}
return m_bDoSubclass;
}
LONG_PTR m_dwStyle;
LONG_PTR m_dwExStyle;
CPoint m_Point;
DWORD m_dwData; // 1=Sepcial WND, 2=Styles Changed,4=VK_ESCAPE, 8=in Print
BOOL m_bDrawBorder;
HMENU m_hMenu;
CBitmap m_Screen;
HRGN m_hRgn;
BOOL m_bDoSubclass;
//HWND m_hRightShade;
//HWND m_hBottomShade;
//UINT m_TimerID;
};
public:
CNewMenuHook();
~CNewMenuHook();
public:
static CMenuHookData* GetMenuHookData(HWND hWnd);
static BOOL AddTheme(CMenuTheme*);
static CMenuTheme* RemoveTheme(DWORD dwThemeId);
static CMenuTheme* FindTheme(DWORD dwThemeId);
private:
static LRESULT CALLBACK NewMenuHook(int code, WPARAM wParam, LPARAM lParam);
static BOOL CheckSubclassing(HWND hWnd,BOOL bSpecialWnd);
static LRESULT CALLBACK SubClassMenu(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
static void UnsubClassMenu(HWND hWnd);
static BOOL SubClassMenu2(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, DWORD* pResult);
public:
static HMENU m_hLastMenu;
static DWORD m_dwMsgPos;
static DWORD m_bSubclassFlag;
private:
static HMODULE m_hLibrary;
static HMODULE m_hThemeLibrary;
static HHOOK HookOldMenuCbtFilter;
#ifdef _TRACE_MENU_LOGFILE
static HANDLE m_hLogFile;
#endif //_TRACE_MENU_LOGFILE
// an map of actual opened Menu and submenu
static CTypedPtrMap<CMapPtrToPtr,HWND,CMenuHookData*> m_MenuHookData;
// Stores list of all defined Themes
static CTypedPtrList<CPtrList, CMenuTheme*>* m_pRegisteredThemesList;
};
/////////////////////////////////////////////////////////////////////////////
// CNewMenuIconLock Helperclass for reference-counting !
class CNewMenuIconLock
{
CNewMenuIcons* m_pIcons;
public:
CNewMenuIconLock(CNewMenuIcons* pIcons):m_pIcons(pIcons)
{
m_pIcons->AddRef();
}
~CNewMenuIconLock()
{
m_pIcons->Release();
}
operator CNewMenuIcons*(){return m_pIcons;}
};
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
IMPLEMENT_DYNAMIC(CNewMenuIcons,CObject);
CNewMenuIcons::CNewMenuIcons()
: m_lpszResourceName(NULL),
m_hInst(NULL),
m_hBitmap(NULL),
m_nColors(0),
m_crTransparent(CLR_NONE),
m_dwRefCount(0)
{
}
CNewMenuIcons::~CNewMenuIcons()
{
if(m_lpszResourceName && !IS_INTRESOURCE(m_lpszResourceName))
{
delete (LPTSTR)m_lpszResourceName;
}
}
int CNewMenuIcons::AddRef()
{
if(this==NULL)
return NULL;
return ++m_dwRefCount;
}
int CNewMenuIcons::Release()
{
if(this==NULL)
return NULL;
DWORD dwCount = --m_dwRefCount;
if(m_dwRefCount==0)
{
if(CNewMenu::m_pSharedMenuIcons)
{
POSITION pos = CNewMenu::m_pSharedMenuIcons->Find(this);
if(pos)
{
CNewMenu::m_pSharedMenuIcons->RemoveAt(pos);
}
}
delete this;
}
return dwCount;
}
#if defined(_DEBUG) || defined(_AFXDLL)
// Diagnostic Support
void CNewMenuIcons::AssertValid() const
{
CObject::AssertValid();
}
void CNewMenuIcons::Dump(CDumpContext& dc) const
{
CObject::Dump(dc);
dc << _T("NewMenuIcons: ") << _T("\n");
}
#endif
BOOL CNewMenuIcons::DoMatch(LPCTSTR lpszResourceName, HMODULE hInst)
{
if(hInst==m_hInst && lpszResourceName)
{
if(IS_INTRESOURCE(m_lpszResourceName))
{
return (lpszResourceName==m_lpszResourceName);
}
return (_tcscmp(lpszResourceName,m_lpszResourceName)==0);
}
return FALSE;
}
BOOL CNewMenuIcons::DoMatch(HBITMAP hBitmap, CSize size, UINT* pID)
{
if(pID && m_hBitmap==hBitmap)
{
CSize iconSize = GetIconSize();
if(iconSize==size)
{
int nCount = (int)m_IDs.GetSize();
for(int nIndex=0 ; nIndex<nCount ; nIndex++,pID++)
{
if( (*pID)==0 || m_IDs.GetAt(nIndex)!=(*pID) )
{
return FALSE;
}
}
return TRUE;
}
}
return FALSE;
}
BOOL CNewMenuIcons::DoMatch(WORD* pIconInfo, COLORREF crTransparent)
{
if(m_crTransparent==crTransparent && pIconInfo!=NULL)
{
CNewMenuIconInfo* pInfo = (CNewMenuIconInfo*)pIconInfo;
// Check for the same resource ID
if( pInfo->wBitmapID && IS_INTRESOURCE(m_lpszResourceName) &&
((UINT)(UINT_PTR)m_lpszResourceName)==pInfo->wBitmapID)
{
int nCount = (int)m_IDs.GetSize();
WORD* pID = pInfo->ids();
for(int nIndex=0 ; nIndex<nCount ; nIndex++,pID++)
{
if( (*pID)==0 || m_IDs.GetAt(nIndex)!=(*pID) )
{
return FALSE;
}
}
return TRUE;
}
}
return FALSE;
}
int CNewMenuIcons::FindIndex(UINT nID)
{
int nIndex = (int)m_IDs.GetSize();
while(nIndex--)
{
if(m_IDs.GetAt(nIndex)==nID)
{
return nIndex*MENU_ICONS;
}
}
return -1;
}
BOOL CNewMenuIcons::GetIconSize(int* cx, int* cy)
{
return ::ImageList_GetIconSize(m_IconsList,cx,cy);
}
CSize CNewMenuIcons::GetIconSize()
{
int cx=0;
int cy=0;
if(::ImageList_GetIconSize(m_IconsList,&cx,&cy))
{
return CSize(cx,cy);
}
return CSize(0,0);
}
void CNewMenuIcons::OnSysColorChange()
{
if(m_lpszResourceName!=NULL)
{
int cx=16,cy=16;
if(GetIconSize(&cx, &cy) && LoadBitmap(cx,cy,m_lpszResourceName,m_hInst))
{
MakeImages();
}
}
}
BOOL CNewMenuIcons::LoadBitmap(int nWidth, int nHeight, LPCTSTR lpszResourceName, HMODULE hInst)
{
m_nColors = 0;
HBITMAP hBitmap = LoadColorBitmap(lpszResourceName,hInst,&m_nColors);
if(hBitmap!=NULL)
{
CBitmap bitmap;
bitmap.Attach(hBitmap);
if(m_IconsList.GetSafeHandle())
{
m_IconsList.DeleteImageList();
}
m_IconsList.Create(nWidth,nHeight,ILC_COLORDDB|ILC_MASK,0,10);
m_IconsList.Add(&bitmap,m_crTransparent);
return TRUE;
}
return FALSE;
}
BOOL CNewMenuIcons::LoadToolBar(HBITMAP hBitmap, CSize size, UINT* pID, COLORREF crTransparent)
{
BOOL bResult = FALSE;
m_nColors = 0;
if(hBitmap!=NULL)
{
BITMAP myInfo = {0};
if(GetObject(hBitmap,sizeof(myInfo),&myInfo))
{
m_crTransparent = crTransparent;
if(m_IconsList.GetSafeHandle())
{
m_IconsList.DeleteImageList();
}
m_IconsList.Create(size.cx,size.cy,ILC_COLORDDB|ILC_MASK,0,10);
// Changed by Mehdy Bohlool(zy) ( December_28_2003 )
//
// CImageList::Add function change the background color ( color
// specified as transparent ) to black, and this bitmap may use
// after call to this function, It seem that Load functions do
// not change their source data provider ( currently hBitmap ).
// Old Code:
// CBitmap* pBitmap = CBitmap::FromHandle(hBitmap);
// m_IconsList.Add(pBitmap,m_crTransparent);
// New Code:
{
HBITMAP hBitmapCopy;
hBitmapCopy = (HBITMAP) CopyImage( hBitmap, IMAGE_BITMAP, 0,0,0);
CBitmap* pBitmap = CBitmap::FromHandle(hBitmapCopy);
m_IconsList.Add(pBitmap,m_crTransparent);
DeleteObject( hBitmapCopy );
}
while(*pID)
{
UINT nID = *(pID++);
m_IDs.Add(nID);
bResult = TRUE;
}
MakeImages();
}
}
return bResult;
}
BOOL CNewMenuIcons::LoadToolBar(WORD* pIconInfo, COLORREF crTransparent)
{
BOOL bResult = FALSE;
m_crTransparent = crTransparent;
CNewMenuIconInfo* pInfo = (CNewMenuIconInfo*)pIconInfo;
if (LoadBitmap(pInfo->wWidth,pInfo->wHeight,MAKEINTRESOURCE(pInfo->wBitmapID)))
{
SetResourceName(MAKEINTRESOURCE(pInfo->wBitmapID));
WORD* pID = pInfo->ids();
while(*pID)
{
UINT nID = *(pID++);
m_IDs.Add(nID);
bResult = TRUE;
}
MakeImages();
}
return bResult;
}
void CNewMenuIcons::SetResourceName(LPCTSTR lpszResourceName)
{
ASSERT_VALID(this);
ASSERT(lpszResourceName != NULL);
if(m_lpszResourceName && !IS_INTRESOURCE(m_lpszResourceName))
{
delete [](LPTSTR)m_lpszResourceName;
}
if( lpszResourceName && !IS_INTRESOURCE(lpszResourceName))
{
size_t bufSizeTchar = _tcslen(lpszResourceName)+1;
m_lpszResourceName = new TCHAR[bufSizeTchar];
_tcscpy_s((LPTSTR)m_lpszResourceName,bufSizeTchar,lpszResourceName);
}
else
{
m_lpszResourceName = lpszResourceName;
}
}
BOOL CNewMenuIcons::LoadToolBar(LPCTSTR lpszResourceName, HMODULE hInst)
{
ASSERT_VALID(this);
SetResourceName(lpszResourceName);
m_hInst = hInst;
// determine location of the bitmap in resource
if(hInst==0)
{
hInst = AfxFindResourceHandle(lpszResourceName, RT_TOOLBAR);
}
HRSRC hRsrc = ::FindResource(hInst, lpszResourceName, RT_TOOLBAR);
if (hRsrc == NULL)
{ // Special purpose when you try to load it from a dll 30.05.2002
if(AfxGetResourceHandle()!=hInst)
{
hInst = AfxGetResourceHandle();
hRsrc = ::FindResource(hInst, lpszResourceName, RT_TOOLBAR);
}
if (hRsrc == NULL)
{
return FALSE;
}
}
HGLOBAL hGlobal = LoadResource(hInst, hRsrc);
if (hGlobal == NULL)
{
return FALSE;
}
CToolBarData* pData = (CToolBarData*)LockResource(hGlobal);
if (pData == NULL)
{
return FALSE;
}
BOOL bResult = FALSE;
ASSERT(pData->wVersion == 1);
if(LoadBitmap(pData->wWidth,pData->wHeight,lpszResourceName,hInst))
{
// Remove all previous ID's
m_IDs.RemoveAll();
for (int i = 0; i < pData->wItemCount; i++)
{
UINT nID = pData->items()[i];
if (nID)
{
m_IDs.Add(nID);
bResult = TRUE;
}
}
}
UnlockResource(hGlobal);
FreeResource(hGlobal);
MakeImages();
return bResult;
}
int CNewMenuIcons::AddGloomIcon(HICON hIcon, int nIndex)
{
ICONINFO iconInfo = {0};
if(!GetIconInfo(hIcon,&iconInfo))
{
return -1;
}
CSize size = GetIconSize();
CDC myDC;
myDC.CreateCompatibleDC(0);
CBitmap bmColor;
bmColor.Attach(iconInfo.hbmColor);
CBitmap bmMask;
bmMask.Attach(iconInfo.hbmMask);
CBitmap* pOldBitmap = myDC.SelectObject(&bmColor);
COLORREF crPixel;
for(int i=0;i<size.cx;++i)
{
for(int j=0;j<size.cy;++j)
{
crPixel = myDC.GetPixel(i,j);
// Jan-12-2005 - Mark P. Peterson - [email protected] - http://www.RhinoSoft.com/
// added so the gloom value can be adjusted, this was 50
myDC.SetPixel(i,j,DarkenColor(CNewMenu::GetGloomFactor(), crPixel));
}
}
myDC.SelectObject(pOldBitmap);
if(nIndex==-1)
{
return m_IconsList.Add(&bmColor,&bmMask);
}
return (m_IconsList.Replace(nIndex,&bmColor,&bmMask)) ? nIndex: -1;
}
int CNewMenuIcons::AddGrayIcon(HICON hIcon, int nIndex)
{
ICONINFO iconInfo = {0};
if(!GetIconInfo(hIcon,&iconInfo))
{
return -1;
}
CBitmap bmColor;
bmColor.Attach(iconInfo.hbmColor);
CBitmap bmMask;
bmMask.Attach(iconInfo.hbmMask);
COLORREF blendcolor;
switch (CNewMenu::GetMenuDrawMode())
{
case CNewMenu::STYLE_XP_2003:
case CNewMenu::STYLE_XP_2003_NOBORDER:
case CNewMenu::STYLE_COLORFUL_NOBORDER:
case CNewMenu::STYLE_COLORFUL:
blendcolor = LightenColor(115,CNewMenu::GetMenuBarColor2003());
break;
case CNewMenu::STYLE_XP:
case CNewMenu::STYLE_XP_NOBORDER:
blendcolor = LightenColor(115,CNewMenu::GetMenuBarColorXP());
break;
default:
blendcolor = LightenColor(115,CNewMenu::GetMenuBarColor());
break;
}
MakeGrayAlphablend(&bmColor,110, blendcolor);
if(nIndex==-1)
{
return m_IconsList.Add(&bmColor,&bmMask);
}
return (m_IconsList.Replace(nIndex,&bmColor,&bmMask)) ? nIndex: -1;
}
BOOL CNewMenuIcons::MakeImages()
{
int nCount = m_IconsList.GetImageCount();
if(!nCount)
{
return FALSE;
}
CSize size = GetIconSize();
CImageList ilTemp;
ilTemp.Attach(m_IconsList.Detach());
m_IconsList.Create(size.cx,size.cy,ILC_COLORDDB|ILC_MASK,0,10);
for(int nIndex=0;nIndex<nCount;nIndex++)
{
HICON hIcon = ilTemp.ExtractIcon(nIndex);
m_IconsList.Add(hIcon);
AddGloomIcon(hIcon);
AddGrayIcon(hIcon);
DestroyIcon(hIcon);
}
return TRUE;
}
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
IMPLEMENT_DYNAMIC(CNewMenuBitmaps,CNewMenuIcons);
CNewMenuBitmaps::CNewMenuBitmaps()
{
}
CNewMenuBitmaps::~CNewMenuBitmaps()
{
}
int CNewMenuBitmaps::Add(UINT nID, COLORREF crTransparent)
{
int nIndex = (int)m_IDs.GetSize();
while(nIndex--)
{
if(m_IDs.GetAt(nIndex)==nID)
{
return nIndex*MENU_ICONS;
}
}
// Try to load the bitmap for getting dimension
HBITMAP hBitmap = LoadColorBitmap(MAKEINTRESOURCE(nID),0);
if(hBitmap!=NULL)
{
CBitmap temp;
temp.Attach(hBitmap);
BITMAP bitmap = {0};
if(!temp.GetBitmap(&bitmap))
{
return -1;
}
if(m_IconsList.GetSafeHandle()==NULL)
{
m_IconsList.Create(bitmap.bmWidth,bitmap.bmHeight,ILC_COLORDDB|ILC_MASK,0,10);
}
else
{
CSize size = GetIconSize();
// Wrong size?
if(size.cx!=bitmap.bmWidth || size.cy!=bitmap.bmHeight)
{
return -1;
}
}
m_TranspColors.Add(crTransparent);
m_IDs.Add(nID);
nIndex = m_IconsList.Add(&temp,crTransparent);
HICON hIcon = m_IconsList.ExtractIcon(nIndex);
AddGloomIcon(hIcon);
AddGrayIcon(hIcon);
DestroyIcon(hIcon);
//SetBlendImage();
return nIndex;
}
return -1;
}
void CNewMenuBitmaps::OnSysColorChange()
{
int nCount = (int)m_IDs.GetSize();
for(int nIndex=0;nIndex<nCount;nIndex+=MENU_ICONS)
{
//Todo reload icons
HICON hIcon = m_IconsList.ExtractIcon(nIndex);
AddGloomIcon(hIcon,nIndex+1);
AddGrayIcon(hIcon,nIndex+2);
DestroyIcon(hIcon);
}
}
int CNewMenuBitmaps::Add(HICON hIcon, UINT nID)
{
ICONINFO iconInfo = {0};
if(!GetIconInfo(hIcon,&iconInfo))
{
return -1;
}
CBitmap temp;
temp.Attach(iconInfo.hbmColor);
::DeleteObject(iconInfo.hbmMask);
BITMAP bitmap = {0};
if(!temp.GetBitmap(&bitmap))
{
return -1;
}
if(m_IconsList.GetSafeHandle()==NULL)
{
m_IconsList.Create(bitmap.bmWidth,bitmap.bmHeight,ILC_COLORDDB|ILC_MASK,0,10);
}
else
{
CSize size = GetIconSize();
// Wrong size?
if(size.cx!=bitmap.bmWidth || size.cy!=bitmap.bmHeight)
{
return -1;
}
}
if(nID)
{
int nIndex = (int)m_IDs.GetSize();
while(nIndex--)
{
if(m_IDs.GetAt(nIndex)==nID)
{
// We found the index also replace the icon
nIndex = nIndex*MENU_ICONS;
m_IconsList.Replace(nIndex,hIcon);
AddGloomIcon(hIcon,nIndex+1);
AddGrayIcon(hIcon,nIndex+2);
return nIndex;
}
}
}
COLORREF clr = CLR_NONE;
m_TranspColors.Add(clr);
m_IDs.Add(nID);
int nIndex = m_IconsList.Add(hIcon);
AddGloomIcon(hIcon);
AddGrayIcon(hIcon);
return nIndex;
}
int CNewMenuBitmaps::Add(CBitmap* pBitmap, COLORREF crTransparent)
{
ASSERT(pBitmap);
BITMAP bitmap = {0};
if(!pBitmap->GetBitmap(&bitmap))
{
return -1;
}
if(m_IconsList.GetSafeHandle()==NULL)
{
m_IconsList.Create(bitmap.bmWidth,bitmap.bmHeight,ILC_COLORDDB|ILC_MASK,0,10);
}
else
{
CSize size = GetIconSize();
// Wrong size?
if(size.cx!=bitmap.bmWidth || size.cy!=bitmap.bmHeight)
{
return -1;
}
}
UINT nID = 0;
m_TranspColors.Add(crTransparent);
m_IDs.Add(nID);
int nIndex = m_IconsList.Add(pBitmap,crTransparent);
HICON hIcon = m_IconsList.ExtractIcon(nIndex);
AddGloomIcon(hIcon);
AddGrayIcon(hIcon);
DestroyIcon(hIcon);
//SetBlendImage();
return nIndex;
}
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
IMPLEMENT_DYNAMIC(CNewMenuItemData,CObject);
CNewMenuItemData::CNewMenuItemData()
: m_nTitleFlags(0),
m_nFlags(0),
m_nID(0),
m_nSyncFlag(0),
m_pData(NULL),
m_pMenuIcon(NULL),
m_nMenuIconOffset(-1)
{
}
CNewMenuItemData::~CNewMenuItemData()
{
// it's a safe release. Do not care for NULL pointers.
m_pMenuIcon->Release();
}
// Get the string, along with (manufactured) accelerator text.
CString CNewMenuItemData::GetString (HACCEL hAccel)
{
if (m_nFlags & MF_POPUP )
{ // No accelerators if we're the title of a popup menu. Otherwise we get spurious accels
hAccel = NULL;
}
CString s = m_szMenuText;
int iTabIndex = s.Find ('\t');
if (!hAccel || iTabIndex>= 0) // Got one hard coded in, or we're a popup menu
{
if (!hAccel && iTabIndex>= 0)
{
s = s.Left (iTabIndex);
}
return s;
}
// OK, we've got to go hunting through the default accelerator.
if (hAccel == INVALID_HANDLE_VALUE)
{
hAccel = NULL;
CFrameWnd *pFrame = DYNAMIC_DOWNCAST(CFrameWnd, AfxGetMainWnd ());
// No frame. Maybe we're part of a dialog app. etc.
if (pFrame)
{
hAccel = pFrame->GetDefaultAccelerator ();
}
}
// No default found, or we've turned accelerators off.
if (hAccel == NULL)
{
return s;
}
// Get the number of entries
int nEntries = ::CopyAcceleratorTable (hAccel, NULL, 0);
if (nEntries)
{
ACCEL *pAccel = (ACCEL *)_alloca(nEntries*sizeof(ACCEL));
if (::CopyAcceleratorTable (hAccel, pAccel, nEntries))
{
CString sAccel;
for (int n = 0; n < nEntries; n++)
{
if (pAccel [n].cmd != (WORD) m_nID)
{
continue;
}
if (!sAccel.IsEmpty ())
{
sAccel += _T(", ");
}
// Translate the accelerator into more useful code.
if (pAccel [n].fVirt & FALT) sAccel += _T("Alt+");
if (pAccel [n].fVirt & FCONTROL) sAccel += _T("Ctrl+");
if (pAccel [n].fVirt & FSHIFT) sAccel += _T("Shift+");
if (pAccel [n].fVirt & FVIRTKEY)
{
TCHAR keyname[64];
UINT vkey = MapVirtualKey(pAccel [n].key, 0)<<16;
GetKeyNameText(vkey, keyname, sizeof(keyname));
sAccel += keyname;
}
else
{
sAccel += (TCHAR)pAccel [n].key;
}
}
if (!sAccel.IsEmpty ()) // We found one!
{
s += '\t';
s += sAccel;
}
}
}
return s;
}
void CNewMenuItemData::SetString(LPCTSTR szMenuText)
{
m_szMenuText = szMenuText;
}
#if defined(_DEBUG) || defined(_AFXDLL)
// Diagnostic Support
void CNewMenuItemData::AssertValid() const
{
CObject::AssertValid();
}
void CNewMenuItemData::Dump(CDumpContext& dc) const
{
CObject::Dump(dc);
dc << _T("MenuItem: ") << m_szMenuText << _T("\n");
}
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
IMPLEMENT_DYNAMIC(CNewMenuItemDataTitle,CNewMenuItemData);
CNewMenuItemDataTitle::CNewMenuItemDataTitle()
: m_clrTitle(CLR_DEFAULT),
m_clrLeft(CLR_DEFAULT),
m_clrRight(CLR_DEFAULT)
{
}
CNewMenuItemDataTitle::~CNewMenuItemDataTitle()
{
}
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
IMPLEMENT_DYNAMIC(CNewMenu,CMenu);
// actual selectet menu-draw mode
CMenuTheme* CNewMenu::m_pActMenuDrawing = NULL;
CTypedPtrList<CPtrList, CNewMenuIcons*>* CNewMenu::m_pSharedMenuIcons = NULL;
// Gloabal logfont for all menutitles
LOGFONT CNewMenu::m_MenuTitleFont = {16, 0, 0, 0, FW_BOLD,
0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH,_T("Arial")};
void CNewMenu::SetMenuTitleFont(CFont* pFont)
{
ASSERT(pFont);
pFont->GetLogFont(&m_MenuTitleFont);
}
void CNewMenu::SetMenuTitleFont(LOGFONT* pLogFont)
{
ASSERT(pLogFont);
m_MenuTitleFont = *pLogFont;
}
LOGFONT CNewMenu::GetMenuTitleFont()
{
return m_MenuTitleFont;
}
DWORD CNewMenu::m_dwLastActiveItem = NULL;
// how the menu's are drawn in winXP
BOOL CNewMenu::m_bEnableXpBlending = TRUE;
BOOL CNewMenu::m_bNewMenuBorderAllMenu = TRUE;
BOOL CNewMenu::m_bSelectDisable = TRUE;
// Jan-12-2005 - Mark P. Peterson - [email protected] - http://www.RhinoSoft.com/
// added so the gloom value can be adjusted
// 50 is the default, may be too high, 20 is subtle
int CNewMenu::m_nGloomFactor = 50;
const Win32Type g_Shell = IsShellType();
BOOL bRemoteSession = FALSE;
// one instance of the hook for menu-subclassing
static CNewMenuHook MyNewMenuHookInstance;
CNewMenu::CNewMenu(HMENU hParent)
: m_hTempOwner(NULL),
m_hParentMenu(hParent),
m_bIsPopupMenu(TRUE),
m_dwOpenMenu(NULL),
m_LastActiveMenuRect(0,0,0,0),
m_pData(NULL),
m_hAccelToDraw((HACCEL)INVALID_HANDLE_VALUE)
{
// O.S. - no dynamic icons by default
m_bDynIcons = FALSE;
// Icon sizes default to 16 x 16
m_iconX = 16;
m_iconY = 15;
m_selectcheck = -1;
m_unselectcheck = -1;
m_checkmaps=NULL;
m_checkmapsshare=FALSE;
// set the color used for the transparent background in all bitmaps
m_bitmapBackground = CLR_DEFAULT;
}
CNewMenu::~CNewMenu()
{
DestroyMenu();
}
COLORREF CNewMenu::GetMenuColor(HMENU hMenu)
{
if(hMenu!=NULL)
{
MENUINFO menuInfo={0};
menuInfo.cbSize = sizeof(menuInfo);
menuInfo.fMask = MIM_BACKGROUND;
if(::GetMenuInfo(hMenu,&menuInfo) && menuInfo.hbrBack)
{
LOGBRUSH logBrush;
if(GetObject(menuInfo.hbrBack,sizeof(LOGBRUSH),&logBrush))
{
return logBrush.lbColor;
}
}
}
if(IsShellType()==WinXP)
{
BOOL bFlatMenu = FALSE;
// theme ist not checket, that must be so
if( (SystemParametersInfo(SPI_GETFLATMENU,0,&bFlatMenu,0) && bFlatMenu==TRUE) )
{
return GetSysColor(COLOR_MENUBAR);
}
}
return GetSysColor(COLOR_MENU);
}
COLORREF CNewMenu::GetMenuBarColorXP()
{
// Win95 or WinNT do not support to change the menubarcolor
if(IsShellType()==Win95 || IsShellType()==WinNT4)
{
return GetSysColor(COLOR_MENU);
}
return GetSysColor(COLOR_3DFACE);
}
HRESULT localGetCurrentThemeName( LPWSTR pszThemeFileName, int dwMaxNameChars,
LPWSTR pszColorBuff, int cchMaxColorChars,
LPWSTR pszSizeBuff, int cchMaxSizeChars)
{
static CNewLoadLib menuInfo(_T("UxTheme.dll"),"GetCurrentThemeName");
if(menuInfo.m_pProg)
{
typedef HRESULT (WINAPI* FktGetCurrentThemeName)(LPWSTR pszThemeFileName,int dwMaxNameChars, LPWSTR pszColorBuff, int cchMaxColorChars, LPWSTR pszSizeBuff, int cchMaxSizeChars);
return ((FktGetCurrentThemeName)menuInfo.m_pProg)(pszThemeFileName, dwMaxNameChars, pszColorBuff, cchMaxColorChars, pszSizeBuff, cchMaxSizeChars);
}
return NULL;
}
HANDLE localGetWindowTheme(HWND hWnd)
{
static CNewLoadLib menuInfo(_T("UxTheme.dll"),"GetWindowTheme");
if(menuInfo.m_pProg)
{
typedef HANDLE (WINAPI* FktGetWindowTheme)(HWND hWnd);
return ((FktGetWindowTheme)menuInfo.m_pProg)(hWnd);
}
return NULL;
}
HANDLE localOpenThemeData( HWND hWnd, LPCWSTR pszClassList)
{
static CNewLoadLib menuInfo(_T("UxTheme.dll"),"OpenThemeData");
if(menuInfo.m_pProg)
{
typedef HANDLE (WINAPI* FktOpenThemeData)(HWND hWnd, LPCWSTR pszClassList);
return ((FktOpenThemeData)menuInfo.m_pProg)(hWnd,pszClassList);
}
return NULL;
}
HRESULT localCloseThemeData(HANDLE hTheme)
{
static CNewLoadLib menuInfo(_T("UxTheme.dll"),"CloseThemeData");
if(menuInfo.m_pProg)
{
typedef HRESULT (WINAPI* FktCloseThemeData)(HANDLE hTheme);
return ((FktCloseThemeData)menuInfo.m_pProg)(hTheme);
}
return NULL;
}
HRESULT localGetThemeColor(HANDLE hTheme,
int iPartId,
int iStateId,
int iColorId,
COLORREF *pColor)
{
static CNewLoadLib menuInfo(_T("UxTheme.dll"),"GetThemeColor");
if(menuInfo.m_pProg)
{
typedef HRESULT (WINAPI* FktGetThemeColor)(HANDLE hTheme,int iPartId,int iStateId,int iColorId, COLORREF *pColor);
return ((FktGetThemeColor)menuInfo.m_pProg)(hTheme, iPartId, iStateId, iColorId, pColor);
}
return S_FALSE;
}
COLORREF CNewMenu::GetMenuBarColor2003()
{
COLORREF colorLeft,colorRight;
GetMenuBarColor2003(colorLeft,colorRight);
return colorLeft;
}
void CNewMenu::GetMenuBarColor2003(COLORREF& color1, COLORREF& color2, BOOL bBackgroundColor /* = TRUE */)
{
// Win95 or WinNT do not support to change the menubarcolor
if(IsShellType()==Win95 || IsShellType()==WinNT4)
{
color1 = color2 = GetSysColor(COLOR_MENU);
return;
}
if(GetMenuDrawMode()==STYLE_COLORFUL_NOBORDER ||
GetMenuDrawMode()==STYLE_COLORFUL)
{
COLORREF colorWindow = DarkenColor(10,GetSysColor(COLOR_WINDOW));
COLORREF colorCaption = GetSysColor(COLOR_ACTIVECAPTION);
CClientDC myDC(NULL);
COLORREF nearColor = myDC.GetNearestColor(MidColor(colorWindow,colorCaption));
// some colorscheme corrections (Andreas Schärer)
if (nearColor == 15779244) //standartblau
{ //entspricht (haar-)genau office 2003
nearColor = RGB(163,194,245);
}
else if (nearColor == 15132390) //standartsilber
{
nearColor = RGB(215,215,229);
}
else if (nearColor == 13425878) //olivgrün
{
nearColor = RGB(218,218,170);
}
color1 = nearColor;
color2 = LightenColor(110,color1);
return;
}
else
{
if (IsMenuThemeActive())
{
COLORREF colorWindow = DarkenColor(10,GetSysColor(COLOR_WINDOW));
COLORREF colorCaption = GetSysColor(COLOR_ACTIVECAPTION);
//CWnd* pWnd = AfxGetMainWnd();
//if (pWnd)
{
//HANDLE hTheme = localOpenThemeData(pWnd->GetSafeHwnd(),L"Window");
// get the them from desktop window
HANDLE hTheme = localOpenThemeData(NULL,L"Window");
if(hTheme)
{
COLORREF color = CLR_NONE;
// defined in Tmschema.h
// TM_PART(1, WP, CAPTION)
// TM_STATE(1, CS, ACTIVE)
// TM_PROP(204, TMT, COLOR, COLOR)
//for (int iColorID=0;iColorID<6000;iColorID++)
//{
// if(localGetThemeColor(hTheme,1,1,iColorID,&color)==S_OK)
// {
// colorCaption = color;
// }
//}
// TM_PROP(3804, TMT, EDGELIGHTCOLOR, COLOR) // edge color
// TM_PROP(3821, TMT, FILLCOLORHINT, COLOR) // hint about fill color used (for custom controls)
if(localGetThemeColor(hTheme,1,1,3821,&color)==S_OK && (color!=1))
{
colorCaption = color;
}
//TM_PROP(3805, TMT, EDGEHIGHLIGHTCOLOR, COLOR) // edge color
if(localGetThemeColor(hTheme,1,1,3805,&color)==S_OK && (color!=1))
{
colorWindow = color;
}
localCloseThemeData(hTheme);
// left side Menubar
switch(colorCaption)
{
case 0x00e55400: // blue
color1 = RGB(163,194,245);
break;
case 0x00bea3a4: // silver
color1 = RGB(215,215,229);
break;
case 0x0086b8aa: //olive green
color1 = RGB(218,218,170);
break;
default:
{
CClientDC myDC(NULL);
color1 = myDC.GetNearestColor(MidColor(colorWindow,colorCaption));
}
break;
}
if (bBackgroundColor)
{
color2 = LightenColor(110,color1);
}
else
{
color2 = LightenColor(200,color1);
color1 = DarkenColor(20,color1);
}
return;
}
}
CClientDC myDC(NULL);
COLORREF nearColor = myDC.GetNearestColor(MidColor(colorWindow,colorCaption));
// some colorscheme corrections (Andreas Schärer)
if (nearColor == 15779244) //standartblau
{ //entspricht (haar-)genau office 2003
color1 = RGB(163,194,245);
}
else if (nearColor == 15132390) //standartsilber
{
color1 = RGB(215,215,229);
}
else if (nearColor == 13425878) //olivgrün
{
color1 = RGB(218,218,170);
}
else
{
color1 = nearColor;
}
if (bBackgroundColor)
{
color2 = LightenColor(100,color1);
}
else
{
color2 = LightenColor(200,color1);
color1 = DarkenColor(20,color1);
}
}
else
{
//color1 = ::GetSysColor(COLOR_MENU);
color1 = ::GetSysColor(COLOR_BTNFACE); // same as COLOR_3DFACE
color2 = ::GetSysColor(COLOR_WINDOW);
color2 = GetAlphaBlendColor(color1,color2,220);
}
}
}
COLORREF CNewMenu::GetMenuBarColor(HMENU hMenu)
{
if(hMenu!=NULL)
{
MENUINFO menuInfo = {0};
menuInfo.cbSize = sizeof(menuInfo);
menuInfo.fMask = MIM_BACKGROUND;
if(::GetMenuInfo(hMenu,&menuInfo) && menuInfo.hbrBack)
{
LOGBRUSH logBrush;
if(GetObject(menuInfo.hbrBack,sizeof(LOGBRUSH),&logBrush))
{
return logBrush.lbColor;
}
}
}
if(IsShellType()==WinXP)
{
BOOL bFlatMenu = FALSE;
if((SystemParametersInfo(SPI_GETFLATMENU,0,&bFlatMenu,0) && bFlatMenu==TRUE) ||
(IsMenuThemeActive()))
{
return GetSysColor(COLOR_MENUBAR);
}
}
// May-05-2005 - Mark P. Peterson ([email protected]) - Changed to use the menubar color, I could not find why COLOR_MENU should
// be used when not flat and no XP Theme is active. The problem is that using this shows the wrong color in any other theme, when
// the background color of menus is something other than the same color of the menu bar.
return (GetMenuBarColorXP());
// return GetSysColor(COLOR_MENU);
}
void CNewMenu::SetLastMenuRect(HDC hDC, LPRECT pRect)
{
if(!m_bIsPopupMenu)
{
HWND hWnd = WindowFromDC(hDC);
if(hWnd && pRect)
{
CRect Temp;
GetWindowRect(hWnd,Temp);
m_LastActiveMenuRect = *pRect;
m_LastActiveMenuRect.OffsetRect(Temp.TopLeft());
#ifdef _TRACE_MENU_
AfxTrace(_T("ActiveRect: (%ld,%ld,%ld,%ld)\n"),m_LastActiveMenuRect.left,m_LastActiveMenuRect.top,m_LastActiveMenuRect.right,m_LastActiveMenuRect.bottom);
#endif
}
}
}
void CNewMenu::SetLastMenuRect(LPRECT pRect)
{
ASSERT(pRect);
m_LastActiveMenuRect = *pRect;
}
BOOL CNewMenu::IsNewShell()
{
return (g_Shell>=Win95);
}
BOOL CNewMenu::OnMeasureItem(const MSG* pMsg)
{
if(pMsg->message==WM_MEASUREITEM)
{
LPMEASUREITEMSTRUCT lpMIS = (LPMEASUREITEMSTRUCT)pMsg->lParam;
if(lpMIS->CtlType==ODT_MENU)
{
CMenu* pMenu=NULL;
if(::IsMenu(UIntToHMenu(lpMIS->itemID)) )
{
pMenu = CMenu::FromHandlePermanent(UIntToHMenu(lpMIS->itemID) );
}
else
{
_AFX_THREAD_STATE* pThreadState = AfxGetThreadState ();
if (pThreadState->m_hTrackingWindow == pMsg->hwnd)
{
// start from popup
pMenu = FindPopupMenuFromIDData(pThreadState->m_hTrackingMenu,lpMIS->itemID,lpMIS->itemData);
}
if(pMenu==NULL)
{
// start from menubar
pMenu = FindPopupMenuFromIDData(::GetMenu(pMsg->hwnd),lpMIS->itemID,lpMIS->itemData);
if(pMenu==NULL)
{
// finaly start from system menu.
pMenu = FindPopupMenuFromIDData(::GetSystemMenu(pMsg->hwnd,FALSE),lpMIS->itemID,lpMIS->itemData);
#ifdef USE_NEW_MENU_BAR
if(!pMenu)
{ // Support for new menubar
static UINT WM_GETMENU = ::RegisterWindowMessage(_T("CNewMenuBar::WM_GETMENU"));
pMenu = FindPopupMenuFromIDData((HMENU)::SendMessage(pMsg->hwnd,WM_GETMENU,0,0),lpMIS->itemID,lpMIS->itemData);
}
#endif
}
}
}
if(pMenu!=NULL)
{
#ifdef _TRACE_MENU_
UINT oldWidth = lpMIS->itemWidth;
#endif //_TRACE_MENU_
pMenu->MeasureItem(lpMIS);
#ifdef _TRACE_MENU_
AfxTrace(_T("NewMenu MeasureItem: ID:0x08%X, oW:0x%X, W:0x%X, H:0x%X\n"),lpMIS->itemID,oldWidth,lpMIS->itemWidth,lpMIS->itemHeight);
#endif //_TRACE_MENU_
return TRUE;
}
}
}
return FALSE;
}
CMenu* CNewMenu::FindPopupMenuFromID(HMENU hMenu, UINT nID)
{
// check for a valid menu-handle
if ( ::IsMenu(hMenu))
{
CMenu *pMenu = CMenu::FromHandlePermanent(hMenu);
if(pMenu)
{
return FindPopupMenuFromID(pMenu,nID);
}
}
return NULL;
}
CMenu* CNewMenu::FindPopupMenuFromIDData(HMENU hMenu, UINT nID, ULONG_PTR pData)
{
// check for a valid menu-handle
if ( ::IsMenu(hMenu))
{
CMenu *pMenu = CMenu::FromHandlePermanent(hMenu);
if(pMenu)
{
return FindPopupMenuFromIDData(pMenu,nID,pData);
}
}
return NULL;
}
CMenu* CNewMenu::FindPopupMenuFromIDData(CMenu* pMenu, UINT nID, ULONG_PTR pData)
{
if(!pMenu || !IsMenu(pMenu->m_hMenu))
{
return NULL;
}
ASSERT_VALID(pMenu);
// walk through all items, looking for ID match
UINT nItems = pMenu->GetMenuItemCount();
for (int iItem = 0; iItem < (int)nItems; iItem++)
{
CMenu* pPopup = pMenu->GetSubMenu(iItem);
if (pPopup!=NULL)
{
// recurse to child popup
pPopup = FindPopupMenuFromIDData(pPopup, nID, pData);
// check popups on this popup
if (pPopup != NULL)
{
return pPopup;
}
}
else if (pMenu->GetMenuItemID(iItem) == nID)
{
MENUITEMINFO MenuItemInfo = {0};
MenuItemInfo.cbSize = sizeof(MenuItemInfo);
MenuItemInfo.fMask = MIIM_DATA;
if(pMenu->GetMenuItemInfo(iItem,&MenuItemInfo,TRUE))
{
if(MenuItemInfo.dwItemData==pData)
{
// it is a normal item inside our popup
return pMenu;
}
}
}
}
// not found
return NULL;
}
CMenu* CNewMenu::FindPopupMenuFromID(CMenu* pMenu, UINT nID)
{
if(!pMenu || !IsMenu(pMenu->m_hMenu))
{
return NULL;
}
ASSERT_VALID(pMenu);
// walk through all items, looking for ID match
UINT nItems = pMenu->GetMenuItemCount();
for (int iItem = 0; iItem < (int)nItems; iItem++)
{
CMenu* pPopup = pMenu->GetSubMenu(iItem);
if (pPopup != NULL)
{
// recurse to child popup
pPopup = FindPopupMenuFromID(pPopup, nID);
// check popups on this popup
if (pPopup != NULL)
{
return pPopup;
}
}
else if (pMenu->GetMenuItemID(iItem) == nID)
{
// it is a normal item inside our popup
return pMenu;
}
}
// not found
return NULL;
}
BOOL CNewMenu::DestroyMenu()
{
// Destroy Sub menus:
int nIndex = (int)m_SubMenus.GetSize();
while(nIndex--)
{
// Destroy only if we createt it!!!!!
CNewMenu* pMenu = DYNAMIC_DOWNCAST(CNewMenu,CMenu::FromHandlePermanent(m_SubMenus[nIndex]));
if(pMenu)
{
delete pMenu;
}
}
m_SubMenus.RemoveAll();
// Destroy menu data
nIndex = (int)m_MenuItemList.GetSize();
while(nIndex--)
{
delete(m_MenuItemList[nIndex]);
}
m_MenuItemList.RemoveAll();
if(m_checkmaps&&!m_checkmapsshare)
{
delete m_checkmaps;
m_checkmaps=NULL;
}
// Call base-class implementation last:
return(CMenu::DestroyMenu());
};
UINT CNewMenu::GetMenuDrawMode()
{
ASSERT(m_pActMenuDrawing);
return m_pActMenuDrawing->m_dwThemeId;
}
UINT CNewMenu::SetMenuDrawMode(UINT mode)
{
#ifdef _TRACE_MENU_
if(mode&1)
{
AfxTrace(_T("\nDraw menu no border\n"));
}
else
{
AfxTrace(_T("\nDraw menu with border\n"));
}
#endif // _TRACE_MENU_
// under wine we disable flat menu and shade drawing
if(bWine)
{
switch(mode)
{
case STYLE_ORIGINAL:
mode = STYLE_ORIGINAL_NOBORDER;
break;
case STYLE_XP:
mode = STYLE_XP_NOBORDER;
break;
case STYLE_SPECIAL:
mode = STYLE_SPECIAL_NOBORDER;
break;
case STYLE_ICY:
mode = STYLE_ICY_NOBORDER;
break;
case STYLE_XP_2003:
mode = STYLE_XP_2003_NOBORDER;
break;
case STYLE_COLORFUL:
mode = STYLE_COLORFUL_NOBORDER;
break;
}
}
UINT nOldMode = (UINT)STYLE_UNDEFINED;
CMenuTheme* pTheme = CNewMenuHook::FindTheme(mode);
if(pTheme)
{
if(m_pActMenuDrawing)
{
nOldMode = m_pActMenuDrawing->m_dwThemeId;
}
m_pActMenuDrawing = pTheme;
}
return nOldMode;
}
HMENU CNewMenu::GetParent()
{
return m_hParentMenu;
}
BOOL CNewMenu::IsPopup()
{
return m_bIsPopupMenu;
}
BOOL CNewMenu::SetPopup(BOOL bIsPopup)
{
BOOL bOldFlag = m_bIsPopupMenu;
m_bIsPopupMenu = bIsPopup;
return bOldFlag;
}
BOOL CNewMenu::SetSelectDisableMode(BOOL mode)
{
BOOL bOldMode = m_bSelectDisable;
m_bSelectDisable=mode;
return bOldMode;
}
BOOL CNewMenu::GetSelectDisableMode()
{
return m_bSelectDisable;
}
BOOL CNewMenu::SetXpBlending(BOOL bEnable)
{
BOOL bOldMode = m_bEnableXpBlending;
m_bEnableXpBlending = bEnable;
return bOldMode;
}
BOOL CNewMenu::GetXpBlending()
{
return m_bEnableXpBlending;
}
// Jan-12-2005 - Mark P. Peterson - [email protected] - http://www.RhinoSoft.com/
// added SetGloomFactor() and GetGloomFactor() so that the glooming can be done in a more or less subtle way
int CNewMenu::SetGloomFactor(int nGloomFactor)
{
int nOldGloomFactor = m_nGloomFactor;
// set the new gloom factor
m_nGloomFactor = nGloomFactor;
// return the previous gloom factor
return (nOldGloomFactor);
} // SetGloomFactor
int CNewMenu::GetGloomFactor()
{
// return the current gloom factor
return (m_nGloomFactor);
} // GetGloomFactor
// Function to set how default menu border were drawn
//(enable=TRUE means that all menu in the application has the same border)
BOOL CNewMenu::SetNewMenuBorderAllMenu(BOOL bEnable /* =TRUE*/)
{
BOOL bOldMode = m_bNewMenuBorderAllMenu;
m_bNewMenuBorderAllMenu = bEnable;
return bOldMode;
}
BOOL CNewMenu::GetNewMenuBorderAllMenu()
{
return m_bNewMenuBorderAllMenu;
}
void CNewMenu::OnSysColorChange()
{
static DWORD dwLastTicks = 0;
DWORD dwAktTicks = GetTickCount();
// Last Update 2 sec
if((dwAktTicks-dwLastTicks)>2000)
{
dwLastTicks = dwAktTicks;
if(m_pSharedMenuIcons)
{
POSITION pos = m_pSharedMenuIcons->GetHeadPosition();
while(pos)
{
CNewMenuIcons* pMenuIcons = m_pSharedMenuIcons->GetNext(pos);
pMenuIcons->OnSysColorChange();
}
}
}
}
void CNewMenu::MeasureItem( LPMEASUREITEMSTRUCT lpMIS )
{
ASSERT(m_pActMenuDrawing);
BOOL bIsMenuBar = IsMenuBar(UIntToHMenu(lpMIS->itemID));
if(!bIsMenuBar && m_hParentMenu && !FindMenuItem(lpMIS->itemID)) //::IsMenu(UIntToHMenu(lpMIS->itemID)) )
{
CNewMenu* pMenu = DYNAMIC_DOWNCAST(CNewMenu,CMenu::FromHandlePermanent(m_hParentMenu));
if(pMenu)
{
((*pMenu).*m_pActMenuDrawing->m_pMeasureItem)(lpMIS,bIsMenuBar);
return;
}
}
((*this).*m_pActMenuDrawing->m_pMeasureItem)(lpMIS,bIsMenuBar);
}
void CNewMenu::DrawItem (LPDRAWITEMSTRUCT lpDIS)
{
ASSERT(m_pActMenuDrawing);
BOOL bIsMenuBar = m_hParentMenu ? FALSE: ((m_bIsPopupMenu)?FALSE:TRUE);
if(bIsMenuBar && m_dwLastActiveItem==lpDIS->itemData)
{
if(! (lpDIS->itemState&ODS_HOTLIGHT) )
{
// Mark for redraw helper for win 98
m_dwLastActiveItem = NULL;
}
}
(this->*m_pActMenuDrawing->m_pDrawItem)(lpDIS,bIsMenuBar);
}
// Erase the Background of the menu
BOOL CNewMenu::EraseBkgnd(HWND hWnd, HDC hDC)
{
CDC* pDC = CDC::FromHandle (hDC);
CRect Rect;
// Get the size of the menu...
GetClientRect(hWnd, Rect );
pDC->FillSolidRect (Rect,GetMenuColor());
return TRUE;
}
void CNewMenu::DrawTitle(LPDRAWITEMSTRUCT lpDIS,BOOL bIsMenuBar)
{
ASSERT(m_pActMenuDrawing);
(this->*m_pActMenuDrawing->m_pDrawTitle)(lpDIS,bIsMenuBar);
}
void CNewMenu::DrawMenuTitle(LPDRAWITEMSTRUCT lpDIS, BOOL bIsMenuBar)
{
UNREFERENCED_PARAMETER(bIsMenuBar);
CDC* pDC = CDC::FromHandle(lpDIS->hDC);
CNewMenuItemData* pMenuData = (CNewMenuItemData*)(lpDIS->itemData);
ASSERT(pMenuData);
COLORREF colorWindow = GetSysColor(COLOR_WINDOW);
COLORREF colorMenuBar = GetMenuColor();
COLORREF colorLeft = MixedColor(colorWindow,colorMenuBar);
COLORREF colorRight = ::GetSysColor(COLOR_ACTIVECAPTION);
COLORREF colorText = ::GetSysColor(COLOR_CAPTIONTEXT);
CSize iconSize(0,0);
if(pMenuData->m_nMenuIconOffset!=(-1) && pMenuData->m_pMenuIcon)
{
iconSize = pMenuData->m_pMenuIcon->GetIconSize();
if(iconSize!=CSize(0,0))
{
iconSize += CSize(4,4);
}
}
CNewMenuItemDataTitle* pItem = DYNAMIC_DOWNCAST(CNewMenuItemDataTitle,pMenuData);
if(pItem)
{
if(pItem->m_clrRight!=CLR_DEFAULT)
{
colorRight = pItem->m_clrRight;
}
if(pItem->m_clrLeft!=CLR_DEFAULT)
{
colorLeft = pItem->m_clrLeft;
}
if(pItem->m_clrTitle!=CLR_DEFAULT)
{
colorText = pItem->m_clrTitle;
}
}
CRect rcClipBox;
HWND hWnd = ::WindowFromDC(lpDIS->hDC);
// try to get the real size of the client window
if(hWnd==NULL || !GetClientRect(hWnd,rcClipBox) )
{
// when we have menu animation the DC is a memory DC
pDC->GetClipBox(rcClipBox);
}
// draw the title bar
CRect rect = lpDIS->rcItem;
CPoint TextPoint;
CFont Font;
LOGFONT MyFont = m_MenuTitleFont;
if(pMenuData->m_nTitleFlags&MFT_SIDE_TITLE)
{
rect.top = rcClipBox.top;
rect.bottom = rcClipBox.bottom;
rect.right += GetSystemMetrics(SM_CXMENUCHECK);
MyFont.lfOrientation = 900;
MyFont.lfEscapement = 900;
TextPoint = CPoint(rect.left+2, rect.bottom-4-iconSize.cy);
}
else
{
MyFont.lfOrientation = 0;
MyFont.lfEscapement = 0;
TextPoint = CPoint(rect.left+2+iconSize.cx, rect.top);
}
Font.CreateFontIndirect(&MyFont);
CFont *pOldFont = pDC->SelectObject(&Font);
SIZE size = {0,0};
VERIFY(::GetTextExtentPoint32(pDC->m_hDC,pMenuData->m_szMenuText,pMenuData->m_szMenuText.GetLength(),&size));
COLORREF oldColor = pDC->SetTextColor(colorText);
int OldMode = pDC->SetBkMode(TRANSPARENT);
if(pMenuData->m_nTitleFlags&MFT_GRADIENT)
{
if(pMenuData->m_nTitleFlags&MFT_SIDE_TITLE)
{
DrawGradient(pDC,rect,colorLeft,colorRight,false);
}
else
{
DrawGradient(pDC,rect,colorRight,colorLeft,true);
}
}
else
{
if(pMenuData->m_nTitleFlags&MFT_ROUND)
{
if(pMenuData->m_nTitleFlags&MFT_SIDE_TITLE)
{
TextPoint.y-=2;
rect.right = rect.left+size.cy+4;
}
else
{
int maxSpace = ((rect.Width()-size.cx)/2);
TextPoint.x+=min(maxSpace,10);
}
CBrush brush(colorRight);
CPen* pOldPen = (CPen*)pDC->SelectStockObject(WHITE_PEN);
CBrush* pOldBrush = pDC->SelectObject(&brush);
pDC->RoundRect(rect,CPoint(10,10));
pDC->SelectObject(pOldBrush);
pDC->SelectObject(pOldPen);
}
else
{
pDC->FillSolidRect(rect,colorRight);
}
}
if (pMenuData->m_nTitleFlags&MFT_SUNKEN)
{
pDC->Draw3dRect(rect,GetSysColor(COLOR_3DSHADOW),GetSysColor(COLOR_3DHILIGHT));
}
if (pMenuData->m_nTitleFlags&MFT_CENTER)
{
if (pMenuData->m_nTitleFlags&MFT_SIDE_TITLE)
{
TextPoint.y = rect.bottom - ((rect.Height()-size.cx-iconSize.cy)>>1)-iconSize.cy;
}
else
{
TextPoint.x = rect.left + ((rect.Width()-size.cx-iconSize.cx)>>1)+iconSize.cx;
}
}
pDC->TextOut(TextPoint.x,TextPoint.y, pMenuData->GetString(m_bDrawAccelerators ? m_hAccelToDraw : NULL));
if(pMenuData->m_nMenuIconOffset!=(-1) && pMenuData->m_pMenuIcon)
{
CPoint ptImage = TextPoint;
if (pMenuData->m_nTitleFlags&MFT_SIDE_TITLE)
{
ptImage.y += 2;
}
else
{
ptImage.x -= iconSize.cx;
ptImage.y += 2;
}
// draws the icon
HICON hDrawIcon2 = pMenuData->m_pMenuIcon->m_IconsList.ExtractIcon(pMenuData->m_nMenuIconOffset);
pDC->DrawState(ptImage, iconSize-CSize(4,4), hDrawIcon2, DSS_NORMAL,(HBRUSH)NULL);
DestroyIcon(hDrawIcon2);
}
if(pMenuData->m_nTitleFlags&MFT_LINE)
{
if(pMenuData->m_nTitleFlags&MFT_SIDE_TITLE)
{
CRect rect2(rect.left+20,rect.top+5,rect.left+22,rect.bottom-5);
pDC->Draw3dRect(rect2,GetSysColor(COLOR_3DSHADOW),GetSysColor(COLOR_3DHILIGHT));
rect2.OffsetRect(3,0);
rect2.InflateRect(0,-10);
pDC->Draw3dRect(rect2,GetSysColor(COLOR_3DSHADOW),GetSysColor(COLOR_3DHILIGHT));
}
else
{
CRect rect2(rect.left+2,rect.bottom-7,rect.right-2,rect.bottom-5);
pDC->Draw3dRect(rect2,GetSysColor(COLOR_3DHILIGHT),GetSysColor(COLOR_3DSHADOW));
rect2.OffsetRect(0,3);
rect2.InflateRect(-10,0);
pDC->Draw3dRect(rect2,GetSysColor(COLOR_3DSHADOW),GetSysColor(COLOR_3DHILIGHT));
}
}
pDC->SetBkMode(OldMode);
pDC->SetTextColor(oldColor);
pDC->SelectObject(pOldFont);
}
void CNewMenu::DrawItem_WinXP(LPDRAWITEMSTRUCT lpDIS, BOOL bIsMenuBar)
{
ASSERT(lpDIS != NULL);
CNewMenuItemData* pMenuData = (CNewMenuItemData*)(lpDIS->itemData);
ASSERT(pMenuData);
UINT nFlags = pMenuData->m_nFlags;
CNewMemDC memDC(&lpDIS->rcItem,lpDIS->hDC);
CDC* pDC;
if( bIsMenuBar || (nFlags&MF_SEPARATOR) )
{ // For title and menubardrawing disable memory painting
memDC.DoCancel();
pDC = CDC::FromHandle(lpDIS->hDC);
}
else
{
pDC = &memDC;
}
COLORREF colorWindow = GetSysColor(COLOR_WINDOW);
// COLORREF colorMenuBar = bIsMenuBar?GetMenuBarColor(m_hMenu):GetMenuColor();
COLORREF colorMenuBar = GetMenuBarColor(m_hMenu);
COLORREF colorMenu = MixedColor(colorWindow,colorMenuBar);
COLORREF colorBitmap = MixedColor(GetMenuBarColor(m_hMenu),colorWindow);
COLORREF colorSel = GetXpHighlightColor();
COLORREF colorBorder = GetSysColor(COLOR_HIGHLIGHT);//DarkenColor(128,colorMenuBar);
if(bHighContrast)
{
colorBorder = GetSysColor(COLOR_BTNTEXT);
}
if (NumScreenColors() <= 256)
{
colorBitmap = GetSysColor(COLOR_BTNFACE);
}
// Better contrast when you have less than 256 colors
if(pDC->GetNearestColor(colorMenu)==pDC->GetNearestColor(colorBitmap))
{
colorMenu = colorWindow;
colorBitmap = colorMenuBar;
}
//CPen Pen(PS_SOLID,0,GetSysColor(COLOR_HIGHLIGHT));
CPen Pen(PS_SOLID,0,colorBorder);
if(bIsMenuBar)
{
#ifdef _TRACE_MENU_
// AfxTrace(_T("BarState: 0x%lX Menus %ld\n"),lpDIS->itemState,m_dwOpenMenu);
#endif
if(!IsMenu(UIntToHMenu(lpDIS->itemID)) && (lpDIS->itemState&ODS_SELECTED_OPEN))
{
lpDIS->itemState = (lpDIS->itemState&~(ODS_SELECTED|ODS_SELECTED_OPEN))|ODS_HOTLIGHT;
}
else if(!(lpDIS->itemState&ODS_SELECTED_OPEN) && !m_dwOpenMenu && lpDIS->itemState&ODS_SELECTED)
{
lpDIS->itemState = (lpDIS->itemState&~ODS_SELECTED)|ODS_HOTLIGHT;
}
if(!(lpDIS->itemState&ODS_HOTLIGHT))
{
colorSel = colorBitmap;
}
colorMenu = colorMenuBar;
}
CBrush m_brSel(colorSel);
CBrush m_brBitmap(colorBitmap);
CRect RectIcon(lpDIS->rcItem);
CRect RectText(lpDIS->rcItem);
CRect RectSel(lpDIS->rcItem);
if(bIsMenuBar)
{
RectText.InflateRect (0,0,0,0);
if(lpDIS->itemState&ODS_DRAW_VERTICAL)
RectSel.InflateRect (0,0,0, -4);
else
RectSel.InflateRect (0,0,-2 -2,0);
}
else
{
if(nFlags&MFT_RIGHTORDER)
{
RectIcon.left = RectIcon.right - (m_iconX + 8);
RectText.right = RectIcon.left;
}
else
{
RectIcon.right = RectIcon.left + m_iconX + 8;
RectText.left = RectIcon.right;
}
// Draw for Bitmapbackground
pDC->FillSolidRect (RectIcon,colorBitmap);
}
// Draw for Textbackground
pDC->FillSolidRect (RectText,colorMenu);
// Spacing for submenu only in popups
if(!bIsMenuBar)
{
if(nFlags&MFT_RIGHTORDER)
{
RectText.left += 15;
RectText.right -= 4;
}
else
{
RectText.left += 4;
RectText.right -= 15;
}
}
// Flag for highlighted item
if(lpDIS->itemState & (ODS_HOTLIGHT|ODS_INACTIVE) )
{
lpDIS->itemState |= ODS_SELECTED;
}
if(bIsMenuBar && (lpDIS->itemState&ODS_SELECTED) )
{
if(!(lpDIS->itemState&ODS_INACTIVE) )
{
SetLastMenuRect(lpDIS->hDC,RectSel);
if(!(lpDIS->itemState&ODS_HOTLIGHT) )
{
// Create a new pen for the special color
Pen.DeleteObject();
colorBorder = bHighContrast?GetSysColor(COLOR_BTNTEXT):DarkenColor(128,GetMenuBarColor());
Pen.CreatePen(PS_SOLID,0,colorBorder);
int X,Y;
CRect rect = RectText;
int winH = rect.Height();
// Simulate a shadow on right edge...
if (NumScreenColors() <= 256)
{
DWORD clr = GetSysColor(COLOR_BTNSHADOW);
if(lpDIS->itemState&ODS_DRAW_VERTICAL)
{
int winW = rect.Width();
for (Y=0; Y<=1 ;Y++)
{
for (X=4; X<=(winW-1) ;X++)
{
pDC->SetPixel(rect.left+X,rect.bottom-Y,clr);
}
}
}
else
{
for (X=3; X<=4 ;X++)
{
for (Y=4; Y<=(winH-1) ;Y++)
{
pDC->SetPixel(rect.right - X, Y+rect.top, clr );
}
}
}
}
else
{
if(lpDIS->itemState&ODS_DRAW_VERTICAL)
{
int winW = rect.Width();
COLORREF barColor = pDC->GetPixel(rect.left+4,rect.bottom-4);
for (Y=1; Y<=4 ;Y++)
{
for (X=0; X<4 ;X++)
{
if(barColor==CLR_INVALID)
{
barColor = pDC->GetPixel(rect.left+X,rect.bottom-Y);
}
pDC->SetPixel(rect.left+X,rect.bottom-Y,colorMenuBar);
}
for (X=4; X<8 ;X++)
{
pDC->SetPixel(rect.left+X,rect.bottom-Y,DarkenColor(2* 3 * Y * (X - 3), colorMenuBar));
}
for (X=8; X<=(winW-1) ;X++)
{
pDC->SetPixel(rect.left+X,rect.bottom-Y, DarkenColor(2*15 * Y, colorMenuBar) );
}
}
}
else
{
for (X=1; X<=4 ;X++)
{
for (Y=0; Y<4 ;Y++)
{
pDC->SetPixel(rect.right-X,Y+rect.top, colorMenuBar );
}
for (Y=4; Y<8 ;Y++)
{
pDC->SetPixel(rect.right-X,Y+rect.top,DarkenColor(2* 3 * X * (Y - 3), colorMenuBar));
}
for (Y=8; Y<=(winH-1) ;Y++)
{
pDC->SetPixel(rect.right - X, Y+rect.top, DarkenColor(2*15 * X, colorMenuBar) );
}
}
}
}
}
}
}
// For keyboard navigation only
BOOL bDrawSmallSelection = FALSE;
// remove the selected bit if it's grayed out
if( (lpDIS->itemState&ODS_GRAYED) && !m_bSelectDisable)
{
if( lpDIS->itemState & ODS_SELECTED )
{
lpDIS->itemState = lpDIS->itemState & (~ODS_SELECTED);
DWORD MsgPos = ::GetMessagePos();
if( MsgPos==CNewMenuHook::m_dwMsgPos )
{
bDrawSmallSelection = TRUE;
}
else
{
CNewMenuHook::m_dwMsgPos = MsgPos;
}
}
}
// Draw the seperator
if( nFlags & MF_SEPARATOR )
{
if( pMenuData->m_nTitleFlags&MFT_TITLE )
{
DrawTitle(lpDIS,bIsMenuBar);
}
else
{
// Draw only the seperator
CRect rect;
rect.top = RectText.CenterPoint().y;
rect.bottom = rect.top+1;
if(nFlags&MFT_RIGHTORDER)
{
rect.right = RectText.right;
rect.left = lpDIS->rcItem.left;
}
else
{
rect.right = lpDIS->rcItem.right;
rect.left = RectText.left;
}
pDC->FillSolidRect(rect,GetSysColor(COLOR_GRAYTEXT));
}
}
else
{
if( (lpDIS->itemState & ODS_SELECTED) && !(lpDIS->itemState&ODS_INACTIVE) )
{
pDC->FillSolidRect(RectSel,colorSel);
// Draw the selection
CPen* pOldPen = pDC->SelectObject(&Pen);
CBrush* pOldBrush = (CBrush*)pDC->SelectStockObject(HOLLOW_BRUSH);
pDC->Rectangle(RectSel);
pDC->SelectObject(pOldBrush);
pDC->SelectObject(pOldPen);
}
else if (bDrawSmallSelection)
{
pDC->FillSolidRect(RectSel,colorMenu);
// Draw the selection for keyboardnavigation
CPen* pOldPen = pDC->SelectObject(&Pen);
CBrush* pOldBrush = (CBrush*)pDC->SelectStockObject(HOLLOW_BRUSH);
pDC->Rectangle(RectSel);
pDC->SelectObject(pOldBrush);
pDC->SelectObject(pOldPen);
}
UINT state = lpDIS->itemState;
BOOL standardflag=FALSE;
BOOL selectedflag=FALSE;
BOOL disableflag=FALSE;
BOOL checkflag=FALSE;
CString strText = pMenuData->GetString(m_bDrawAccelerators ? m_hAccelToDraw : NULL);
if( (state&ODS_CHECKED) && (pMenuData->m_nMenuIconOffset<0) )
{
if(state&ODS_SELECTED && m_selectcheck>0)
{
checkflag=TRUE;
}
else if(m_unselectcheck>0)
{
checkflag=TRUE;
}
}
else if(pMenuData->m_nMenuIconOffset != -1)
{
standardflag=TRUE;
if(state&ODS_SELECTED)
{
selectedflag=TRUE;
}
else if(state&ODS_GRAYED)
{
disableflag=TRUE;
}
}
// draw the menutext
if(!strText.IsEmpty())
{
LOGFONT logFontMenu;
CFont fontMenu;
#ifdef _NEW_MENU_USER_FONT
logFontMenu = MENU_USER_FONT;
#else
NONCLIENTMETRICS nm = {0};
nm.cbSize = sizeof (nm);
VERIFY (SystemParametersInfo(SPI_GETNONCLIENTMETRICS,nm.cbSize,&nm,0));
logFontMenu = nm.lfMenuFont;
#endif
// Default selection?
if(state&ODS_DEFAULT)
{
// Make the font bold
logFontMenu.lfWeight = FW_BOLD;
}
if(state&ODS_DRAW_VERTICAL)
{
// rotate font 90?
logFontMenu.lfOrientation = -900;
logFontMenu.lfEscapement = -900;
}
fontMenu.CreateFontIndirect(&logFontMenu);
CString leftStr;
CString rightStr;
leftStr.Empty();
rightStr.Empty();
int tablocr=strText.ReverseFind(_T('\t'));
if(tablocr!=-1)
{
rightStr=strText.Mid(tablocr+1);
leftStr=strText.Left(strText.Find(_T('\t')));
}
else
{
leftStr = strText;
}
// Draw the text in the correct color:
UINT nFormat = DT_LEFT| DT_SINGLELINE|DT_VCENTER;
UINT nFormatr = DT_RIGHT|DT_SINGLELINE|DT_VCENTER;
if(nFlags&MFT_RIGHTORDER)
{
nFormat = DT_RIGHT| DT_SINGLELINE|DT_VCENTER|DT_RTLREADING;
nFormatr = DT_LEFT|DT_SINGLELINE|DT_VCENTER;
}
int iOldMode = pDC->SetBkMode( TRANSPARENT);
CFont* pOldFont = pDC->SelectObject (&fontMenu);
COLORREF OldTextColor;
if( (lpDIS->itemState&ODS_GRAYED) ||
(bIsMenuBar && lpDIS->itemState&ODS_INACTIVE) )
{
// Draw the text disabled?
OldTextColor = pDC->SetTextColor(GetSysColor(COLOR_GRAYTEXT));
}
else
{
// Draw the text normal
if( bHighContrast && !bIsMenuBar && !(state&ODS_SELECTED) )
{
OldTextColor = pDC->SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
}
else
{
OldTextColor = pDC->SetTextColor(GetSysColor(COLOR_MENUTEXT));
}
}
UINT dt_Hide = (lpDIS->itemState & ODS_NOACCEL)?DT_HIDEPREFIX:0;
if(dt_Hide && g_Shell>=Win2000)
{
BOOL bMenuUnderlines = TRUE;
if(SystemParametersInfo( SPI_GETKEYBOARDCUES,0,&bMenuUnderlines,0)==TRUE && bMenuUnderlines==TRUE)
{
// do not hide
dt_Hide = 0;
}
}
if(bIsMenuBar)
{
MenuDrawText(pDC->m_hDC,leftStr,-1,RectSel, DT_SINGLELINE|DT_VCENTER|DT_CENTER|dt_Hide);
}
else
{
pDC->DrawText(leftStr,RectText, nFormat|dt_Hide);
if(tablocr!=-1)
{
pDC->DrawText (rightStr,RectText,nFormatr|dt_Hide);
}
}
pDC->SetTextColor(OldTextColor);
pDC->SelectObject(pOldFont);
pDC->SetBkMode(iOldMode);
}
// Draw the bitmap or checkmarks
if(!bIsMenuBar)
{
CRect rect2 = RectText;
if(checkflag||standardflag||selectedflag||disableflag)
{
if(checkflag && m_checkmaps)
{
CPoint ptImage(RectIcon.left+3,RectIcon.top+4);
if(state&ODS_SELECTED)
{
m_checkmaps->Draw(pDC,1,ptImage,ILD_TRANSPARENT);
}
else
{
m_checkmaps->Draw(pDC,0,ptImage,ILD_TRANSPARENT);
}
}
else
{
CSize size = pMenuData->m_pMenuIcon->GetIconSize();
HICON hDrawIcon = pMenuData->m_pMenuIcon->m_IconsList.ExtractIcon(pMenuData->m_nMenuIconOffset);
//CPoint ptImage(RectIcon.left+3,RectIcon.top+ 4);
CPoint ptImage( RectIcon.left+3, RectIcon.top + ((RectIcon.Height()-size.cy)>>1) );
// Need to draw the checked state
if (state&ODS_CHECKED)
{
CRect rect = RectIcon;
if(nFlags&MFT_RIGHTORDER)
{
rect.InflateRect (-2,-1,-1,-1);
}
else
{
rect.InflateRect (-1,-1,-2,-1);
}
if(selectedflag)
{
if (NumScreenColors() > 256)
{
pDC->FillSolidRect(rect,MixedColor(colorSel,GetSysColor(COLOR_HIGHLIGHT)));
}
else
{
pDC->FillSolidRect(rect,colorSel); //GetSysColor(COLOR_HIGHLIGHT)
}
}
else
{
pDC->FillSolidRect(rect,MixedColor(colorBitmap,GetSysColor(COLOR_HIGHLIGHT)));
}
CPen* pOldPen = pDC->SelectObject(&Pen);
CBrush* pOldBrush = (CBrush*)pDC->SelectStockObject(HOLLOW_BRUSH);
pDC->Rectangle(rect);
pDC->SelectObject(pOldBrush);
pDC->SelectObject(pOldPen);
}
// Correcting of a smaler icon
if(size.cx<m_iconX)
{
ptImage.x += (m_iconX-size.cx)>>1;
}
if(state & ODS_DISABLED)
{
if(m_bEnableXpBlending)
{
// draws the icon blended
HICON hDrawIcon2 = pMenuData->m_pMenuIcon->m_IconsList.ExtractIcon(pMenuData->m_nMenuIconOffset+2);
pDC->DrawState(ptImage, size, hDrawIcon2, DSS_NORMAL,(HBRUSH)NULL);
DestroyIcon(hDrawIcon2);
}
else
{
CBrush Brush;
Brush.CreateSolidBrush(pDC->GetNearestColor(DarkenColor(70,colorBitmap)));
pDC->DrawState(ptImage, size, hDrawIcon, DSS_MONO, &Brush);
}
}
else
{
if(selectedflag)
{
CBrush Brush;
// Color of the shade
Brush.CreateSolidBrush(pDC->GetNearestColor(DarkenColorXP(colorSel)));
if(!(state & ODS_CHECKED))
{
ptImage.x++; ptImage.y++;
pDC->DrawState(ptImage, size, hDrawIcon, DSS_NORMAL | DSS_MONO, &Brush);
ptImage.x-=2; ptImage.y-=2;
}
pDC->DrawState(ptImage, size, hDrawIcon, DSS_NORMAL,(HBRUSH)NULL);
}
else
{
if(m_bEnableXpBlending)
{
// draws the icon blended
HICON hDrawIcon2 = pMenuData->m_pMenuIcon->m_IconsList.ExtractIcon(pMenuData->m_nMenuIconOffset+1);
pDC->DrawState(ptImage, size, hDrawIcon2, DSS_NORMAL,(HBRUSH)NULL);
DestroyIcon(hDrawIcon2);
}
else
{
// draws the icon with normal color
pDC->DrawState(ptImage, size, hDrawIcon, DSS_NORMAL,(HBRUSH)NULL);
}
}
}
DestroyIcon(hDrawIcon);
}
}
if(pMenuData->m_nMenuIconOffset<0 /*&& state&ODS_CHECKED */ && !checkflag)
{
MENUITEMINFO info = {0};
info.cbSize = sizeof(info);
info.fMask = MIIM_CHECKMARKS;
::GetMenuItemInfo(HWndToHMenu(lpDIS->hwndItem),lpDIS->itemID,MF_BYCOMMAND, &info);
if(state&ODS_CHECKED || info.hbmpUnchecked)
{
CRect rect = RectIcon;
if(nFlags&MFT_RIGHTORDER)
{
rect.InflateRect (-2,-1,-1,-1);
}
else
{
rect.InflateRect (-1,-1,-2,-1);
}
// draw the color behind checkmarks
if(state&ODS_SELECTED)
{
if (NumScreenColors() > 256)
{
pDC->FillSolidRect(rect,MixedColor(colorSel,GetSysColor(COLOR_HIGHLIGHT)));
}
else
{
pDC->FillSolidRect(rect,colorSel);
}
}
else
{
pDC->FillSolidRect(rect,MixedColor(colorBitmap,GetSysColor(COLOR_HIGHLIGHT)));
}
CPen* pOldPen = pDC->SelectObject(&Pen);
CBrush* pOldBrush = (CBrush*)pDC->SelectStockObject(HOLLOW_BRUSH);
pDC->Rectangle(rect);
pDC->SelectObject(pOldBrush);
pDC->SelectObject(pOldPen);
if (state&ODS_CHECKED)
{
CRect rect(RectIcon);
rect.InflateRect(2,((m_iconY-RectIcon.Height())>>1)+2);
if (!info.hbmpChecked)
{ // Checkmark
DrawSpecialCharStyle(pDC,rect,98,state);
}
else if(!info.hbmpUnchecked)
{ // Bullet
DrawSpecialCharStyle(pDC,rect,105,state);
}
else
{ // Draw Bitmap
BITMAP myInfo = {0};
GetObject((HGDIOBJ)info.hbmpChecked,sizeof(myInfo),&myInfo);
CPoint Offset = RectIcon.TopLeft() + CPoint((RectIcon.Width()-myInfo.bmWidth)/2,(RectIcon.Height()-myInfo.bmHeight)/2);
pDC->DrawState(Offset,CSize(0,0),info.hbmpChecked,DST_BITMAP|DSS_MONO);
}
}
else if(info.hbmpUnchecked)
{
// Draw Bitmap
BITMAP myInfo = {0};
GetObject((HGDIOBJ)info.hbmpUnchecked,sizeof(myInfo),&myInfo);
CPoint Offset = RectIcon.TopLeft() + CPoint((RectIcon.Width()-myInfo.bmWidth)/2,(RectIcon.Height()-myInfo.bmHeight)/2);
if(state & ODS_DISABLED)
{
pDC->DrawState(Offset,CSize(0,0),info.hbmpUnchecked,DST_BITMAP|DSS_MONO|DSS_DISABLED);
}
else
{
pDC->DrawState(Offset,CSize(0,0),info.hbmpUnchecked,DST_BITMAP|DSS_MONO);
}
}
}
else if ((lpDIS->itemID&0xffff)>=SC_SIZE && (lpDIS->itemID&0xffff)<=SC_HOTKEY )
{
DrawSpecial_WinXP(pDC,RectIcon,lpDIS->itemID,state);
}
}
}
}
}
void CNewMenu::DrawItem_XP_2003(LPDRAWITEMSTRUCT lpDIS, BOOL bIsMenuBar)
{
#ifdef _TRACE_MENU_
AfxTrace(_T("BarState: 0x%lX MenuID 0x%lX\n"),lpDIS->itemState,lpDIS->itemID);
#endif
ASSERT(lpDIS != NULL);
CNewMenuItemData* pMenuData = (CNewMenuItemData*)(lpDIS->itemData);
ASSERT(pMenuData);
UINT nFlags = pMenuData->m_nFlags;
CNewMemDC memDC(&lpDIS->rcItem,lpDIS->hDC);
CDC* pDC;
if( bIsMenuBar || (nFlags&MF_SEPARATOR) )
{ // For title and menubardrawing disable memory painting
memDC.DoCancel();
pDC = CDC::FromHandle(lpDIS->hDC);
}
else
{
pDC = &memDC;
}
COLORREF colorWindow = DarkenColor(10,GetSysColor(COLOR_WINDOW));
COLORREF colorMenuBar = bIsMenuBar?GetMenuBarColor():GetMenuColor();
COLORREF colorMenu = MixedColor(colorWindow,colorMenuBar);
COLORREF colorBitmap = MixedColor(GetMenuBarColor(),colorWindow);
COLORREF colorSel = GetXpHighlightColor();
COLORREF colorBorder = GetSysColor(COLOR_HIGHLIGHT);//DarkenColor(128,colorMenuBar);
//COLORREF colorCaption = GetSysColor(COLOR_ACTIVECAPTION); //RGB(0,84,227);
//COLORREF cc1 = MixedColor(colorWindow,colorCaption);
//COLORREF cc2 = MidColor(colorWindow,colorCaption);
COLORREF colorCheck = RGB(255,192,111);
COLORREF colorCheckSel = RGB(254,128,62);
colorSel = RGB(255,238,194);
if(!IsMenuThemeActive() &&
GetMenuDrawMode()!=STYLE_COLORFUL_NOBORDER &&
GetMenuDrawMode()!=STYLE_COLORFUL)
{
colorSel = GetXpHighlightColor();
//colorCheck = pDC->GetNearestColor(DarkenColorXP(colorSel));
colorCheckSel = MixedColor(colorSel,GetSysColor(COLOR_HIGHLIGHT));
colorCheck = colorCheckSel;
}
colorBitmap = colorMenuBar = GetMenuBarColor2003();
if(bHighContrast)
{
colorBorder = GetSysColor(COLOR_BTNTEXT);
}
// Better contrast when you have less than 256 colors
if(pDC->GetNearestColor(colorMenu)==pDC->GetNearestColor(colorBitmap))
{
colorMenu = colorWindow;
colorBitmap = colorMenuBar;
}
CPen Pen(PS_SOLID,0,colorBorder);
if(bIsMenuBar)
{
if(!IsMenu(UIntToHMenu(lpDIS->itemID)) && (lpDIS->itemState&ODS_SELECTED_OPEN))
{
lpDIS->itemState = (lpDIS->itemState&~(ODS_SELECTED|ODS_SELECTED_OPEN))|ODS_HOTLIGHT;
}
else if( !(lpDIS->itemState&ODS_SELECTED_OPEN) && !m_dwOpenMenu && lpDIS->itemState&ODS_SELECTED)
{
lpDIS->itemState = (lpDIS->itemState&~ODS_SELECTED)|ODS_HOTLIGHT;
}
if(!(lpDIS->itemState&ODS_HOTLIGHT))
{
colorSel = colorBitmap;
}
colorMenu = colorMenuBar;
}
CBrush m_brSel(colorSel);
CBrush m_brBitmap(colorBitmap);
CRect RectIcon(lpDIS->rcItem);
CRect RectText(lpDIS->rcItem);
CRect RectSel(lpDIS->rcItem);
if(bIsMenuBar)
{
RectText.InflateRect (0,0,0,0);
if(lpDIS->itemState&ODS_DRAW_VERTICAL)
{
RectSel.InflateRect (0,0,0, -4);
}
else
{
RectSel.InflateRect (0,0,-4,0);
}
if(lpDIS->itemState&ODS_SELECTED)
{
if(lpDIS->itemState&ODS_DRAW_VERTICAL)
RectText.bottom -=4;
else
RectText.right -=4;
if(NumScreenColors() <= 256)
{
pDC->FillSolidRect(RectText,colorMenu);
}
else
{
DrawGradient(pDC,RectText,colorMenu,colorBitmap,FALSE,TRUE);
}
if(lpDIS->itemState&ODS_DRAW_VERTICAL)
{
RectText.bottom +=4;
}
else
{
RectText.right +=4;
}
}
else
{
MENUINFO menuInfo = {0};
menuInfo.cbSize = sizeof(menuInfo);
menuInfo.fMask = MIM_BACKGROUND;
if(::GetMenuInfo(m_hMenu,&menuInfo) && menuInfo.hbrBack)
{
CBrush *pBrush = CBrush::FromHandle(menuInfo.hbrBack);
CPoint brushOrg(0,0);
// new support for menubar
CControlBar* pControlBar = DYNAMIC_DOWNCAST(CControlBar,pDC->GetWindow());
if(pControlBar)
{
CFrameWnd* pFrame = pControlBar->GetParentFrame();
if(pFrame)
{
CRect windowRect;
pFrame->GetWindowRect(windowRect);
pControlBar->ScreenToClient(windowRect);
brushOrg = windowRect.TopLeft();
}
}
VERIFY(pBrush->UnrealizeObject());
CPoint oldOrg = pDC->SetBrushOrg(brushOrg);
pDC->FillRect(RectText,pBrush);
pDC->SetBrushOrg(oldOrg);
}
else
{
pDC->FillSolidRect(RectText,colorMenu);
}
}
}
else
{
if(nFlags&MFT_RIGHTORDER)
{
RectIcon.left = RectIcon.right - (m_iconX + 8);
RectText.right= RectIcon.left;
// Draw for Bitmapbackground
DrawGradient(pDC,RectIcon,colorBitmap,colorMenu,TRUE);
}
else
{
RectIcon.right = RectIcon.left + m_iconX + 8;
RectText.left = RectIcon.right;
// Draw for Bitmapbackground
DrawGradient(pDC,RectIcon,colorMenu,colorBitmap,TRUE);
}
// Draw for Textbackground
pDC->FillSolidRect(RectText,colorMenu);
}
// Spacing for submenu only in popups
if(!bIsMenuBar)
{
if(nFlags&MFT_RIGHTORDER)
{
RectText.left += 15;
RectText.right -= 4;
}
else
{
RectText.left += 4;
RectText.right -= 15;
}
}
// Flag for highlighted item
if(lpDIS->itemState & (ODS_HOTLIGHT|ODS_INACTIVE) )
{
lpDIS->itemState |= ODS_SELECTED;
}
if(bIsMenuBar && (lpDIS->itemState&ODS_SELECTED) )
{
if(!(lpDIS->itemState&ODS_INACTIVE) )
{
SetLastMenuRect(lpDIS->hDC,RectSel);
if(!(lpDIS->itemState&ODS_HOTLIGHT) )
{
// Create a new pen for the special color
Pen.DeleteObject();
colorBorder = bHighContrast?GetSysColor(COLOR_BTNTEXT):DarkenColor(128,GetMenuBarColor());
Pen.CreatePen(PS_SOLID,0,colorBorder);
int X,Y;
CRect rect = RectText;
int winH = rect.Height();
// Simulate a shadow on right edge...
if (NumScreenColors() <= 256)
{
DWORD clr = GetSysColor(COLOR_BTNSHADOW);
if(lpDIS->itemState&ODS_DRAW_VERTICAL)
{
int winW = rect.Width();
for (Y=0; Y<=1 ;Y++)
{
for (X=4; X<=(winW-1) ;X++)
{
pDC->SetPixel(rect.left+X,rect.bottom-Y,clr);
}
}
}
else
{
for (X=3; X<=4 ;X++)
{
for (Y=4; Y<=(winH-1) ;Y++)
{
pDC->SetPixel(rect.right - X, Y + rect.top, clr );
}
}
}
}
else
{
if(lpDIS->itemState&ODS_DRAW_VERTICAL)
{
int winW = rect.Width();
COLORREF barColor = pDC->GetPixel(rect.left+4,rect.bottom-4);
for (Y=1; Y<=4 ;Y++)
{
for (X=0; X<4 ;X++)
{
if(barColor==CLR_INVALID)
{
barColor = pDC->GetPixel(rect.left+X,rect.bottom-Y);
}
pDC->SetPixel(rect.left+X,rect.bottom-Y,barColor);
}
for (X=4; X<8 ;X++)
{
pDC->SetPixel(rect.left+X,rect.bottom-Y,DarkenColor(2* 3 * Y * (X - 3), barColor));
}
for (X=8; X<=(winW-1) ;X++)
{
pDC->SetPixel(rect.left+X,rect.bottom-Y, DarkenColor(2*15 * Y, barColor) );
}
}
}
else
{
COLORREF barColor = pDC->GetPixel(rect.right-1,rect.top);
for (X=1; X<=4 ;X++)
{
for (Y=0; Y<4 ;Y++)
{
if(barColor==CLR_INVALID)
{
barColor = pDC->GetPixel(rect.right-X,Y+rect.top);
}
pDC->SetPixel(rect.right-X,Y+rect.top, barColor );
}
for (Y=4; Y<8 ;Y++)
{
pDC->SetPixel(rect.right-X,Y+rect.top,DarkenColor(2* 3 * X * (Y - 3), barColor));
}
for (Y=8; Y<=(winH-1) ;Y++)
{
pDC->SetPixel(rect.right - X, Y+rect.top, DarkenColor(2*15 * X, barColor) );
}
}
}
}
}
}
}
// For keyboard navigation only
BOOL bDrawSmallSelection = FALSE;
// remove the selected bit if it's grayed out
if( (lpDIS->itemState&ODS_GRAYED) && !m_bSelectDisable)
{
if( lpDIS->itemState & ODS_SELECTED )
{
lpDIS->itemState = lpDIS->itemState & (~ODS_SELECTED);
DWORD MsgPos = ::GetMessagePos();
if( MsgPos==CNewMenuHook::m_dwMsgPos )
{
bDrawSmallSelection = TRUE;
}
else
{
CNewMenuHook::m_dwMsgPos = MsgPos;
}
}
}
// Draw the seperator
if( nFlags & MFT_SEPARATOR )
{
if( pMenuData->m_nTitleFlags&MFT_TITLE )
{
DrawTitle(lpDIS,bIsMenuBar);
}
else
{
// Draw only the seperator
CRect rect;
rect.top = RectText.CenterPoint().y;
rect.bottom = rect.top+1;
if(nFlags&MFT_RIGHTORDER)
{
rect.right = RectText.right;
rect.left = lpDIS->rcItem.left;
}
else
{
rect.right = lpDIS->rcItem.right;
rect.left = RectText.left;
}
pDC->FillSolidRect(rect,GetSysColor(COLOR_GRAYTEXT));
}
}
else
{
if( (lpDIS->itemState & ODS_SELECTED) && !(lpDIS->itemState&ODS_INACTIVE) )
{
if(bIsMenuBar)
{
if(NumScreenColors() <= 256)
{
pDC->FillSolidRect(RectSel,colorWindow);
}
else
{
DrawGradient(pDC,RectSel,colorWindow,colorSel,FALSE,TRUE);
}
}
else
{
pDC->FillSolidRect(RectSel,colorSel);
}
// Draw the selection
CPen* pOldPen = pDC->SelectObject(&Pen);
CBrush* pOldBrush = (CBrush*)pDC->SelectStockObject(HOLLOW_BRUSH);
pDC->Rectangle(RectSel);
pDC->SelectObject(pOldBrush);
pDC->SelectObject(pOldPen);
}
else if (bDrawSmallSelection)
{
pDC->FillSolidRect(RectSel,colorMenu);
// Draw the selection for keyboardnavigation
CPen* pOldPen = pDC->SelectObject(&Pen);
CBrush* pOldBrush = (CBrush*)pDC->SelectStockObject(HOLLOW_BRUSH);
pDC->Rectangle(RectSel);
pDC->SelectObject(pOldBrush);
pDC->SelectObject(pOldPen);
}
UINT state = lpDIS->itemState;
BOOL standardflag=FALSE;
BOOL selectedflag=FALSE;
BOOL disableflag=FALSE;
BOOL checkflag=FALSE;
CString strText = pMenuData->GetString(m_bDrawAccelerators ? m_hAccelToDraw : NULL);
if( (state&ODS_CHECKED) && (pMenuData->m_nMenuIconOffset<0) )
{
if(state&ODS_SELECTED && m_selectcheck>0)
{
checkflag=TRUE;
}
else if(m_unselectcheck>0)
{
checkflag=TRUE;
}
}
else if(pMenuData->m_nMenuIconOffset != -1)
{
standardflag = TRUE;
if(state&ODS_SELECTED)
{
selectedflag=TRUE;
}
else if(state&ODS_GRAYED)
{
disableflag=TRUE;
}
}
if(!strText.IsEmpty())
{ // draw the menutext
LOGFONT logFontMenu;
CFont fontMenu;
#ifdef _NEW_MENU_USER_FONT
logFontMenu = MENU_USER_FONT;
#else
NONCLIENTMETRICS nm = {0};
nm.cbSize = sizeof (nm);
VERIFY (SystemParametersInfo(SPI_GETNONCLIENTMETRICS,nm.cbSize,&nm,0));
logFontMenu = nm.lfMenuFont;
#endif
// Default selection?
if(state&ODS_DEFAULT)
{
// Make the font bold
logFontMenu.lfWeight = FW_BOLD;
}
if(state&ODS_DRAW_VERTICAL)
{
// rotate font 90?
logFontMenu.lfOrientation = -900;
logFontMenu.lfEscapement = -900;
}
fontMenu.CreateFontIndirect(&logFontMenu);
CString leftStr;
CString rightStr;
leftStr.Empty();
rightStr.Empty();
int tablocr = strText.ReverseFind(_T('\t'));
if(tablocr!=-1)
{
rightStr = strText.Mid(tablocr+1);
leftStr = strText.Left(strText.Find(_T('\t')));
}
else
{
leftStr=strText;
}
// Draw the text in the correct color:
UINT nFormat = DT_LEFT| DT_SINGLELINE|DT_VCENTER;
UINT nFormatr = DT_RIGHT|DT_SINGLELINE|DT_VCENTER;
if(nFlags&MFT_RIGHTORDER)
{
nFormat = DT_RIGHT| DT_SINGLELINE|DT_VCENTER|DT_RTLREADING;
nFormatr = DT_LEFT|DT_SINGLELINE|DT_VCENTER;
}
int iOldMode = pDC->SetBkMode( TRANSPARENT);
CFont* pOldFont = pDC->SelectObject (&fontMenu);
COLORREF OldTextColor;
if( (lpDIS->itemState&ODS_GRAYED) ||
(bIsMenuBar && lpDIS->itemState&ODS_INACTIVE) )
{
// Draw the text disabled?
if(bIsMenuBar && (NumScreenColors() <= 256) )
{
OldTextColor = pDC->SetTextColor(colorWindow);
}
else
{
OldTextColor = pDC->SetTextColor(GetSysColor(COLOR_GRAYTEXT));
}
}
else
{
// Draw the text normal
if( bHighContrast && !bIsMenuBar && !(state&ODS_SELECTED) )
{
OldTextColor = pDC->SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
}
else
{
OldTextColor = pDC->SetTextColor(GetSysColor(COLOR_MENUTEXT));
}
}
// Office 2003 ignors this settings
UINT dt_Hide = 0;//(lpDIS->itemState & ODS_NOACCEL)?DT_HIDEPREFIX:0;
if(bIsMenuBar)
{
MenuDrawText(pDC->m_hDC,leftStr,-1,RectSel, DT_SINGLELINE|DT_VCENTER|DT_CENTER|dt_Hide);
}
else
{
pDC->DrawText(leftStr,RectText, nFormat|dt_Hide);
if(tablocr!=-1)
{
pDC->DrawText (rightStr,RectText,nFormatr|dt_Hide);
}
}
pDC->SetTextColor(OldTextColor);
pDC->SelectObject(pOldFont);
pDC->SetBkMode(iOldMode);
}
// Draw the bitmap or checkmarks
if(!bIsMenuBar)
{
CRect rect2 = RectText;
if(checkflag||standardflag||selectedflag||disableflag)
{
if(checkflag && m_checkmaps)
{
CPoint ptImage(RectIcon.left+3,RectIcon.top+4);
if(state&ODS_SELECTED)
{
m_checkmaps->Draw(pDC,1,ptImage,ILD_TRANSPARENT);
}
else
{
m_checkmaps->Draw(pDC,0,ptImage,ILD_TRANSPARENT);
}
}
else
{
CSize size = pMenuData->m_pMenuIcon->GetIconSize();
HICON hDrawIcon = pMenuData->m_pMenuIcon->m_IconsList.ExtractIcon(pMenuData->m_nMenuIconOffset);
//CPoint ptImage(RectIcon.left+3,RectIcon.top+ 4);
CPoint ptImage( RectIcon.left+3, RectIcon.top + ((RectIcon.Height()-size.cy)>>1) );
// Need to draw the checked state
if (state&ODS_CHECKED)
{
CRect rect = RectIcon;
if(nFlags&MFT_RIGHTORDER)
{
rect.InflateRect (-2,-1,-1,-1);
}
else
{
rect.InflateRect (-1,-1,-2,-1);
}
if(selectedflag)
{
pDC->FillSolidRect(rect,colorCheckSel);
}
else
{
pDC->FillSolidRect(rect,colorCheck);
}
CPen* pOldPen = pDC->SelectObject(&Pen);
CBrush* pOldBrush = (CBrush*)pDC->SelectStockObject(HOLLOW_BRUSH);
pDC->Rectangle(rect);
pDC->SelectObject(pOldBrush);
pDC->SelectObject(pOldPen);
}
// Correcting of a smaler icon
if(size.cx<m_iconX)
{
ptImage.x += (m_iconX-size.cx)>>1;
}
if(state & ODS_DISABLED)
{
//if(m_bEnableXpBlending)
{
// draws the icon blended
HICON hDrawIcon2 = pMenuData->m_pMenuIcon->m_IconsList.ExtractIcon(pMenuData->m_nMenuIconOffset+2);
pDC->DrawState(ptImage, size, hDrawIcon2, DSS_NORMAL,(HBRUSH)NULL);
DestroyIcon(hDrawIcon2);
}
//else
//{
// CBrush Brush;
// Brush.CreateSolidBrush(pDC->GetNearestColor(DarkenColor(70,colorBitmap)));
// pDC->DrawState(ptImage, size, hDrawIcon, DSS_MONO, &Brush);
//}
}
else
{
if(selectedflag)
{
//if(!(state & ODS_CHECKED))
//{
// CBrush Brush;
// // Color of the shade
// Brush.CreateSolidBrush(pDC->GetNearestColor(DarkenColorXP(colorSel)));
// ptImage.x++; ptImage.y++;
// pDC->DrawState(ptImage, size, hDrawIcon, DSS_NORMAL | DSS_MONO, &Brush);
// ptImage.x-=2; ptImage.y-=2;
//}
pDC->DrawState(ptImage, size, hDrawIcon, DSS_NORMAL,(HBRUSH)NULL);
}
else
{
if(m_bEnableXpBlending)
{
// draws the icon blended
HICON hDrawIcon2 = pMenuData->m_pMenuIcon->m_IconsList.ExtractIcon(pMenuData->m_nMenuIconOffset+1);
pDC->DrawState(ptImage, size, hDrawIcon2, DSS_NORMAL,(HBRUSH)NULL);
DestroyIcon(hDrawIcon2);
}
else
{
// draws the icon with normal color
pDC->DrawState(ptImage, size, hDrawIcon, DSS_NORMAL,(HBRUSH)NULL);
//ImageList_DrawEx(pMenuData->m_pMenuIcon->m_IconsList,pMenuData->m_nMenuIconOffset,pDC->GetSafeHdc(),ptImage.x,ptImage.y,0,0,CLR_DEFAULT,CLR_DEFAULT,ILD_NORMAL);
}
}
}
DestroyIcon(hDrawIcon);
}
}
if(pMenuData->m_nMenuIconOffset<0 /*&& state&ODS_CHECKED */ && !checkflag)
{
MENUITEMINFO info = {0};
info.cbSize = sizeof(info);
info.fMask = MIIM_CHECKMARKS;
::GetMenuItemInfo(HWndToHMenu(lpDIS->hwndItem),lpDIS->itemID,MF_BYCOMMAND, &info);
if(state&ODS_CHECKED || info.hbmpUnchecked)
{
CRect rect = RectIcon;
if(nFlags&MFT_RIGHTORDER)
{
rect.InflateRect (-2,-1,-1,-1);
}
else
{
rect.InflateRect (-1,-1,-2,-1);
}
// draw the color behind checkmarks
if(state&ODS_SELECTED)
{
pDC->FillSolidRect(rect,colorCheckSel);
}
else
{
pDC->FillSolidRect(rect,colorCheck);
}
CPen* pOldPen = pDC->SelectObject(&Pen);
CBrush* pOldBrush = (CBrush*)pDC->SelectStockObject(HOLLOW_BRUSH);
pDC->Rectangle(rect);
pDC->SelectObject(pOldBrush);
pDC->SelectObject(pOldPen);
if (state&ODS_CHECKED)
{
CRect rect(RectIcon);
rect.InflateRect(2,((m_iconY-RectIcon.Height())>>1)+2);
if (!info.hbmpChecked)
{ // Checkmark
DrawSpecialCharStyle(pDC,rect,98,state);
}
else if(!info.hbmpUnchecked)
{ // Bullet
DrawSpecialCharStyle(pDC,rect,105,state);
}
else
{ // Draw Bitmap
BITMAP myInfo = {0};
GetObject((HGDIOBJ)info.hbmpChecked,sizeof(myInfo),&myInfo);
CPoint Offset = RectIcon.TopLeft() + CPoint((RectIcon.Width()-myInfo.bmWidth)/2,(RectIcon.Height()-myInfo.bmHeight)/2);
pDC->DrawState(Offset,CSize(0,0),info.hbmpChecked,DST_BITMAP|DSS_MONO);
}
}
else
{
// Draw Bitmap
BITMAP myInfo = {0};
GetObject((HGDIOBJ)info.hbmpUnchecked,sizeof(myInfo),&myInfo);
CPoint Offset = RectIcon.TopLeft() + CPoint((RectIcon.Width()-myInfo.bmWidth)/2,(RectIcon.Height()-myInfo.bmHeight)/2);
if(state & ODS_DISABLED)
{
pDC->DrawState(Offset,CSize(0,0),info.hbmpUnchecked,DST_BITMAP|DSS_MONO|DSS_DISABLED);
}
else
{
pDC->DrawState(Offset,CSize(0,0),info.hbmpUnchecked,DST_BITMAP|DSS_MONO);
}
}
}
else if ((lpDIS->itemID&0xffff)>=SC_SIZE && (lpDIS->itemID&0xffff)<=SC_HOTKEY )
{
DrawSpecial_WinXP(pDC,RectIcon,lpDIS->itemID,state);
}
}
}
}
}
void CNewMenu::DrawItem_SpecialStyle (LPDRAWITEMSTRUCT lpDIS, BOOL bIsMenuBar)
{
if(!bIsMenuBar)
{
DrawItem_OldStyle(lpDIS,bIsMenuBar);
return;
}
ASSERT(lpDIS != NULL);
//CNewMemDC memDC(&lpDIS->rcItem,lpDIS->hDC);
//CDC* pDC = &memDC;
CDC* pDC = CDC::FromHandle(lpDIS->hDC);
ASSERT(lpDIS->itemData);
CNewMenuItemData* pMenuData = (CNewMenuItemData*)(lpDIS->itemData);
CRect rect(lpDIS->rcItem);
//rect.InflateRect(0,-1);
COLORREF colorBack;
if(lpDIS->itemState&(ODS_SELECTED|ODS_HOTLIGHT))
{
colorBack = GetSysColor(COLOR_HIGHLIGHT);
SetLastMenuRect(lpDIS->hDC,rect);
}
else
{
colorBack = GetMenuBarColor();
}
pDC->FillSolidRect(rect,colorBack);
int iOldMode = pDC->SetBkMode( TRANSPARENT);
CString strText = pMenuData->GetString(m_bDrawAccelerators ? m_hAccelToDraw : NULL);
COLORREF crTextColor;
if(!(lpDIS->itemState & ODS_GRAYED))
{
if(lpDIS->itemState&(ODS_SELECTED|ODS_HOTLIGHT))
{
crTextColor = GetSysColor(COLOR_HIGHLIGHTTEXT);
}
else
{
crTextColor = GetSysColor(COLOR_MENUTEXT);
}
}
else
{
crTextColor = GetSysColor(COLOR_GRAYTEXT);
}
COLORREF oldColor = pDC->SetTextColor(crTextColor);
CFont fontMenu;
LOGFONT logFontMenu;
#ifdef _NEW_MENU_USER_FONT
logFontMenu = MENU_USER_FONT;
#else
NONCLIENTMETRICS nm = {0};
nm.cbSize = sizeof (nm);
VERIFY (SystemParametersInfo(SPI_GETNONCLIENTMETRICS,nm.cbSize,&nm,0));
logFontMenu = nm.lfMenuFont;
#endif
if(lpDIS->itemState&ODS_DRAW_VERTICAL)
{
// rotate font 90?
logFontMenu.lfOrientation = -900;
logFontMenu.lfEscapement = -900;
}
fontMenu.CreateFontIndirect (&logFontMenu);
CFont* pOldFont = pDC->SelectObject(&fontMenu);
UINT dt_Hide = (lpDIS->itemState & ODS_NOACCEL)?DT_HIDEPREFIX:0;
if(dt_Hide && g_Shell>=Win2000)
{
BOOL bMenuUnderlines = TRUE;
if(SystemParametersInfo( SPI_GETKEYBOARDCUES,0,&bMenuUnderlines,0)==TRUE && bMenuUnderlines==TRUE)
{
// do not hide
dt_Hide = 0;
}
}
MenuDrawText(pDC->m_hDC,strText,-1,rect,DT_CENTER|DT_SINGLELINE|DT_VCENTER|dt_Hide);
pDC->SelectObject(pOldFont);
pDC->SetTextColor(oldColor);
pDC->SetBkMode( iOldMode);
}
void CNewMenu::DrawItem_Icy(LPDRAWITEMSTRUCT lpDIS, BOOL bIsMenuBar)
{
ASSERT(lpDIS != NULL);
CRect rect;
ASSERT(lpDIS->itemData);
CNewMenuItemData* pMenuData = (CNewMenuItemData*)(lpDIS->itemData);
UINT nFlags = pMenuData->m_nFlags;
CNewMemDC memDC(&lpDIS->rcItem,lpDIS->hDC);
CDC* pDC;
if( bIsMenuBar || (nFlags&MF_SEPARATOR) )
{ // For title and menubardrawing disable memory painting
memDC.DoCancel();
pDC = CDC::FromHandle(lpDIS->hDC);
}
else
{
pDC = &memDC;
}
COLORREF colorMenu = GetMenuColor();
COLORREF colorBack = bIsMenuBar?GetMenuBarColor():colorMenu;
COLORREF color3DShadow = DarkenColor(60,colorMenu);
COLORREF color3DHilight = LightenColor(60,colorMenu);
COLORREF colorGrayText = DarkenColor(100,colorMenu);//GetSysColor(COLOR_GRAYTEXT);
COLORREF colorHilight = GetSysColor(COLOR_HIGHLIGHT);
COLORREF colorGrayed = bHighContrast?GetSysColor(COLOR_BTNSHADOW):pDC->GetNearestColor(DarkenColor(70,color3DShadow));
if(bHighContrast)
{
color3DShadow = GetSysColor(COLOR_BTNTEXT);
color3DHilight = GetSysColor(COLOR_BTNTEXT);
}
CRect RectIcon(lpDIS->rcItem);
CRect RectText(lpDIS->rcItem);
CRect RectSel(lpDIS->rcItem);
RectIcon.InflateRect (-1,0,0,0);
RectText.InflateRect (-1,0,0,0);
RectSel.InflateRect (0,0,0,0);
if(!bIsMenuBar)
{
if(nFlags&MFT_RIGHTORDER)
{
RectIcon.left = RectIcon.right - (m_iconX + 6 + GAP);
RectText.right = RectIcon.left;
}
else
{
RectIcon.right = RectIcon.left + m_iconX + 6 + GAP;
RectText.left = RectIcon.right;
}
}
else
{
RectText.right += 6;
RectSel.InflateRect(0,0,-1,-1);
RectText.InflateRect (1,-2,0,0);
if(!IsMenu(UIntToHMenu(lpDIS->itemID)) && (lpDIS->itemState&ODS_SELECTED_OPEN))
{
lpDIS->itemState = (lpDIS->itemState&~(ODS_SELECTED|ODS_SELECTED_OPEN))|ODS_HOTLIGHT;
}
else if(!(lpDIS->itemState&ODS_SELECTED_OPEN) && !m_dwOpenMenu && lpDIS->itemState&ODS_SELECTED)
{
lpDIS->itemState = (lpDIS->itemState&~ODS_SELECTED)|ODS_HOTLIGHT;
}
if(lpDIS->itemState&(ODS_SELECTED|ODS_HOTLIGHT))
{
SetLastMenuRect(lpDIS->hDC,RectSel);
}
}
// For keyboard navigation only
BOOL bDrawSmallSelection = FALSE;
// remove the selected bit if it's grayed out
if( (lpDIS->itemState&ODS_GRAYED) && !m_bSelectDisable )
{
if(lpDIS->itemState & ODS_SELECTED)
{
lpDIS->itemState &= ~ODS_SELECTED;
DWORD MsgPos = ::GetMessagePos();
if(MsgPos==CNewMenuHook::m_dwMsgPos)
{
bDrawSmallSelection = TRUE;
}
else
{
CNewMenuHook::m_dwMsgPos = MsgPos;
}
}
}
if(nFlags & MF_SEPARATOR)
{
if(pMenuData->m_nTitleFlags&MFT_TITLE)
{
DrawTitle(lpDIS,bIsMenuBar);
}
else
{
rect = lpDIS->rcItem;
//pDC->FillSolidRect(rect,colorBack);
pDC->FillSolidRect(rect,color3DHilight);
rect.left += 1;
rect.right -= 1;
pDC->DrawEdge(&rect,EDGE_ETCHED,BF_TOP);
}
}
else
{
CRect rect2;
BOOL standardflag=FALSE,selectedflag=FALSE,disableflag=FALSE;
BOOL checkflag=FALSE;
CBrush m_brSelect;
int nIconNormal=-1;
// set some colors and the font
m_brSelect.CreateSolidBrush(colorHilight);
rect2=rect=RectSel;
// draw the up/down/focused/disabled state
UINT state = lpDIS->itemState;
nIconNormal = pMenuData->m_nMenuIconOffset;
if( (state&ODS_CHECKED) && nIconNormal<0)
{
if(state&ODS_SELECTED && m_selectcheck>0)
{
checkflag = TRUE;
}
else if(m_unselectcheck>0)
{
checkflag = TRUE;
}
}
else if(nIconNormal != -1)
{
standardflag = TRUE;
if(state&ODS_SELECTED && !(state&ODS_GRAYED))
{
selectedflag=TRUE;
}
else if(state&ODS_GRAYED)
{
disableflag=TRUE;
}
}
if(bIsMenuBar)
{
CRect tempRect = rect;
tempRect.InflateRect (0,0,0,1);
rect.OffsetRect(0,1);
rect2=rect;
if( bHighContrast || (state&ODS_INACTIVE) || (!(state&ODS_HOTLIGHT) && !(state&ODS_SELECTED)) )
{
// pDC->FillSolidRect(tempRect,colorBack);
MENUINFO menuInfo = {0};
menuInfo.cbSize = sizeof(menuInfo);
menuInfo.fMask = MIM_BACKGROUND;
if(!bHighContrast && ::GetMenuInfo(m_hMenu,&menuInfo) && menuInfo.hbrBack)
{
CBrush *pBrush = CBrush::FromHandle(menuInfo.hbrBack);
VERIFY(pBrush->UnrealizeObject());
CPoint oldOrg = pDC->SetBrushOrg(0,0);
pDC->FillRect(tempRect,pBrush);
pDC->SetBrushOrg(oldOrg);
}
else
{
pDC->FillSolidRect(tempRect,colorBack);
}
}
else
{
colorBack = GetMenuColor();
DrawGradient(pDC,tempRect,LightenColor(30,colorBack),DarkenColor(30,colorBack),false,true);
}
}
else
{
if(bHighContrast)
{
pDC->FillSolidRect (rect,colorBack);
}
else
{
DrawGradient(pDC,rect,LightenColor(30,colorBack),DarkenColor(30,colorBack),false,true);
}
}
// Draw the selection
if(state&ODS_SELECTED)
{
// You need only Text highlight and that's what you get
if(!bIsMenuBar)
{
if(checkflag||standardflag||selectedflag||disableflag||state&ODS_CHECKED)
{
rect2 = RectText;
}
if(bHighContrast)
{
pDC->FillSolidRect (rect2,colorHilight);
}
else
{
DrawGradient(pDC,rect2,LightenColor(30,colorHilight),DarkenColor(30,colorHilight),false,true);
}
pDC->Draw3dRect(rect2 ,color3DShadow,color3DHilight);
}
else
{
pDC->Draw3dRect(rect2 ,color3DShadow,color3DHilight);
}
}
else if(bIsMenuBar && (state&ODS_HOTLIGHT) && !(state&ODS_INACTIVE))
{
pDC->Draw3dRect(rect,color3DHilight,color3DShadow);
}
else if (bDrawSmallSelection)
{
pDC->DrawFocusRect(rect);
}
// Draw the Bitmap or checkmarks
if(!bIsMenuBar)
{
CRect IconRect = RectIcon;
// center the image
IconRect.InflateRect(-(RectIcon.Width()-m_iconX)>>1,-(RectIcon.Height()-m_iconY)>>1);
CPoint ptImage = IconRect.TopLeft();
IconRect.InflateRect(2,2);
if(checkflag||standardflag||selectedflag||disableflag)
{
if(checkflag && m_checkmaps)
{
if(state&ODS_SELECTED)
{
m_checkmaps->Draw(pDC,1,ptImage,ILD_TRANSPARENT);
}
else
{
m_checkmaps->Draw(pDC,0,ptImage,ILD_TRANSPARENT);
}
}
else
{
// Need to draw the checked state
if (IsNewShell())
{
if(state&ODS_CHECKED)
{
pDC->Draw3dRect(IconRect,color3DShadow,color3DHilight);
}
else if (selectedflag)
{
pDC->Draw3dRect(IconRect,color3DHilight,color3DShadow);
}
}
CSize size = pMenuData->m_pMenuIcon->GetIconSize();
// Correcting of a smaler icon
if(size.cx<m_iconX)
{
ptImage.x += (m_iconX-size.cx)>>1;
}
if(size.cy<m_iconY)
{
ptImage.y += (m_iconY-size.cy)>>1;
}
HICON hDrawIcon = pMenuData->m_pMenuIcon->m_IconsList.ExtractIcon(pMenuData->m_nMenuIconOffset);
if(state & ODS_DISABLED)
{
CBrush Brush;
Brush.CreateSolidBrush(colorGrayed);
pDC->DrawState(ptImage, size, hDrawIcon, DSS_NORMAL | DSS_MONO, (HBRUSH)Brush);
}
else
{
pDC->DrawState(ptImage, size, hDrawIcon, DSS_NORMAL, (HBRUSH)NULL);
}
DestroyIcon(hDrawIcon);
}
}
if ((lpDIS->itemID&0xffff)>=SC_SIZE && (lpDIS->itemID&0xffff)<=SC_HOTKEY )
{
DrawSpecial_OldStyle(pDC,IconRect,lpDIS->itemID,state);
}
else if(nIconNormal<0 /*&& state&ODS_CHECKED */&& !checkflag)
{
MENUITEMINFO info = {0};
info.cbSize = sizeof(info);
info.fMask = MIIM_CHECKMARKS;
::GetMenuItemInfo(HWndToHMenu(lpDIS->hwndItem),lpDIS->itemID,MF_BYCOMMAND, &info);
Draw3DCheckmark(pDC, IconRect,info.hbmpChecked,info.hbmpUnchecked,state);
}
}
CString strText;
strText = pMenuData->GetString(m_bDrawAccelerators ? m_hAccelToDraw : NULL);
if(!strText.IsEmpty())
{
COLORREF crText = GetSysColor(COLOR_MENUTEXT);
if(bIsMenuBar)
{
rect.left += 6;
if(lpDIS->itemState&ODS_INACTIVE)
{
crText = colorGrayText;
}
}
else
{
if(lpDIS->itemState&ODS_SELECTED)
{
crText = GetSysColor(COLOR_HIGHLIGHTTEXT);
}
rect.left += m_iconX + 12;
}
CRect rectt(rect.left,rect.top-1,rect.right,rect.bottom-1);
// Find tabs
CString leftStr,rightStr;
leftStr.Empty();rightStr.Empty();
int tablocr = strText.ReverseFind(_T('\t'));
if(tablocr!=-1)
{
rightStr = strText.Mid(tablocr+1);
leftStr = strText.Left(strText.Find(_T('\t')));
rectt.right -= m_iconX;
}
else
{
leftStr = strText;
}
int iOldMode = pDC->SetBkMode( TRANSPARENT);
// Draw the text in the correct colour:
UINT dt_Hide = (lpDIS->itemState & ODS_NOACCEL)?DT_HIDEPREFIX:0;
if(dt_Hide && g_Shell>=Win2000)
{
BOOL bMenuUnderlines = TRUE;
if(SystemParametersInfo( SPI_GETKEYBOARDCUES,0,&bMenuUnderlines,0)==TRUE && bMenuUnderlines==TRUE)
{
// do not hide
dt_Hide = 0;
}
}
UINT nFormat = DT_LEFT|DT_SINGLELINE|DT_VCENTER|dt_Hide;
UINT nFormatr = DT_RIGHT|DT_SINGLELINE|DT_VCENTER|dt_Hide;
if(nFlags&MFT_RIGHTORDER)
{
nFormat = DT_RIGHT| DT_SINGLELINE|DT_VCENTER|DT_RTLREADING|dt_Hide;
nFormatr = DT_LEFT|DT_SINGLELINE|DT_VCENTER|dt_Hide;
}
if(bIsMenuBar)
{
rectt = RectSel;
rectt.OffsetRect(-1,0);
if(state & ODS_SELECTED)
{
rectt.OffsetRect(1,1);
}
nFormat = DT_CENTER|DT_SINGLELINE|DT_VCENTER|dt_Hide;
}
else
{
if(nFlags&MFT_RIGHTORDER)
{
RectText.left += 15;
RectText.right -= 4;
}
else
{
RectText.left += 4;
RectText.right -= 15;
}
}
CFont fontMenu;
LOGFONT logFontMenu;
#ifdef _NEW_MENU_USER_FONT
logFontMenu = MENU_USER_FONT;
#else
NONCLIENTMETRICS nm = {0};
nm.cbSize = sizeof (nm);
VERIFY (SystemParametersInfo(SPI_GETNONCLIENTMETRICS,nm.cbSize,&nm,0));
logFontMenu = nm.lfMenuFont;
#endif
// Default selection?
if(state&ODS_DEFAULT)
{
// Make the font bold
logFontMenu.lfWeight = FW_BOLD;
}
if(state&ODS_DRAW_VERTICAL)
{
// rotate font 90?
logFontMenu.lfOrientation = -900;
logFontMenu.lfEscapement = -900;
}
fontMenu.CreateFontIndirect (&logFontMenu);
CFont* pOldFont = pDC->SelectObject(&fontMenu);
if(!(lpDIS->itemState & ODS_GRAYED))
{
pDC->SetTextColor(crText);
if(bIsMenuBar)
{
MenuDrawText(pDC->m_hDC,leftStr,-1,RectText,nFormat);
if(tablocr!=-1)
{
MenuDrawText(pDC->m_hDC,rightStr,-1,RectText,nFormatr);
}
}
else
{
pDC->DrawText (leftStr,RectText,nFormat);
if(tablocr!=-1)
{
pDC->DrawText (rightStr,RectText,nFormatr);
}
}
}
else
{
// Draw the disabled text
if(!(state & ODS_SELECTED))
{
CRect offset = RectText;
offset.OffsetRect (1,1);
pDC->SetTextColor(colorGrayed);
pDC->DrawText(leftStr,RectText, nFormat);
if(tablocr!=-1)
{
pDC->DrawText(rightStr,RectText,nFormatr);
}
}
else
{
// And the standard Grey text:
pDC->SetTextColor(colorBack);
pDC->DrawText(leftStr,RectText, nFormat);
if(tablocr!=-1)
{
pDC->DrawText (rightStr,RectText,nFormatr);
}
}
}
pDC->SelectObject(pOldFont);
pDC->SetBkMode( iOldMode );
}
m_brSelect.DeleteObject();
}
}
void CNewMenu::DrawItem_OldStyle (LPDRAWITEMSTRUCT lpDIS, BOOL bIsMenuBar)
{
ASSERT(lpDIS != NULL);
CRect rect;
ASSERT(lpDIS->itemData);
CNewMenuItemData* pMenuData = (CNewMenuItemData*)(lpDIS->itemData);
UINT nFlags = pMenuData->m_nFlags;
CNewMemDC memDC(&lpDIS->rcItem,lpDIS->hDC);
CDC* pDC;
if( bIsMenuBar || (nFlags&MF_SEPARATOR) )
{ // For title and menubardrawing disable memory painting
memDC.DoCancel();
pDC = CDC::FromHandle(lpDIS->hDC);
}
else
{
pDC = &memDC;
}
COLORREF colorBack = bIsMenuBar?GetMenuBarColor():GetSysColor(COLOR_MENU);
CRect RectIcon(lpDIS->rcItem);
CRect RectText(lpDIS->rcItem);
CRect RectSel(lpDIS->rcItem);
RectIcon.InflateRect (-1,0,0,0);
RectText.InflateRect (-1,0,0,0);
RectSel.InflateRect (0,0,0,0);
if(!bIsMenuBar)
{
if(nFlags&MFT_RIGHTORDER)
{
RectIcon.left = RectIcon.right - (m_iconX + 6 + GAP);
RectText.right = RectIcon.left;
}
else
{
RectIcon.right = RectIcon.left + m_iconX + 6 + GAP;
RectText.left = RectIcon.right;
}
}
else
{
RectText.right += 6;
RectText.InflateRect (1,0,0,0);
RectSel.InflateRect (0,0,-2,0);
RectSel.OffsetRect(1,-1);
#ifdef _TRACE_MENU_
// AfxTrace(_T("BarState: 0x%lX Menus %ld\n"),lpDIS->itemState,m_dwOpenMenu);
#endif
if(!IsMenu(UIntToHMenu(lpDIS->itemID)) && (lpDIS->itemState&ODS_SELECTED_OPEN))
{
lpDIS->itemState = (lpDIS->itemState&~(ODS_SELECTED|ODS_SELECTED_OPEN))|ODS_HOTLIGHT;
}
else if( !(lpDIS->itemState&ODS_SELECTED_OPEN) && !m_dwOpenMenu && lpDIS->itemState&ODS_SELECTED)
{
lpDIS->itemState = (lpDIS->itemState&~ODS_SELECTED)|ODS_HOTLIGHT;
}
if(lpDIS->itemState&(ODS_SELECTED|ODS_HOTLIGHT))
{
SetLastMenuRect(lpDIS->hDC,RectSel);
}
}
// For keyboard navigation only
BOOL bDrawSmallSelection = FALSE;
// remove the selected bit if it's grayed out
if( (lpDIS->itemState&ODS_GRAYED) && !m_bSelectDisable )
{
if(lpDIS->itemState & ODS_SELECTED)
{
lpDIS->itemState &= ~ODS_SELECTED;
DWORD MsgPos = ::GetMessagePos();
if(MsgPos==CNewMenuHook::m_dwMsgPos)
{
bDrawSmallSelection = TRUE;
}
else
{
CNewMenuHook::m_dwMsgPos = MsgPos;
}
}
}
if(nFlags & MF_SEPARATOR)
{
if(pMenuData->m_nTitleFlags&MFT_TITLE)
{
DrawTitle(lpDIS,bIsMenuBar);
}
else
{
rect = lpDIS->rcItem;
pDC->FillSolidRect(rect,colorBack);
rect.left += 1;
rect.top += 1;
pDC->DrawEdge(&rect,EDGE_ETCHED,BF_TOP);
}
}
else
{
CRect rect2;
BOOL standardflag=FALSE,selectedflag=FALSE,disableflag=FALSE;
BOOL checkflag=FALSE;
CBrush m_brSelect;
int nIconNormal=-1;
//CImageList *bitmap=NULL;
// set some colors and the font
m_brSelect.CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
// draw the colored rectangle portion
rect2=rect=RectSel;
// draw the up/down/focused/disabled state
UINT state = lpDIS->itemState;
nIconNormal = pMenuData->m_nMenuIconOffset;
if( (state&ODS_CHECKED) && nIconNormal<0)
{
if(state&ODS_SELECTED && m_selectcheck>0)
{
checkflag = TRUE;
}
else if(m_unselectcheck>0)
{
checkflag = TRUE;
}
}
else if(nIconNormal != -1)
{
standardflag=TRUE;
if(state&ODS_SELECTED && !(state&ODS_GRAYED))
{
selectedflag = TRUE;
}
else if(state&ODS_GRAYED)
{
disableflag = TRUE;
}
}
if(bIsMenuBar)
{
//rect.InflateRect (1,0,0,0);
rect.OffsetRect(-1,1);
rect2=rect;
rect.right +=2;
pDC->FillSolidRect (rect,colorBack);
rect.right -=2;
}
else
{
// Draw the background
pDC->FillSolidRect (rect,colorBack);
}
// Draw the selection
if(state&ODS_SELECTED)
{
// You need only Text highlight and that's what you get
if(!bIsMenuBar)
{
if(checkflag||standardflag||selectedflag||disableflag||state&ODS_CHECKED)
{
rect2 = RectText;
}
pDC->FillRect(rect2,&m_brSelect);
}
else
{
pDC->Draw3dRect(rect ,GetSysColor(COLOR_3DSHADOW),GetSysColor(COLOR_3DHILIGHT));
}
}
else if(bIsMenuBar && (state&ODS_HOTLIGHT) && !(state&ODS_INACTIVE))
{
pDC->Draw3dRect(rect,GetSysColor(COLOR_3DHILIGHT),GetSysColor(COLOR_3DSHADOW));
}
else if (bDrawSmallSelection)
{
pDC->DrawFocusRect(rect);
}
// Draw the Bitmap or checkmarks
if(!bIsMenuBar)
{
CRect IconRect = RectIcon;
// center the image
IconRect.InflateRect(-(RectIcon.Width()-m_iconX)>>1,-(RectIcon.Height()-m_iconY)>>1);
CPoint ptImage = IconRect.TopLeft();
IconRect.InflateRect(2,2);
if(checkflag||standardflag||selectedflag||disableflag)
{
if(checkflag && m_checkmaps)
{
if(state&ODS_SELECTED)
{
m_checkmaps->Draw(pDC,1,ptImage,ILD_TRANSPARENT);
}
else
{
m_checkmaps->Draw(pDC,0,ptImage,ILD_TRANSPARENT);
}
}
else
{
// Need to draw the checked state
if (IsNewShell())
{
if(state&ODS_CHECKED)
{
pDC->Draw3dRect(IconRect,GetSysColor(COLOR_3DSHADOW),GetSysColor(COLOR_3DHILIGHT));
}
else if (selectedflag)
{
pDC->Draw3dRect(IconRect,GetSysColor(COLOR_3DHILIGHT),GetSysColor(COLOR_3DSHADOW));
}
}
CSize size = pMenuData->m_pMenuIcon->GetIconSize();
// Correcting of a smaler icon
if(size.cx<m_iconX)
{
ptImage.x += (m_iconX-size.cx)>>1;
}
if(size.cy<m_iconY)
{
ptImage.y += (m_iconY-size.cy)>>1;
}
HICON hDrawIcon = pMenuData->m_pMenuIcon->m_IconsList.ExtractIcon(pMenuData->m_nMenuIconOffset);
if(state & ODS_DISABLED)
{
// Jan-19-2005 - Mark P. Peterson - [email protected] - http://www.RhinoSoft.com/
// opted to use blended disabled icons instead, the default is just too bad to think about using
HICON hDrawIcon2 = pMenuData->m_pMenuIcon->m_IconsList.ExtractIcon(pMenuData->m_nMenuIconOffset+2);
pDC->DrawState(ptImage, size, hDrawIcon2, DSS_NORMAL,(HBRUSH)NULL);
DestroyIcon(hDrawIcon2);
// pDC->DrawState(ptImage, size, hDrawIcon, DSS_DISABLED, (HBRUSH)NULL);
}
else
{
pDC->DrawState(ptImage, size, hDrawIcon, DSS_NORMAL, (HBRUSH)NULL);
}
DestroyIcon(hDrawIcon);
}
}
if ((lpDIS->itemID&0xffff)>=SC_SIZE && (lpDIS->itemID&0xffff)<=SC_HOTKEY )
{
DrawSpecial_OldStyle(pDC,IconRect,lpDIS->itemID,state);
}
else if(nIconNormal<0 /*&& state&ODS_CHECKED */ && !checkflag)
{
MENUITEMINFO info = {0};
info.cbSize = sizeof(info);
info.fMask = MIIM_CHECKMARKS;
::GetMenuItemInfo(HWndToHMenu(lpDIS->hwndItem),lpDIS->itemID,MF_BYCOMMAND, &info);
Draw3DCheckmark(pDC, IconRect,info.hbmpChecked,info.hbmpUnchecked,state);
}
}
CString strText;
strText = pMenuData->GetString(m_bDrawAccelerators ? m_hAccelToDraw : NULL);
if(!strText.IsEmpty())
{
COLORREF crText = GetSysColor(COLOR_MENUTEXT);
if(bIsMenuBar)
{
if(lpDIS->itemState&ODS_INACTIVE)
crText = GetSysColor(COLOR_GRAYTEXT);
}
else
{
if(lpDIS->itemState&ODS_SELECTED)
{
crText = GetSysColor(COLOR_HIGHLIGHTTEXT);
}
}
// Find tabs
CString leftStr,rightStr;
leftStr.Empty();rightStr.Empty();
int tablocr = strText.ReverseFind(_T('\t'));
if(tablocr!=-1)
{
rightStr = strText.Mid(tablocr+1);
leftStr = strText.Left(strText.Find(_T('\t')));
}
else
{
leftStr = strText;
}
int iOldMode = pDC->SetBkMode( TRANSPARENT);
// Draw the text in the correct colour:
UINT dt_Hide = (lpDIS->itemState & ODS_NOACCEL)?DT_HIDEPREFIX:0;
if(dt_Hide && g_Shell>=Win2000)
{
BOOL bMenuUnderlines = TRUE;
if(SystemParametersInfo( SPI_GETKEYBOARDCUES,0,&bMenuUnderlines,0)==TRUE && bMenuUnderlines==TRUE)
{
// do not hide
dt_Hide = 0;
}
}
UINT nFormat = DT_LEFT|DT_SINGLELINE|DT_VCENTER|dt_Hide;
UINT nFormatr = DT_RIGHT|DT_SINGLELINE|DT_VCENTER|dt_Hide;
if(nFlags&MFT_RIGHTORDER)
{
nFormat = DT_RIGHT| DT_SINGLELINE|DT_VCENTER|DT_RTLREADING|dt_Hide;
nFormatr = DT_LEFT|DT_SINGLELINE|DT_VCENTER|dt_Hide;
}
if(bIsMenuBar)
{
if(state & ODS_SELECTED)
{
RectText.OffsetRect(1,1);
}
nFormat = DT_CENTER|DT_SINGLELINE|DT_VCENTER|dt_Hide;
}
else
{
if(nFlags&MFT_RIGHTORDER)
{
RectText.left += 15;
RectText.right -= 4;
}
else
{
RectText.left += 4;
RectText.right -= 15;
}
}
CFont fontMenu;
LOGFONT logFontMenu;
#ifdef _NEW_MENU_USER_FONT
logFontMenu = MENU_USER_FONT;
#else
NONCLIENTMETRICS nm = {0};
nm.cbSize = sizeof (nm);
VERIFY (SystemParametersInfo(SPI_GETNONCLIENTMETRICS,nm.cbSize,&nm,0));
logFontMenu = nm.lfMenuFont;
#endif
// Default selection?
if(state&ODS_DEFAULT)
{
// Make the font bold
logFontMenu.lfWeight = FW_BOLD;
}
if(state&ODS_DRAW_VERTICAL)
{
// rotate font 90?
logFontMenu.lfOrientation = -900;
logFontMenu.lfEscapement = -900;
}
fontMenu.CreateFontIndirect (&logFontMenu);
CFont* pOldFont = pDC->SelectObject(&fontMenu);
if(!(lpDIS->itemState & ODS_GRAYED))
{
pDC->SetTextColor(crText);
if(bIsMenuBar)
{
MenuDrawText(pDC->m_hDC,leftStr,-1,RectText,nFormat);
if(tablocr!=-1)
{
MenuDrawText(pDC->m_hDC,rightStr,-1,RectText,nFormatr);
}
}
else
{
pDC->DrawText (leftStr,RectText,nFormat);
if(tablocr!=-1)
{
pDC->DrawText (rightStr,RectText,nFormatr);
}
}
}
else
{
// Draw the disabled text
if(!(state & ODS_SELECTED))
{
CRect offset = RectText;
offset.OffsetRect (1,1);
pDC->SetTextColor(GetSysColor(COLOR_BTNHILIGHT));
pDC->DrawText(leftStr,&offset, nFormat);
if(tablocr!=-1)
{
pDC->DrawText (rightStr,&offset,nFormatr);
}
pDC->SetTextColor(GetSysColor(COLOR_GRAYTEXT));
pDC->DrawText(leftStr,RectText, nFormat);
if(tablocr!=-1)
{
pDC->DrawText(rightStr,RectText,nFormatr);
}
}
else
{
// And the standard Grey text:
pDC->SetTextColor(colorBack);
pDC->DrawText(leftStr,RectText, nFormat);
if(tablocr!=-1)
{
pDC->DrawText (rightStr,RectText,nFormatr);
}
}
}
pDC->SelectObject(pOldFont);
pDC->SetBkMode( iOldMode );
}
m_brSelect.DeleteObject();
}
}
BOOL CNewMenu::IsMenuBar(HMENU hMenu)
{
BOOL bIsMenuBar = FALSE;
if(!FindMenuItem(HMenuToUInt(hMenu)))
{
if(m_hParentMenu==NULL)
{
return m_bIsPopupMenu?FALSE:TRUE;
}
CNewMenu* pMenu = DYNAMIC_DOWNCAST(CNewMenu,CMenu::FromHandlePermanent(m_hParentMenu));
if (pMenu!=NULL)
{
return pMenu->m_bIsPopupMenu?FALSE:TRUE;
}
}
else
{
// Test for only one item not bar
bIsMenuBar = m_hParentMenu ? FALSE: ((m_bIsPopupMenu)?FALSE:TRUE);
}
return bIsMenuBar;
}
/*
==========================================================================
void CNewMenu::MeasureItem(LPMEASUREITEMSTRUCT)
---------------------------------------------
Called by the framework when it wants to know what the width and height
of our item will be. To accomplish this we provide the width of the
icon plus the width of the menu text, and then the height of the icon.
==========================================================================
*/
void CNewMenu::MeasureItem_OldStyle( LPMEASUREITEMSTRUCT lpMIS, BOOL bIsMenuBar )
{
ASSERT(lpMIS->itemData);
CNewMenuItemData* pMenuData = (CNewMenuItemData*)(lpMIS->itemData);
UINT state = pMenuData->m_nFlags;
if(state & MF_SEPARATOR)
{
if(pMenuData->m_nTitleFlags&MFT_TITLE)
{
SIZE size = {0,0};
{// We need this sub-block for releasing the dc
// DC of the desktop
CClientDC myDC(NULL);
CFont font;
LOGFONT MyFont = m_MenuTitleFont;
MyFont.lfOrientation = 0;
MyFont.lfEscapement = 0;
font.CreateFontIndirect(&MyFont);
CFont* pOldFont = myDC.SelectObject (&font);
CString lpstrText = pMenuData->GetString(m_bDrawAccelerators ? m_hAccelToDraw : NULL);
VERIFY(::GetTextExtentPoint32(myDC.m_hDC,lpstrText,(int)_tcslen(lpstrText),&size));
// Select old font in
myDC.SelectObject(pOldFont);
} // We need this sub-block for releasing the dc
CSize iconSize(0,0);
if(pMenuData->m_nMenuIconOffset!=(-1) && pMenuData->m_pMenuIcon)
{
iconSize = pMenuData->m_pMenuIcon->GetIconSize();
if(iconSize!=CSize(0,0))
{
iconSize += CSize(2,2);
}
}
if(pMenuData->m_nTitleFlags&MFT_SIDE_TITLE)
{
if(bWine)
{
lpMIS->itemWidth = max(size.cy,iconSize.cx);
}
else
{
lpMIS->itemWidth = max(size.cy,iconSize.cx) - GetSystemMetrics(SM_CXMENUCHECK);
}
// Don't make the menu higher than menuitems in it
lpMIS->itemHeight = 0;
if(pMenuData->m_nTitleFlags&MFT_LINE)
{
lpMIS->itemWidth += 8;
}
else if(pMenuData->m_nTitleFlags&MFT_ROUND)
{
lpMIS->itemWidth += 4;
}
}
else
{
lpMIS->itemWidth = size.cx + iconSize.cx;
lpMIS->itemHeight = max(size.cy,iconSize.cy);
if(pMenuData->m_nTitleFlags&MFT_LINE)
{
lpMIS->itemHeight += 8;
}
}
}
else
{
lpMIS->itemHeight = 3;
lpMIS->itemWidth = 3;
}
}
else
{
//Get pointer to text SK
CString itemText = pMenuData->GetString(m_bDrawAccelerators ? m_hAccelToDraw : NULL);
SIZE size = {0,0};
{// We need this sub-block for releasing the dc
CFont fontMenu;
LOGFONT logFontMenu;
#ifdef _NEW_MENU_USER_FONT
logFontMenu = MENU_USER_FONT;
#else
NONCLIENTMETRICS nm = {0};
nm.cbSize = sizeof (nm);
VERIFY (SystemParametersInfo(SPI_GETNONCLIENTMETRICS,nm.cbSize,&nm,0));
logFontMenu = nm.lfMenuFont;
#endif
// Default selection?
if(GetDefaultItem(0, FALSE) == pMenuData->m_nID)
{
// Make the font bold
logFontMenu.lfWeight = FW_BOLD;
}
fontMenu.CreateFontIndirect (&logFontMenu);
// DC of the desktop
CClientDC myDC(NULL);
// Select menu font in...
CFont* pOldFont = myDC.SelectObject (&fontMenu);
VERIFY(::GetTextExtentPoint32(myDC.m_hDC,itemText,itemText.GetLength(),&size));
// Select old font in
myDC.SelectObject(pOldFont);
} // We need this sub-block for releasing the dc
// Set width and height:
if(bIsMenuBar)
{
if(itemText.Find(_T("&"))>=0)
{
lpMIS->itemWidth = size.cx - GetSystemMetrics(SM_CXMENUCHECK)/2;
}
else
{
lpMIS->itemWidth = size.cx;
}
}
else
{
lpMIS->itemWidth = m_iconX + size.cx + m_iconX + GAP;
}
int temp = GetSystemMetrics(SM_CYMENU);
lpMIS->itemHeight = (temp>(m_iconY+4)) ? temp : (m_iconY+4);
if(lpMIS->itemHeight<((UINT)size.cy) )
{
lpMIS->itemHeight=((UINT)size.cy);
}
// set status bar as appropriate
UINT nItemID = (lpMIS->itemID & 0xFFF0);
// Special case for system menu
if (nItemID>=SC_SIZE && nItemID<=SC_HOTKEY)
{
BOOL bGetNext = FALSE;
// search the actual menu item
for (int j=0;j<m_MenuItemList.GetUpperBound();++j)
{
CNewMenuItemData* pTemp = m_MenuItemList[j];
if(pTemp==pMenuData || bGetNext==TRUE)
{
bGetNext = TRUE;
pTemp = m_MenuItemList[j+1];
if(pTemp->m_nID)
{
lpMIS->itemData = (ULONG_PTR)pTemp;
lpMIS->itemID = pTemp->m_nID;
UINT nOrgWidth = lpMIS->itemWidth;
MeasureItem_OldStyle(lpMIS,bIsMenuBar);
// Restore old values
lpMIS->itemData = (ULONG_PTR)pMenuData;
lpMIS->itemID = pMenuData->m_nID;
lpMIS->itemWidth = max(lpMIS->itemWidth,nOrgWidth);
break;
}
}
}
lpMIS->itemHeight = temp;
}
}
}
void CNewMenu::MeasureItem_Icy( LPMEASUREITEMSTRUCT lpMIS, BOOL bIsMenuBar )
{
ASSERT(lpMIS->itemData);
CNewMenuItemData* pMenuData = (CNewMenuItemData*)(lpMIS->itemData);
UINT state = pMenuData->m_nFlags;
if(state & MF_SEPARATOR)
{
if(pMenuData->m_nTitleFlags&MFT_TITLE)
{
SIZE size = {0,0};
{// We need this sub-block for releasing the dc
// DC of the desktop
CClientDC myDC(NULL);
CFont font;
LOGFONT MyFont = m_MenuTitleFont;
MyFont.lfOrientation = 0;
MyFont.lfEscapement = 0;
font.CreateFontIndirect(&MyFont);
CFont* pOldFont = myDC.SelectObject (&font);
CString lpstrText = pMenuData->GetString(m_bDrawAccelerators ? m_hAccelToDraw : NULL);
VERIFY(::GetTextExtentPoint32(myDC.m_hDC,lpstrText,(int)_tcslen(lpstrText),&size));
// Select old font in
myDC.SelectObject(pOldFont);
} // We need this sub-block for releasing the dc
CSize iconSize(0,0);
if(pMenuData->m_nMenuIconOffset!=(-1) && pMenuData->m_pMenuIcon)
{
iconSize = pMenuData->m_pMenuIcon->GetIconSize();
if(iconSize!=CSize(0,0))
{
iconSize += CSize(2,2);
}
}
if(pMenuData->m_nTitleFlags&MFT_SIDE_TITLE)
{
if(bWine)
{
lpMIS->itemWidth = max(size.cy,iconSize.cx);
}
else
{
lpMIS->itemWidth = max(size.cy,iconSize.cx) - GetSystemMetrics(SM_CXMENUCHECK);
}
// Don't make the menu higher than menuitems in it
lpMIS->itemHeight = 0;
if(pMenuData->m_nTitleFlags&MFT_LINE)
{
lpMIS->itemWidth += 8;
}
else if(pMenuData->m_nTitleFlags&MFT_ROUND)
{
lpMIS->itemWidth += 4;
}
}
else
{
lpMIS->itemWidth = size.cx + iconSize.cx;
lpMIS->itemHeight = max(size.cy,iconSize.cy);
if(pMenuData->m_nTitleFlags&MFT_LINE)
{
lpMIS->itemHeight += 8;
}
}
}
else
{
lpMIS->itemHeight = 3;
lpMIS->itemWidth = 3;
}
}
else
{
//Get pointer to text SK
CString itemText = pMenuData->GetString(m_bDrawAccelerators ? m_hAccelToDraw : NULL);
SIZE size = {0,0};
{// We need this sub-block for releasing the dc
LOGFONT logFontMenu;
CFont fontMenu;
#ifdef _NEW_MENU_USER_FONT
logFontMenu = MENU_USER_FONT;
#else
NONCLIENTMETRICS nm = {0};
nm.cbSize = sizeof (nm);
VERIFY (SystemParametersInfo(SPI_GETNONCLIENTMETRICS,nm.cbSize,&nm,0));
logFontMenu = nm.lfMenuFont;
#endif
// Default selection?
if(GetDefaultItem(0, FALSE) == pMenuData->m_nID)
{
// Make the font bold
logFontMenu.lfWeight = FW_BOLD;
}
fontMenu.CreateFontIndirect (&logFontMenu);
// DC of the desktop
CClientDC myDC(NULL);
// Select menu font in...
CFont* pOldFont = myDC.SelectObject (&fontMenu);
// Check the Key-Shortcut replacing for japanise/chinese calculating space
itemText.Replace(_T("\t"),_T("nnn"));
VERIFY(::GetTextExtentPoint32(myDC.m_hDC,itemText,itemText.GetLength(),&size));
// Select old font in
myDC.SelectObject(pOldFont);
}// We need this sub-block for releasing the dc
// Set width and height:
if(bIsMenuBar)
{
if(itemText.Find(_T("&"))>=0)
{
lpMIS->itemWidth = size.cx - GetSystemMetrics(SM_CXMENUCHECK)/2;
}
else
{
lpMIS->itemWidth = size.cx;
}
}
else
{
lpMIS->itemWidth = m_iconX + size.cx + m_iconX + GAP;
}
int temp = GetSystemMetrics(SM_CYMENU);
lpMIS->itemHeight = (temp>(m_iconY + 6)) ? temp : (m_iconY+6);
if(lpMIS->itemHeight<((UINT)size.cy) )
{
lpMIS->itemHeight=((UINT)size.cy);
}
// set status bar as appropriate
UINT nItemID = (lpMIS->itemID & 0xFFF0);
// Special case for system menu
if (nItemID>=SC_SIZE && nItemID<=SC_HOTKEY)
{
BOOL bGetNext = FALSE;
// search the actual menu item
for (int j=0;j<m_MenuItemList.GetUpperBound();++j)
{
CNewMenuItemData* pTemp = m_MenuItemList[j];
if(pTemp==pMenuData || bGetNext==TRUE)
{
bGetNext = TRUE;
pTemp = m_MenuItemList[j+1];
if(pTemp->m_nID)
{
lpMIS->itemData = (ULONG_PTR)pTemp;
lpMIS->itemID = pTemp->m_nID;
UINT nOrgWidth = lpMIS->itemWidth;
MeasureItem_Icy(lpMIS,bIsMenuBar);
// Restore old values
lpMIS->itemData = (ULONG_PTR)pMenuData;
lpMIS->itemID = pMenuData->m_nID;
lpMIS->itemWidth = max(lpMIS->itemWidth,nOrgWidth);
break;
}
}
}
lpMIS->itemHeight = temp;
}
}
}
void CNewMenu::MeasureItem_WinXP( LPMEASUREITEMSTRUCT lpMIS, BOOL bIsMenuBar )
{
ASSERT(lpMIS->itemData);
CNewMenuItemData* pMenuData = (CNewMenuItemData*)(lpMIS->itemData);
UINT nFlag = pMenuData->m_nFlags;
if(nFlag & MF_SEPARATOR)
{
if(pMenuData->m_nTitleFlags&MFT_TITLE)
{
SIZE size = {0,0};
{// We need this sub-block for releasing the dc
// DC of the desktop
CClientDC myDC(NULL);
CFont font;
LOGFONT MyFont = m_MenuTitleFont;
MyFont.lfOrientation = 0;
MyFont.lfEscapement = 0;
font.CreateFontIndirect(&MyFont);
CFont* pOldFont = myDC.SelectObject (&font);
CString lpstrText = pMenuData->GetString(m_bDrawAccelerators ? m_hAccelToDraw : NULL);
VERIFY(::GetTextExtentPoint32(myDC.m_hDC,lpstrText,(int)_tcslen(lpstrText),&size));
// Select old font in
myDC.SelectObject(pOldFont);
}
CSize iconSize(0,0);
if(pMenuData->m_nMenuIconOffset!=(-1) && pMenuData->m_pMenuIcon)
{
iconSize = pMenuData->m_pMenuIcon->GetIconSize();
if(iconSize!=CSize(0,0))
{
iconSize += CSize(2,2);
}
}
if(pMenuData->m_nTitleFlags&MFT_SIDE_TITLE)
{
if(bWine)
{
lpMIS->itemWidth = max(size.cy,iconSize.cx);
}
else
{
lpMIS->itemWidth = max(size.cy,iconSize.cx) - GetSystemMetrics(SM_CXMENUCHECK);
}
// Don't make the menu higher than menuitems in it
lpMIS->itemHeight = 0;
if(pMenuData->m_nTitleFlags&MFT_LINE)
{
lpMIS->itemWidth += 8;
}
else if(pMenuData->m_nTitleFlags&MFT_ROUND)
{
lpMIS->itemWidth += 4;
}
}
else
{
lpMIS->itemWidth = size.cx + iconSize.cx;
lpMIS->itemHeight = max(size.cy,iconSize.cy);
if(pMenuData->m_nTitleFlags&MFT_LINE)
{
lpMIS->itemHeight += 8;
}
}
}
else
{
lpMIS->itemHeight = 3;
lpMIS->itemWidth = 3;
}
}
else
{
SIZE size = {0,0};
//Get pointer to text SK
CString itemText = pMenuData->GetString(m_bDrawAccelerators ? m_hAccelToDraw : NULL);
{ // We need this sub-block for releasing the dc
CFont fontMenu;
LOGFONT logFontMenu;
#ifdef _NEW_MENU_USER_FONT
logFontMenu = MENU_USER_FONT;
#else
NONCLIENTMETRICS nm = {0};
nm.cbSize = sizeof (NONCLIENTMETRICS);
VERIFY (SystemParametersInfo(SPI_GETNONCLIENTMETRICS,nm.cbSize,&nm,0));
logFontMenu = nm.lfMenuFont;
#endif
// Default selection?
if (GetDefaultItem(0, FALSE) == pMenuData->m_nID)
{
// Make the font bold
logFontMenu.lfWeight = FW_BOLD;
}
fontMenu.CreateFontIndirect (&logFontMenu);
// DC of the desktop
CClientDC myDC(NULL);
// Select menu font in...
CFont* pOldFont = myDC.SelectObject (&fontMenu);
// Check the Key-Shortcut replacing for japanise/chinese calculating space
itemText.Replace(_T("\t"),_T("nnn"));
VERIFY(::GetTextExtentPoint32(myDC.m_hDC,itemText,itemText.GetLength(),&size));
// Select old font in
myDC.SelectObject(pOldFont);
}// We need this sub-block for releasing the dc
int temp = GetSystemMetrics(SM_CYMENU);
// Set width and height:
if(bIsMenuBar)
{
if(itemText.Find(_T("&"))>=0)
{
lpMIS->itemWidth = size.cx-6; // - GetSystemMetrics(SM_CXMENUCHECK)/2;
}
else
{
lpMIS->itemWidth = size.cx;
}
lpMIS->itemHeight = temp >(m_iconY+2) ? temp : m_iconY+2;
}
else
{
if(nFlag&MF_POPUP)
{
lpMIS->itemWidth = 2 + m_iconX + 4 + size.cx + GetSystemMetrics(SM_CYMENU);
}
else
{
lpMIS->itemWidth = 2 + m_iconX +4+ size.cx + GetSystemMetrics(SM_CYMENU) / 2;
}
lpMIS->itemHeight = temp>m_iconY+8 ? temp : m_iconY+7;
}
if(lpMIS->itemHeight<((UINT)size.cy) )
{
lpMIS->itemHeight=((UINT)size.cy);
}
// set status bar as appropriate
UINT nItemID = (lpMIS->itemID & 0xFFF0);
// Special case for system menu
if (nItemID>=SC_SIZE && nItemID<=SC_HOTKEY)
{
BOOL bGetNext = FALSE;
// search the actual menu item
for (int j=0;j<m_MenuItemList.GetUpperBound();++j)
{
CNewMenuItemData* pTemp = m_MenuItemList[j];
if(pTemp==pMenuData || bGetNext==TRUE)
{
bGetNext = TRUE;
pTemp = m_MenuItemList[j+1];
if(pTemp->m_nID)
{
lpMIS->itemData = (ULONG_PTR)pTemp;
lpMIS->itemID = pTemp->m_nID;
UINT nOrgWidth = lpMIS->itemWidth;
MeasureItem_WinXP(lpMIS,bIsMenuBar);
// Restore old values
lpMIS->itemData = (ULONG_PTR)pMenuData;
lpMIS->itemID = pMenuData->m_nID;
lpMIS->itemWidth = max(lpMIS->itemWidth,nOrgWidth);
break;
}
}
}
lpMIS->itemHeight = temp;
}
}
//AfxTrace("IsMenuBar %ld, Height %2ld, width %3ld, ID 0x%08lX \r\n",int(bIsMenuBar),lpMIS->itemHeight,lpMIS->itemWidth,lpMIS->itemID);
}
void CNewMenu::SetIconSize (int width, int height)
{
m_iconX = width;
m_iconY = height;
}
CSize CNewMenu::GetIconSize()
{
return CSize(m_iconX,m_iconY);
}
BOOL CNewMenu::AppendODMenu(LPCTSTR lpstrText, UINT nFlags, UINT nID, int nIconNormal)
{
return CNewMenu::AppendODMenu(lpstrText,nFlags,nID,(CImageList*)NULL,nIconNormal);
}
BOOL CNewMenu::AppendODMenu(LPCTSTR lpstrText, UINT nFlags, UINT nID,
CBitmap* pBmp)
{
int nIndex = -1;
CNewMenuIconLock iconLock(GetMenuIcon(nIndex,pBmp));
return AppendODMenu(lpstrText,nFlags,nID,iconLock,nIndex);
}
BOOL CNewMenu::AppendODMenu(LPCTSTR lpstrText, UINT nFlags, UINT nID,
CImageList* pil, int xoffset)
{
int nIndex = 0;
// Helper for addref and release
CNewMenuIconLock iconLock(GetMenuIcon(nIndex,nID,pil,xoffset));
return AppendODMenu(lpstrText,nFlags,nID,iconLock,nIndex);
}
BOOL CNewMenu::AppendODMenu(LPCTSTR lpstrText, UINT nFlags, UINT nID,
CNewMenuIcons* pIcons, int nIndex)
{
// Add the MF_OWNERDRAW flag if not specified:
if(!nID)
{
if(nFlags&MF_BYPOSITION)
nFlags=MF_SEPARATOR|MF_OWNERDRAW|MF_BYPOSITION;
else
nFlags=MF_SEPARATOR|MF_OWNERDRAW;
}
else if(!(nFlags & MF_OWNERDRAW))
{
nFlags |= MF_OWNERDRAW;
}
if(nFlags & MF_POPUP)
{
CNewMenu* pSubMenu = DYNAMIC_DOWNCAST(CNewMenu,CMenu::FromHandlePermanent(UIntToHMenu(nID)));
if(pSubMenu)
{
pSubMenu->m_hParentMenu = m_hMenu;
}
}
CNewMenuItemData* pItemData = new CNewMenuItemData;
m_MenuItemList.Add(pItemData);
pItemData->SetString(lpstrText);
pIcons->AddRef();
pItemData->m_pMenuIcon->Release();
pItemData->m_pMenuIcon = pIcons;
pItemData->m_nFlags = nFlags;
pItemData->m_nID = nID;
if(pIcons && nIndex>=0)
{
pItemData->m_nMenuIconOffset = nIndex;
CSize size = pIcons->GetIconSize();
m_iconX = max(m_iconX,size.cx);
m_iconY = max(m_iconY,size.cy);
}
else
{
pItemData->m_nMenuIconOffset = -1;
}
// for having automated shortcut handling, thank to Mehdy Bohlool
if (CMenu::AppendMenu(nFlags&~MF_OWNERDRAW, nID, pItemData->m_szMenuText))
{
return CMenu::ModifyMenu( CMenu::GetMenuItemCount()-1, MF_BYPOSITION| nFlags, nID, (LPCTSTR)pItemData );
}
return FALSE;
}
BOOL CNewMenu::InsertODMenu(UINT nPosition, LPCTSTR lpstrText, UINT nFlags, UINT nID,
int nIconNormal)
{
int nIndex = -1;
CNewMenuIcons* pIcons=NULL;
if(nIconNormal>=0)
{
if(LoadFromToolBar(nID,nIconNormal,nIndex))
{
// the nIconNormal is a toolbar
pIcons = GetToolbarIcons(nIconNormal);
if(pIcons)
{
nIndex = pIcons->FindIndex(nID);
}
}
else
{
// the nIconNormal is a bitmap
pIcons = GetMenuIcon(nIndex,nIconNormal);
}
}
CNewMenuIconLock iconLock(pIcons);
return InsertODMenu(nPosition,lpstrText,nFlags,nID,iconLock,nIndex);
}
BOOL CNewMenu::InsertODMenu(UINT nPosition, LPCTSTR lpstrText, UINT nFlags, UINT nID,
CBitmap* pBmp)
{
int nIndex = -1;
CNewMenuIconLock iconLock(GetMenuIcon(nIndex,pBmp));
return InsertODMenu(nPosition,lpstrText,nFlags,nID,iconLock,nIndex);
}
BOOL CNewMenu::InsertODMenu(UINT nPosition, LPCTSTR lpstrText, UINT nFlags, UINT nID,
CImageList *pil, int xoffset)
{
int nIndex = -1;
CNewMenuIconLock iconLock(GetMenuIcon(nIndex,nID,pil,xoffset));
return InsertODMenu(nPosition,lpstrText,nFlags,nID,iconLock,nIndex);
}
BOOL CNewMenu::InsertODMenu(UINT nPosition, LPCTSTR lpstrText, UINT nFlags, UINT nID,
CNewMenuIcons* pIcons, int nIndex)
{
if(!(nFlags & MF_BYPOSITION))
{
int iPosition =0;
CNewMenu* pMenu = FindMenuOption(nPosition,iPosition);
if(pMenu)
{
return(pMenu->InsertODMenu(iPosition,lpstrText,nFlags|MF_BYPOSITION,nID,pIcons,nIndex));
}
else
{
return(FALSE);
}
}
if(!nID)
{
nFlags=MF_SEPARATOR|MF_OWNERDRAW|MF_BYPOSITION;
}
else if(!(nFlags & MF_OWNERDRAW))
{
nFlags |= MF_OWNERDRAW;
}
if(nFlags & MF_POPUP)
{
CNewMenu* pSubMenu = DYNAMIC_DOWNCAST(CNewMenu,CMenu::FromHandlePermanent(UIntToHMenu(nID)));
if(pSubMenu)
{
pSubMenu->m_hParentMenu = m_hMenu;
}
}
//Stephane Clog suggested adding this, believe it or not it's in the help
if(nPosition==(UINT)-1)
{
nPosition = GetMenuItemCount();
}
CNewMenuItemData *pItemData = new CNewMenuItemData;
m_MenuItemList.InsertAt(nPosition,pItemData);
pItemData->SetString(lpstrText);
pIcons->AddRef();
pItemData->m_pMenuIcon->Release();
pItemData->m_pMenuIcon = pIcons;
pItemData->m_nFlags = nFlags;
pItemData->m_nID = nID;
if(pIcons && nIndex>=0)
{
pItemData->m_nMenuIconOffset = nIndex;
CSize size = pIcons->GetIconSize();
m_iconX = max(m_iconX,size.cx);
m_iconY = max(m_iconY,size.cy);
}
else
{
pItemData->m_nMenuIconOffset = -1;
}
// for having automated shortcut handling, thank to Mehdy Bohlool
if (CMenu::InsertMenu(nPosition,nFlags&~MF_OWNERDRAW,nID,pItemData->m_szMenuText))
{
return CMenu::ModifyMenu(nPosition, MF_BYPOSITION| nFlags, nID, (LPCTSTR)pItemData );
}
return FALSE;
}
// Same as ModifyMenu but replacement for CNewMenu
BOOL CNewMenu::ModifyODMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem,LPCTSTR lpszNewItem)
{
if(!(nFlags & MF_BYPOSITION))
{
int iPosition =0;
CNewMenu* pMenu = FindMenuOption(nPosition,iPosition);
if(pMenu)
{
return(pMenu->ModifyODMenu(iPosition,nFlags|MF_BYPOSITION,nIDNewItem,lpszNewItem));
}
else
{
return(FALSE);
}
}
UINT nMenuID = GetMenuItemID(nPosition);
if(nMenuID==(UINT)-1)
{
nMenuID = HMenuToUInt(::GetSubMenu(m_hMenu,nPosition));
}
CNewMenuItemData* pItemData = FindMenuItem(nMenuID);
BOOL bRet = CMenu::ModifyMenu(nPosition, nFlags, nIDNewItem,lpszNewItem);
if(pItemData)
{
pItemData->m_nID = nIDNewItem;
GetMenuString(nPosition,pItemData->m_szMenuText,MF_BYPOSITION);
CMenu::ModifyMenu(nPosition, nFlags|MF_OWNERDRAW, nIDNewItem,(LPCTSTR)pItemData);
}
if(bRet && (nFlags & MF_POPUP) )
{
CNewMenu* pSubMenu = DYNAMIC_DOWNCAST(CNewMenu,CMenu::FromHandlePermanent(UIntToHMenu(nIDNewItem)));
if(pSubMenu)
{
pSubMenu->m_hParentMenu = m_hMenu;
}
}
return bRet;
}
BOOL CNewMenu::ModifyODMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem, const CBitmap* pBmp)
{
if(!(nFlags & MF_BYPOSITION))
{
int iPosition =0;
CNewMenu* pMenu = FindMenuOption(nPosition,iPosition);
if(pMenu)
{
return(pMenu->ModifyODMenu(iPosition,nFlags|MF_BYPOSITION,nIDNewItem,pBmp));
}
else
{
return(FALSE);
}
}
UINT nMenuID = GetMenuItemID(nPosition);
if(nMenuID==(UINT)-1)
{
nMenuID = HMenuToUInt(::GetSubMenu(m_hMenu,nPosition));
}
CNewMenuItemData* pItemData = FindMenuItem(nMenuID);
BOOL bRet = CMenu::ModifyMenu(nPosition, nFlags, nIDNewItem,pBmp);
if(pItemData)
{
pItemData->m_nID = nIDNewItem;
pItemData->m_szMenuText.Empty();
CMenu::ModifyMenu(nPosition, nFlags|MF_OWNERDRAW, nIDNewItem,(LPCTSTR)pItemData);
}
if(bRet && (nFlags & MF_POPUP) )
{
CNewMenu* pSubMenu = DYNAMIC_DOWNCAST(CNewMenu,CMenu::FromHandlePermanent(UIntToHMenu(nIDNewItem)));
if(pSubMenu)
{
pSubMenu->m_hParentMenu = m_hMenu;
}
}
return bRet;
}
BOOL CNewMenu::ModifyODMenu(LPCTSTR lpstrText, UINT nID, int nIconNormal)
{
int nLoc;
CNewMenuItemData* pItemData;
CArray<CNewMenu*,CNewMenu*>newSubs;
CArray<int,int&>newLocs;
BOOL bModifyOK = TRUE;
// Find the old CNewMenuItemData structure:
CNewMenu* pSubMenu = FindMenuOption(nID,nLoc);
do {
if(pSubMenu && nLoc>=0)
{
pItemData = pSubMenu->m_MenuItemList[nLoc];
}
else
{
// Create a new CNewMenuItemData structure:
pItemData = new CNewMenuItemData;
m_MenuItemList.Add(pItemData);
}
BOOL bTextChanged = FALSE;
ASSERT(pItemData);
if(lpstrText && pItemData->m_szMenuText.Compare(lpstrText)!=NULL)
{
bTextChanged = TRUE;
pItemData->SetString(lpstrText);
}
pItemData->m_nMenuIconOffset=-1;
if(nIconNormal>=0)
{
int nxOffset = -1;
CNewMenuIcons* pIcons=NULL;
if(LoadFromToolBar(nID,nIconNormal,nxOffset))
{
// the nIconNormal is a toolbar
pIcons = GetToolbarIcons(nIconNormal);
if(pIcons)
{
pItemData->m_nMenuIconOffset = pIcons->FindIndex(nID);
}
}
else
{
// the nIconNormal is a bitmap
pIcons = GetMenuIcon(pItemData->m_nMenuIconOffset,nIconNormal);
}
pIcons->AddRef();
pItemData->m_pMenuIcon->Release();
pItemData->m_pMenuIcon = pIcons;
if(pIcons)
{
CSize size = pIcons->GetIconSize();
pSubMenu->m_iconX = max(pSubMenu->m_iconX,size.cx);
pSubMenu->m_iconY = max(pSubMenu->m_iconY,size.cy);
}
}
pItemData->m_nFlags &= ~(MF_BYPOSITION);
pItemData->m_nFlags |= MF_OWNERDRAW;
pItemData->m_nID = nID;
// for having automated shortcut handling
if(pSubMenu && bTextChanged)
{
if(pSubMenu->ModifyMenu(nLoc, MF_BYPOSITION|(pItemData->m_nFlags&~MF_OWNERDRAW), nID,pItemData->m_szMenuText) )
{
if(!pSubMenu->ModifyMenu(nLoc, MF_BYPOSITION|pItemData->m_nFlags, nID,(LPCTSTR)pItemData))
{
bModifyOK = FALSE;
}
}
else
{
bModifyOK = FALSE;
}
}
newSubs.Add(pSubMenu);
newLocs.Add(nLoc);
if(pSubMenu && nLoc>=0)
{
pSubMenu = FindAnotherMenuOption(nID,nLoc,newSubs,newLocs);
}
else
{
pSubMenu = NULL;
}
}while(pSubMenu);
return (CMenu::ModifyMenu(nID,pItemData->m_nFlags,nID,(LPCTSTR)pItemData)) && bModifyOK;
}
BOOL CNewMenu::ModifyODMenu(LPCTSTR lpstrText, UINT nID, CImageList *pil, int xoffset)
{
int nIndex = 0;
CNewMenuIcons* pIcons = GetMenuIcon(nIndex,nID,pil,xoffset);
pIcons->AddRef();
BOOL bResult = ModifyODMenu(lpstrText,nID,pIcons,nIndex);
pIcons->Release();
return bResult;
}
BOOL CNewMenu::ModifyODMenu(LPCTSTR lpstrText, UINT nID, CNewMenuIcons* pIcons, int xoffset)
{
ASSERT(pIcons);
int nLoc;
CNewMenuItemData *pItemData;
CArray<CNewMenu*,CNewMenu*>newSubs;
CArray<int,int&>newLocs;
BOOL bModifyOK = TRUE;
// Find the old CNewMenuItemData structure:
CNewMenu *pSubMenu = FindMenuOption(nID,nLoc);
do {
if(pSubMenu && nLoc>=0)
{
pItemData = pSubMenu->m_MenuItemList[nLoc];
}
else
{
// Create a new CNewMenuItemData structure:
pItemData = new CNewMenuItemData;
m_MenuItemList.Add(pItemData);
}
BOOL bTextChanged = FALSE;
ASSERT(pItemData);
if(lpstrText && pItemData->m_szMenuText.Compare(lpstrText)!=NULL)
{
bTextChanged = TRUE;
pItemData->SetString(lpstrText);
}
if(pIcons)
{
pIcons->AddRef();
pItemData->m_pMenuIcon->Release();
pItemData->m_pMenuIcon = pIcons;
pItemData->m_nMenuIconOffset = xoffset;
int x=0;
int y=0;
if(pSubMenu && pIcons->GetIconSize(&x,&y))
{
// Correct the size of the menuitem
pSubMenu->m_iconX = max(pSubMenu->m_iconX,x);
pSubMenu->m_iconY = max(pSubMenu->m_iconY,y);
}
}
else
{
pItemData->m_nMenuIconOffset = -1;
}
pItemData->m_nFlags &= ~(MF_BYPOSITION);
pItemData->m_nFlags |= MF_OWNERDRAW;
pItemData->m_nID = nID;
// for having automated shortcut handling
if(pSubMenu && bTextChanged)
{
if(pSubMenu->ModifyMenu(nLoc, MF_BYPOSITION|(pItemData->m_nFlags&~MF_OWNERDRAW), nID,pItemData->m_szMenuText) )
{
if(!pSubMenu->ModifyMenu(nLoc, MF_BYPOSITION|pItemData->m_nFlags, nID,(LPCTSTR)pItemData))
{
bModifyOK = FALSE;
}
}
else
{
bModifyOK = FALSE;
}
}
newSubs.Add(pSubMenu);
newLocs.Add(nLoc);
if(pSubMenu && nLoc>=0)
{
pSubMenu = FindAnotherMenuOption(nID,nLoc,newSubs,newLocs);
}
else
{
pSubMenu = NULL;
}
} while(pSubMenu);
return (CMenu::ModifyMenu(nID,pItemData->m_nFlags,nID,(LPCTSTR)pItemData)) && bModifyOK;
}
BOOL CNewMenu::ModifyODMenu(LPCTSTR lpstrText, UINT nID, CBitmap* bmp)
{
if (bmp)
{
CImageList temp;
temp.Create(m_iconX,m_iconY,ILC_COLORDDB|ILC_MASK,1,1);
temp.Add(bmp,GetBitmapBackground());
return ModifyODMenu(lpstrText,nID,&temp,0);
}
return ModifyODMenu(lpstrText,nID,(CImageList*)NULL,0);
}
BOOL CNewMenu::ModifyODMenu(LPCTSTR lpstrText, UINT nID, COLORREF fill, COLORREF border, int hatchstyle)
{
// Get device context
CSize bitmap_size(m_iconX,m_iconY);
CBitmap bmp;
{
CClientDC DC(0);
ColorBitmap(&DC,bmp,bitmap_size,fill,border,hatchstyle);
}
return ModifyODMenu(lpstrText,nID,&bmp);
}
BOOL CNewMenu::ModifyODMenu(LPCTSTR lpstrText, LPCTSTR OptionText, int nIconNormal)
{
int nIndex = 0;
CNewMenu* pOptionMenu = FindMenuOption(OptionText,nIndex);
if(pOptionMenu!=NULL && nIndex>=0)
{
CNewMenuItemData* pItemData = pOptionMenu->m_MenuItemList[nIndex];
BOOL bTextChanged = FALSE;
ASSERT(pItemData);
if(lpstrText && pItemData->m_szMenuText.Compare(lpstrText)!=NULL)
{
bTextChanged = TRUE;
pItemData->SetString(lpstrText);
}
pItemData->m_nMenuIconOffset = nIconNormal;
if(nIconNormal>=0)
{
CNewMenuIcons* pIcons = GetMenuIcon(pItemData->m_nMenuIconOffset,nIconNormal);
pIcons->AddRef();
pItemData->m_pMenuIcon->Release();
pItemData->m_pMenuIcon = pIcons;
CNewMenuBitmaps* pMenuIcon = DYNAMIC_DOWNCAST(CNewMenuBitmaps,pItemData->m_pMenuIcon);
if(pMenuIcon)
{
CSize size = pMenuIcon->GetIconSize();
pOptionMenu->m_iconX = max(pOptionMenu->m_iconX,size.cx);
pOptionMenu->m_iconY = max(pOptionMenu->m_iconY,size.cy);
}
}
// for having automated shortcut handling
if(pOptionMenu && bTextChanged)
{
if(!pOptionMenu->ModifyMenu(nIndex, MF_BYPOSITION|(pItemData->m_nFlags&~MF_OWNERDRAW), pItemData->m_nID,pItemData->m_szMenuText) ||
!pOptionMenu->ModifyMenu(nIndex, MF_BYPOSITION|pItemData->m_nFlags, pItemData->m_nID,(LPCTSTR)pItemData))
{
return FALSE;
}
}
return TRUE;
}
return FALSE;
}
CNewMenuItemData* CNewMenu::NewODMenu(UINT pos, UINT nFlags, UINT nID, LPCTSTR string)
{
CNewMenuItemData* pItemData;
pItemData = new CNewMenuItemData;
pItemData->m_nFlags = nFlags;
pItemData->m_nID = nID;
if(!(nFlags&MF_BITMAP))
{
pItemData->SetString (string);
}
if(nFlags & MF_POPUP)
{
CNewMenu* pSubMenu = DYNAMIC_DOWNCAST(CNewMenu,CMenu::FromHandlePermanent(UIntToHMenu(nID)));
if(pSubMenu)
{
pSubMenu->m_hParentMenu = m_hMenu;
}
}
BOOL bModified = FALSE;
if (nFlags&MF_OWNERDRAW)
{
bModified = ModifyMenu(pos,nFlags,nID,(LPCTSTR)pItemData);
}
else if (nFlags&MF_BITMAP)
{
bModified = ModifyMenu(pos,nFlags,nID,(CBitmap*)string);
}
else if (nFlags&MF_SEPARATOR)
{
ASSERT(nFlags&MF_SEPARATOR);
bModified = ModifyMenu(pos,nFlags,nID);
}
else // (nFlags&MF_STRING)
{
ASSERT(!(nFlags&MF_OWNERDRAW));
bModified = ModifyMenu(pos,nFlags,nID,pItemData->GetString(m_bDrawAccelerators ? m_hAccelToDraw : NULL));
}
if(!bModified)
{
ShowLastError(_T("Error from Menu: ModifyMenu"));
}
return(pItemData);
};
BOOL CNewMenu::LoadToolBars(const UINT* arID, int n, HMODULE hInst)
{
ASSERT(arID);
BOOL returnflag = TRUE;
for(int i=0;i<n;++i)
{
if(!LoadToolBar(arID[i],hInst))
{
returnflag = FALSE;
}
}
return(returnflag);
}
DWORD CNewMenu::SetMenuIcons(CNewMenuIcons* pMenuIcons)
{
ASSERT(pMenuIcons);
int nCount = (int)pMenuIcons->m_IDs.GetSize();
while(nCount--)
{
ModifyODMenu(NULL,pMenuIcons->m_IDs[nCount],pMenuIcons,nCount*MENU_ICONS);
}
return pMenuIcons->m_dwRefCount;
}
CNewMenuIcons* CNewMenu::GetMenuIcon(int &nIndex, UINT nID, CImageList *pil, int xoffset)
{
if(pil==NULL || xoffset<0)
{
nIndex=-1;
return NULL;
}
HICON hIcon = pil->ExtractIcon(xoffset);
if(m_pSharedMenuIcons!=NULL)
{
POSITION pos = m_pSharedMenuIcons->GetHeadPosition();
while(pos)
{
CNewMenuBitmaps* pMenuIcon = DYNAMIC_DOWNCAST(CNewMenuBitmaps,m_pSharedMenuIcons->GetNext(pos));
if(pMenuIcon)
{
nIndex = pMenuIcon->Add(hIcon,nID);
if(nIndex!=-1)
{
DestroyIcon(hIcon);
return pMenuIcon;
}
}
}
}
else
{
m_pSharedMenuIcons = new CTypedPtrList<CPtrList, CNewMenuIcons*>;
}
CNewMenuBitmaps* pMenuIcon = new CNewMenuBitmaps();
pMenuIcon->m_crTransparent = m_bitmapBackground;
nIndex = pMenuIcon->Add(hIcon,nID);
DestroyIcon(hIcon);
if(nIndex!=-1)
{
m_pSharedMenuIcons->AddTail(pMenuIcon);
return pMenuIcon;
}
delete pMenuIcon;
return NULL;
}
CNewMenuIcons* CNewMenu::GetMenuIcon(int &nIndex, int nID)
{
if(m_pSharedMenuIcons!=NULL)
{
POSITION pos = m_pSharedMenuIcons->GetHeadPosition();
while(pos)
{
CNewMenuBitmaps* pMenuIcon = DYNAMIC_DOWNCAST(CNewMenuBitmaps,m_pSharedMenuIcons->GetNext(pos));
if(pMenuIcon)
{
if(m_bDynIcons)
{
nIndex = pMenuIcon->Add((HICON)(INT_PTR)nID);
}
else
{
nIndex = pMenuIcon->Add(nID,m_bitmapBackground);
}
if(nIndex!=-1)
{
return pMenuIcon;
}
}
}
}
else
{
m_pSharedMenuIcons = new CTypedPtrList<CPtrList, CNewMenuIcons*>;
}
CNewMenuBitmaps* pMenuIcon = new CNewMenuBitmaps();
pMenuIcon->m_crTransparent = m_bitmapBackground;
nIndex = pMenuIcon->Add(nID,m_bitmapBackground);
if(nIndex!=-1)
{
m_pSharedMenuIcons->AddTail(pMenuIcon);
return pMenuIcon;
}
delete pMenuIcon;
return NULL;
}
CNewMenuIcons* CNewMenu::GetMenuIcon(int &nIndex, CBitmap* pBmp)
{
if(pBmp==NULL)
{
nIndex=-1;
return NULL;
}
if(m_pSharedMenuIcons!=NULL)
{
POSITION pos = m_pSharedMenuIcons->GetHeadPosition();
while(pos)
{
CNewMenuBitmaps* pMenuIcon = DYNAMIC_DOWNCAST(CNewMenuBitmaps,m_pSharedMenuIcons->GetNext(pos));
if(pMenuIcon)
{
nIndex = pMenuIcon->Add(pBmp,m_bitmapBackground);
if(nIndex!=-1)
{
return pMenuIcon;
}
}
}
}
else
{
m_pSharedMenuIcons = new CTypedPtrList<CPtrList, CNewMenuIcons*>;
}
CNewMenuBitmaps* pMenuIcon = new CNewMenuBitmaps();
pMenuIcon->m_crTransparent = m_bitmapBackground;
nIndex = pMenuIcon->Add(pBmp,m_bitmapBackground);
if(nIndex!=-1)
{
m_pSharedMenuIcons->AddTail(pMenuIcon);
return pMenuIcon;
}
delete pMenuIcon;
return NULL;
}
CNewMenuIcons* CNewMenu::GetToolbarIcons(UINT nToolBar, HMODULE hInst)
{
ASSERT_VALID(this);
ASSERT(nToolBar != NULL);
if(m_pSharedMenuIcons!=NULL)
{
POSITION pos = m_pSharedMenuIcons->GetHeadPosition();
while(pos)
{
CNewMenuIcons* pMenuIcon = m_pSharedMenuIcons->GetNext(pos);
if(pMenuIcon->DoMatch(MAKEINTRESOURCE(nToolBar),hInst))
{
return pMenuIcon;
}
}
}
else
{
m_pSharedMenuIcons = new CTypedPtrList<CPtrList, CNewMenuIcons*>;
}
CNewMenuIcons* pMenuIcon = new CNewMenuIcons();
pMenuIcon->m_crTransparent = m_bitmapBackground;
if(pMenuIcon->LoadToolBar(MAKEINTRESOURCE(nToolBar),hInst))
{
m_pSharedMenuIcons->AddTail(pMenuIcon);
return pMenuIcon;
}
delete pMenuIcon;
return NULL;
}
BOOL CNewMenu::LoadToolBar(LPCTSTR lpszResourceName, HMODULE hInst)
{
CNewMenuIcons* pMenuIcon = GetToolbarIcons((UINT)(UINT_PTR)lpszResourceName,hInst);
if(pMenuIcon)
{
SetMenuIcons(pMenuIcon);
return TRUE;
}
return FALSE;
}
BOOL CNewMenu::LoadToolBar(HBITMAP hBitmap, CSize size, UINT* pID, COLORREF crTransparent)
{
ASSERT_VALID(this);
ASSERT(pID);
if(crTransparent==CLR_NONE)
{
crTransparent = m_bitmapBackground;
}
if(m_pSharedMenuIcons!=NULL)
{
POSITION pos = m_pSharedMenuIcons->GetHeadPosition();
while(pos)
{
CNewMenuIcons* pMenuIcon = m_pSharedMenuIcons->GetNext(pos);
if(pMenuIcon->DoMatch(hBitmap,size,pID))
{
SetMenuIcons(pMenuIcon);
return TRUE;
}
}
}
else
{
m_pSharedMenuIcons = new CTypedPtrList<CPtrList, CNewMenuIcons*>;
}
CNewMenuIcons* pMenuIcon = new CNewMenuIcons();
if(pMenuIcon->LoadToolBar(hBitmap,size,pID,crTransparent))
{
m_pSharedMenuIcons->AddTail(pMenuIcon);
SetMenuIcons(pMenuIcon);
return TRUE;
}
delete pMenuIcon;
return FALSE;
}
BOOL CNewMenu::LoadToolBar(WORD* pToolInfo, COLORREF crTransparent)
{
ASSERT_VALID(this);
ASSERT(pToolInfo);
if(crTransparent==CLR_NONE)
{
crTransparent = m_bitmapBackground;
}
if(m_pSharedMenuIcons!=NULL)
{
POSITION pos = m_pSharedMenuIcons->GetHeadPosition();
while(pos)
{
CNewMenuIcons* pMenuIcon = m_pSharedMenuIcons->GetNext(pos);
if(pMenuIcon->DoMatch(pToolInfo,crTransparent))
{
SetMenuIcons(pMenuIcon);
return TRUE;
}
}
}
else
{
m_pSharedMenuIcons = new CTypedPtrList<CPtrList, CNewMenuIcons*>;
}
CNewMenuIcons* pMenuIcon = new CNewMenuIcons();
if(pMenuIcon->LoadToolBar(pToolInfo,crTransparent))
{
m_pSharedMenuIcons->AddTail(pMenuIcon);
SetMenuIcons(pMenuIcon);
return TRUE;
}
delete pMenuIcon;
return FALSE;
}
// Jan-12-2005 - Mark P. Peterson - [email protected] - http://www.RhinoSoft.com/
// added this function as a helper to LoadToolBar(WORD* pToolInfo, COLORREF crTransparent), the purpose of this function
// is to easily load a high color toolbar to the menu, instead of creating and maintaining a command map. this function
// simply reads an existing 16 bit toolbar, and builds the word map based on that toolbar, using the 256 color bitmap.
BOOL CNewMenu::LoadToolBar(UINT n16ToolBarID, UINT n256BitmapID, COLORREF transparentColor, HMODULE hInst)
{
BOOL bRet = FALSE;
// determine location of the bitmap in resource
if(hInst==0)
{
hInst = AfxFindResourceHandle(MAKEINTRESOURCE(n16ToolBarID), RT_TOOLBAR);
}
HRSRC hRsrc = ::FindResource(hInst, MAKEINTRESOURCE(n16ToolBarID), RT_TOOLBAR);
if (hRsrc == NULL)
{ // Special purpose when you try to load it from a dll 30.05.2002
if(AfxGetResourceHandle()!=hInst)
{
hInst = AfxGetResourceHandle();
hRsrc = ::FindResource(hInst, MAKEINTRESOURCE(n16ToolBarID), RT_TOOLBAR);
}
if (hRsrc == NULL)
{
return FALSE;
}
}
HGLOBAL hGlobal = LoadResource(hInst, hRsrc);
if (hGlobal)
{
CToolBarData* pData = (CToolBarData*)LockResource(hGlobal);
if (pData)
{
int nSize = sizeof(WORD)*(pData->wItemCount+4);
// no need for delete
WORD* pToolId = (WORD*)_alloca(nSize);
// sets also the last entry to zero
ZeroMemory(pToolId,nSize);
pToolId[0] = (WORD)n256BitmapID;
pToolId[1] = pData->wWidth;
pToolId[2] = pData->wHeight;
WORD* pTemp = pToolId+3;
for (int nIndex = 0; nIndex < pData->wItemCount; nIndex++)
{ // not a seperator?
if( (pData->items()[nIndex]) )
{
*pTemp++ = pData->items()[nIndex];
}
}
// load the toolbar images into the menu
bRet = LoadToolBar(pToolId, transparentColor);
UnlockResource(hGlobal);
}
FreeResource(hGlobal);
}
// return TRUE for success, FALSE for failure
return (bRet);
} // LoadHiColor
BOOL CNewMenu::LoadToolBar(UINT nToolBar, HMODULE hInst)
{
return LoadToolBar((LPCTSTR)(UINT_PTR)nToolBar,hInst);
}
BOOL CNewMenu::LoadFromToolBar(UINT nID, UINT nToolBar, int& xoffset)
{
int xset,offset;
UINT nStyle;
BOOL returnflag=FALSE;
CToolBar bar;
CWnd* pWnd = AfxGetMainWnd();
if (pWnd == NULL)
{
pWnd = CWnd::GetDesktopWindow();
}
bar.Create(pWnd);
if(bar.LoadToolBar(nToolBar))
{
offset=bar.CommandToIndex(nID);
if(offset>=0)
{
bar.GetButtonInfo(offset,nID,nStyle,xset);
if(xset>0)
{
xoffset = xset;
}
returnflag=TRUE;
}
}
return returnflag;
}
// O.S.
CNewMenuItemData* CNewMenu::FindMenuItem(UINT nID)
{
CNewMenuItemData *pData = NULL;
int i;
for(i = 0; i < m_MenuItemList.GetSize(); i++)
{
if (m_MenuItemList[i]->m_nID == nID)
{
pData = m_MenuItemList[i];
break;
}
}
if (!pData)
{
int loc;
CNewMenu *pMenu = FindMenuOption(nID, loc);
ASSERT(pMenu != this);
if (loc >= 0)
{
return pMenu->FindMenuItem(nID);
}
}
return pData;
}
CNewMenu* CNewMenu::FindAnotherMenuOption(int nId, int& nLoc,
CArray<CNewMenu*,CNewMenu*>&newSubs,
CArray<int,int&>&newLocs)
{
int i,numsubs,j;
CNewMenu *pSubMenu,*pgoodmenu;
BOOL foundflag;
for(i=0;i<(int)(GetMenuItemCount());++i)
{
pSubMenu = DYNAMIC_DOWNCAST(CNewMenu,GetSubMenu(i));
if(pSubMenu)
{
pgoodmenu = pSubMenu->FindAnotherMenuOption(nId,nLoc,newSubs,newLocs);
if(pgoodmenu)
{
return pgoodmenu;
}
}
else if(nId==(int)GetMenuItemID(i))
{
numsubs = (int)newSubs.GetSize();
foundflag = TRUE;
for(j=0;j<numsubs;++j)
{
if(newSubs[j]==this && newLocs[j]==i)
{
foundflag = FALSE;
break;
}
}
if(foundflag)
{
nLoc = i;
return this;
}
}
}
nLoc = -1;
return NULL;
}
CNewMenu* CNewMenu::FindMenuOption(int nId, int& nLoc)
{
int i;
CNewMenu *pSubMenu,*pgoodmenu;
for(i=0;i<(int)(GetMenuItemCount());++i)
{
pSubMenu = DYNAMIC_DOWNCAST(CNewMenu,GetSubMenu(i));
if(pSubMenu)
{
pgoodmenu = pSubMenu->FindMenuOption(nId,nLoc);
if(pgoodmenu)
{
return pgoodmenu;
}
}
else if(nId==(int)GetMenuItemID(i))
{
nLoc = i;
return(this);
}
}
nLoc = -1;
return NULL;
}
CNewMenu* CNewMenu::FindMenuOption(LPCTSTR lpstrText, int& nLoc)
{
int i;
// First look for all item text.
for(i=0;i<(int)m_MenuItemList.GetSize();++i)
{
if(m_MenuItemList[i]->m_szMenuText.Compare(lpstrText)==NULL)
{
nLoc = i;
return this;
}
}
CNewMenu* pSubMenu;
// next, look in all submenus
for(i=0; i<(int)(GetMenuItemCount());++i)
{
pSubMenu = DYNAMIC_DOWNCAST(CNewMenu,GetSubMenu(i));
if(pSubMenu)
{
pSubMenu = pSubMenu->FindMenuOption(lpstrText,nLoc);
if(pSubMenu)
{
return pSubMenu;
}
}
}
nLoc = -1;
return NULL;
}
BOOL CNewMenu::LoadMenu(HMENU hMenu)
{
if(!::IsMenu(hMenu) || !Attach(hMenu))
{
return FALSE;
}
m_bIsPopupMenu = FALSE;
for(int i=0;i<(int)(GetMenuItemCount());++i)
{
HMENU hSubMenu = ::GetSubMenu(m_hMenu,i);
if(hSubMenu)
{
CNewMenu* pMenu = new CNewMenu(m_hMenu);
m_SubMenus.Add(hSubMenu);
pMenu->LoadMenu(hSubMenu);
pMenu->m_bIsPopupMenu = TRUE;
}
}
SynchronizeMenu();
return TRUE;
}
BOOL CNewMenu::LoadMenu(int nResource)
{
return(CNewMenu::LoadMenu(MAKEINTRESOURCE(nResource)));
}
BOOL CNewMenu::LoadMenu(LPCTSTR lpszResourceName)
{
ASSERT(this);
HMENU hMenu = ::LoadMenu(AfxFindResourceHandle(lpszResourceName,RT_MENU), lpszResourceName);
#ifdef _DEBUG
ShowLastError(_T("Error from Menu: LoadMenu"));
#endif
return LoadMenu(hMenu);
}
BOOL CNewMenu::SetItemData(UINT uiId, DWORD_PTR dwItemData, BOOL fByPos)
{
MENUITEMINFO MenuItemInfo = {0};
MenuItemInfo.cbSize = sizeof(MenuItemInfo);
MenuItemInfo.fMask = MIIM_DATA;
if(::GetMenuItemInfo(m_hMenu,uiId,fByPos,&MenuItemInfo))
{
CNewMenuItemData* pItem = CheckMenuItemData(MenuItemInfo.dwItemData);
if(pItem)
{
pItem->m_pData = (void*)dwItemData;
return TRUE;
}
}
return FALSE;
}
BOOL CNewMenu::SetItemDataPtr(UINT uiId, void* pItemData, BOOL fByPos )
{
return SetItemData(uiId, (DWORD_PTR) pItemData, fByPos);
}
DWORD_PTR CNewMenu::GetItemData(UINT uiId, BOOL fByPos) const
{
MENUITEMINFO MenuItemInfo = {0};
MenuItemInfo.cbSize = sizeof(MenuItemInfo);
MenuItemInfo.fMask = MIIM_DATA;
if(::GetMenuItemInfo(m_hMenu,uiId,fByPos,&MenuItemInfo))
{
CNewMenuItemData* pItem = CheckMenuItemData(MenuItemInfo.dwItemData);
if(pItem)
{
return (DWORD_PTR)pItem->m_pData;
}
}
return DWORD_PTR(-1);
}
void* CNewMenu::GetItemDataPtr(UINT uiId, BOOL fByPos) const
{
return (void*)GetItemData(uiId,fByPos);
}
BOOL CNewMenu::SetMenuData(DWORD_PTR dwMenuData)
{
m_pData = (void*)dwMenuData;
return TRUE;
}
BOOL CNewMenu::SetMenuDataPtr(void* pMenuData)
{
m_pData = (void*)pMenuData;
return TRUE;
}
DWORD_PTR CNewMenu::GetMenuData() const
{
return (DWORD_PTR)m_pData;
}
void* CNewMenu::GetMenuDataPtr() const
{
return m_pData;
}
BOOL CNewMenu::m_bDrawAccelerators = TRUE;
BOOL CNewMenu::SetAcceleratorsDraw (BOOL bDraw)
{
BOOL bOld = m_bDrawAccelerators;
m_bDrawAccelerators = bDraw;
return bOld;
}
BOOL CNewMenu::GetAcceleratorsDraw ()
{
return m_bDrawAccelerators;
}
BYTE CNewMenu::m_bAlpha = 255;
BYTE CNewMenu::SetAlpha(BYTE bAlpha)
{
BYTE oldAlpha = m_bAlpha;
m_bAlpha = bAlpha;
return oldAlpha;
}
BYTE CNewMenu::GetAlpha()
{
return m_bAlpha;
}
// INVALID_HANDLE_VALUE = Draw default frame's accel. NULL = Off
HACCEL CNewMenu::SetAccelerator (HACCEL hAccel)
{
HACCEL hOld = m_hAccelToDraw;
m_hAccelToDraw = hAccel;
return hOld;
}
HACCEL CNewMenu::GetAccelerator ()
{
return m_hAccelToDraw;
}
void CNewMenu::LoadCheckmarkBitmap(int unselect, int select)
{
if(unselect>0 && select>0)
{
m_selectcheck = select;
m_unselectcheck = unselect;
if(m_checkmaps)
{
m_checkmaps->DeleteImageList();
}
else
{
m_checkmaps = new CImageList();
}
m_checkmaps->Create(m_iconX,m_iconY,ILC_MASK,2,1);
BOOL flag1 = AddBitmapToImageList(m_checkmaps,unselect);
BOOL flag2 = AddBitmapToImageList(m_checkmaps,select);
if(!flag1||!flag2)
{
m_checkmaps->DeleteImageList();
delete m_checkmaps;
m_checkmaps = NULL;
}
}
}
BOOL CNewMenu::GetMenuText(UINT id, CString& string, UINT nFlags/*= MF_BYPOSITION*/)
{
if(MF_BYPOSITION&nFlags)
{
UINT numMenuItems = (int)m_MenuItemList.GetSize();
if(id<numMenuItems)
{
string = m_MenuItemList[id]->GetString(m_bDrawAccelerators ? m_hAccelToDraw : NULL);
return TRUE;
}
}
else
{
int uiLoc;
CNewMenu* pMenu = FindMenuOption(id,uiLoc);
if(NULL!=pMenu)
{
return pMenu->GetMenuText(uiLoc,string);
}
}
return FALSE;
}
CNewMenuItemData* CNewMenu::CheckMenuItemData(ULONG_PTR nItemData) const
{
for(int i=0;i<m_MenuItemList.GetSize();++i)
{
CNewMenuItemData* pItem = m_MenuItemList[i];
if ( ((ULONG_PTR)pItem)==nItemData )
{
return pItem;
}
}
return NULL;
}
CNewMenuItemData* CNewMenu::FindMenuList(UINT nID)
{
for(int i=0;i<m_MenuItemList.GetSize();++i)
{
CNewMenuItemData* pMenuItem = m_MenuItemList[i];
if(pMenuItem->m_nID==nID && !pMenuItem->m_nSyncFlag)
{
pMenuItem->m_nSyncFlag = 1;
return pMenuItem;
}
}
return NULL;
}
void CNewMenu::InitializeMenuList(int value)
{
for(int i=0;i<m_MenuItemList.GetSize();++i)
{
m_MenuItemList[i]->m_nSyncFlag = value;
}
}
void CNewMenu::DeleteMenuList()
{
for(int i=0;i<m_MenuItemList.GetSize();++i)
{
if(!m_MenuItemList[i]->m_nSyncFlag)
{
delete m_MenuItemList[i];
}
}
}
void CNewMenu::SynchronizeMenu()
{
CTypedPtrArray<CPtrArray, CNewMenuItemData*> temp;
CNewMenuItemData *pItemData;
CString string;
UINT submenu,state,j;
InitializeMenuList(0);
for(j=0;j<GetMenuItemCount();++j)
{
MENUITEMINFO menuInfo = {0};
menuInfo.cbSize = sizeof(menuInfo);
// we get a wrong state for seperators
menuInfo.fMask = MIIM_TYPE|MIIM_ID|MIIM_STATE;
// item doesn't exist
if(!GetMenuItemInfo(j,&menuInfo,TRUE))
{
break;
}
state = GetMenuState(j,MF_BYPOSITION);
if(state!=menuInfo.fState)
{
state|=0;
}
pItemData=NULL;
if(state==UINT_PTR(-1))
{
break;
}
if(!(state&MF_SYSMENU))
{
if(menuInfo.fType&MFT_RIGHTJUSTIFY)
{
state |= MF_RIGHTJUSTIFY;
}
// MFT_RIGHTORDER is the same value as MFT_SYSMENU.
// We distinguish between the two by also looking for MFT_BITMAP.
if(!(state&MF_BITMAP) && (menuInfo.fType&MFT_RIGHTORDER) )
{
state |= MFT_RIGHTORDER;
}
}
// Special purpose for Windows NT 4.0
if(state&MF_BITMAP)
{
// Bitmap-button like system menu, maximize, minimize and close
// just ignore.
UINT nID = GetMenuItemID(j);
pItemData = FindMenuList(nID);
if(!pItemData)
{
//if(nID>=SC_SIZE && nID<=SC_HOTKEY)
// we do not support bitmap in menu because the OS handle it not right with
// ownerdrawn style so let show the default one
{
pItemData = new CNewMenuItemData;
pItemData->m_nFlags = state;
pItemData->m_nID = nID;
}
//else
//{
// // sets the handle of the bitmap
// pItemData = NewODMenu(j,state|MF_BYPOSITION|MF_OWNERDRAW,nID,menuInfo.dwTypeData);
//}
}
}
else if(state&MF_POPUP)
{
HMENU hSubMenu = GetSubMenu(j)->m_hMenu;
submenu = HMenuToUInt(hSubMenu);
pItemData = FindMenuList(submenu);
GetMenuString(j,string,MF_BYPOSITION);
if(!pItemData)
{
state &= ~(MF_USECHECKBITMAPS|MF_SEPARATOR);
pItemData = NewODMenu(j,state|MF_BYPOSITION|MF_POPUP|MF_OWNERDRAW,submenu,string);
}
else if(!string.IsEmpty ())
{
pItemData->SetString(string);
}
CNewMenu* pSubMenu = DYNAMIC_DOWNCAST(CNewMenu,CMenu::FromHandlePermanent(hSubMenu));
if(pSubMenu && pSubMenu->m_hParentMenu!=m_hMenu)
{ // Sets again the parent to this one
pSubMenu->m_hParentMenu = m_hMenu;
}
}
else if(state&MF_SEPARATOR)
{
pItemData = FindMenuList(0);
if(!pItemData)
{
pItemData = NewODMenu(j,state|MF_BYPOSITION|MF_OWNERDRAW,0,_T(""));
}
else
{
pItemData->m_nFlags = state|MF_BYPOSITION|MF_OWNERDRAW;
ModifyMenu(j,pItemData->m_nFlags,0,(LPCTSTR)pItemData);
}
}
else
{
UINT nID = GetMenuItemID(j);
pItemData = FindMenuList(nID);
GetMenuString(j,string,MF_BYPOSITION);
if(!pItemData)
{
pItemData = NewODMenu(j,state|MF_BYPOSITION|MF_OWNERDRAW,nID,string);
}
else
{
pItemData->m_nFlags = state|MF_BYPOSITION|MF_OWNERDRAW;
if(string.GetLength()>0)
{
pItemData->SetString(string);
}
ModifyMenu(j,pItemData->m_nFlags,nID,(LPCTSTR)pItemData);
}
}
if(pItemData)
{
temp.Add(pItemData);
}
}
DeleteMenuList();
m_MenuItemList.RemoveAll();
m_MenuItemList.Append(temp);
temp.RemoveAll();
}
void CNewMenu::OnInitMenuPopup(HWND hWnd, CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
{
UNREFERENCED_PARAMETER(nIndex);
UNREFERENCED_PARAMETER(bSysMenu);
#ifdef _TRACE_MENU_
AfxTrace(_T("InitMenuPopup: 0x%lx from Wnd 0x%lx\n"),HMenuToUInt(pPopupMenu->m_hMenu),HWndToUInt(hWnd));
#endif
CNewMenuHook::m_hLastMenu = pPopupMenu->m_hMenu;
if(IsMenu(pPopupMenu->m_hMenu))
{
CNewMenu* pSubMenu = DYNAMIC_DOWNCAST(CNewMenu,pPopupMenu);
if(pSubMenu)
{
pSubMenu->m_hTempOwner = hWnd;
pSubMenu->OnInitMenuPopup();
HMENU hMenu = pSubMenu->GetParent();
CNewMenu* pParent = DYNAMIC_DOWNCAST(CNewMenu,CMenu::FromHandlePermanent(hMenu));
if(pParent)
{
pParent->m_dwOpenMenu += 1;
if(pParent->m_dwOpenMenu==1 && !pParent->m_bIsPopupMenu)
{
// Redraw the menubar for the shade
CRect rect = pParent->GetLastActiveMenuRect();
if(!rect.IsRectEmpty())
{
rect.InflateRect(0,0,10,10);
CPoint Point(0,0);
ClientToScreen(hWnd,&Point);
rect.OffsetRect(-Point);
RedrawWindow(hWnd,rect,0,RDW_FRAME|RDW_INVALIDATE);
}
}
}
}
}
}
BOOL CNewMenu::Replace(UINT nID, UINT nNewID)
{
int nLoc=0;
CNewMenu* pTempMenu = FindMenuOption(nID,nLoc);
if(pTempMenu && nLoc >= 0)
{
#ifdef _TRACE_MENU_
AfxTrace(_T("Replace MenuID 0x%X => 0x%X\n"),nID,nNewID);
#endif
CNewMenuItemData* pData = pTempMenu->m_MenuItemList[nLoc];
UINT nFlags = pData->m_nFlags|MF_OWNERDRAW|MF_BYPOSITION;
pData->m_nID = nNewID;
return pTempMenu->ModifyMenu(nLoc,nFlags,nNewID,(LPCTSTR)pData);
}
return FALSE;
}
void CNewMenu::OnInitMenuPopup()
{
m_bIsPopupMenu = true;
SynchronizeMenu();
// Special purpose for windows XP with themes!!!
if(g_Shell==WinXP)
{
Replace(SC_RESTORE,SC_RESTORE+1);
Replace(SC_CLOSE,SC_CLOSE+1);
Replace(SC_MINIMIZE,SC_MINIMIZE+1);
}
}
BOOL CNewMenu::OnUnInitPopupMenu()
{
#ifdef _TRACE_MENU_
AfxTrace(_T("UnInitMenuPopup: 0x%lx\n"),HMenuToUInt(m_hMenu));
#endif
if(g_Shell==WinXP)
{
// Special purpose for windows XP with themes!!!
// Restore old values otherwise you have disabled windowbuttons
Replace(SC_MINIMIZE+1,SC_MINIMIZE);
Replace(SC_RESTORE+1,SC_RESTORE);
if(Replace(SC_CLOSE+1,SC_CLOSE))
{
//EnableMenuItem(SC_CLOSE, MF_BYCOMMAND|MF_ENABLED);
SetWindowPos(m_hTempOwner,0,0,0,0,0,SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER);
}
//Replace(SC_RESTORE+1,SC_RESTORE);
//Replace(SC_MINIMIZE+1,SC_MINIMIZE);
}
HMENU hMenu = GetParent();
CNewMenu* pParent = DYNAMIC_DOWNCAST(CNewMenu,CMenu::FromHandlePermanent(hMenu));
if(pParent)
{
pParent->m_dwOpenMenu -= 1;
if(pParent->m_dwOpenMenu>=NULL && !pParent->m_bIsPopupMenu)
{
pParent->m_dwOpenMenu = 0;
// Redraw the menubar for the shade
CRect rect = pParent->GetLastActiveMenuRect();
if(!rect.IsRectEmpty())
{
rect.InflateRect(0,0,10,10);
CPoint Point(0,0);
ClientToScreen(m_hTempOwner,&Point);
rect.OffsetRect(-Point);
RedrawWindow(m_hTempOwner,rect,0,RDW_FRAME|RDW_INVALIDATE);
}
return TRUE;
}
}
return FALSE;
}
LRESULT CNewMenu::FindKeyboardShortcut(UINT nChar, UINT nFlags, CMenu* pMenu)
{
UNREFERENCED_PARAMETER(nFlags);
CNewMenu* pNewMenu = DYNAMIC_DOWNCAST(CNewMenu,pMenu);
if(pNewMenu)
{
//SK: modified for Unicode correctness
CString key(_T('&'),2);
key.SetAt(1,(TCHAR)nChar);
key.MakeLower();
CString menutext;
int menusize = (int)pNewMenu->GetMenuItemCount();
if(menusize!=(pNewMenu->m_MenuItemList.GetSize()))
{
pNewMenu->SynchronizeMenu();
}
for(int i=0;i<menusize;++i)
{
if(pNewMenu->GetMenuText(i,menutext))
{
menutext.MakeLower();
if(menutext.Find(key)>=0)
{
return(MAKELRESULT(i,2));
}
}
}
}
return NULL;
}
BOOL CNewMenu::AddBitmapToImageList(CImageList* bmplist,UINT nResourceID)
{
// O.S.
if (m_bDynIcons)
{
bmplist->Add((HICON)(UINT_PTR)nResourceID);
return TRUE;
}
CBitmap mybmp;
HBITMAP hbmp = LoadSysColorBitmap(nResourceID);
if(hbmp)
{
// Object will be destroyd by destructor of CBitmap
mybmp.Attach(hbmp);
}
else
{
mybmp.LoadBitmap(nResourceID);
}
if (mybmp.m_hObject && bmplist->Add(&mybmp,GetBitmapBackground())>=0 )
{
return TRUE;
}
return FALSE;
}
COLORREF CNewMenu::SetBitmapBackground(COLORREF newColor)
{
COLORREF oldColor = m_bitmapBackground;
m_bitmapBackground = newColor;
return oldColor;
}
COLORREF CNewMenu::GetBitmapBackground()
{
if(m_bitmapBackground==CLR_DEFAULT)
return GetSysColor(COLOR_3DFACE);
return m_bitmapBackground;
}
BOOL CNewMenu::Draw3DCheckmark(CDC *pDC, CRect rect, HBITMAP hbmpChecked, HBITMAP hbmpUnchecked, DWORD dwState)
{
if(dwState&ODS_CHECKED || hbmpUnchecked)
{
rect.InflateRect(-1,-1);
if (IsNewShell()) //SK: looks better on the old shell
{
pDC->DrawEdge(rect, BDR_SUNKENOUTER, BF_RECT);
}
rect.InflateRect (2,2);
if(dwState&ODS_CHECKED)
{
if (!hbmpChecked)
{ // Checkmark
rect.OffsetRect(1,2);
DrawSpecialCharStyle(pDC,rect,98,dwState);
}
else if(!hbmpUnchecked)
{ // Bullet
DrawSpecialCharStyle(pDC,rect,105,dwState);
}
else
{
// Draw Bitmap
BITMAP myInfo = {0};
GetObject((HGDIOBJ)hbmpChecked,sizeof(myInfo),&myInfo);
CPoint Offset = rect.TopLeft() + CPoint((rect.Width()-myInfo.bmWidth)/2,(rect.Height()-myInfo.bmHeight)/2);
pDC->DrawState(Offset,CSize(0,0),hbmpChecked,DST_BITMAP|DSS_MONO);
}
}
else
{
// Draw Bitmap
BITMAP myInfo = {0};
GetObject((HGDIOBJ)hbmpUnchecked,sizeof(myInfo),&myInfo);
CPoint Offset = rect.TopLeft() + CPoint((rect.Width()-myInfo.bmWidth)/2,(rect.Height()-myInfo.bmHeight)/2);
if(dwState & ODS_DISABLED)
{
pDC->DrawState(Offset,CSize(0,0),hbmpUnchecked,DST_BITMAP|DSS_MONO|DSS_DISABLED);
}
else
{
pDC->DrawState(Offset,CSize(0,0),hbmpUnchecked,DST_BITMAP|DSS_MONO);
}
}
return TRUE;
}
return FALSE;
}
HBITMAP CNewMenu::LoadSysColorBitmap(int nResourceId)
{
HINSTANCE hInst = AfxFindResourceHandle(MAKEINTRESOURCE(nResourceId),RT_BITMAP);
HRSRC hRsrc = ::FindResource(hInst,MAKEINTRESOURCE(nResourceId),RT_BITMAP);
if (hRsrc == NULL)
{
return NULL;
}
// determine how many colors in the bitmap
HGLOBAL hglb;
if ((hglb = LoadResource(hInst, hRsrc)) == NULL)
{
return NULL;
}
LPBITMAPINFOHEADER lpBitmap = (LPBITMAPINFOHEADER)LockResource(hglb);
if (lpBitmap == NULL)
{
return NULL;
}
WORD numcol = NumBitmapColors(lpBitmap);
::FreeResource(hglb);
if(numcol!=16)
{
return(NULL);
}
return AfxLoadSysColorBitmap(hInst, hRsrc, FALSE);
}
// sPos means Seperator's position, since we have no way to find the
// seperator's position in the menu we have to specify them when we call the
// RemoveMenu to make sure the unused seperators are removed;
// sPos = None no seperator removal;
// = Head seperator in front of this menu item;
// = Tail seperator right after this menu item;
// = Both seperators at both ends;
// remove the menu item based on their text, return -1 if not found, otherwise
// return the menu position;
int CNewMenu::RemoveMenu(LPCTSTR pText, ESeperator sPos)
{
int nPos = GetMenuPosition(pText);
if(nPos != -1)
{
switch (sPos)
{
case CNewMenu::NONE:
RemoveMenu(nPos, MF_BYPOSITION);
break;
case CNewMenu::HEAD:
ASSERT(nPos - 1 >= 0);
RemoveMenu(nPos-1, MF_BYPOSITION);
break;
case CNewMenu::TAIL:
RemoveMenu(nPos+1, MF_BYPOSITION);
break;
case CNewMenu::BOTH:
// remove the end first;
RemoveMenu(nPos+1, MF_BYPOSITION);
// remove the head;
ASSERT(nPos - 1 >= 0);
RemoveMenu(nPos-1, MF_BYPOSITION);
break;
}
}
return nPos;
}
BOOL CNewMenu::RemoveMenu(UINT uiId, UINT nFlags)
{
if(MF_BYPOSITION&nFlags)
{
UINT nItemState = GetMenuState(uiId,MF_BYPOSITION);
if((nItemState&MF_SEPARATOR) && !(nItemState&MF_POPUP))
{
CNewMenuItemData* pData = m_MenuItemList.GetAt(uiId);
m_MenuItemList.RemoveAt(uiId);
delete pData;
}
else
{
CMenu* pSubMenu = GetSubMenu(uiId);
if(NULL==pSubMenu)
{
UINT uiCommandId = GetMenuItemID(uiId);
for(int i=0;i<m_MenuItemList.GetSize(); i++)
{
if(m_MenuItemList[i]->m_nID==uiCommandId)
{
CNewMenuItemData* pData = m_MenuItemList.GetAt(i);
m_MenuItemList.RemoveAt(i);
delete pData;
break;
}
}
}
else
{
// Only remove the menu.
int numSubMenus = (int)m_SubMenus.GetSize();
while(numSubMenus--)
{
if(m_SubMenus[numSubMenus]==pSubMenu->m_hMenu)
{
m_SubMenus.RemoveAt(numSubMenus);
}
}
numSubMenus = (int)m_MenuItemList.GetSize();
while(numSubMenus--)
{
if(m_MenuItemList[numSubMenus]->m_nID==HMenuToUInt(pSubMenu->m_hMenu) )
{
CNewMenuItemData* pData = m_MenuItemList.GetAt(numSubMenus);
m_MenuItemList.RemoveAt(numSubMenus);
delete pData;
break;
}
}
// Don't delete it's only remove
//delete pSubMenu;
}
}
}
else
{
int iPosition =0;
CNewMenu* pMenu = FindMenuOption(uiId,iPosition);
if(pMenu)
{
return pMenu->RemoveMenu(iPosition,MF_BYPOSITION);
}
}
return CMenu::RemoveMenu(uiId,nFlags);
}
BOOL CNewMenu::DeleteMenu(UINT uiId, UINT nFlags)
{
if(MF_BYPOSITION&nFlags)
{
UINT nItemState = GetMenuState(uiId,MF_BYPOSITION);
if( (nItemState&MF_SEPARATOR) && !(nItemState&MF_POPUP))
{
CNewMenuItemData* pData = m_MenuItemList.GetAt(uiId);
m_MenuItemList.RemoveAt(uiId);
delete pData;
}
else
{
CMenu* pSubMenu = GetSubMenu(uiId);
if(NULL==pSubMenu)
{
UINT uiCommandId = GetMenuItemID(uiId);
for(int i=0;i<m_MenuItemList.GetSize(); i++)
{
if(m_MenuItemList[i]->m_nID==uiCommandId)
{
CNewMenuItemData* pData = m_MenuItemList.GetAt(i);
m_MenuItemList.RemoveAt(i);
delete pData;
}
}
}
else
{
BOOL bCanDelete = FALSE;
int numSubMenus = (int)m_SubMenus.GetSize();
while(numSubMenus--)
{
if(m_SubMenus[numSubMenus]==pSubMenu->m_hMenu)
{
m_SubMenus.RemoveAt(numSubMenus);
bCanDelete = TRUE;
}
}
numSubMenus = (int)m_MenuItemList.GetSize();
while(numSubMenus--)
{
if(m_MenuItemList[numSubMenus]->m_nID==HMenuToUInt(pSubMenu->m_hMenu) )
{
CNewMenuItemData* pData = m_MenuItemList.GetAt(numSubMenus);
m_MenuItemList.RemoveAt(numSubMenus);
delete pData;
break;
}
}
// Did we created the menu
if(bCanDelete)
{ // Oh yes so we can destroy it
delete pSubMenu;
}
}
}
}
else
{
int iPosition =0;
CNewMenu* pMenu = FindMenuOption(uiId,iPosition);
if(pMenu)
{
return pMenu->DeleteMenu(iPosition,MF_BYPOSITION);
}
}
return CMenu::DeleteMenu(uiId,nFlags);
}
BOOL CNewMenu::AppendMenu(UINT nFlags, UINT nIDNewItem, LPCTSTR lpszNewItem, int nIconNormal)
{
return AppendODMenu(lpszNewItem,nFlags,nIDNewItem,nIconNormal);
}
BOOL CNewMenu::AppendMenu(UINT nFlags, UINT nIDNewItem, LPCTSTR lpszNewItem, CImageList* il, int xoffset)
{
return AppendODMenu(lpszNewItem,nFlags,nIDNewItem,il,xoffset);
}
BOOL CNewMenu::AppendMenu(UINT nFlags, UINT nIDNewItem, LPCTSTR lpszNewItem, CBitmap* bmp)
{
return AppendODMenu(lpszNewItem,nFlags,nIDNewItem,bmp);
}
BOOL CNewMenu::InsertMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem, LPCTSTR lpszNewItem, int nIconNormal)
{
return InsertODMenu(nPosition,lpszNewItem,nFlags,nIDNewItem,nIconNormal);
}
BOOL CNewMenu::InsertMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem, LPCTSTR lpszNewItem, CImageList* il, int xoffset)
{
return InsertODMenu(nPosition,lpszNewItem,nFlags,nIDNewItem,il,xoffset);
}
BOOL CNewMenu::InsertMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem, LPCTSTR lpszNewItem, CBitmap* bmp)
{
return InsertODMenu(nPosition,lpszNewItem,nFlags,nIDNewItem,bmp);
}
CNewMenu* CNewMenu::AppendODPopupMenu(LPCTSTR lpstrText)
{
CNewMenu* pSubMenu = new CNewMenu(m_hMenu);
pSubMenu->m_unselectcheck=m_unselectcheck;
pSubMenu->m_selectcheck=m_selectcheck;
pSubMenu->m_checkmaps=m_checkmaps;
pSubMenu->m_checkmapsshare=TRUE;
pSubMenu->CreatePopupMenu();
if(AppendODMenu(lpstrText,MF_POPUP,HMenuToUInt(pSubMenu->m_hMenu), -1))
{
m_SubMenus.Add(pSubMenu->m_hMenu);
return pSubMenu;
}
delete pSubMenu;
return NULL;
}
CMenu* CNewMenu::GetSubMenu(int nPos) const
{
return CMenu::GetSubMenu (nPos);
}
CMenu* CNewMenu::GetSubMenu(LPCTSTR lpszSubMenuName) const
{
int num = GetMenuItemCount ();
CString name;
MENUITEMINFO info = {0};
for (int i=0; i<num; i++)
{
GetMenuString (i, name, MF_BYPOSITION);
// fix from George Menhorn
if(name.IsEmpty())
{
info.cbSize = sizeof (MENUITEMINFO);
info.fMask = MIIM_DATA;
::GetMenuItemInfo(m_hMenu, i, TRUE, &info);
CNewMenuItemData* pItemData = CheckMenuItemData(info.dwItemData);
if (pItemData)
{
name = pItemData->GetString(m_bDrawAccelerators ? m_hAccelToDraw : NULL);
}
}
if (name.Compare (lpszSubMenuName) == 0)
{
return CMenu::GetSubMenu (i);
}
}
return NULL;
}
// Tongzhe Cui, Functions to remove a popup menu based on its name. Seperators
// before and after the popup menu can also be removed if they exist.
int CNewMenu::GetMenuPosition(LPCTSTR pText)
{
for(int i=0;i<(int)(GetMenuItemCount());++i)
{
if(!GetSubMenu(i))
{
for(int j=0;j<m_MenuItemList.GetSize();++j)
{
if(m_MenuItemList[j]->m_szMenuText.Compare(pText)==NULL)
{
return j;
}
}
}
}
// means no found;
return -1;
}
BOOL CNewMenu::RemoveMenuTitle()
{
int numMenuItems = (int)m_MenuItemList.GetSize();
// We need a seperator at the beginning of the menu
if(!numMenuItems || !((m_MenuItemList[0]->m_nFlags)&MF_SEPARATOR) )
{
return FALSE;
}
CNewMenuItemData* pMenuData = m_MenuItemList[0];
// Check for title
if(pMenuData->m_nTitleFlags&MFT_TITLE)
{
if(numMenuItems>0)
{
CNewMenuItemData* pMenuNextData = m_MenuItemList[1];
if((pMenuNextData->m_nFlags&MF_MENUBREAK))
{
pMenuNextData->m_nFlags &= ~MF_MENUBREAK;
CMenu::ModifyMenu(1,MF_BYPOSITION|pMenuNextData->m_nFlags,pMenuNextData->m_nID,(LPCTSTR)pMenuNextData);
}
}
// Now remove the title
RemoveMenu(0,MF_BYPOSITION);
return TRUE;
}
return FALSE;
}
BOOL CNewMenu::SetMenuTitle(LPCTSTR pTitle, UINT nTitleFlags, int nIconNormal)
{
int nIndex = -1;
CNewMenuIconLock iconLock(GetMenuIcon(nIndex,nIconNormal));
return SetMenuTitle(pTitle,nTitleFlags,iconLock,nIndex);
}
BOOL CNewMenu::SetMenuTitle(LPCTSTR pTitle, UINT nTitleFlags, CBitmap* pBmp)
{
int nIndex = -1;
CNewMenuIconLock iconLock(GetMenuIcon(nIndex,pBmp));
return SetMenuTitle(pTitle,nTitleFlags,iconLock,nIndex);
}
BOOL CNewMenu::SetMenuTitle(LPCTSTR pTitle, UINT nTitleFlags, CImageList *pil, int xoffset)
{
int nIndex = -1;
CNewMenuIconLock iconLock(GetMenuIcon(nIndex,0,pil,xoffset));
return SetMenuTitle(pTitle,nTitleFlags,iconLock,nIndex);
}
BOOL CNewMenu::SetMenuTitle(LPCTSTR pTitle, UINT nTitleFlags, CNewMenuIcons* pIcons, int nIndex)
{
// Check if menu is valid
if(!::IsMenu(m_hMenu))
{
return FALSE;
}
// Check the menu integrity
if((int)GetMenuItemCount()!=(int)m_MenuItemList.GetSize())
{
SynchronizeMenu();
}
int numMenuItems = (int)m_MenuItemList.GetSize();
// We need a seperator at the beginning of the menu
if(!numMenuItems || !((m_MenuItemList[0]->m_nFlags)&MF_SEPARATOR) )
{
// We add the special menu item for title
CNewMenuItemData *pItemData = new CNewMenuItemDataTitle;
m_MenuItemList.InsertAt(0,pItemData);
pItemData->SetString(pTitle);
pItemData->m_nFlags = MF_BYPOSITION|MF_SEPARATOR|MF_OWNERDRAW;
VERIFY(CMenu::InsertMenu(0,MF_SEPARATOR|MF_BYPOSITION,0,pItemData->m_szMenuText));
VERIFY(CMenu::ModifyMenu(0, MF_BYPOSITION|MF_SEPARATOR|MF_OWNERDRAW, 0, (LPCTSTR)pItemData ));
//InsertMenu(0,MF_SEPARATOR|MF_BYPOSITION);
}
numMenuItems = (int)m_MenuItemList.GetSize();
if(numMenuItems)
{
CNewMenuItemData* pMenuData = m_MenuItemList[0];
if(pMenuData->m_nFlags&MF_SEPARATOR)
{
pIcons->AddRef();
pMenuData->m_pMenuIcon->Release();
pMenuData->m_pMenuIcon = pIcons;
if(pIcons && nIndex>=0)
{
pMenuData->m_nMenuIconOffset = nIndex;
//CSize size = pIcons->GetIconSize();
//m_iconX = max(m_iconX,size.cx);
//m_iconY = max(m_iconY,size.cy);
}
else
{
pMenuData->m_nMenuIconOffset = -1;
}
pMenuData->SetString(pTitle);
pMenuData->m_nTitleFlags = nTitleFlags|MFT_TITLE;
if(numMenuItems>1)
{
CNewMenuItemData* pMenuData = m_MenuItemList[1];
if(nTitleFlags&MFT_SIDE_TITLE)
{
if(!(pMenuData->m_nFlags&MF_MENUBREAK))
{
pMenuData->m_nFlags |= MF_MENUBREAK;
CMenu::ModifyMenu(1,MF_BYPOSITION|pMenuData->m_nFlags,pMenuData->m_nID,(LPCTSTR)pMenuData);
}
}
else
{
if((pMenuData->m_nFlags&MF_MENUBREAK))
{
pMenuData->m_nFlags &= ~MF_MENUBREAK;
CMenu::ModifyMenu(1,MF_BYPOSITION|pMenuData->m_nFlags,pMenuData->m_nID,(LPCTSTR)pMenuData);
}
}
return TRUE;
}
}
}
return FALSE;
}
CNewMenuItemDataTitle* CNewMenu::GetMemuItemDataTitle()
{
// Check if menu is valid
if(!this || !::IsMenu(m_hMenu))
{
return NULL;
}
// Check the menu integrity
if((int)GetMenuItemCount()!=(int)m_MenuItemList.GetSize())
{
SynchronizeMenu();
}
if(m_MenuItemList.GetSize()>0)
{
return DYNAMIC_DOWNCAST(CNewMenuItemDataTitle,m_MenuItemList[0]);
}
return NULL;
}
BOOL CNewMenu::SetMenuTitleColor(COLORREF clrTitle, COLORREF clrLeft, COLORREF clrRight)
{
CNewMenuItemDataTitle* pItem = GetMemuItemDataTitle();
if(pItem)
{
pItem->m_clrTitle = clrTitle;
pItem->m_clrLeft = clrLeft;
pItem->m_clrRight = clrRight;
return TRUE;
}
return FALSE;
}
BOOL CNewMenu::SetMenuText(UINT id, CString string, UINT nFlags/*= MF_BYPOSITION*/ )
{
if(MF_BYPOSITION&nFlags)
{
int numMenuItems = (int)m_MenuItemList.GetSize();
if(id<UINT(numMenuItems))
{
// get current menu state so it doesn't change
UINT nState = GetMenuState(id, MF_BYPOSITION);
nState &= ~(MF_BITMAP|MF_OWNERDRAW|MF_SEPARATOR);
// change the menutext
CNewMenuItemData* pItemData = m_MenuItemList[id];
pItemData->SetString(string);
if(CMenu::ModifyMenu(id,MF_BYPOSITION|MF_STRING | nState, pItemData->m_nID, string))
{
return ModifyMenu(id,MF_BYPOSITION | MF_OWNERDRAW,pItemData->m_nID,(LPCTSTR)pItemData);
}
}
}
else
{
int uiLoc;
CNewMenu* pMenu = FindMenuOption(id,uiLoc);
if(NULL!=pMenu)
{
return pMenu->SetMenuText(uiLoc,string);
}
}
return FALSE;
}
// courtesy of Warren Stevens
void CNewMenu::ColorBitmap(CDC* pDC, CBitmap& bmp, CSize size, COLORREF fill, COLORREF border, int hatchstyle)
{
// Create a memory DC
CDC MemDC;
MemDC.CreateCompatibleDC(pDC);
bmp.CreateCompatibleBitmap(pDC, size.cx, size.cy);
CPen border_pen(PS_SOLID, 1, border);
CBrush fill_brush;
if(hatchstyle!=-1)
{
fill_brush.CreateHatchBrush(hatchstyle, fill);
}
else
{
fill_brush.CreateSolidBrush(fill);
}
CBitmap* pOldBitmap = MemDC.SelectObject(&bmp);
CPen* pOldPen = MemDC.SelectObject(&border_pen);
CBrush* pOldBrush = MemDC.SelectObject(&fill_brush);
MemDC.Rectangle(0,0, size.cx, size.cy);
if(NULL!=pOldBrush) { MemDC.SelectObject(pOldBrush); }
if(NULL!=pOldPen) { MemDC.SelectObject(pOldPen); }
if(NULL!=pOldBitmap) { MemDC.SelectObject(pOldBitmap); }
}
void CNewMenu::DrawSpecial_OldStyle(CDC* pDC, LPCRECT pRect, UINT nID, DWORD dwStyle)
{
COLORREF oldColor;
if( (dwStyle&ODS_GRAYED) || (dwStyle&ODS_INACTIVE))
{
oldColor = pDC->SetTextColor(::GetSysColor(COLOR_GRAYTEXT));
}
else if (dwStyle&ODS_SELECTED)
{
oldColor = pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
}
else
{
oldColor = pDC->SetTextColor(::GetSysColor(COLOR_MENUTEXT));
}
BOOL bBold = (dwStyle&ODS_DEFAULT) ? TRUE : FALSE;
switch(nID&0xfff0)
{
case SC_MINIMIZE:
DrawSpecialChar(pDC,pRect,48,bBold); // Min
break;
case SC_MAXIMIZE:
DrawSpecialChar(pDC,pRect,49,bBold); // Max
break;
case SC_CLOSE:
DrawSpecialChar(pDC,pRect,114,bBold); // Close
break;
case SC_RESTORE:
DrawSpecialChar(pDC,pRect,50,bBold); // restore
break;
}
pDC->SetTextColor(oldColor);
}
void CNewMenu::DrawSpecial_WinXP(CDC* pDC, LPCRECT pRect, UINT nID, DWORD dwStyle)
{
TCHAR cSign = 0;
switch(nID&0xfff0)
{
case SC_MINIMIZE:
cSign = 48; // Min
break;
case SC_MAXIMIZE:
cSign = 49;// Max
break;
case SC_CLOSE:
cSign = 114;// Close
break;
case SC_RESTORE:
cSign = 50;// Restore
break;
}
if(cSign)
{
COLORREF oldColor;
BOOL bBold = (dwStyle&ODS_DEFAULT) ? TRUE : FALSE;
CRect rect(pRect);
rect.InflateRect(0,(m_iconY-rect.Height())>>1);
if( (dwStyle&ODS_GRAYED) || (dwStyle&ODS_INACTIVE))
{
oldColor = pDC->SetTextColor(::GetSysColor(COLOR_GRAYTEXT));
}
else if(dwStyle&ODS_SELECTED)
{
oldColor = pDC->SetTextColor(DarkenColorXP(GetXpHighlightColor()));
rect.OffsetRect(1,1);
DrawSpecialChar(pDC,rect,cSign,bBold);
pDC->SetTextColor(::GetSysColor(COLOR_MENUTEXT));
rect.OffsetRect(-2,-2);
}
else
{
oldColor = pDC->SetTextColor(::GetSysColor(COLOR_MENUTEXT));
}
DrawSpecialChar(pDC,rect,cSign,bBold);
pDC->SetTextColor(oldColor);
}
}
CRect CNewMenu::GetLastActiveMenuRect()
{
return m_LastActiveMenuRect;
}
void CNewMenu::DrawSpecialCharStyle(CDC* pDC, LPCRECT pRect, TCHAR Sign, DWORD dwStyle)
{
COLORREF oldColor;
if( (dwStyle&ODS_GRAYED) || (dwStyle&ODS_INACTIVE))
{
oldColor = pDC->SetTextColor(::GetSysColor(COLOR_GRAYTEXT));
}
else
{
oldColor = pDC->SetTextColor(::GetSysColor(COLOR_MENUTEXT));
}
DrawSpecialChar(pDC,pRect,Sign,(dwStyle&ODS_DEFAULT) ? TRUE : FALSE);
pDC->SetTextColor(oldColor);
}
void CNewMenu::DrawSpecialChar(CDC* pDC, LPCRECT pRect, TCHAR Sign, BOOL bBold)
{
// 48 Min
// 49 Max
// 50 Restore
// 98 Checkmark
// 105 Bullet
// 114 Close
CFont MyFont;
LOGFONT logfont;
CRect rect(pRect);
rect.DeflateRect(2,2);
logfont.lfHeight = -rect.Height();
logfont.lfWidth = 0;
logfont.lfEscapement = 0;
logfont.lfOrientation = 0;
logfont.lfWeight = (bBold) ? FW_BOLD:FW_NORMAL;
logfont.lfItalic = FALSE;
logfont.lfUnderline = FALSE;
logfont.lfStrikeOut = FALSE;
logfont.lfCharSet = DEFAULT_CHARSET;
logfont.lfOutPrecision = OUT_DEFAULT_PRECIS;
logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
logfont.lfQuality = DEFAULT_QUALITY;
logfont.lfPitchAndFamily = DEFAULT_PITCH;
_tcscpy_s(logfont.lfFaceName,ARRAY_SIZE(logfont.lfFaceName),_T("Marlett"));
MyFont.CreateFontIndirect (&logfont);
CFont* pOldFont = pDC->SelectObject (&MyFont);
int OldMode = pDC->SetBkMode(TRANSPARENT);
pDC->DrawText (&Sign,1,rect,DT_CENTER|DT_SINGLELINE);
pDC->SetBkMode(OldMode);
pDC->SelectObject(pOldFont);
}
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMenuTheme::CMenuTheme()
: m_dwThemeId(0),
m_dwFlags(0),
m_pMeasureItem(NULL),
m_pDrawItem(NULL),
m_pDrawTitle(NULL),
m_BorderTopLeft(0,0),
m_BorderBottomRight(0,0)
{
}
CMenuTheme::CMenuTheme( DWORD dwThemeId,
pItemMeasureFkt pMeasureItem,
pItemDrawFkt pDrawItem,
pItemDrawFkt pDrawTitle,
DWORD dwFlags)
:m_dwThemeId(dwThemeId),
m_dwFlags(dwFlags),
m_pMeasureItem(pMeasureItem),
m_pDrawItem(pDrawItem),
m_pDrawTitle(pDrawTitle)
{
UpdateSysColors();
UpdateSysMetrics();
}
CMenuTheme::~CMenuTheme()
{
}
void CMenuTheme::DrawFrame(CDC* pDC, CRect rectOuter, CRect rectInner, COLORREF crBorder)
{
CRect Temp;
rectInner.right -= 1;
// Border top
Temp.SetRect(rectOuter.TopLeft(),CPoint(rectOuter.right,rectInner.top));
pDC->FillSolidRect(Temp,crBorder);
// Border bottom
Temp.SetRect(CPoint(rectOuter.left,rectInner.bottom),rectOuter.BottomRight());
pDC->FillSolidRect(Temp,crBorder);
// Border left
Temp.SetRect(rectOuter.TopLeft(),CPoint(rectInner.left,rectOuter.bottom));
pDC->FillSolidRect(Temp,crBorder);
// Border right
Temp.SetRect(CPoint(rectInner.right,rectOuter.top),rectOuter.BottomRight());
pDC->FillSolidRect(Temp,crBorder);
}
BOOL CMenuTheme::DoDrawBorder()
{
return (m_dwFlags&1)?TRUE:FALSE;
}
void CMenuTheme::DrawSmalBorder( HWND hWnd, HDC hDC)
{
CNewMenuHook::CMenuHookData* pData = CNewMenuHook::GetMenuHookData(hWnd);
if(pData!=NULL)
{
if(pData->m_hMenu)
{
CNewMenu* pMenu = DYNAMIC_DOWNCAST(CNewMenu,CMenu::FromHandlePermanent(pData->m_hMenu));
if(pMenu && pMenu->GetParent())
{
CNewMenu* pParentMenu = DYNAMIC_DOWNCAST(CNewMenu,CMenu::FromHandlePermanent(pMenu->GetParent()));
if(pParentMenu && !pParentMenu->IsPopup())
{
CRect Rect;
// Get the size of the menu...
GetWindowRect(hWnd, Rect );
Rect.OffsetRect(pData->m_Point - Rect.TopLeft());
Rect &= pParentMenu->GetLastActiveMenuRect();
if(!Rect.IsRectEmpty())
{
if(Rect.Width()>Rect.Height())
{
Rect.InflateRect(-1,0);
}
else
{
Rect.InflateRect(0,-1);
}
Rect.OffsetRect(-pData->m_Point);
CDC* pDC = CDC::FromHandle(hDC);
COLORREF colorSmalBorder;
if (NumScreenColors() > 256)
{
colorSmalBorder = MixedColor(CNewMenu::GetMenuBarColor(),GetSysColor(COLOR_WINDOW));
}
else
{
colorSmalBorder = GetSysColor(COLOR_BTNFACE);
}
pDC->FillSolidRect(Rect,colorSmalBorder);
}
}
}
}
}
}
void CMenuTheme::DrawShade( HWND hWnd, HDC hDC, CPoint screen)
{
if(IsShadowEnabled())
return;
// Get the size of the menu...
CRect Rect;
GetWindowRect(hWnd, Rect );
long winW = Rect.Width();
long winH = Rect.Height();
long xOrg = screen.x;
long yOrg = screen.y;
CNewMenuHook::CMenuHookData* pData = CNewMenuHook::GetMenuHookData(hWnd);
CDC* pDC = CDC::FromHandle(hDC);
CDC memDC;
memDC.CreateCompatibleDC(pDC);
CBitmap* pOldBitmap = memDC.SelectObject(&pData->m_Screen);
HDC hDcDsk = memDC.m_hDC;
xOrg = 0;
yOrg = 0;
//// Get the desktop hDC...
//HDC hDcDsk = GetWindowDC(0);
int X,Y;
// Simulate a shadow on right edge...
if (NumScreenColors() <= 256)
{
DWORD rgb = ::GetSysColor(COLOR_BTNSHADOW);
BitBlt(hDC,winW-2,0, 2,winH,hDcDsk,xOrg+winW-2,0,SRCCOPY);
BitBlt(hDC,0,winH-2,winW,2,hDcDsk,0,yOrg+winH-2,SRCCOPY);
for (X=3; X<=4 ;X++)
{
for (Y=0; Y<4 ;Y++)
{
SetPixel(hDC,winW-X,Y,GetPixel(hDcDsk,xOrg+winW-X,yOrg+Y));
}
for (Y=4; Y<8 ;Y++)
{
SetPixel(hDC,winW-X,Y,rgb);
}
for (Y=8; Y<=(winH-5) ;Y++)
{
SetPixel( hDC, winW - X, Y, rgb);
}
for (Y=(winH-4); Y<=(winH-3) ;Y++)
{
SetPixel( hDC, winW - X, Y, rgb);
}
}
// Simulate a shadow on the bottom edge...
for(Y=3; Y<=4 ;Y++)
{
for(X=0; X<=3 ;X++)
{
SetPixel(hDC,X,winH-Y, GetPixel(hDcDsk,xOrg+X,yOrg+winH-Y));
}
for(X=4; X<=7 ;X++)
{
SetPixel( hDC, X, winH - Y, rgb);
}
for(X=8; X<=(winW-5) ;X++)
{
SetPixel( hDC, X, winH - Y, rgb);
}
}
}
else
{
for (X=1; X<=4 ;X++)
{
for (Y=0; Y<4 ;Y++)
{
SetPixel(hDC,winW-X,Y, GetPixel(hDcDsk,xOrg+winW-X,yOrg+Y) );
}
for (Y=4; Y<8 ;Y++)
{
COLORREF c = GetPixel(hDcDsk, xOrg + winW - X, yOrg + Y);
SetPixel(hDC,winW-X,Y,DarkenColor(2* 3 * X * (Y - 3), c));
}
for (Y=8; Y<=(winH-5) ;Y++)
{
COLORREF c = GetPixel(hDcDsk, xOrg + winW - X, yOrg + Y);
SetPixel( hDC, winW - X, Y, DarkenColor(2* 15 * X, c) );
}
for (Y=(winH-4); Y<=(winH-1) ;Y++)
{
COLORREF c = GetPixel(hDcDsk, xOrg + winW - X, yOrg + Y);
SetPixel( hDC, winW - X, Y, DarkenColor(2* 3 * X * -(Y - winH), c));
}
}
// Simulate a shadow on the bottom edge...
for(Y=1; Y<=4 ;Y++)
{
for(X=0; X<=3 ;X++)
{
SetPixel(hDC,X,winH-Y, GetPixel(hDcDsk,xOrg+X,yOrg+winH-Y));
}
for(X=4; X<=7 ;X++)
{
COLORREF c = GetPixel(hDcDsk, xOrg + X, yOrg + winH - Y);
SetPixel( hDC, X, winH - Y, DarkenColor(2*3 * (X - 3) * Y, c));
}
for(X=8; X<=(winW-5) ;X++)
{
COLORREF c = GetPixel(hDcDsk, xOrg + X, yOrg + winH - Y);
SetPixel( hDC, X, winH - Y, DarkenColor(2* 15 * Y, c));
}
}
}
memDC.SelectObject(pOldBitmap);
//// Release the desktop hDC...
//ReleaseDC(0,hDcDsk);
}
#define CX_GRIPPER 3
#define CY_GRIPPER 3
#define CX_BORDER_GRIPPER 2
#define CY_BORDER_GRIPPER 2
void CMenuTheme::UpdateSysColors()
{
clrBtnFace = ::GetSysColor(COLOR_BTNFACE);
clrBtnShadow = ::GetSysColor(COLOR_BTNSHADOW);
clrBtnHilite = ::GetSysColor(COLOR_BTNHIGHLIGHT);
clrBtnText = ::GetSysColor(COLOR_BTNTEXT);
clrWindowFrame = ::GetSysColor(COLOR_WINDOWFRAME);
}
void CMenuTheme::UpdateSysMetrics()
{
m_BorderTopLeft = CSize(2,2);
if(!IsShadowEnabled())
{
m_BorderBottomRight = CSize(5,6);
}
else
{
m_BorderBottomRight = CSize(2,2);
}
}
void CMenuTheme::GetBarColor(COLORREF &clrUpperColor, COLORREF &clrMediumColor, COLORREF &clrBottomColor, COLORREF &clrDarkLine)
{
if(IsMenuThemeActive())
{
COLORREF menuColor = CNewMenu::GetMenuBarColor2003();
// corrections from Andreas Schärer
switch(menuColor)
{
case RGB(163,194,245)://blau
{
clrUpperColor = RGB(221,236,254);
clrMediumColor = RGB(196, 219,249);
clrBottomColor = RGB(129,169,226);
clrDarkLine = RGB(59,97,156);
break;
}
case RGB(215,215,229)://silber
{
clrUpperColor = RGB(243,244,250);
clrMediumColor = RGB(225,226,236);
clrBottomColor = RGB(153,151,181);
clrDarkLine = RGB(124,124,148);
break;
}
case RGB(218,218,170)://olivgrün
{
clrUpperColor = RGB(244,247,222);
clrMediumColor = RGB(209,222,172);
clrBottomColor = RGB(183,198,145);
clrDarkLine = RGB(96,128,88);
break;
}
default:
{
clrUpperColor = LightenColor(140,menuColor);
clrMediumColor = LightenColor(115,menuColor);
clrBottomColor = DarkenColor(40,menuColor);
clrDarkLine = DarkenColor(110,menuColor);
break;
}
}
}
else
{
COLORREF menuColor, menuColor2;
CNewMenu::GetMenuBarColor2003(menuColor, menuColor2, FALSE);
clrUpperColor = menuColor2;
clrBottomColor = menuColor;
clrMediumColor = GetAlphaBlendColor(clrBottomColor, clrUpperColor,100);
clrDarkLine = DarkenColor(50,clrBottomColor);
}
}
void CMenuTheme::PaintCorner(CDC *pDC, LPCRECT pRect, COLORREF color)
{
pDC->SetPixel(pRect->left+1,pRect->top ,color);
pDC->SetPixel(pRect->left+0,pRect->top ,color);
pDC->SetPixel(pRect->left+0,pRect->top+1,color);
pDC->SetPixel(pRect->left+0,pRect->bottom ,color);
pDC->SetPixel(pRect->left+0,pRect->bottom-1,color);
pDC->SetPixel(pRect->left+1,pRect->bottom ,color);
pDC->SetPixel(pRect->right-1,pRect->top ,color);
pDC->SetPixel(pRect->right ,pRect->top ,color);
pDC->SetPixel(pRect->right ,pRect->top+1,color);
pDC->SetPixel(pRect->right-1,pRect->bottom ,color);
pDC->SetPixel(pRect->right ,pRect->bottom ,color);
pDC->SetPixel(pRect->right ,pRect->bottom-1,color);
}
void CMenuTheme::DrawGripper(CDC* pDC, const CRect& rect, DWORD dwStyle,
int m_cxLeftBorder, int m_cxRightBorder,
int m_cyTopBorder, int m_cyBottomBorder)
{
// only draw the gripper if not floating and gripper is specified
if ((dwStyle & (CBRS_GRIPPER|CBRS_FLOATING)) == CBRS_GRIPPER)
{
// draw the gripper in the border
switch (CNewMenu::GetMenuDrawMode())
{
case CNewMenu::STYLE_XP:
case CNewMenu::STYLE_XP_NOBORDER:
{
COLORREF col = DarkenColorXP(CNewMenu::GetMenuBarColorXP());
CPen pen(PS_SOLID,0,col);
CPen* pOld = pDC->SelectObject(&pen);
if (dwStyle & CBRS_ORIENT_HORZ)
{
for (int n=rect.top+m_cyTopBorder+2*CY_BORDER_GRIPPER;n<rect.Height()-m_cyTopBorder-m_cyBottomBorder-4*CY_BORDER_GRIPPER;n+=2)
{
pDC->MoveTo(rect.left+CX_BORDER_GRIPPER+2,n);
pDC->LineTo(rect.left+CX_BORDER_GRIPPER+CX_GRIPPER+2,n);
}
}
else
{
for (int n=rect.top+m_cxLeftBorder+2*CX_BORDER_GRIPPER;n<rect.Width()-m_cxLeftBorder-m_cxRightBorder-2*CX_BORDER_GRIPPER;n+=2)
{
pDC->MoveTo(n,rect.top+CY_BORDER_GRIPPER+2);
pDC->LineTo(n,rect.top+CY_BORDER_GRIPPER+CY_GRIPPER+2);
}
}
pDC->SelectObject(pOld);
}
break;
case CNewMenu::STYLE_ICY:
case CNewMenu::STYLE_ICY_NOBORDER:
{
COLORREF color = DarkenColor(100,CNewMenu::GetMenuColor());
if (dwStyle & CBRS_ORIENT_HORZ)
{
for (int n=rect.top+m_cyTopBorder+2*CY_BORDER_GRIPPER;n<rect.Height()-m_cyTopBorder-m_cyBottomBorder-4*CY_BORDER_GRIPPER;n+=4)
{
pDC->FillSolidRect(rect.left+CX_BORDER_GRIPPER+2+m_cxLeftBorder,n +1,2,2,color);
}
}
else
{
for (int n=rect.top+m_cxLeftBorder+2*CX_BORDER_GRIPPER;n<rect.Width()-m_cxRightBorder-2*CX_BORDER_GRIPPER;n+=4)
{
pDC->FillSolidRect(n, rect.top+CY_BORDER_GRIPPER+2+m_cxLeftBorder,2,2,color);
}
}
}
break;
case CNewMenu::STYLE_XP_2003_NOBORDER:
case CNewMenu::STYLE_XP_2003:
case CNewMenu::STYLE_COLORFUL_NOBORDER:
case CNewMenu::STYLE_COLORFUL:
{
COLORREF clrUpperColor, clrMediumColor, clrBottomColor, clrDarkLine;
CNewMenu::GetActualMenuTheme()->GetBarColor(clrUpperColor,clrMediumColor,clrBottomColor,clrDarkLine);
COLORREF color1 = GetSysColor(COLOR_WINDOW);
//COLORREF color2 = DarkenColor(40,MidColor(GetSysColor(COLOR_BTNFACE),color1));
if (dwStyle & CBRS_ORIENT_HORZ)
{
for (int n=rect.top+m_cyTopBorder+2*CY_BORDER_GRIPPER;n<rect.Height()-m_cyTopBorder-m_cyBottomBorder-4*CY_BORDER_GRIPPER;n+=4)
{
pDC->FillSolidRect(rect.left+CX_BORDER_GRIPPER+3+m_cxLeftBorder,n+1+1,2,2,color1);
pDC->FillSolidRect(rect.left+CX_BORDER_GRIPPER+2+m_cxLeftBorder,n +1,2,2,clrDarkLine);
}
}
else
{
for (int n=rect.top+m_cxLeftBorder+2*CX_BORDER_GRIPPER;n<rect.Width()-m_cxRightBorder-2*CX_BORDER_GRIPPER;n+=4)
{
pDC->FillSolidRect(n+1,rect.top+CY_BORDER_GRIPPER+3+m_cxLeftBorder,2,2,color1);
pDC->FillSolidRect(n, rect.top+CY_BORDER_GRIPPER+2+m_cxLeftBorder,2,2,clrDarkLine);
}
}
}
break;
default:
{
//BPO late this can be eliminated (cached?)
clrBtnShadow = ::GetSysColor(COLOR_BTNSHADOW);
clrBtnHilite = ::GetSysColor(COLOR_BTNHIGHLIGHT);
CRect temp = rect;
//temp.left+=2;
if (dwStyle & CBRS_ORIENT_HORZ)
{
pDC->Draw3dRect(rect.left+CX_BORDER_GRIPPER+m_cxLeftBorder,
rect.top+m_cyTopBorder,
CX_GRIPPER, rect.Height()-m_cyTopBorder-m_cyBottomBorder,
clrBtnHilite, clrBtnShadow);
}
else
{
temp.top+=2;
pDC->Draw3dRect(rect.left+m_cyTopBorder,
rect.top+CY_BORDER_GRIPPER,
rect.Width()-m_cyTopBorder-m_cyBottomBorder, CY_GRIPPER,
clrBtnHilite, clrBtnShadow);
}
}
break;
}
}
}
void CMenuTheme::DrawCorner(CDC* pDC, LPCRECT pRect, DWORD dwStyle)
{
if ((dwStyle & (CBRS_GRIPPER|CBRS_FLOATING)) == CBRS_GRIPPER)
{
// draw the gripper in the border
switch (CNewMenu::GetMenuDrawMode())
{
case CNewMenu::STYLE_ICY:
case CNewMenu::STYLE_ICY_NOBORDER:
{
// make round corners
COLORREF color = GetSysColor(COLOR_3DLIGHT);
PaintCorner(pDC,pRect,color);
}
break;
case CNewMenu::STYLE_XP_2003_NOBORDER:
case CNewMenu::STYLE_XP_2003:
case CNewMenu::STYLE_COLORFUL_NOBORDER:
case CNewMenu::STYLE_COLORFUL:
{
// make round corners
COLORREF color = CNewMenu::GetMenuBarColor2003();
PaintCorner(pDC,pRect,color);
}
break;
}
}
}
void SetWindowShade(HWND hWndMenu, CNewMenuHook::CMenuHookData* pData );
#define CMS_MENUFADE 175
#define MENU_TIMER_ID 0x1234
BOOL CMenuTheme::OnInitWnd(HWND hWnd)
{
CNewMenuHook::CMenuHookData* pData = CNewMenuHook::GetMenuHookData(hWnd);
ASSERT(pData);
if( pData->m_bDoSubclass)
{
if(!DoDrawBorder())
{
if(g_Shell>=Win2000 && CNewMenu::GetAlpha()!=255)
{
// Flag for changing styles
pData->m_dwData |= 2;
SetWindowLongPtr (hWnd, GWL_EXSTYLE,(pData->m_dwExStyle| WS_EX_LAYERED));
SetLayeredWindowAttributes(hWnd, 0, CNewMenu::GetAlpha(), LWA_ALPHA);
pData->m_dwData |= 4;
SetTimer(hWnd,MENU_TIMER_ID,50,NULL);
}
}
else
{
// Flag for changing styles
pData->m_dwData |= 2;
SetWindowLongPtr (hWnd, GWL_STYLE, pData->m_dwStyle & (~WS_BORDER) );
if(g_Shell>=Win2000 && CNewMenu::GetAlpha()!=255)
{
SetWindowLongPtr (hWnd, GWL_EXSTYLE,(pData->m_dwExStyle| WS_EX_LAYERED) & ~(WS_EX_WINDOWEDGE|WS_EX_DLGMODALFRAME));
SetLayeredWindowAttributes(hWnd, 0, CNewMenu::GetAlpha(), LWA_ALPHA);
pData->m_dwData |= 4;
SetTimer(hWnd,MENU_TIMER_ID,50,NULL);
//RedrawWindow(hWnd,NULL,NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
}
else
{
SetWindowLongPtr (hWnd, GWL_EXSTYLE,pData->m_dwExStyle & ~(WS_EX_WINDOWEDGE|WS_EX_DLGMODALFRAME));
}
//if(!IsShadowEnabled())
//{
// BOOL bAnimate = FALSE;
// if(SystemParametersInfo(SPI_GETMENUANIMATION,0,&bAnimate,0) && bAnimate==TRUE)
// {
// // All menuanimation should be terminated after 200 ms
// pData->m_TimerID = GetSafeTimerID(hWnd,200);
// }
// else
// {
// pData->m_TimerID = GetSafeTimerID(hWnd,500);
// //SetWindowShade(hWnd, pData);
// }
//}
return TRUE;
}
}
return FALSE;
}
BOOL CMenuTheme::OnUnInitWnd(HWND hWnd)
{
CNewMenuHook::CMenuHookData* pData = CNewMenuHook::GetMenuHookData(hWnd);
if(pData)
{
if(pData->m_dwData&4)
{
KillTimer(hWnd,MENU_TIMER_ID);
pData->m_dwData &= ~4;
}
HMENU hMenu = pData->m_hMenu;
if(IsMenu(hMenu))
{
CNewMenu* pNewMenu = DYNAMIC_DOWNCAST(CNewMenu,CMenu::FromHandlePermanent(hMenu));
if(pNewMenu)
{
// Redraw menubar on place.
pNewMenu->OnUnInitPopupMenu();
}
}
//// Destroy object and window for shading support
//if(pData->m_TimerID)
//{
// KillTimer(hWnd,pData->m_TimerID);
// pData->m_TimerID = NULL;
//}
//if(pData->m_hRightShade)
//{
// DestroyWindow(pData->m_hRightShade);
// pData->m_hRightShade = NULL;
//}
//if(pData->m_hBottomShade)
//{
// DestroyWindow(pData->m_hBottomShade);
// pData->m_hBottomShade = NULL;
//}
// were windows-style changed?
if(pData->m_dwData&2)
{
SetLastError(0);
if(!(pData->m_dwData&1))
{
SetWindowLongPtr (hWnd, GWL_STYLE,pData->m_dwStyle);
ShowLastError(_T("Error from Menu: SetWindowLongPtr I"));
}
else
{
// Restore old Styles for special menu!!
// (Menu 0x10012!!!) special VISIBLE flag must be set
SetWindowLongPtr (hWnd, GWL_STYLE,pData->m_dwStyle|WS_VISIBLE);
ShowLastError(_T("Error from Menu: SetWindowLongPtr I, Special"));
}
SetWindowLongPtr (hWnd, GWL_EXSTYLE, pData->m_dwExStyle);
ShowLastError(_T("Error from Menu: SetWindowLongPtr II"));
// Normaly when you change the style you shold call next function
// but in this case you would lose the focus for the menu!!
//SetWindowPos(hWnd,0,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED|SWP_HIDEWINDOW);
}
}
return TRUE;
}
BOOL CMenuTheme::OnEraseBkgnd(HWND hWnd, HDC hDC)
{
// CNewMenuHook::CMenuHookData* pData = CNewMenuHook::GetMenuHookData(hWnd);
// Get the size of the menu...
CDC* pDC = CDC::FromHandle (hDC);
CRect Rect;
GetClientRect(hWnd, Rect );
if(DoDrawBorder())
{
Rect.InflateRect(+2,0,-1,0);
}
else
{
Rect.InflateRect(+2,0,0,0);
}
pDC->FillSolidRect (Rect,CNewMenu::GetMenuColor(0));//GetSysColor(COLOR_MENU));
return TRUE;
}
BOOL CMenuTheme::OnWindowPosChanging(HWND hWnd, LPWINDOWPOS pPos)
{
UNREFERENCED_PARAMETER(hWnd);
if(DoDrawBorder())
{
#ifdef _TRACE_MENU_
AfxTrace(_T("WindowPosChanging hwnd=0x%lX, (%ld,%ld)(%ld,%ld)\n"),hWnd,pPos->x,pPos->y,pPos->cx,pPos->cy);
#endif
if(!IsShadowEnabled())
{
pPos->cx +=2;
pPos->cy +=2;
}
else
{
pPos->cx -=2;
pPos->cy -=2;
}
pPos->y -=1;
#ifdef _TRACE_MENU_
AfxTrace(_T("WindowPosChanged hwnd=0x%lX, (%ld,%ld)(%ld,%ld)\n"),hWnd,pPos->x,pPos->y,pPos->cx,pPos->cy);
#endif
return TRUE;
}
return FALSE;
}
BOOL CMenuTheme::OnNcCalcSize(HWND hWnd, NCCALCSIZE_PARAMS* pCalc)
{
UNREFERENCED_PARAMETER(hWnd);
if(DoDrawBorder())
{
#ifdef _TRACE_MENU_
AfxTrace(_T("OnNcCalcSize 0 hwnd=0x%lX, (top=%ld,bottom=%ld,left=%ld,right=%ld)\n"),hWnd,pCalc->rgrc->top,pCalc->rgrc->bottom,pCalc->rgrc->left,pCalc->rgrc->right);
#endif
int cx=0,cy=0;
if(!IsShadowEnabled())
{
cx = 5;
cy = 6;
}
else
{
cx = 1;
cy = 2;
}
pCalc->rgrc->top += m_BorderTopLeft.cy;
pCalc->rgrc->left += m_BorderTopLeft.cx;
pCalc->rgrc->bottom -= cy;
pCalc->rgrc->right -= cx;
#ifdef _TRACE_MENU_
AfxTrace(_T("OnNcCalcSize 0 hwnd=0x%lX, (top=%ld,bottom=%ld,left=%ld,right=%ld)\n"),hWnd,pCalc->rgrc->top,pCalc->rgrc->bottom,pCalc->rgrc->left,pCalc->rgrc->right);
AfxTrace(_T("OnNcCalcSize 2 hwnd=0x%lX, (top=%ld,bottom=%ld,left=%ld,right=%ld)\n"),hWnd,pCalc->rgrc[2].top,pCalc->rgrc[2].bottom,pCalc->rgrc[2].left,pCalc->rgrc[2].right);
#endif
//WNDPROC oldWndProc = (WNDPROC)::GetProp(hWnd, _OldMenuProc);
//LRESULT result = NULL;
//BOOL bCallDefault = TRUE;
//result = CallWindowProc(oldWndProc, hWnd, uMsg, wParam, lParam);
//return true;
}
return FALSE;
}
BOOL CMenuTheme::OnCalcFrameRect(HWND hWnd,LPRECT pRect)
{
if(GetWindowRect(hWnd,pRect))
{
if(DoDrawBorder())
{
pRect->top += 2;
pRect->left += 2;
if(!IsShadowEnabled())
{
pRect->bottom -= 7;
pRect->right -= 7;
}
else
{
pRect->bottom -= 3;
pRect->right -= 3;
}
}
return TRUE;
}
return FALSE;
}
void* CMenuTheme::SetScreenBitmap(HWND hWnd, HDC hDC)
{
UNREFERENCED_PARAMETER(hDC);
CNewMenuHook::CMenuHookData* pData = CNewMenuHook::GetMenuHookData(hWnd);
if(pData->m_Screen.m_hObject==NULL)
{
// Get the desktop hDC...
HDC hDcDsk = GetWindowDC(0);
CDC* pDcDsk = CDC::FromHandle(hDcDsk);
CDC dc;
dc.CreateCompatibleDC(pDcDsk);
CRect rect;
GetWindowRect(hWnd,rect);
pData->m_Screen.CreateCompatibleBitmap(pDcDsk,rect.Width()+10,rect.Height()+10);
CBitmap* pOldBitmap = dc.SelectObject(&pData->m_Screen);
dc.BitBlt(0,0,rect.Width()+10,rect.Height()+10,pDcDsk,pData->m_Point.x,pData->m_Point.y,SRCCOPY);
dc.SelectObject(pOldBitmap);
// Release the desktop hDC...
ReleaseDC(0,hDcDsk);
}
return pData;
}
BOOL CMenuTheme::OnDrawBorder(HWND hWnd, HDC hDC, BOOL bOnlyBorder)
{
CNewMenuHook::CMenuHookData* pData = (CNewMenuHook::CMenuHookData*)SetScreenBitmap(hWnd,hDC);
if(DoDrawBorder() && pData)
{
CRect rect;
CRect client;
CDC* pDC = CDC::FromHandle (hDC);
// Get the size of the menu...
GetWindowRect(hWnd, rect );
GetClientRect(hWnd, client);
CPoint offset(0,0);
ClientToScreen(hWnd,&offset);
client.OffsetRect(offset-rect.TopLeft());
long winW = rect.Width();
long winH = rect.Height();
if(!IsShadowEnabled())
{
if(!bOnlyBorder)
{
DrawFrame(pDC,CRect(CPoint(1,1),CSize(winW-6,winH-6)),client,CNewMenu::GetMenuColor());
}
if(bHighContrast)
{
pDC->Draw3dRect(CRect(CPoint(0,0),CSize(winW-4,winH-4)),GetSysColor(COLOR_BTNTEXT ),GetSysColor(COLOR_BTNTEXT ));
}
else
{
pDC->Draw3dRect(CRect(CPoint(0,0),CSize(winW-4,winH-4)),GetSysColor(COLOR_HIGHLIGHT),GetSysColor(COLOR_HIGHLIGHT));
DrawShade(hWnd,hDC,pData->m_Point);
}
}
else
{
if(!bOnlyBorder)
{
DrawFrame(pDC,CRect(CPoint(1,1),CSize(winW-2,winH-2)),client,CNewMenu::GetMenuColor());
//pDC->FillSolidRect(winW-2,2,2,winH-2,RGB(0,0,255));
}
if(bHighContrast)
{
pDC->Draw3dRect(CRect(CPoint(0,0),CSize(winW-0,winH-0)),GetSysColor(COLOR_BTNTEXT ),GetSysColor(COLOR_BTNTEXT ));
}
else
{
pDC->Draw3dRect(CRect(CPoint(0,0),CSize(winW-0,winH-0)),GetSysColor(COLOR_HIGHLIGHT),GetSysColor(COLOR_HIGHLIGHT));
}
}
//DrawSmalBorder(hWnd,hDC);
return TRUE;
}
return FALSE;
}
CMenuThemeXP::CMenuThemeXP(DWORD dwThemeId,
pItemMeasureFkt pMeasureItem,
pItemDrawFkt pDrawItem,
pItemDrawFkt pDrawTitle,
DWORD dwFlags)
:CMenuTheme(dwThemeId,pMeasureItem,pDrawItem,pDrawTitle,dwFlags)
{
}
BOOL CMenuThemeXP::OnDrawBorder(HWND hWnd, HDC hDC, BOOL bOnlyBorder)
{
CNewMenuHook::CMenuHookData* pData = (CNewMenuHook::CMenuHookData*)SetScreenBitmap(hWnd,hDC);
if(DoDrawBorder() && pData)
{
UINT nMenuDrawMode = CNewMenu::GetMenuDrawMode();
CRect rect;
CRect client;
CDC* pDC = CDC::FromHandle (hDC);
// Get the size of the menu...
GetWindowRect(hWnd, rect );
GetClientRect(hWnd,client);
CPoint offset(0,0);
ClientToScreen(hWnd,&offset);
client.OffsetRect(offset-rect.TopLeft());
long winW = rect.Width();
long winH = rect.Height();
// Same Color as in DrawItem_WinXP
COLORREF crMenuBar = CNewMenu::GetMenuColor(pData->m_hMenu);
COLORREF crWindow = GetSysColor(COLOR_WINDOW);
COLORREF crThinBorder = MixedColor(crWindow,crMenuBar);
COLORREF clrBorder = DarkenColor(128,crMenuBar);
COLORREF colorBitmap;
if (NumScreenColors() > 256)
{
colorBitmap = MixedColor(crMenuBar,crWindow);
}
else
{
colorBitmap = GetSysColor(COLOR_BTNFACE);
}
// Better contrast when you have less than 256 colors
if(pDC->GetNearestColor(crThinBorder)==pDC->GetNearestColor(colorBitmap))
{
crThinBorder = crWindow;
colorBitmap = crMenuBar;
}
if(!IsShadowEnabled())
{
if(!bOnlyBorder)
{
DrawFrame(pDC,CRect(CPoint(1,1),CSize(winW-6,winH-6)),client,crThinBorder);
}
if(bHighContrast)
{
pDC->Draw3dRect(CRect(CPoint(0,0),CSize(winW-4,winH-4)),GetSysColor(COLOR_BTNTEXT),GetSysColor(COLOR_BTNTEXT));
}
else
{
pDC->Draw3dRect(CRect(CPoint(1,1),CSize(winW-6,winH-6)),crThinBorder,crThinBorder);
pDC->FillSolidRect(1,2,1,winH-8,colorBitmap);
pDC->Draw3dRect(CRect(CPoint(0,0),CSize(winW-4,winH-4)),clrBorder,clrBorder);
DrawShade(hWnd,pDC->m_hDC,pData->m_Point);
}
}
else
{
if(!bOnlyBorder)
{
DrawFrame(pDC,CRect(CPoint(1,1),CSize(winW-2,winH-2)),client,crThinBorder);
}
if(bHighContrast)
{
pDC->Draw3dRect(CRect(CPoint(0,0),CSize(winW-0,winH-0)),GetSysColor(COLOR_BTNTEXT ),GetSysColor(COLOR_BTNTEXT ));
}
else
{
pDC->Draw3dRect(CRect(CPoint(1,1),CSize(winW-2,winH-2)),crThinBorder,crThinBorder);
if(nMenuDrawMode==CNewMenu::STYLE_XP_2003 || nMenuDrawMode==CNewMenu::STYLE_XP_2003_NOBORDER)
{
pDC->FillSolidRect(1,2,1,winH-4,crWindow);
}
else
{
pDC->FillSolidRect(1,2,1,winH-4,colorBitmap);
}
pDC->Draw3dRect(CRect(CPoint(0,0),CSize(winW-0,winH-0)),clrBorder,clrBorder);
}
}
DrawSmalBorder(hWnd,pDC->m_hDC);
return TRUE;
}
return FALSE;
}
BOOL CMenuThemeXP::OnEraseBkgnd(HWND hWnd, HDC hDC)
{
CNewMenuHook::CMenuHookData* pData = CNewMenuHook::GetMenuHookData(hWnd);
if(pData->m_hMenu==NULL)
{
return CMenuTheme::OnEraseBkgnd(hWnd,hDC);
}
// Get the size of the menu...
CDC* pDC = CDC::FromHandle (hDC);
CRect Rect;
GetClientRect(hWnd, Rect );
if(DoDrawBorder())
{
Rect.InflateRect(+2,0,-1,0);
}
else
{
Rect.InflateRect(+2,0,0,0);
}
//BPO!!!!!!!!!! fehler Zeichnet auch in den rand hinein 2
//pDC->FillSolidRect (Rect,CNewMenu::GetMenuColor());
pDC->FillSolidRect (Rect,CNewMenu::GetMenuBarColor(pData->m_hMenu));
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMenuTheme2003 for drawing border and the rest
CMenuTheme2003::CMenuTheme2003( DWORD dwThemeId,
pItemMeasureFkt pMeasureItem,
pItemDrawFkt pDrawItem,
pItemDrawFkt pDrawTitle,
DWORD dwFlags)
: CMenuThemeXP(dwThemeId,pMeasureItem,pDrawItem,pDrawTitle,dwFlags)
{
}
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
const TCHAR _OldMenuProc[] = _T("OldMenuProc");
HMODULE CNewMenuHook::m_hLibrary = NULL;
HMODULE CNewMenuHook::m_hThemeLibrary = NULL;
HHOOK CNewMenuHook::HookOldMenuCbtFilter = NULL;
HMENU CNewMenuHook::m_hLastMenu = NULL;
DWORD CNewMenuHook::m_dwMsgPos = 0;
DWORD CNewMenuHook::m_bSubclassFlag = 0;
#ifdef _TRACE_MENU_LOGFILE
HANDLE CNewMenuHook::m_hLogFile = INVALID_HANDLE_VALUE;
#endif //_TRACE_MENU_LOGFILE
CTypedPtrList<CPtrList, CMenuTheme*>* CNewMenuHook::m_pRegisteredThemesList = NULL;
CTypedPtrMap<CMapPtrToPtr,HWND,CNewMenuHook::CMenuHookData*> CNewMenuHook::m_MenuHookData;
#ifndef SM_REMOTESESSION
#define SM_REMOTESESSION 0x1000
#endif
CNewMenuHook::CNewMenuHook()
{
if(g_Shell>=Win2000 && GetSystemMetrics(SM_REMOTESESSION))
{
bRemoteSession=TRUE;
}
{ // Detecting wine because we have some issue
HMODULE hModule = GetModuleHandle(_T("kernel32.dll"));
bWine = hModule && GetProcAddress(hModule,"wine_get_unix_file_name");
// if(Wine)
// {
// MessageBox(NULL,_T("We are running under wine!!"),_T("wine detected"),MB_OK);
// }
}
HIGHCONTRAST highcontrast = {0};
highcontrast.cbSize = sizeof(highcontrast);
if(SystemParametersInfo(SPI_GETHIGHCONTRAST,sizeof(highcontrast),&highcontrast,0) )
{
bHighContrast = ((highcontrast.dwFlags&HCF_HIGHCONTRASTON)!=0);
}
#ifdef _TRACE_MENU_LOGFILE
m_hLogFile = CreateFile(_T("c:\\NewMenuLog.txt"), GENERIC_WRITE, FILE_SHARE_WRITE,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(m_hLogFile!=INVALID_HANDLE_VALUE)
{
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_WARN, m_hLogFile);
_RPT0(_CRT_WARN,_T("file message\n"));
}
#endif // _TRACE_MENU_LOGFILE
// Try to load theme library from XP
m_hThemeLibrary = LoadLibrary(_T("uxtheme.dll"));
if(m_hThemeLibrary)
{
pIsThemeActive = (FktIsThemeActive)GetProcAddress(m_hThemeLibrary,"IsThemeActive");
pSetWindowTheme = (FktSetWindowTheme)GetProcAddress(m_hThemeLibrary,"SetWindowTheme");
}
else
{
pIsThemeActive = NULL;
}
// Try to load the library for gradient drawing
m_hLibrary = LoadLibrary(_T("Msimg32.dll"));
// Don't use the gradientfill under Win98 because it is buggy!!!
if(g_Shell!=Win98 && m_hLibrary)
{
pGradientFill = (FktGradientFill)GetProcAddress(m_hLibrary,"GradientFill");
}
else
{
pGradientFill = NULL;
}
AddTheme(new CMenuTheme(CNewMenu::STYLE_ICY,
&CNewMenu::MeasureItem_Icy,
&CNewMenu::DrawItem_Icy,
&CNewMenu::DrawMenuTitle,TRUE));
AddTheme(new CMenuTheme(CNewMenu::STYLE_ICY_NOBORDER,
&CNewMenu::MeasureItem_Icy,
&CNewMenu::DrawItem_Icy,
&CNewMenu::DrawMenuTitle));
AddTheme(new CMenuTheme(CNewMenu::STYLE_ORIGINAL,
&CNewMenu::MeasureItem_OldStyle,
&CNewMenu::DrawItem_OldStyle,
&CNewMenu::DrawMenuTitle,TRUE));
AddTheme(new CMenuTheme(CNewMenu::STYLE_ORIGINAL_NOBORDER,
&CNewMenu::MeasureItem_OldStyle,
&CNewMenu::DrawItem_OldStyle,
&CNewMenu::DrawMenuTitle));
AddTheme(new CMenuThemeXP(CNewMenu::STYLE_XP,
&CNewMenu::MeasureItem_WinXP,
&CNewMenu::DrawItem_WinXP,
&CNewMenu::DrawMenuTitle,TRUE));
AddTheme(new CMenuThemeXP(CNewMenu::STYLE_XP_NOBORDER,
&CNewMenu::MeasureItem_WinXP,
&CNewMenu::DrawItem_WinXP,
&CNewMenu::DrawMenuTitle));
AddTheme(new CMenuTheme2003(CNewMenu::STYLE_XP_2003,
&CNewMenu::MeasureItem_WinXP,
&CNewMenu::DrawItem_XP_2003,
&CNewMenu::DrawMenuTitle,TRUE));
AddTheme(new CMenuTheme2003(CNewMenu::STYLE_XP_2003_NOBORDER,
&CNewMenu::MeasureItem_WinXP,
&CNewMenu::DrawItem_XP_2003,
&CNewMenu::DrawMenuTitle));
AddTheme(new CMenuThemeXP(CNewMenu::STYLE_COLORFUL,
&CNewMenu::MeasureItem_WinXP,
&CNewMenu::DrawItem_XP_2003,
&CNewMenu::DrawMenuTitle,TRUE));
AddTheme(new CMenuThemeXP(CNewMenu::STYLE_COLORFUL_NOBORDER,
&CNewMenu::MeasureItem_WinXP,
&CNewMenu::DrawItem_XP_2003,
&CNewMenu::DrawMenuTitle));
AddTheme(new CMenuTheme(CNewMenu::STYLE_SPECIAL,
&CNewMenu::MeasureItem_OldStyle,
&CNewMenu::DrawItem_SpecialStyle,
&CNewMenu::DrawMenuTitle,TRUE));
AddTheme(new CMenuTheme(CNewMenu::STYLE_SPECIAL_NOBORDER,
&CNewMenu::MeasureItem_OldStyle,
&CNewMenu::DrawItem_SpecialStyle,
&CNewMenu::DrawMenuTitle));
// CNewMenu::m_pActMenuDrawing = FindTheme(CNewMenu::STYLE_ORIGINAL);
// CNewMenu::m_pActMenuDrawing = FindTheme(CNewMenu::STYLE_ORIGINAL_NOBORDER);
CNewMenu::m_pActMenuDrawing = FindTheme(CNewMenu::STYLE_XP);
// CNewMenu::m_pActMenuDrawing = FindTheme(CNewMenu::STYLE_XP_NOBORDER);
if (HookOldMenuCbtFilter == NULL)
{
HookOldMenuCbtFilter = ::SetWindowsHookEx(WH_CALLWNDPROC, NewMenuHook, NULL, ::GetCurrentThreadId());
if (HookOldMenuCbtFilter == NULL)
{
ShowLastError(_T("Error from Menu: SetWindowsHookEx"));
AfxThrowMemoryException();
}
}
}
CNewMenuHook::~CNewMenuHook()
{
if (HookOldMenuCbtFilter != NULL)
{
if(!::UnhookWindowsHookEx(HookOldMenuCbtFilter))
{
ShowLastError(_T("Error from Menu: UnhookWindowsHookEx"));
}
HookOldMenuCbtFilter = NULL;
}
// Destroy all registered themes.
if( m_pRegisteredThemesList!= NULL)
{
while(m_pRegisteredThemesList->GetCount())
{
CMenuTheme* pTheme = m_pRegisteredThemesList->RemoveTail();
delete pTheme;
}
delete m_pRegisteredThemesList;
m_pRegisteredThemesList = NULL;
}
pIsThemeActive = NULL;
FreeLibrary(m_hThemeLibrary);
pGradientFill = NULL;
FreeLibrary(m_hLibrary);
// Cleanup for shared menu icons
if(CNewMenu::m_pSharedMenuIcons)
{
delete CNewMenu::m_pSharedMenuIcons;
CNewMenu::m_pSharedMenuIcons = NULL;
}
#ifdef _TRACE_MENU_LOGFILE
if(m_hLogFile!=INVALID_HANDLE_VALUE)
{
CloseHandle(m_hLogFile);
m_hLogFile = INVALID_HANDLE_VALUE;
}
#endif
}
BOOL CNewMenuHook::AddTheme(CMenuTheme* pTheme)
{
if( m_pRegisteredThemesList== NULL)
{
m_pRegisteredThemesList = new CTypedPtrList<CPtrList, CMenuTheme*>;
}
if(m_pRegisteredThemesList->Find(pTheme))
{
return FALSE;
}
m_pRegisteredThemesList->AddTail(pTheme);
return TRUE;
}
CMenuTheme* CNewMenuHook::RemoveTheme(DWORD dwThemeId)
{
CMenuTheme* pTheme = FindTheme(dwThemeId);
if(pTheme==NULL)
{
return NULL;
}
POSITION pos = m_pRegisteredThemesList->Find(pTheme);
ASSERT(pos);
if(pos)
{
m_pRegisteredThemesList->RemoveAt(pos);
if(m_pRegisteredThemesList->GetCount()==NULL)
{
// Destroy the empty list.
delete m_pRegisteredThemesList;
m_pRegisteredThemesList = NULL;
}
}
return pTheme;
}
CMenuTheme* CNewMenuHook::FindTheme(DWORD dwThemeId)
{
if(m_pRegisteredThemesList==NULL)
{
return NULL;
}
POSITION pos = m_pRegisteredThemesList->GetHeadPosition();
while(pos)
{
CMenuTheme* pTheme = m_pRegisteredThemesList->GetNext(pos);
if(pTheme->m_dwThemeId==dwThemeId)
{
return pTheme;
}
}
return NULL;
}
CNewMenuHook::CMenuHookData* CNewMenuHook::GetMenuHookData(HWND hWnd)
{
CMenuHookData* pData=NULL;
if(m_MenuHookData.Lookup(hWnd,pData))
{
return pData;
}
return NULL;
}
void CNewMenuHook::UnsubClassMenu(HWND hWnd)
{
AFX_MANAGE_STATE(AfxGetModuleState());
WNDPROC oldWndProc = (WNDPROC)::GetProp(hWnd, _OldMenuProc);
ASSERT(oldWndProc != NULL);
SetLastError(0);
if(!SetWindowLongPtr(hWnd, GWLP_WNDPROC, (INT_PTR)oldWndProc))
{
ShowLastError(_T("Error from Menu: SetWindowLongPtr III"));
}
RemoveProp(hWnd, _OldMenuProc);
GlobalDeleteAtom(GlobalFindAtom(_OldMenuProc));
// now Clean up
HMENU hMenu = NULL;
// Restore old Styles for special menu!! (Menu 0x10012!!!)
CMenuHookData* pData = GetMenuHookData(hWnd);
if(pData)
{
hMenu = pData->m_hMenu;
CNewMenu::m_pActMenuDrawing->OnUnInitWnd(hWnd);
m_MenuHookData.RemoveKey(hWnd);
delete pData;
}
#ifdef _TRACE_MENU_
AfxTrace(_T("Unsubclass Menu=0x%lX, hwnd=0x%lX\n"),hMenu,hWnd);
#endif
}
LRESULT CALLBACK CNewMenuHook::SubClassMenu(HWND hWnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam) // second message parameter
{
AFX_MANAGE_STATE(AfxGetModuleState());
WNDPROC oldWndProc = (WNDPROC)::GetProp(hWnd, _OldMenuProc);
LRESULT result = NULL;
BOOL bCallDefault = TRUE;
#ifdef _TRACE_MENU_
static long NestedLevel = 0;
NestedLevel++;
MSG msg = {hWnd,uMsg,wParam,lParam,0,0,0};
TCHAR Buffer[30];
wsprintf(Buffer,_T("Level %02ld"),NestedLevel);
MyTraceMsg(Buffer,&msg);
#endif
CMenuHookData* pData = GetMenuHookData(hWnd);
if(NULL == pData)
{
return ::CallWindowProc(oldWndProc, hWnd, uMsg, wParam, lParam);
}
ASSERT(pData);
switch(uMsg)
{
case WM_NCPAINT:
ASSERT(pData);
if(pData->m_bDoSubclass)
{
#ifdef _TRACE_MENU_
AfxTrace(_T("WM_NCPAINT (0x%x) 0x%X, 0x%X\n"),hWnd,wParam,lParam);
#endif
if(!pData->m_bDrawBorder)
{
if(pData->m_hRgn!=(HRGN)wParam)
{
if(pData->m_hRgn!=(HRGN)1)
{
DeleteObject(pData->m_hRgn);
pData->m_hRgn=(HRGN)1;
}
if(wParam!=1)
{
CRgn dest;
dest.CreateRectRgn( 0, 0, 1, 1);
dest.CopyRgn(CRgn::FromHandle((HRGN)wParam));
pData->m_hRgn = (HRGN)dest.Detach();
}
}
}
if(pData->m_dwData&8)
{
// do not call default!!!
bCallDefault=FALSE;
}
if(pData->m_bDrawBorder && CNewMenu::m_pActMenuDrawing->DoDrawBorder())
{
//HDC hDC = GetWindowDC(hWnd);
HDC hDC;
//if(wParam!=1)
// hDC = GetDCEx(hWnd, (HRGN)wParam, DCX_WINDOW|DCX_INTERSECTRGN);
//else
hDC = GetWindowDC (hWnd);
#ifdef _TRACE_MENU_
if(wParam!=1)
{
DWORD dwCount = GetRegionData((HRGN)wParam,0,0);
RGNDATA* pRegionData = (RGNDATA*)_alloca(dwCount);
GetRegionData((HRGN)wParam,dwCount,pRegionData);
TRACE(_T("WM_NCPAINT (0x%x) region %ld "),hWnd,pRegionData->rdh.nCount);
CRect* pRect = (CRect*)pRegionData->Buffer;
for(DWORD n=0; n<pRegionData->rdh.nCount; n++)
{
TRACE( _T("(%ld,%ld,%ld,%ld)"),pRect[n].left,pRect[n].top,pRect[n].right,pRect[n].bottom);
}
TRACE(_T("\r\n"));
}
#endif // _TRACE_MENU_
if(hDC)
{
if(CNewMenu::m_pActMenuDrawing->OnDrawBorder(hWnd,hDC))
{
CRect rect;
if(CNewMenu::m_pActMenuDrawing->OnCalcFrameRect(hWnd,rect))
{
CRgn rgn;
rect.InflateRect(-1,-1);
rgn.CreateRectRgnIndirect(rect);
// do we need a combination of the regions?
//if(wParam!=1)
//{
// rgn.CombineRgn(&rgn,CRgn::FromHandle((HRGN)wParam),RGN_AND);
//}
ASSERT(oldWndProc);
bCallDefault=FALSE;
result = CallWindowProc(oldWndProc, hWnd, uMsg, (WPARAM)rgn.m_hObject, lParam);
//result = CallWindowProc(oldWndProc, hWnd, uMsg, wParam, lParam);
// Redraw the border and shade
CNewMenu::m_pActMenuDrawing->OnDrawBorder(hWnd,hDC,true);
}
}
ReleaseDC(hWnd,hDC);
}
}
if(CNewMenu::m_pActMenuDrawing->DoDrawBorder() && bCallDefault)
{
// Save the background
HDC hDC = GetWindowDC (hWnd);
CNewMenu::m_pActMenuDrawing->SetScreenBitmap(hWnd,hDC);
ReleaseDC(hWnd,hDC);
}
}
break;
case WM_PRINT:
if(pData && pData->m_bDoSubclass)
{
if(CNewMenu::m_pActMenuDrawing->DoDrawBorder())
{
// Mark for WM_PRINT
pData->m_dwData |= 8;
// pData->m_bDrawBorder = FALSE;
// We need to create a bitmap for drawing
// We can't clipp or make a offset to the DC because NT2000 (blue-screen!!)
CRect rect;
GetWindowRect(hWnd, rect);
CDC dc;
CBitmap bitmap;
CDC* pDC = CDC::FromHandle((HDC)wParam);
dc.CreateCompatibleDC(pDC);
bitmap.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
CBitmap* pOldBitmap = dc.SelectObject(&bitmap);
// new
// dc.FillSolidRect(0,0,rect.Width(), rect.Height(),CNewMenu::GetMenuBarColor(pData->m_hMenu));
CNewMenu::m_pActMenuDrawing->OnDrawBorder(hWnd,dc.m_hDC);
CRect rectClient;
if(CNewMenu::m_pActMenuDrawing->OnCalcFrameRect(hWnd,rectClient))
{
// might as well clip to the same rectangle
CRect clipRect = rectClient;
clipRect.OffsetRect(rectClient.TopLeft()-rect.TopLeft());
clipRect.InflateRect(-1,-1);
dc.IntersectClipRect(clipRect);
result = CallWindowProc(oldWndProc, hWnd, uMsg, (WPARAM)dc.m_hDC, lParam&~PRF_CLIENT);
pDC->BitBlt(0,0, rect.Width(), rect.Height(), &dc,0,0, SRCCOPY);
GetClientRect(hWnd,clipRect);
SelectClipRgn(dc.m_hDC,NULL);
dc.IntersectClipRect(clipRect);
SendMessage(hWnd,WM_ERASEBKGND,(WPARAM)dc.m_hDC,0);
SendMessage(hWnd,WM_PRINTCLIENT,(WPARAM)dc.m_hDC,lParam);
CPoint wndOffset(0,0);
ClientToScreen(hWnd,&wndOffset);
wndOffset -= rect.TopLeft();
pDC->BitBlt(wndOffset.x,wndOffset.y, clipRect.Width()-1, clipRect.Height(), &dc, 0, 0, SRCCOPY);
//pDC->BitBlt(wndOffset.x,wndOffset.y, clipRect.Width(), clipRect.Height(), &dc, 0, 0, SRCCOPY);
}
//
dc.SelectObject(pOldBitmap);
bCallDefault=FALSE;
// Clear for WM_PRINT
pData->m_dwData &= ~8;
}
}
break;
case WM_ERASEBKGND:
ASSERT(pData);
if(pData->m_bDoSubclass)
{
if(CNewMenu::m_pActMenuDrawing->DoDrawBorder())
{
if(!(pData->m_dwData&8) && !pData->m_bDrawBorder )
{
pData->m_bDrawBorder = true;
//SendMessage(hWnd,WM_NCPAINT,(WPARAM)pData->m_hRgn,0);
SendMessage(hWnd,WM_NCPAINT,(WPARAM)1,0);
}
}
if(CNewMenu::m_pActMenuDrawing->OnEraseBkgnd(hWnd,(HDC)wParam))
{
bCallDefault=FALSE;
result = TRUE;
}
}
break;
case WM_WINDOWPOSCHANGED:
case WM_WINDOWPOSCHANGING:
{
ASSERT(pData);
LPWINDOWPOS pPos = (LPWINDOWPOS)lParam;
if(uMsg==WM_WINDOWPOSCHANGING)
{
CNewMenu::m_pActMenuDrawing->OnWindowPosChanging(hWnd,pPos);
}
if(!(pPos->flags&SWP_NOMOVE) )
{
if(pData->m_Point==CPoint(0,0))
{
pData->m_Point = CPoint(pPos->x,pPos->y);
}
else if(pData->m_Point!=CPoint(pPos->x,pPos->y))
{
/* CRect rect(0,0,0,0);
if(!GetWindowRect(hWnd,rect))
{
AfxTrace(_T("Error get rect\n"));
}
#ifdef _TRACE_MENU_
DWORD dwPos =GetMessagePos();
AfxTrace(_T("Rect pos (%ld/%ld), dimensions [%ld,%ld], Delta(%ld/%ld),MPos %lx\n"),
pData->m_Point.x,pData->m_Point.y,rect.Width(),rect.Height(),
pData->m_Point.x-pPos->x,pData->m_Point.y-pPos->y,dwPos);
#endif
*/
if(!(pPos->flags&SWP_NOSIZE))
{
UnsubClassMenu(hWnd);
}
else
{
pData->m_Point=CPoint(pPos->x,pPos->y);
pData->m_Screen.DeleteObject();
}
}
}
}
break;
case WM_KEYDOWN:
if(wParam==VK_ESCAPE)
{
if(pData)
{
pData->m_dwData |= 4;
}
}
m_dwMsgPos = GetMessagePos();
break;
case WM_NCCALCSIZE:
if(pData->m_bDoSubclass)
{
NCCALCSIZE_PARAMS* pCalc = (NCCALCSIZE_PARAMS*)lParam;
if(CNewMenu::m_pActMenuDrawing->OnNcCalcSize(hWnd,pCalc))
{
bCallDefault=FALSE;
}
}
break;
case WM_SHOWWINDOW:
// Hide the window ? Test for 98 and 2000
if(wParam==NULL)
{
// Special handling for NT 2000 and WND 0x10012.
UnsubClassMenu(hWnd);
}
break;
case WM_NCDESTROY:
UnsubClassMenu (hWnd);
break;
case WM_TIMER:
if(wParam==MENU_TIMER_ID)
{
if(g_Shell>=Win2000)
{
LONG_PTR dwExStyle = GetWindowLongPtr(hWnd, GWL_EXSTYLE);
if( !(dwExStyle&WS_EX_LAYERED) )
{
SetWindowLongPtr (hWnd, GWL_EXSTYLE,dwExStyle| WS_EX_LAYERED);
SetLayeredWindowAttributes(hWnd, 0, CNewMenu::GetAlpha(), LWA_ALPHA);
pData->m_dwData &= ~4;
KillTimer(hWnd,MENU_TIMER_ID);
}
}
}
break;
// if(pData->m_TimerID && pData->m_TimerID==wParam)
// {
// bCallDefault = FALSE;
// KillTimer(hWnd,pData->m_TimerID);
// pData->m_TimerID = NULL;
// result = 0;
// // Create shade windows
// SetWindowShade(hWnd, pData);
// }
// break;
//default:
// {
// static const UINT WBHook = RegisterWindowMessage(_T("WBHook"));
// if (uMsg==WBHook)
// {
// bCallDefault = false;
// }
// }
// break;
}
if( bCallDefault )
{
ASSERT(oldWndProc != NULL);
// call original wndproc for default handling
result = CallWindowProc(oldWndProc, hWnd, uMsg, wParam, lParam);
}
#ifdef _TRACE_MENU_
NestedLevel--;
#endif
return result;
}
BOOL CNewMenuHook::CheckSubclassing(HWND hWnd, BOOL bSpecialWnd)
{
TCHAR Name[20];
int Count = GetClassName (hWnd,Name,ARRAY_SIZE(Name));
// Check for the menu-class
if(Count!=6 || _tcscmp(Name,_T("#32768"))!=0)
{
// does not match to menuclass
return false;
}
BOOL bDoNewSubclass = FALSE;
CMenuHookData* pData=GetMenuHookData(hWnd);
// check if we have allready some data
if(pData==NULL)
{
// a way for get the menu-handle not documented
if(!m_hLastMenu)
{
// WinNt 4.0 will crash in submenu
m_hLastMenu = (HMENU)SendMessage(hWnd,0x01E1,0,0);
}
CMenu *pMenu = CMenu::FromHandlePermanent(m_hLastMenu);
// now we support only new menu
if( !DYNAMIC_DOWNCAST(CNewMenu,pMenu) )
{
return false;
}
WNDPROC oldWndProc;
// subclass the window with the proc which does gray backgrounds
oldWndProc = (WNDPROC)GetWindowLongPtr(hWnd, GWLP_WNDPROC);
if (oldWndProc != NULL && GetProp(hWnd, _OldMenuProc) == NULL)
{
ASSERT(oldWndProc!=SubClassMenu);
if(!SetProp(hWnd, _OldMenuProc, oldWndProc))
{
ShowLastError(_T("Error from Menu: SetProp"));
}
if ((WNDPROC)GetProp(hWnd, _OldMenuProc) == oldWndProc)
{
GlobalAddAtom(_OldMenuProc);
CMenuHookData* pData=GetMenuHookData(hWnd);
ASSERT(pData==NULL);
if(pData==NULL)
{
pData = new CMenuHookData(hWnd,bSpecialWnd);
m_MenuHookData.SetAt (hWnd,pData);
SetLastError(0);
if(!SetWindowLongPtr(hWnd, GWLP_WNDPROC,(INT_PTR)SubClassMenu))
{
ShowLastError(_T("Error from Menu: SetWindowLongPtr IV"));
}
bDoNewSubclass = TRUE;
#ifdef _TRACE_MENU_
//SendMessage(hWnd,0x01E1,0,0) a way for get the menu-handle
AfxTrace(_T("Subclass Menu=0x%lX, hwnd=0x%lX\n"),pData->m_hMenu,hWnd);
#endif
CNewMenu::m_pActMenuDrawing->OnInitWnd(hWnd);
}
}
else
{
ASSERT(0);
}
}
}
// Menu was set also assign it to this menu.
if(m_hLastMenu)
{
CMenuHookData* pData = GetMenuHookData(hWnd);
if(pData)
{
// Safe actual menu
pData->SetMenu(m_hLastMenu);
// Reset for the next menu
m_hLastMenu = NULL;
//
CNewMenu::m_pActMenuDrawing->OnInitWnd(hWnd);
}
}
return bDoNewSubclass;
}
/////////////////////////////////////////////////////////////////////////////
// CNewMenuThreadHook class used to hook for threads
// Jan-17-2005 - Mark P. Peterson - [email protected] - http://www.RhinoSoft.com/
CNewMenuThreadHook::CNewMenuThreadHook()
{
// set the hook handler for this thread
m_hHookOldMenuCbtFilter = ::SetWindowsHookEx(WH_CALLWNDPROC, CNewMenuHook::NewMenuHook, NULL, ::GetCurrentThreadId());
} // CNewMenuThreadHook
CNewMenuThreadHook::~CNewMenuThreadHook()
{
// reset the hook handler
if (m_hHookOldMenuCbtFilter)
{
::UnhookWindowsHookEx(m_hHookOldMenuCbtFilter);
}
// clear the handle
m_hHookOldMenuCbtFilter = NULL;
} // ~CNewMenuThreadHook
/////////////////////////////////////////////////////////////////////////////
// CNewMenuTempHandler class used to add NewMenu to system dialog
class CNewMenuTempHandler : public CObject
{
CNewMenu m_SystemNewMenu;
WNDPROC m_oldWndProc;
HWND m_hWnd;
public:
CNewMenuTempHandler(HWND hWnd)
{
m_hWnd = hWnd;
VERIFY(SetProp(hWnd,_T("CNewMenuTempHandler"),this));
// Subclass the dialog control.
m_oldWndProc = (WNDPROC)(LONG_PTR)SetWindowLongPtr(hWnd, GWLP_WNDPROC,(INT_PTR)TempSubclass);
}
~CNewMenuTempHandler()
{
SetWindowLongPtr(m_hWnd, GWLP_WNDPROC,(INT_PTR)m_oldWndProc);
VERIFY(RemoveProp(m_hWnd,_T("CNewMenuTempHandler")));
}
LRESULT Default(UINT uMsg, WPARAM wParam, LPARAM lParam )
{
// call original wndproc for default handling
return CallWindowProc(m_oldWndProc, m_hWnd, uMsg, wParam, lParam);
}
LRESULT OnCmd(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
MSG msg = {m_hWnd,uMsg,wParam,lParam,0,0,0};
switch(uMsg)
{
case WM_DRAWITEM:
{
if(m_SystemNewMenu.m_hMenu)
{
DRAWITEMSTRUCT* lpDrawItemStruct = (DRAWITEMSTRUCT*)lParam;
if (lpDrawItemStruct->CtlType == ODT_MENU)
{
CMenu* pMenu = CMenu::FromHandlePermanent((HMENU)lpDrawItemStruct->hwndItem);
if (DYNAMIC_DOWNCAST(CNewMenu,pMenu))
{
pMenu->DrawItem(lpDrawItemStruct);
return true; // eat it
}
}
}
return Default(uMsg, wParam, lParam);
}
case WM_MEASUREITEM:
if(CNewMenu::OnMeasureItem(&msg))
{
return TRUE;
}
break;
case WM_MENUCHAR:
{
CMenu* pMenu = CMenu::FromHandle(UIntToHMenu((UINT)lParam));;
LRESULT lresult;
if( DYNAMIC_DOWNCAST(CNewMenu,pMenu) )
lresult=CNewMenu::FindKeyboardShortcut(LOWORD(wParam), HIWORD(wParam),pMenu );
else
lresult=Default(uMsg, wParam, lParam);
return lresult;
}
break;
case WM_INITMENUPOPUP:
{
CMenu* pMenu = CMenu::FromHandle(UIntToHMenu((UINT)wParam));
LRESULT result = Default(uMsg, wParam, lParam);
CNewMenu::OnInitMenuPopup(m_hWnd, pMenu, LOWORD(lParam), HIWORD(lParam));
return result;
}
case WM_INITDIALOG:
if(CNewMenuHook::m_bSubclassFlag&NEW_MENU_DIALOG_SYSTEM_MENU)
{
LRESULT bRetval = Default(uMsg, wParam, lParam);
VERIFY(m_SystemNewMenu.m_hMenu==0);
HMENU hMenu = ::GetSystemMenu(m_hWnd,FALSE);
if(IsMenu(hMenu))
{
CMenu* pMenu = CMenu::FromHandlePermanent(hMenu);
// Only attach to CNewMenu once
if (DYNAMIC_DOWNCAST(CNewMenu,pMenu)==NULL )
{
m_SystemNewMenu.Attach(hMenu);
}
}
return bRetval;
}
break;
case WM_DESTROY:
LRESULT result = Default(uMsg, wParam, lParam);
delete this;
return result;
}
return Default(uMsg, wParam, lParam);
}
// Subclass procedure
static LRESULT APIENTRY TempSubclass(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
AFX_MANAGE_STATE(AfxGetModuleState());
CNewMenuTempHandler* pTemp = (CNewMenuTempHandler*)GetProp(hwnd,_T("CNewMenuTempHandler"));
ASSERT(pTemp);
return pTemp->OnCmd(uMsg, wParam, lParam);
}
};
LRESULT CALLBACK CNewMenuHook::NewMenuHook(int code, WPARAM wParam, LPARAM lParam)
{
AFX_MANAGE_STATE(AfxGetModuleState());
CWPSTRUCT* pTemp = (CWPSTRUCT*)lParam;
if(code == HC_ACTION )
{
HWND hWnd = pTemp->hwnd;
#ifdef _TRACE_MENU_
static HWND acthMenu = NULL;
static HWND acthWnd = NULL;
// Check if we need to find out the window
if (hWnd && hWnd!=acthWnd && hWnd!=acthMenu)
{
TCHAR Name[20];
int Count = GetClassName (hWnd,Name,ARRAY_SIZE(Name));
// Check for the menu-class
if(Count!=6 || _tcscmp(Name,_T("#32768"))!=0)
{
// does not match to menuclass
acthWnd = hWnd;
}
else
{
acthMenu = hWnd;
// AfxTrace(_T("Found new menu HWND: 0x%08X\n"),acthMenu);
}
}
// Trace all menu msg
if(acthMenu==hWnd && acthMenu)
{
MSG msg = {hWnd,pTemp->message,pTemp->wParam,pTemp->lParam,0,0,0};
MyTraceMsg(_T(" Menu "),&msg);
}
#endif
// Normal and special handling for menu 0x10012
if(pTemp->message==WM_CREATE || pTemp->message==0x01E2)
{
if(!CheckSubclassing(hWnd,pTemp->message==0x01E2))
{
if( (m_bSubclassFlag&NEW_MENU_DIALOG_SUBCLASS) && pTemp->message==WM_CREATE)
{
TCHAR Name[20];
int Count = GetClassName (hWnd,Name,ARRAY_SIZE(Name));
// Check for the Dialog-class
if(Count==6 && _tcscmp(Name,_T("#32770"))==0 )
{
// Only first dialog
// m_bSubclassFlag &= ~NEW_MENU_DIALOG_SUBCLASS;
// Freed by WM_DESTROY
new CNewMenuTempHandler(hWnd);
}
}
}
}
}
return CallNextHookEx(HookOldMenuCbtFilter, code,wParam, lParam);
}
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
IMPLEMENT_DYNAMIC(CNewDialog,CDialog)
BEGIN_MESSAGE_MAP(CNewDialog, CNewFrame<CDialog>)
//{{AFX_MSG_MAP(CNewDialog)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
ON_WM_INITMENUPOPUP()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
CNewDialog::CNewDialog()
{
}
CNewDialog::CNewDialog(LPCTSTR lpszTemplateName, CWnd* pParentWnd)
{
ASSERT(IS_INTRESOURCE(lpszTemplateName) || AfxIsValidString(lpszTemplateName));
m_pParentWnd = pParentWnd;
m_lpszTemplateName = lpszTemplateName;
if (IS_INTRESOURCE(m_lpszTemplateName))
m_nIDHelp = LOWORD((DWORD_PTR)m_lpszTemplateName);
}
CNewDialog::CNewDialog(UINT nIDTemplate, CWnd* pParentWnd)
{
m_pParentWnd = pParentWnd;
m_lpszTemplateName = MAKEINTRESOURCE(nIDTemplate);
m_nIDHelp = nIDTemplate;
}
BOOL CNewDialog::OnInitDialog()
{
BOOL bRetval = CDialog::OnInitDialog();
HMENU hMenu = m_SystemNewMenu.Detach();
HMENU hSysMenu = ::GetSystemMenu(m_hWnd,FALSE);
if(hMenu!=hSysMenu)
{
if(IsMenu(hMenu))
{
if(!::DestroyMenu(hMenu))
{
ShowLastError(_T("Error from Menu: DestroyMenu"));
}
}
}
m_SystemNewMenu.Attach(hSysMenu);
m_DefaultNewMenu.LoadMenu(::GetMenu(m_hWnd));
if(IsMenu(m_DefaultNewMenu.m_hMenu))
{
UpdateMenuBarColor(m_DefaultNewMenu);
}
return bRetval;
}
extern void AFXAPI AfxCancelModes(HWND hWndRcvr);
// Most of the code is copied from the MFC code from CFrameWnd::OnInitMenuPopup
void CNewDialog::OnInitMenuPopup(CMenu* pMenu, UINT nIndex, BOOL bSysMenu)
{
AfxCancelModes(m_hWnd);
// don't support system menu
if (!bSysMenu)
{
ASSERT(pMenu != NULL);
// check the enabled state of various menu items
CCmdUI state;
state.m_pMenu = pMenu;
ASSERT(state.m_pOther == NULL);
ASSERT(state.m_pParentMenu == NULL);
// determine if menu is popup in top-level menu and set m_pOther to
// it if so (m_pParentMenu == NULL indicates that it is secondary popup)
HMENU hParentMenu;
if (AfxGetThreadState()->m_hTrackingMenu == pMenu->m_hMenu)
{
state.m_pParentMenu = pMenu; // parent == child for tracking popup
}
else if ((hParentMenu = ::GetMenu(m_hWnd)) != NULL)
{
CWnd* pParent = GetTopLevelParent();
// child windows don't have menus -- need to go to the top!
if (pParent != NULL &&
(hParentMenu = ::GetMenu(pParent->m_hWnd)) != NULL)
{
int nIndexMax = ::GetMenuItemCount(hParentMenu);
for (int nIndex = 0; nIndex < nIndexMax; nIndex++)
{
if (::GetSubMenu(hParentMenu, nIndex) == pMenu->m_hMenu)
{
// when popup is found, m_pParentMenu is containing menu
state.m_pParentMenu = CMenu::FromHandle(hParentMenu);
break;
}
}
}
}
state.m_nIndexMax = pMenu->GetMenuItemCount();
for (state.m_nIndex = 0; state.m_nIndex<state.m_nIndexMax; state.m_nIndex++)
{
state.m_nID = pMenu->GetMenuItemID(state.m_nIndex);
if (state.m_nID == 0)
continue; // menu separator or invalid cmd - ignore it
ASSERT(state.m_pOther == NULL);
ASSERT(state.m_pMenu != NULL);
if (state.m_nID == (UINT)-1)
{
// possibly a popup menu, route to first item of that popup
state.m_pSubMenu = pMenu->GetSubMenu(state.m_nIndex);
if (state.m_pSubMenu == NULL ||
(state.m_nID = state.m_pSubMenu->GetMenuItemID(0)) == 0 ||
state.m_nID == (UINT)-1)
{
continue; // first item of popup can't be routed to
}
state.DoUpdate(this, FALSE); // popups are never auto disabled
}
else
{
// normal menu item
// Auto enable/disable if frame window has 'm_bAutoMenuEnable'
// set and command is _not_ a system command.
state.m_pSubMenu = NULL;
state.DoUpdate(this, state.m_nID < 0xF000);
}
// adjust for menu deletions and additions
UINT nCount = pMenu->GetMenuItemCount();
if (nCount < state.m_nIndexMax)
{
state.m_nIndex -= (state.m_nIndexMax - nCount);
while (state.m_nIndex < nCount &&
pMenu->GetMenuItemID(state.m_nIndex) == state.m_nID)
{
state.m_nIndex++;
}
}
state.m_nIndexMax = nCount;
}
}
// Do the work for update
CNewFrame<CDialog>::OnInitMenuPopup(pMenu,nIndex,bSysMenu);
}
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
IMPLEMENT_DYNCREATE(CNewMiniFrameWnd,CMiniFrameWnd)
BEGIN_MESSAGE_MAP(CNewMiniFrameWnd, CNewFrame<CMiniFrameWnd>)
//{{AFX_MSG_MAP(CNewMiniFrameWnd)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
IMPLEMENT_DYNCREATE(CNewMDIChildWnd,CMDIChildWnd)
BEGIN_MESSAGE_MAP(CNewMDIChildWnd, CNewFrame<CMDIChildWnd>)
//{{AFX_MSG_MAP(CNewMDIChildWnd)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
IMPLEMENT_DYNCREATE(CNewMiniDockFrameWnd,CMiniDockFrameWnd);
BEGIN_MESSAGE_MAP(CNewMiniDockFrameWnd, CNewFrame<CMiniDockFrameWnd>)
//{{AFX_MSG_MAP(CNewMiniDockFrameWnd)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
IMPLEMENT_DYNCREATE(CNewFrameWnd,CFrameWnd)
BEGIN_MESSAGE_MAP(CNewFrameWnd, CNewFrame<CFrameWnd>)
//{{AFX_MSG_MAP(CNewFrameWnd)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#if _MFC_VER < 0x0700
#include <../src/afximpl.h>
BOOL CNewFrameWnd::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle,
CWnd* pParentWnd, CCreateContext* pContext)
{
// only do this once
ASSERT_VALID_IDR(nIDResource);
ASSERT(m_nIDHelp == 0 || m_nIDHelp == nIDResource);
m_nIDHelp = nIDResource; // ID for help context (+HID_BASE_RESOURCE)
CString strFullString;
if (strFullString.LoadString(nIDResource))
AfxExtractSubString(m_strTitle, strFullString, 0); // first sub-string
VERIFY(AfxDeferRegisterClass(AFX_WNDFRAMEORVIEW_REG));
// attempt to create the window
LPCTSTR lpszClass = GetIconWndClass(dwDefaultStyle, nIDResource);
LPCTSTR lpszTitle = m_strTitle;
if (!Create(lpszClass, lpszTitle, dwDefaultStyle, rectDefault,
pParentWnd, MAKEINTRESOURCE(nIDResource), 0L, pContext))
{
return FALSE; // will self destruct on failure normally
}
// save the default menu handle
ASSERT(m_hWnd != NULL);
m_hMenuDefault = ::GetMenu(m_hWnd);
// load accelerator resource
LoadAccelTable(MAKEINTRESOURCE(nIDResource));
if (pContext == NULL) // send initial update
SendMessageToDescendants(WM_INITIALUPDATE, 0, 0, TRUE, TRUE);
return TRUE;
}
#endif
BOOL CNewFrameWnd::Create(LPCTSTR lpszClassName,
LPCTSTR lpszWindowName,
DWORD dwStyle,
const RECT& rect,
CWnd* pParentWnd,
LPCTSTR lpszMenuName,
DWORD dwExStyle,
CCreateContext* pContext)
{
if (lpszMenuName != NULL)
{
m_DefaultNewMenu.LoadMenu(lpszMenuName);
// load in a menu that will get destroyed when window gets destroyed
if (m_DefaultNewMenu.m_hMenu == NULL)
{
#if _MFC_VER < 0x0700
TRACE0("Warning: failed to load menu for CNewFrameWnd.\n");
#else
TRACE(traceAppMsg, 0, "Warning: failed to load menu for CNewFrameWnd.\n");
#endif
PostNcDestroy(); // perhaps delete the C++ object
return FALSE;
}
}
m_strTitle = lpszWindowName; // save title for later
if (!CreateEx(dwExStyle, lpszClassName, lpszWindowName, dwStyle,
rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
pParentWnd->GetSafeHwnd(), m_DefaultNewMenu.m_hMenu, (LPVOID)pContext))
{
#if _MFC_VER < 0x0700
TRACE0("Warning: failed to create CNewFrameWnd.\n");
#else
TRACE(traceAppMsg, 0, "Warning: failed to create CNewFrameWnd.\n");
#endif
return FALSE;
}
UpdateMenuBarColor(m_DefaultNewMenu);
return TRUE;
}
#ifdef USE_NEW_DOCK_BAR
//Bug in compiler??
#ifdef _AFXDLL
// control bar docking
// dwDockBarMap
const DWORD CFrameWnd::dwDockBarMap[4][2] =
{
{ AFX_IDW_DOCKBAR_TOP, CBRS_TOP },
{ AFX_IDW_DOCKBAR_BOTTOM, CBRS_BOTTOM },
{ AFX_IDW_DOCKBAR_LEFT, CBRS_LEFT },
{ AFX_IDW_DOCKBAR_RIGHT, CBRS_RIGHT },
};
#endif
// dock bars will be created in the order specified by dwDockBarMap
// this also controls which gets priority during layout
// this order can be changed by calling EnableDocking repetitively
// with the exact order of priority
void CNewFrameWnd::EnableDocking(DWORD dwDockStyle)
{
// must be CBRS_ALIGN_XXX or CBRS_FLOAT_MULTI only
ASSERT((dwDockStyle & ~(CBRS_ALIGN_ANY|CBRS_FLOAT_MULTI)) == 0);
m_pFloatingFrameClass = RUNTIME_CLASS(CNewMiniDockFrameWnd);
for (int i = 0; i < 4; i++)
{
if (dwDockBarMap[i][1] & dwDockStyle & CBRS_ALIGN_ANY)
{
CDockBar* pDock = (CDockBar*)GetControlBar(dwDockBarMap[i][0]);
if (pDock == NULL)
{
pDock = new CNewDockBar;
if (!pDock->Create(this,
WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_CHILD|WS_VISIBLE |
dwDockBarMap[i][1], dwDockBarMap[i][0]))
{
AfxThrowResourceException();
}
}
}
}
}
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
IMPLEMENT_DYNAMIC(CNewMDIFrameWnd,CMDIFrameWnd)
BEGIN_MESSAGE_MAP(CNewMDIFrameWnd, CNewFrame<CMDIFrameWnd>)
//{{AFX_MSG_MAP(CNewMDIFrameWnd)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CNewMDIFrameWnd::ShowMenu(BOOL bShow)
{
// Gets the actual menu
HMENU hMenu = ::GetMenu(m_hWnd);
if(bShow)
{
if(m_hShowMenu)
{
::SetMenu(m_hWnd, m_hShowMenu);
DrawMenuBar();
m_hShowMenu = NULL;
return FALSE;
}
return TRUE;
}
else
{
m_hShowMenu = hMenu;
if(m_hShowMenu)
{
::SetMenu(m_hWnd, NULL);
DrawMenuBar();
return TRUE;
}
return FALSE;
}
}
#if _MFC_VER < 0x0700
BOOL CNewMDIFrameWnd::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle,
CWnd* pParentWnd, CCreateContext* pContext)
{
// only do this once
ASSERT_VALID_IDR(nIDResource);
ASSERT(m_nIDHelp == 0 || m_nIDHelp == nIDResource);
m_nIDHelp = nIDResource; // ID for help context (+HID_BASE_RESOURCE)
CString strFullString;
if (strFullString.LoadString(nIDResource))
AfxExtractSubString(m_strTitle, strFullString, 0); // first sub-string
VERIFY(AfxDeferRegisterClass(AFX_WNDFRAMEORVIEW_REG));
// attempt to create the window
LPCTSTR lpszClass = GetIconWndClass(dwDefaultStyle, nIDResource);
LPCTSTR lpszTitle = m_strTitle;
if (!Create(lpszClass, lpszTitle, dwDefaultStyle, rectDefault,
pParentWnd, MAKEINTRESOURCE(nIDResource), 0L, pContext))
{
return FALSE; // will self destruct on failure normally
}
// save the default menu handle
ASSERT(m_hWnd != NULL);
m_hMenuDefault = ::GetMenu(m_hWnd);
// load accelerator resource
LoadAccelTable(MAKEINTRESOURCE(nIDResource));
if (pContext == NULL) // send initial update
SendMessageToDescendants(WM_INITIALUPDATE, 0, 0, TRUE, TRUE);
// save menu to use when no active MDI child window is present
ASSERT(m_hWnd != NULL);
m_hMenuDefault = ::GetMenu(m_hWnd);
if (m_hMenuDefault == NULL)
TRACE0("Warning: CMDIFrameWnd without a default menu.\n");
return TRUE;
}
#endif
BOOL CNewMDIFrameWnd::Create( LPCTSTR lpszClassName,
LPCTSTR lpszWindowName,
DWORD dwStyle,
const RECT& rect,
CWnd* pParentWnd,
LPCTSTR lpszMenuName,
DWORD dwExStyle,
CCreateContext* pContext)
{
if (lpszMenuName != NULL)
{
m_DefaultNewMenu.LoadMenu(lpszMenuName);
// load in a menu that will get destroyed when window gets destroyed
if (m_DefaultNewMenu.m_hMenu == NULL)
{
#if _MFC_VER < 0x0700
TRACE0("Warning: failed to load menu for CNewMDIFrameWnd.\n");
#else
TRACE(traceAppMsg, 0, "Warning: failed to load menu for CNewMDIFrameWnd.\n");
#endif
PostNcDestroy(); // perhaps delete the C++ object
return FALSE;
}
}
m_strTitle = lpszWindowName; // save title for later
if (!CreateEx(dwExStyle, lpszClassName, lpszWindowName, dwStyle,
rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
pParentWnd->GetSafeHwnd(), m_DefaultNewMenu.m_hMenu, (LPVOID)pContext))
{
#if _MFC_VER < 0x0700
TRACE0("Warning: failed to create CNewMDIFrameWnd.\n");
#else
TRACE(traceAppMsg, 0, "Warning: failed to create CNewMDIFrameWnd.\n");
#endif
return FALSE;
}
UpdateMenuBarColor(m_DefaultNewMenu);
return TRUE;
}
#ifdef USE_NEW_DOCK_BAR
// dock bars will be created in the order specified by dwDockBarMap
// this also controls which gets priority during layout
// this order can be changed by calling EnableDocking repetitively
// with the exact order of priority
void CNewMDIFrameWnd::EnableDocking(DWORD dwDockStyle)
{
// must be CBRS_ALIGN_XXX or CBRS_FLOAT_MULTI only
ASSERT((dwDockStyle & ~(CBRS_ALIGN_ANY|CBRS_FLOAT_MULTI)) == 0);
m_pFloatingFrameClass = RUNTIME_CLASS(CNewMiniDockFrameWnd);
for (int i = 0; i < 4; i++)
{
if (dwDockBarMap[i][1] & dwDockStyle & CBRS_ALIGN_ANY)
{
CDockBar* pDock = (CDockBar*)GetControlBar(dwDockBarMap[i][0]);
if (pDock == NULL)
{
pDock = new CNewDockBar;
if (!pDock->Create(this,
WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_CHILD|WS_VISIBLE |
dwDockBarMap[i][1], dwDockBarMap[i][0]))
{
AfxThrowResourceException();
}
}
}
}
}
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
IMPLEMENT_DYNAMIC(CNewMultiDocTemplate,CMultiDocTemplate)
CNewMultiDocTemplate::CNewMultiDocTemplate(UINT nIDResource,
CRuntimeClass* pDocClass,
CRuntimeClass* pFrameClass,
CRuntimeClass* pViewClass)
: CMultiDocTemplate(nIDResource,pDocClass,pFrameClass,pViewClass)
{
if (m_nIDResource != 0 && m_hMenuShared)
{
// Attach the menu.
m_NewMenuShared.LoadMenu(m_hMenuShared);
// Try to load icons to the toolbar.
m_NewMenuShared.LoadToolBar(m_nIDResource);
}
}
CNewMultiDocTemplate::~CNewMultiDocTemplate()
{
// Let only the CNewMenu to destroy the menu.
if(m_hMenuShared==m_NewMenuShared.m_hMenu)
{
m_hMenuShared = NULL;
}
}
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CNewMenuHelper::CNewMenuHelper(DWORD dwFlags)
{
m_dwOldFlags = CNewMenuHook::m_bSubclassFlag;
CNewMenuHook::m_bSubclassFlag = dwFlags;
m_OldMenuDrawStyle = CNewMenu::GetMenuDrawMode();
if(CNewMenuHook::m_bSubclassFlag&NEW_MENU_DEFAULT_BORDER)
{
CNewMenu::SetMenuDrawMode(m_OldMenuDrawStyle|1);
}
}
CNewMenuHelper::CNewMenuHelper(CNewMenu::EDrawStyle setTempStyle)
{
m_dwOldFlags = CNewMenuHook::m_bSubclassFlag;
m_OldMenuDrawStyle = CNewMenu::SetMenuDrawMode(setTempStyle);
}
CNewMenuHelper::~CNewMenuHelper()
{
// Restore the old border style
CNewMenu::SetMenuDrawMode(m_OldMenuDrawStyle);
CNewMenuHook::m_bSubclassFlag = m_dwOldFlags;
}
// CNewDockBar
IMPLEMENT_DYNCREATE(CNewDockBar, CDockBar)
CNewDockBar::CNewDockBar(BOOL bFloating):CDockBar(bFloating)
{
}
CNewDockBar::~CNewDockBar()
{
}
BEGIN_MESSAGE_MAP(CNewDockBar, CDockBar)
//{{AFX_MSG_MAP(CNewDockBar)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
ON_WM_ERASEBKGND()
ON_WM_NCPAINT()
END_MESSAGE_MAP()
// CNewDockBar diagnostics
#if defined(_DEBUG) || defined(_AFXDLL)
void CNewDockBar::AssertValid() const
{
CDockBar::AssertValid();
}
void CNewDockBar::Dump(CDumpContext& dc) const
{
CDockBar::Dump(dc);
}
#endif //_DEBUG
// CNewDockBar message handlers
void CNewDockBar::EraseNonClient()
{
// get window DC that is clipped to the non-client area
CWindowDC dc(this);
CRect rectClient;
GetClientRect(rectClient);
CRect rectWindow;
GetWindowRect(rectWindow);
ScreenToClient(rectWindow);
rectClient.OffsetRect(-rectWindow.left, -rectWindow.top);
dc.ExcludeClipRect(rectClient);
// draw borders in non-client area
rectWindow.OffsetRect(-rectWindow.left, -rectWindow.top);
//DrawBorders(&dc, rectWindow);
// erase parts not drawn
dc.IntersectClipRect(rectWindow);
SendMessage(WM_ERASEBKGND, (WPARAM)dc.m_hDC);
// draw gripper in non-client area
DrawGripper(&dc, rectWindow);
}
BOOL CNewDockBar::OnEraseBkgnd(CDC* pDC)
{
MENUINFO menuInfo = {0};
menuInfo.cbSize = sizeof(menuInfo);
menuInfo.fMask = MIM_BACKGROUND;
//if(::GetMenuInfo(::GetMenu(::GetParent(m_hWnd)),&menuInfo) && menuInfo.hbrBack)
CBrush *pBrush = GetMenuBarBrush();
if(pBrush)
{
CRect rectA;
CRect rectB;
GetWindowRect(rectA);
::GetWindowRect(::GetParent(m_hWnd),rectB);
// need for win95/98/me
VERIFY(pBrush->UnrealizeObject());
CPoint oldOrg = pDC->SetBrushOrg(-(rectA.left-rectB.left),0);
CRect rect;
pDC->GetClipBox(rect);
pDC->FillRect(rect,pBrush);
pDC->SetBrushOrg(oldOrg);
return true;
}
else
{
// do default drawing
return CDockBar::OnEraseBkgnd(pDC);
}
}
void CNewDockBar::OnNcPaint()
{
// Do not call CDockBar::OnNcPaint() for painting messages
EraseNonClient();
}
DWORD CNewDockBar::RecalcDelayShow(AFX_SIZEPARENTPARAMS* lpLayout)
{
DWORD result = CDockBar::RecalcDelayShow(lpLayout);
#ifdef USE_NEW_MENU_BAR
// we want to have the menubar on its own row or column and align to border
int nCount = (int)m_arrBars.GetSize();
for(int nPos=0;nPos<nCount;nPos++)
{
CControlBar *pBar = GetDockedControlBar(nPos);
if(DYNAMIC_DOWNCAST(CNewMenuBar,pBar))
{
if(nPos && GetDockedControlBar(nPos-1))
{
// insert a row break befor the menubar
m_arrBars.InsertAt(nPos,(void*)0);
nPos++;
nCount++;
}
CRect rect;
pBar->GetWindowRect(rect);
ScreenToClient(rect);
if(pBar->m_dwStyle&CBRS_ORIENT_HORZ)
{
if(rect.left>0)
{
pBar->SetWindowPos(NULL,-5,rect.top,0,0,SWP_NOZORDER|SWP_NOSIZE|SWP_FRAMECHANGED);
}
}
else
{
if(rect.top>0)
{
pBar->SetWindowPos(NULL,rect.left,-5,0,0,SWP_NOZORDER|SWP_NOSIZE|SWP_FRAMECHANGED);
}
}
if((nPos+1)<nCount && GetDockedControlBar(nPos+1))
{
// insert a row break after the menubar
m_arrBars.InsertAt(nPos+1,(void*)0);
nCount++;
}
}
}
#endif //USE_NEW_MENU_BAR
return result;
}
TCHAR szShadeWindowClass[] = _T("ShadeWindow");
typedef struct
{
CRect parentRect;
HWND hParent;
BOOL bSideShade;
}SShadeInfo;
void DrawWindowShade(HDC hDC, CRect rect, COLORREF blendColor)
{
if (NumScreenColors() <= 256)
{
DWORD rgb = ::GetSysColor(COLOR_BTNSHADOW);
COLORREF oldColor = ::SetBkColor(hDC, rgb);
::ExtTextOut(hDC, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
::SetBkColor(hDC, oldColor);
}
else
{
COLORREF ref;
int width = rect.Width();
int height = rect.Height();
int X,Y;
if(width<height)
{
for (X=0; X<=4 ;X++)
{
for (Y=0; Y<=4 ;Y++)
{
// Simulate a shadow on the left edge...
ref = GetAlphaBlendColor(blendColor,GetPixel(hDC,X,Y),255-(4-X)*Y*10);
SetPixel(hDC,X,Y,ref);
}
for (;Y<height;Y++)
{
// Simulate a shadow on the left...
ref = GetAlphaBlendColor(blendColor,GetPixel(hDC,X,Y),240-(4-X)*40);
SetPixel(hDC,X,Y,ref);
}
}
}
else
{
for(Y=0; Y<=4 ;Y++)
{
// Simulate a shadow on the bottom edge...
for(X=0; X<=4 ;X++)
{
ref = GetAlphaBlendColor(blendColor,GetPixel(hDC,X,Y),255-(4-Y)*X*10);
SetPixel(hDC,X,Y,ref);
}
// Simulate a shadow on the bottom...
for(;X<=(width-5);X++)
{
ref = GetAlphaBlendColor(blendColor,GetPixel(hDC,X,Y),240-(4-Y)*40);
SetPixel(hDC,X,Y,ref);
}
// Simulate a shadow on the bottom edge...
for(;X<width;X++)
{
ref = GetAlphaBlendColor(blendColor,GetPixel(hDC,X,Y),255-((width-1-X)*(4-Y))*10);
SetPixel(hDC,X,Y,ref);
}
}
}
}
}
//
// FUNCTION: ShadeWndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the shade window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
LRESULT CALLBACK ShadeWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
// static long NestedLevel = 0;
// NestedLevel++;
// MSG msg = {hWnd,message,wParam,lParam,0,0,0};
// TCHAR Buffer[30];
// wsprintf(Buffer,_T("Level %02ld"),NestedLevel);
// MyTraceMsg(Buffer,&msg);
LRESULT result = 0;
switch (message)
{
case WM_MOVE:
result = DefWindowProc(hWnd, message, wParam, lParam);
InvalidateRect(hWnd,NULL,TRUE);
break;
case WM_ERASEBKGND:
{
CRect rect;
GetClientRect(hWnd,&rect);
COLORREF blendColor = ::GetSysColor(COLOR_ACTIVECAPTION);//RGB(255,0,0);
DrawWindowShade((HDC) wParam, rect, blendColor);
ValidateRect(hWnd,&rect);
}
return FALSE;
case WM_NCHITTEST:
return HTTRANSPARENT;
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hDC = BeginPaint(hWnd, &ps);
CRect rect;
COLORREF blendColor = ::GetSysColor(COLOR_ACTIVECAPTION);//RGB(255,0,0);
GetClientRect(hWnd,&rect);
DrawWindowShade(hDC, rect, blendColor);
ValidateRect(hWnd,&rect);
EndPaint(hWnd, &ps);
}
break;
case WM_TIMER:
{
KillTimer(hWnd,wParam);
CRect rect;
HWND hParent = GetParent(hWnd);
GetWindowRect(hParent,rect);
SetWindowPos(hWnd,0,rect.right,rect.top,6,rect.Height(),SWP_NOZORDER|SWP_SHOWWINDOW);
}
break;
case WM_WINDOWPOSCHANGED :
//if (true)
{
result = DefWindowProc(hWnd, message, wParam, lParam);
WINDOWPOS *pWP = (WINDOWPOS*)lParam;
if (pWP->hwnd != hWnd)
SetWindowPos (hWnd, HWND_TOP, 0, 0, 0, 0,SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
}
break;
case WM_SHOWWINDOW:
{
result = DefWindowProc(hWnd, message, wParam, lParam);
//if(wParam)
//{
// // window is show
// //InvalidateRect(hWnd,NULL,FALSE);
// SetWindowPos(hWnd,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_SHOWWINDOW|SWP_NOACTIVATE);
//}
//else
//{
// // window disappear
// InvalidateRect(hWnd,NULL,FALSE);
//}
}
break;
case WM_CREATE:
{
LPCREATESTRUCT pCreate = (LPCREATESTRUCT)lParam;
ASSERT(pCreate);
//CRect rect;
//GetWindowRect(pCreate->hwndParent,rect);
result = DefWindowProc(hWnd, message, wParam, lParam);
SShadeInfo *pShadeInfo = (SShadeInfo*)pCreate->lpCreateParams;
ASSERT(pShadeInfo);
if(pShadeInfo->bSideShade)
{
SetWindowPos(hWnd,HWND_TOPMOST,
pShadeInfo->parentRect.left+5,pShadeInfo->parentRect.bottom,
pShadeInfo->parentRect.Width(),5,
SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOZORDER);
}
else
{
SetWindowPos(hWnd,HWND_TOPMOST,
pShadeInfo->parentRect.right,pShadeInfo->parentRect.top+5,
5,pShadeInfo->parentRect.Height()-5,
SWP_SHOWWINDOW|SWP_NOACTIVATE);
}
//GetSafeTimerID(hWnd,200);
}
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return result;
}
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage are only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
BOOL ShadeRegisterClass()
{
WNDCLASS wndcls;
wndcls.style = CS_HREDRAW | CS_VREDRAW;
wndcls.lpfnWndProc = (WNDPROC)ShadeWndProc;
wndcls.cbClsExtra = 0;
wndcls.cbWndExtra = 0;
wndcls.hInstance = AfxGetInstanceHandle();
wndcls.hIcon = (HICON)NULL;
wndcls.hCursor = LoadCursor(NULL, IDC_ARROW);
wndcls.hbrBackground = (HBRUSH)NULL;
wndcls.lpszMenuName = (LPCTSTR)NULL;
wndcls.lpszClassName = szShadeWindowClass;
return AfxRegisterClass(&wndcls);
}
void SetWindowShade(HWND hWndParent,LPRECT pRect)
{
ShadeRegisterClass();
SShadeInfo shadeInfo;
shadeInfo.hParent = hWndParent;
if(pRect!=NULL)
{
shadeInfo.parentRect = *pRect;
}
else
{
GetWindowRect(hWndParent,&shadeInfo.parentRect);
}
shadeInfo.bSideShade = true;
HWND hWnd = CreateWindowEx(WS_EX_TRANSPARENT|WS_EX_TOPMOST ,
szShadeWindowClass,
NULL,
WS_POPUP|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,
CW_USEDEFAULT, 0,
CW_USEDEFAULT, 0,
hWndParent, (HMENU)0,
AfxGetInstanceHandle(),
&shadeInfo);
shadeInfo.bSideShade = false;
hWnd = CreateWindowEx( WS_EX_TRANSPARENT|WS_EX_TOPMOST ,
szShadeWindowClass,
NULL,
WS_POPUP|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,
CW_USEDEFAULT, 0,
CW_USEDEFAULT, 0,
hWndParent, (HMENU)0,
AfxGetInstanceHandle(),
&shadeInfo);
}
//void SetWindowShade(HWND hWndMenu, CNewMenuHook::CMenuHookData* pData )
//{
// if(pData==NULL || pData->m_hRightShade!=NULL || pData->m_hBottomShade)
// {
// return;
// }
//
// ShadeRegisterClass();
//
// HWND hWndParent = AfxGetMainWnd()->GetSafeHwnd();
// SShadeInfo shadeInfo;
// shadeInfo.hParent = hWndMenu;
// GetWindowRect(hWndMenu,&shadeInfo.parentRect);
//
// shadeInfo.bSideShade = true;
//
// pData->m_hRightShade = CreateWindowEx(WS_EX_TRANSPARENT|WS_EX_TOPMOST ,
// szShadeWindowClass,
// NULL,
// WS_POPUP|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,
// CW_USEDEFAULT, 0,
// CW_USEDEFAULT, 0,
// hWndParent, (HMENU)0,
// AfxGetInstanceHandle(),
// &shadeInfo);
//
// shadeInfo.bSideShade = false;
// pData->m_hBottomShade = CreateWindowEx( WS_EX_TRANSPARENT|WS_EX_TOPMOST ,
// szShadeWindowClass,
// NULL,
// WS_POPUP|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,
// CW_USEDEFAULT, 0,
// CW_USEDEFAULT, 0,
// hWndParent, (HMENU)0,
// AfxGetInstanceHandle(),
// &shadeInfo);
//}
#ifdef _AFXDLL
static void ForceVectorDelete()
{
// this function is only need for exporting all template
// functions
// never called
ASSERT(FALSE);
new CNewFrameWnd[2];
new CNewMDIChildWnd[2];
new CNewMDIFrameWnd[2];
new CNewDialog[2];
new CNewMiniDockFrameWnd[2];
new CNewMiniFrameWnd[2];
}
void (*_ForceVectorDelete)() = &ForceVectorDelete;
#endif
| [
"antimezhang@91219e7a-2a93-11de-a435-ffa8d773f76a",
"[email protected]@91219e7a-2a93-11de-a435-ffa8d773f76a"
]
| [
[
[
1,
1
],
[
5,
6
],
[
8,
8
],
[
11,
14
],
[
17,
17
],
[
19,
20
],
[
22,
23
],
[
27,
30
],
[
33,
37
],
[
83,
99
],
[
101,
106
],
[
108,
108
],
[
110,
117
],
[
119,
123
],
[
125,
133
],
[
135,
138
],
[
140,
153
],
[
155,
173
],
[
176,
176
],
[
178,
178
],
[
181,
181
],
[
183,
223
],
[
225,
239
],
[
313,
316
],
[
318,
326
],
[
331,
343
],
[
345,
387
],
[
389,
389
],
[
400,
403
],
[
413,
415
],
[
417,
424
],
[
426,
428
],
[
433,
433
],
[
435,
454
],
[
456,
467
],
[
469,
481
],
[
483,
528
],
[
601,
624
],
[
689,
710
],
[
749,
750
],
[
1108,
1125
],
[
1127,
1127
],
[
1129,
1129
],
[
1133,
1133
],
[
1137,
1137
],
[
1140,
1140
],
[
1142,
1142
],
[
1146,
1146
],
[
1161,
1161
],
[
1164,
1164
],
[
1166,
1180
],
[
1182,
1189
],
[
1191,
1195
],
[
1212,
1219
],
[
1221,
1224
],
[
1226,
1228
],
[
1233,
1241
],
[
1246,
1250
],
[
1252,
1260
],
[
1262,
1297
],
[
1321,
1329
],
[
1331,
1337
],
[
1339,
1343
],
[
1347,
1347
],
[
1352,
1359
],
[
1375,
1388
],
[
1391,
1391
],
[
1393,
1412
],
[
1414,
1425
],
[
1427,
1436
],
[
1438,
1462
],
[
1465,
1469
],
[
1471,
1474
],
[
1476,
1484
],
[
1486,
1488
],
[
1490,
1494
],
[
1508,
1516
],
[
1518,
1518
],
[
1529,
1535
],
[
1537,
1540
],
[
1542,
1550
],
[
1566,
1567
],
[
1569,
1577
],
[
1579,
1638
],
[
1640,
1640
],
[
1642,
1642
],
[
1644,
1670
],
[
1672,
1672
],
[
1674,
1675
],
[
1680,
1686
],
[
1689,
1704
],
[
1707,
1715
],
[
1717,
1727
],
[
1730,
1740
],
[
1746,
1762
],
[
1764,
1767
],
[
1769,
1782
],
[
1784,
1809
],
[
1811,
1813
],
[
1819,
1851
],
[
1853,
1868
],
[
1870,
1880
],
[
1882,
1886
],
[
1908,
1915
],
[
1917,
1930
],
[
1932,
1971
],
[
1973,
1985
],
[
1987,
1993
],
[
2043,
2046
],
[
2049,
2060
],
[
2062,
2071
],
[
2073,
2075
],
[
2079,
2099
],
[
2101,
2103
],
[
2105,
2127
],
[
2129,
2133
],
[
2135,
2145
],
[
2147,
2147
],
[
2149,
2175
],
[
2179,
2202
],
[
2205,
2205
],
[
2212,
2212
],
[
2217,
2217
],
[
2221,
2221
],
[
2224,
2241
],
[
2243,
2260
],
[
2262,
2290
],
[
2292,
2309
],
[
2311,
2431
],
[
2433,
2435
],
[
2442,
2450
],
[
2453,
2453
],
[
2528,
2528
],
[
2530,
2544
],
[
2546,
2549
],
[
2568,
2579
],
[
2583,
2604
],
[
2612,
2620
],
[
2627,
2667
],
[
2669,
2671
],
[
2673,
2686
],
[
2691,
2691
],
[
2694,
2694
],
[
2697,
2697
],
[
2722,
2722
],
[
2733,
2733
],
[
2745,
2745
],
[
2762,
2762
],
[
2765,
2765
],
[
2769,
2769
],
[
2793,
2793
],
[
2834,
2834
],
[
2910,
2932
],
[
2934,
2935
],
[
2937,
2937
],
[
2943,
2955
],
[
2959,
2962
],
[
2969,
3001
],
[
3010,
3014
],
[
3016,
3016
],
[
3018,
3020
],
[
3024,
3041
],
[
3043,
3055
],
[
3057,
3081
],
[
3083,
3135
],
[
3138,
3139
],
[
3141,
3148
],
[
3151,
3151
],
[
3154,
3154
],
[
3156,
3175
],
[
3181,
3181
],
[
3186,
3186
],
[
3213,
3257
],
[
3259,
3264
],
[
3266,
3269
],
[
3292,
3294
],
[
3296,
3324
],
[
3326,
3331
],
[
3333,
3346
],
[
3348,
3352
],
[
3354,
3366
],
[
3368,
3391
],
[
3423,
3424
],
[
3433,
3446
],
[
3448,
3453
],
[
3455,
3455
],
[
3457,
3459
],
[
3461,
3466
],
[
3468,
3470
],
[
3472,
3488
],
[
3490,
3498
],
[
3500,
3510
],
[
3512,
3514
],
[
3516,
3518
],
[
3538,
3569
],
[
3571,
3573
],
[
3575,
3579
],
[
3581,
3584
],
[
3586,
3596
],
[
3598,
3614
],
[
3616,
3616
],
[
3622,
3625
],
[
3627,
3634
],
[
3637,
3640
],
[
3647,
3648
],
[
3659,
3659
],
[
3661,
3662
],
[
3664,
3667
],
[
3678,
3691
],
[
3693,
3698
],
[
3701,
3701
],
[
3704,
3705
],
[
3710,
3710
],
[
3715,
3715
],
[
3720,
3720
],
[
3725,
3729
],
[
3735,
3735
],
[
3752,
3752
],
[
3757,
3757
],
[
3770,
3796
],
[
3798,
3806
],
[
3808,
3808
],
[
3816,
3816
],
[
3819,
3851
],
[
3853,
3871
],
[
3873,
3883
],
[
3887,
3887
],
[
3892,
3898
],
[
3906,
3926
],
[
3932,
3936
],
[
3939,
3939
],
[
3941,
3954
],
[
3966,
3967
],
[
3969,
3971
],
[
3973,
3974
],
[
3976,
3985
],
[
3987,
3991
],
[
3993,
4004
],
[
4006,
4006
],
[
4009,
4012
],
[
4020,
4020
],
[
4022,
4044
],
[
4046,
4084
],
[
4086,
4097
],
[
4099,
4111
],
[
4113,
4113
],
[
4121,
4121
],
[
4123,
4147
],
[
4150,
4162
],
[
4164,
4166
],
[
4168,
4171
],
[
4173,
4179
],
[
4181,
4184
],
[
4186,
4193
],
[
4197,
4201
],
[
4203,
4205
],
[
4207,
4211
],
[
4213,
4221
],
[
4223,
4229
],
[
4239,
4239
],
[
4241,
4256
],
[
4262,
4265
],
[
4267,
4274
],
[
4277,
4280
],
[
4290,
4292
],
[
4297,
4298
],
[
4308,
4310
],
[
4312,
4322
],
[
4339,
4339
],
[
4342,
4345
],
[
4348,
4351
],
[
4363,
4363
],
[
4366,
4366
],
[
4368,
4372
],
[
4383,
4396
],
[
4398,
4403
],
[
4406,
4406
],
[
4409,
4410
],
[
4415,
4415
],
[
4420,
4420
],
[
4425,
4425
],
[
4430,
4434
],
[
4440,
4440
],
[
4457,
4457
],
[
4463,
4463
],
[
4480,
4506
],
[
4508,
4516
],
[
4518,
4518
],
[
4527,
4527
],
[
4530,
4550
],
[
4552,
4576
],
[
4578,
4596
],
[
4598,
4603
],
[
4605,
4607
],
[
4616,
4622
],
[
4630,
4650
],
[
4656,
4660
],
[
4663,
4663
],
[
4665,
4685
],
[
4688,
4689
],
[
4691,
4693
],
[
4695,
4696
],
[
4698,
4707
],
[
4709,
4713
],
[
4715,
4726
],
[
4728,
4728
],
[
4731,
4734
],
[
4742,
4742
],
[
4744,
4759
],
[
4761,
4769
],
[
4771,
4774
],
[
4797,
4799
],
[
4801,
4813
],
[
4815,
4827
],
[
4829,
4829
],
[
4837,
4837
],
[
4839,
4856
],
[
4859,
4871
],
[
4873,
4880
],
[
4882,
4888
],
[
4890,
4893
],
[
4895,
4932
],
[
4934,
4950
],
[
4952,
4954
],
[
4969,
4969
],
[
4971,
4971
],
[
4983,
4996
],
[
4998,
4999
],
[
5001,
5005
],
[
5007,
5015
],
[
5017,
5018
],
[
5020,
5023
],
[
5026,
5027
],
[
5030,
5033
],
[
5044,
5046
],
[
5056,
5064
],
[
5066,
5085
],
[
5087,
5093
],
[
5095,
5098
],
[
5100,
5125
],
[
5127,
5146
],
[
5148,
5167
],
[
5169,
5195
],
[
5197,
5225
],
[
5229,
5230
],
[
5232,
5259
],
[
5261,
5274
],
[
5276,
5284
],
[
5290,
5300
],
[
5304,
5343
],
[
5362,
5369
],
[
5385,
5389
],
[
5398,
5404
],
[
5411,
5417
],
[
5427,
5427
],
[
5433,
5439
],
[
5441,
5443
],
[
5445,
5446
],
[
5448,
5453
],
[
5455,
5456
],
[
5458,
5475
],
[
5477,
5479
],
[
5481,
5485
],
[
5487,
5491
],
[
5494,
5495
],
[
5498,
5501
],
[
5512,
5514
],
[
5520,
5520
],
[
5522,
5522
],
[
5528,
5537
],
[
5539,
5558
],
[
5560,
5566
],
[
5568,
5569
],
[
5571,
5640
],
[
5642,
5661
],
[
5665,
5666
],
[
5668,
5695
],
[
5697,
5709
],
[
5716,
5723
],
[
5729,
5738
],
[
5741,
5746
],
[
5748,
5773
],
[
5791,
5795
],
[
5812,
5815
],
[
5824,
5830
],
[
5837,
5843
],
[
5853,
5853
],
[
5859,
5865
],
[
5867,
5876
],
[
5878,
5879
],
[
5881,
5886
],
[
5888,
5889
],
[
5891,
5902
],
[
5905,
5907
],
[
5909,
5912
],
[
5914,
5915
],
[
5921,
5928
],
[
5933,
5945
],
[
5972,
5974
],
[
5983,
5995
],
[
5998,
6011
],
[
6019,
6019
],
[
6021,
6021
],
[
6023,
6024
],
[
6026,
6026
],
[
6028,
6028
],
[
6045,
6069
],
[
6071,
6073
],
[
6075,
6087
],
[
6089,
6099
],
[
6101,
6114
],
[
6141,
6143
],
[
6152,
6157
],
[
6159,
6164
],
[
6167,
6180
],
[
6203,
6203
],
[
6205,
6205
],
[
6216,
6239
],
[
6241,
6243
],
[
6245,
6257
],
[
6259,
6269
],
[
6271,
6278
],
[
6281,
6283
],
[
6288,
6288
],
[
6294,
6294
],
[
6311,
6313
],
[
6322,
6334
],
[
6337,
6350
],
[
6357,
6357
],
[
6366,
6366
],
[
6373,
6373
],
[
6388,
6395
],
[
6397,
6398
],
[
6400,
6402
],
[
6409,
6409
],
[
6412,
6417
],
[
6419,
6421
],
[
6423,
6435
],
[
6437,
6449
],
[
6451,
6458
],
[
6464,
6477
],
[
6479,
6493
],
[
6495,
6522
],
[
6524,
6529
],
[
6532,
6541
],
[
6543,
6595
],
[
6597,
6600
],
[
6602,
6609
],
[
6611,
6611
],
[
6613,
6618
],
[
6621,
6624
],
[
6626,
6637
],
[
6639,
6644
],
[
6647,
6665
],
[
6667,
6680
],
[
6682,
6704
],
[
6706,
6719
],
[
6721,
6839
],
[
6841,
6879
],
[
6881,
6892
],
[
6894,
6920
],
[
6922,
6935
],
[
6937,
6948
],
[
6953,
6989
],
[
6991,
6993
],
[
6995,
7001
],
[
7003,
7010
],
[
7013,
7013
],
[
7015,
7041
],
[
7044,
7045
],
[
7047,
7066
],
[
7068,
7078
],
[
7080,
7089
],
[
7091,
7120
],
[
7122,
7125
],
[
7127,
7161
],
[
7163,
7163
],
[
7165,
7172
],
[
7174,
7210
],
[
7212,
7245
],
[
7283,
7296
],
[
7298,
7320
],
[
7384,
7423
],
[
7426,
7453
],
[
7455,
7493
],
[
7495,
7516
],
[
7518,
7519
],
[
7522,
7543
],
[
7545,
7553
],
[
7555,
7559
],
[
7561,
7562
],
[
7564,
7573
],
[
7576,
7576
],
[
7580,
7583
],
[
7585,
7586
],
[
7588,
7608
],
[
7610,
7647
],
[
7686,
7718
],
[
7721,
7721
],
[
7723,
7739
],
[
7741,
7753
],
[
7755,
7767
],
[
7769,
7775
],
[
7777,
7794
],
[
7799,
7799
],
[
7810,
7813
],
[
7828,
7836
],
[
7841,
7844
],
[
7852,
7882
],
[
7884,
7892
],
[
7894,
7915
],
[
7917,
7919
],
[
7921,
7928
],
[
7930,
7997
],
[
8000,
8004
],
[
8008,
8045
],
[
8047,
8153
],
[
8155,
8190
],
[
8193,
8197
],
[
8199,
8237
],
[
8239,
8262
],
[
8265,
8265
],
[
8267,
8267
],
[
8269,
8270
],
[
8273,
8273
],
[
8275,
8275
],
[
8278,
8328
],
[
8331,
8331
],
[
8333,
8333
],
[
8335,
8337
],
[
8341,
8341
],
[
8343,
8343
],
[
8346,
8367
],
[
8369,
8429
],
[
8431,
8440
],
[
8442,
8459
],
[
8463,
8500
],
[
8523,
8523
],
[
8525,
8539
],
[
8550,
8557
],
[
8572,
8601
],
[
8636,
8648
],
[
8650,
8672
],
[
8675,
8677
],
[
8681,
8681
],
[
8683,
8705
],
[
8707,
8763
],
[
8765,
8771
],
[
8773,
8793
],
[
8795,
8807
],
[
8809,
8814
],
[
8816,
8831
],
[
8833,
8835
],
[
8838,
8849
],
[
8858,
8859
],
[
8870,
8870
],
[
8873,
8908
],
[
8910,
8916
],
[
8918,
8932
],
[
8934,
8934
],
[
8936,
8951
],
[
8953,
8955
],
[
8957,
8959
],
[
8963,
8972
],
[
8974,
8975
],
[
8979,
8979
],
[
8982,
8986
],
[
8988,
8993
],
[
8995,
9004
],
[
9006,
9009
],
[
9011,
9013
],
[
9015,
9017
],
[
9019,
9021
],
[
9023,
9024
],
[
9026,
9031
],
[
9034,
9036
],
[
9038,
9041
],
[
9044,
9044
],
[
9046,
9046
],
[
9048,
9051
],
[
9053,
9055
],
[
9058,
9060
],
[
9063,
9068
],
[
9070,
9072
],
[
9324,
9327
],
[
9329,
9329
],
[
9346,
9346
],
[
9379,
9387
],
[
9393,
9393
],
[
9395,
9395
],
[
9403,
9403
],
[
9422,
9427
],
[
9430,
9432
],
[
9434,
9434
],
[
9437,
9438
],
[
9441,
9452
],
[
9454,
9457
],
[
9459,
9459
],
[
9461,
9461
],
[
9463,
9463
],
[
9465,
9465
],
[
9467,
9476
],
[
9478,
9478
],
[
9480,
9492
],
[
9494,
9494
],
[
9496,
9507
],
[
9509,
9509
],
[
9511,
9519
],
[
9522,
9528
],
[
9530,
9531
],
[
9541,
9574
],
[
9577,
9603
],
[
9605,
9610
],
[
9613,
9626
],
[
9628,
9652
],
[
9654,
9657
],
[
9659,
9663
],
[
9665,
9666
],
[
9669,
9672
],
[
9674,
9679
],
[
9682,
9689
],
[
9691,
9703
],
[
9705,
9711
],
[
9713,
9717
],
[
9719,
9737
],
[
9739,
9739
],
[
9748,
9764
],
[
9766,
9769
],
[
9771,
9771
],
[
9773,
9773
],
[
9775,
9775
],
[
9778,
9784
],
[
9797,
9810
],
[
9812,
9823
],
[
9825,
9829
],
[
9840,
9847
],
[
9850,
9882
],
[
9884,
9884
],
[
9888,
9889
],
[
9893,
9894
],
[
9898,
9899
],
[
9903,
9904
],
[
9908,
9909
],
[
9933,
9934
],
[
9938,
9939
],
[
9943,
9943
],
[
9946,
9946
],
[
9948,
9953
],
[
9955,
9956
],
[
9958,
9965
],
[
9967,
9999
],
[
10001,
10036
],
[
10038,
10048
],
[
10050,
10073
],
[
10075,
10076
],
[
10078,
10078
],
[
10080,
10093
],
[
10095,
10096
],
[
10098,
10118
],
[
10120,
10131
],
[
10133,
10137
],
[
10139,
10139
],
[
10141,
10164
],
[
10166,
10167
],
[
10169,
10172
],
[
10174,
10174
],
[
10176,
10184
],
[
10186,
10189
],
[
10191,
10192
],
[
10194,
10234
],
[
10236,
10237
],
[
10239,
10246
],
[
10248,
10251
],
[
10254,
10265
],
[
10267,
10279
],
[
10281,
10281
],
[
10283,
10285
],
[
10287,
10287
],
[
10289,
10307
],
[
10309,
10331
],
[
10333,
10334
],
[
10336,
10340
],
[
10343,
10343
],
[
10345,
10375
],
[
10377,
10383
],
[
10385,
10393
],
[
10431,
10444
],
[
10446,
10461
],
[
10476,
10477
],
[
10479,
10484
],
[
10486,
10493
],
[
10495,
10498
],
[
10500,
10500
],
[
10502,
10503
],
[
10506,
10506
],
[
10508,
10508
],
[
10510,
10534
],
[
10560,
10569
],
[
10573,
10576
],
[
10579,
10594
],
[
10596,
10608
],
[
10610,
10615
],
[
10617,
10617
],
[
10619,
10619
],
[
10626,
10627
],
[
10629,
10635
],
[
10637,
10640
],
[
10643,
10649
],
[
10651,
10652
],
[
10654,
10661
],
[
10663,
10665
],
[
10669,
10673
],
[
10675,
10726
],
[
10728,
10728
],
[
10730,
10747
],
[
10750,
10786
],
[
10788,
10899
],
[
10907,
10907
],
[
10915,
10915
],
[
10922,
10928
],
[
10936,
10937
],
[
10939,
10940
],
[
10942,
10958
],
[
10960,
10992
],
[
10994,
11007
],
[
11009,
11014
],
[
11016,
11025
],
[
11027,
11035
],
[
11037,
11057
],
[
11059,
11073
],
[
11081,
11083
],
[
11085,
11088
],
[
11090,
11100
],
[
11102,
11110
],
[
11112,
11131
],
[
11133,
11156
],
[
11164,
11170
],
[
11172,
11186
],
[
11188,
11193
],
[
11195,
11222
],
[
11224,
11238
],
[
11240,
11242
],
[
11244,
11262
],
[
11264,
11269
],
[
11271,
11281
],
[
11283,
11286
],
[
11288,
11306
],
[
11311,
11317
],
[
11319,
11362
],
[
11366,
11392
]
],
[
[
2,
4
],
[
7,
7
],
[
9,
10
],
[
15,
16
],
[
18,
18
],
[
21,
21
],
[
24,
26
],
[
31,
32
],
[
38,
82
],
[
100,
100
],
[
107,
107
],
[
109,
109
],
[
118,
118
],
[
124,
124
],
[
134,
134
],
[
139,
139
],
[
154,
154
],
[
174,
175
],
[
177,
177
],
[
179,
180
],
[
182,
182
],
[
224,
224
],
[
240,
312
],
[
317,
317
],
[
327,
330
],
[
344,
344
],
[
388,
388
],
[
390,
399
],
[
404,
412
],
[
416,
416
],
[
425,
425
],
[
429,
432
],
[
434,
434
],
[
455,
455
],
[
468,
468
],
[
482,
482
],
[
529,
600
],
[
625,
688
],
[
711,
748
],
[
751,
1107
],
[
1126,
1126
],
[
1128,
1128
],
[
1130,
1132
],
[
1134,
1136
],
[
1138,
1139
],
[
1141,
1141
],
[
1143,
1145
],
[
1147,
1160
],
[
1162,
1163
],
[
1165,
1165
],
[
1181,
1181
],
[
1190,
1190
],
[
1196,
1211
],
[
1220,
1220
],
[
1225,
1225
],
[
1229,
1232
],
[
1242,
1245
],
[
1251,
1251
],
[
1261,
1261
],
[
1298,
1320
],
[
1330,
1330
],
[
1338,
1338
],
[
1344,
1346
],
[
1348,
1351
],
[
1360,
1374
],
[
1389,
1390
],
[
1392,
1392
],
[
1413,
1413
],
[
1426,
1426
],
[
1437,
1437
],
[
1463,
1464
],
[
1470,
1470
],
[
1475,
1475
],
[
1485,
1485
],
[
1489,
1489
],
[
1495,
1507
],
[
1517,
1517
],
[
1519,
1528
],
[
1536,
1536
],
[
1541,
1541
],
[
1551,
1565
],
[
1568,
1568
],
[
1578,
1578
],
[
1639,
1639
],
[
1641,
1641
],
[
1643,
1643
],
[
1671,
1671
],
[
1673,
1673
],
[
1676,
1679
],
[
1687,
1688
],
[
1705,
1706
],
[
1716,
1716
],
[
1728,
1729
],
[
1741,
1745
],
[
1763,
1763
],
[
1768,
1768
],
[
1783,
1783
],
[
1810,
1810
],
[
1814,
1818
],
[
1852,
1852
],
[
1869,
1869
],
[
1881,
1881
],
[
1887,
1907
],
[
1916,
1916
],
[
1931,
1931
],
[
1972,
1972
],
[
1986,
1986
],
[
1994,
2042
],
[
2047,
2048
],
[
2061,
2061
],
[
2072,
2072
],
[
2076,
2078
],
[
2100,
2100
],
[
2104,
2104
],
[
2128,
2128
],
[
2134,
2134
],
[
2146,
2146
],
[
2148,
2148
],
[
2176,
2178
],
[
2203,
2204
],
[
2206,
2211
],
[
2213,
2216
],
[
2218,
2220
],
[
2222,
2223
],
[
2242,
2242
],
[
2261,
2261
],
[
2291,
2291
],
[
2310,
2310
],
[
2432,
2432
],
[
2436,
2441
],
[
2451,
2452
],
[
2454,
2527
],
[
2529,
2529
],
[
2545,
2545
],
[
2550,
2567
],
[
2580,
2582
],
[
2605,
2611
],
[
2621,
2626
],
[
2668,
2668
],
[
2672,
2672
],
[
2687,
2690
],
[
2692,
2693
],
[
2695,
2696
],
[
2698,
2721
],
[
2723,
2732
],
[
2734,
2744
],
[
2746,
2761
],
[
2763,
2764
],
[
2766,
2768
],
[
2770,
2792
],
[
2794,
2833
],
[
2835,
2909
],
[
2933,
2933
],
[
2936,
2936
],
[
2938,
2942
],
[
2956,
2958
],
[
2963,
2968
],
[
3002,
3009
],
[
3015,
3015
],
[
3017,
3017
],
[
3021,
3023
],
[
3042,
3042
],
[
3056,
3056
],
[
3082,
3082
],
[
3136,
3137
],
[
3140,
3140
],
[
3149,
3150
],
[
3152,
3153
],
[
3155,
3155
],
[
3176,
3180
],
[
3182,
3185
],
[
3187,
3212
],
[
3258,
3258
],
[
3265,
3265
],
[
3270,
3291
],
[
3295,
3295
],
[
3325,
3325
],
[
3332,
3332
],
[
3347,
3347
],
[
3353,
3353
],
[
3367,
3367
],
[
3392,
3422
],
[
3425,
3432
],
[
3447,
3447
],
[
3454,
3454
],
[
3456,
3456
],
[
3460,
3460
],
[
3467,
3467
],
[
3471,
3471
],
[
3489,
3489
],
[
3499,
3499
],
[
3511,
3511
],
[
3515,
3515
],
[
3519,
3537
],
[
3570,
3570
],
[
3574,
3574
],
[
3580,
3580
],
[
3585,
3585
],
[
3597,
3597
],
[
3615,
3615
],
[
3617,
3621
],
[
3626,
3626
],
[
3635,
3636
],
[
3641,
3646
],
[
3649,
3658
],
[
3660,
3660
],
[
3663,
3663
],
[
3668,
3677
],
[
3692,
3692
],
[
3699,
3700
],
[
3702,
3703
],
[
3706,
3709
],
[
3711,
3714
],
[
3716,
3719
],
[
3721,
3724
],
[
3730,
3734
],
[
3736,
3751
],
[
3753,
3756
],
[
3758,
3769
],
[
3797,
3797
],
[
3807,
3807
],
[
3809,
3815
],
[
3817,
3818
],
[
3852,
3852
],
[
3872,
3872
],
[
3884,
3886
],
[
3888,
3891
],
[
3899,
3905
],
[
3927,
3931
],
[
3937,
3938
],
[
3940,
3940
],
[
3955,
3965
],
[
3968,
3968
],
[
3972,
3972
],
[
3975,
3975
],
[
3986,
3986
],
[
3992,
3992
],
[
4005,
4005
],
[
4007,
4008
],
[
4013,
4019
],
[
4021,
4021
],
[
4045,
4045
],
[
4085,
4085
],
[
4098,
4098
],
[
4112,
4112
],
[
4114,
4120
],
[
4122,
4122
],
[
4148,
4149
],
[
4163,
4163
],
[
4167,
4167
],
[
4172,
4172
],
[
4180,
4180
],
[
4185,
4185
],
[
4194,
4196
],
[
4202,
4202
],
[
4206,
4206
],
[
4212,
4212
],
[
4222,
4222
],
[
4230,
4238
],
[
4240,
4240
],
[
4257,
4261
],
[
4266,
4266
],
[
4275,
4276
],
[
4281,
4289
],
[
4293,
4296
],
[
4299,
4307
],
[
4311,
4311
],
[
4323,
4338
],
[
4340,
4341
],
[
4346,
4347
],
[
4352,
4362
],
[
4364,
4365
],
[
4367,
4367
],
[
4373,
4382
],
[
4397,
4397
],
[
4404,
4405
],
[
4407,
4408
],
[
4411,
4414
],
[
4416,
4419
],
[
4421,
4424
],
[
4426,
4429
],
[
4435,
4439
],
[
4441,
4456
],
[
4458,
4462
],
[
4464,
4479
],
[
4507,
4507
],
[
4517,
4517
],
[
4519,
4526
],
[
4528,
4529
],
[
4551,
4551
],
[
4577,
4577
],
[
4597,
4597
],
[
4604,
4604
],
[
4608,
4615
],
[
4623,
4629
],
[
4651,
4655
],
[
4661,
4662
],
[
4664,
4664
],
[
4686,
4687
],
[
4690,
4690
],
[
4694,
4694
],
[
4697,
4697
],
[
4708,
4708
],
[
4714,
4714
],
[
4727,
4727
],
[
4729,
4730
],
[
4735,
4741
],
[
4743,
4743
],
[
4760,
4760
],
[
4770,
4770
],
[
4775,
4796
],
[
4800,
4800
],
[
4814,
4814
],
[
4828,
4828
],
[
4830,
4836
],
[
4838,
4838
],
[
4857,
4858
],
[
4872,
4872
],
[
4881,
4881
],
[
4889,
4889
],
[
4894,
4894
],
[
4933,
4933
],
[
4951,
4951
],
[
4955,
4968
],
[
4970,
4970
],
[
4972,
4982
],
[
4997,
4997
],
[
5000,
5000
],
[
5006,
5006
],
[
5016,
5016
],
[
5019,
5019
],
[
5024,
5025
],
[
5028,
5029
],
[
5034,
5043
],
[
5047,
5055
],
[
5065,
5065
],
[
5086,
5086
],
[
5094,
5094
],
[
5099,
5099
],
[
5126,
5126
],
[
5147,
5147
],
[
5168,
5168
],
[
5196,
5196
],
[
5226,
5228
],
[
5231,
5231
],
[
5260,
5260
],
[
5275,
5275
],
[
5285,
5289
],
[
5301,
5303
],
[
5344,
5361
],
[
5370,
5384
],
[
5390,
5397
],
[
5405,
5410
],
[
5418,
5426
],
[
5428,
5432
],
[
5440,
5440
],
[
5444,
5444
],
[
5447,
5447
],
[
5454,
5454
],
[
5457,
5457
],
[
5476,
5476
],
[
5480,
5480
],
[
5486,
5486
],
[
5492,
5493
],
[
5496,
5497
],
[
5502,
5511
],
[
5515,
5519
],
[
5521,
5521
],
[
5523,
5527
],
[
5538,
5538
],
[
5559,
5559
],
[
5567,
5567
],
[
5570,
5570
],
[
5641,
5641
],
[
5662,
5664
],
[
5667,
5667
],
[
5696,
5696
],
[
5710,
5715
],
[
5724,
5728
],
[
5739,
5740
],
[
5747,
5747
],
[
5774,
5790
],
[
5796,
5811
],
[
5816,
5823
],
[
5831,
5836
],
[
5844,
5852
],
[
5854,
5858
],
[
5866,
5866
],
[
5877,
5877
],
[
5880,
5880
],
[
5887,
5887
],
[
5890,
5890
],
[
5903,
5904
],
[
5908,
5908
],
[
5913,
5913
],
[
5916,
5920
],
[
5929,
5932
],
[
5946,
5971
],
[
5975,
5982
],
[
5996,
5997
],
[
6012,
6018
],
[
6020,
6020
],
[
6022,
6022
],
[
6025,
6025
],
[
6027,
6027
],
[
6029,
6044
],
[
6070,
6070
],
[
6074,
6074
],
[
6088,
6088
],
[
6100,
6100
],
[
6115,
6140
],
[
6144,
6151
],
[
6158,
6158
],
[
6165,
6166
],
[
6181,
6202
],
[
6204,
6204
],
[
6206,
6215
],
[
6240,
6240
],
[
6244,
6244
],
[
6258,
6258
],
[
6270,
6270
],
[
6279,
6280
],
[
6284,
6287
],
[
6289,
6293
],
[
6295,
6310
],
[
6314,
6321
],
[
6335,
6336
],
[
6351,
6356
],
[
6358,
6365
],
[
6367,
6372
],
[
6374,
6387
],
[
6396,
6396
],
[
6399,
6399
],
[
6403,
6408
],
[
6410,
6411
],
[
6418,
6418
],
[
6422,
6422
],
[
6436,
6436
],
[
6450,
6450
],
[
6459,
6463
],
[
6478,
6478
],
[
6494,
6494
],
[
6523,
6523
],
[
6530,
6531
],
[
6542,
6542
],
[
6596,
6596
],
[
6601,
6601
],
[
6610,
6610
],
[
6612,
6612
],
[
6619,
6620
],
[
6625,
6625
],
[
6638,
6638
],
[
6645,
6646
],
[
6666,
6666
],
[
6681,
6681
],
[
6705,
6705
],
[
6720,
6720
],
[
6840,
6840
],
[
6880,
6880
],
[
6893,
6893
],
[
6921,
6921
],
[
6936,
6936
],
[
6949,
6952
],
[
6990,
6990
],
[
6994,
6994
],
[
7002,
7002
],
[
7011,
7012
],
[
7014,
7014
],
[
7042,
7043
],
[
7046,
7046
],
[
7067,
7067
],
[
7079,
7079
],
[
7090,
7090
],
[
7121,
7121
],
[
7126,
7126
],
[
7162,
7162
],
[
7164,
7164
],
[
7173,
7173
],
[
7211,
7211
],
[
7246,
7282
],
[
7297,
7297
],
[
7321,
7383
],
[
7424,
7425
],
[
7454,
7454
],
[
7494,
7494
],
[
7517,
7517
],
[
7520,
7521
],
[
7544,
7544
],
[
7554,
7554
],
[
7560,
7560
],
[
7563,
7563
],
[
7574,
7575
],
[
7577,
7579
],
[
7584,
7584
],
[
7587,
7587
],
[
7609,
7609
],
[
7648,
7685
],
[
7719,
7720
],
[
7722,
7722
],
[
7740,
7740
],
[
7754,
7754
],
[
7768,
7768
],
[
7776,
7776
],
[
7795,
7798
],
[
7800,
7809
],
[
7814,
7827
],
[
7837,
7840
],
[
7845,
7851
],
[
7883,
7883
],
[
7893,
7893
],
[
7916,
7916
],
[
7920,
7920
],
[
7929,
7929
],
[
7998,
7999
],
[
8005,
8007
],
[
8046,
8046
],
[
8154,
8154
],
[
8191,
8192
],
[
8198,
8198
],
[
8238,
8238
],
[
8263,
8264
],
[
8266,
8266
],
[
8268,
8268
],
[
8271,
8272
],
[
8274,
8274
],
[
8276,
8277
],
[
8329,
8330
],
[
8332,
8332
],
[
8334,
8334
],
[
8338,
8340
],
[
8342,
8342
],
[
8344,
8345
],
[
8368,
8368
],
[
8430,
8430
],
[
8441,
8441
],
[
8460,
8462
],
[
8501,
8522
],
[
8524,
8524
],
[
8540,
8549
],
[
8558,
8571
],
[
8602,
8635
],
[
8649,
8649
],
[
8673,
8674
],
[
8678,
8680
],
[
8682,
8682
],
[
8706,
8706
],
[
8764,
8764
],
[
8772,
8772
],
[
8794,
8794
],
[
8808,
8808
],
[
8815,
8815
],
[
8832,
8832
],
[
8836,
8837
],
[
8850,
8857
],
[
8860,
8869
],
[
8871,
8872
],
[
8909,
8909
],
[
8917,
8917
],
[
8933,
8933
],
[
8935,
8935
],
[
8952,
8952
],
[
8956,
8956
],
[
8960,
8962
],
[
8973,
8973
],
[
8976,
8978
],
[
8980,
8981
],
[
8987,
8987
],
[
8994,
8994
],
[
9005,
9005
],
[
9010,
9010
],
[
9014,
9014
],
[
9018,
9018
],
[
9022,
9022
],
[
9025,
9025
],
[
9032,
9033
],
[
9037,
9037
],
[
9042,
9043
],
[
9045,
9045
],
[
9047,
9047
],
[
9052,
9052
],
[
9056,
9057
],
[
9061,
9062
],
[
9069,
9069
],
[
9073,
9323
],
[
9328,
9328
],
[
9330,
9345
],
[
9347,
9378
],
[
9388,
9392
],
[
9394,
9394
],
[
9396,
9402
],
[
9404,
9421
],
[
9428,
9429
],
[
9433,
9433
],
[
9435,
9436
],
[
9439,
9440
],
[
9453,
9453
],
[
9458,
9458
],
[
9460,
9460
],
[
9462,
9462
],
[
9464,
9464
],
[
9466,
9466
],
[
9477,
9477
],
[
9479,
9479
],
[
9493,
9493
],
[
9495,
9495
],
[
9508,
9508
],
[
9510,
9510
],
[
9520,
9521
],
[
9529,
9529
],
[
9532,
9540
],
[
9575,
9576
],
[
9604,
9604
],
[
9611,
9612
],
[
9627,
9627
],
[
9653,
9653
],
[
9658,
9658
],
[
9664,
9664
],
[
9667,
9668
],
[
9673,
9673
],
[
9680,
9681
],
[
9690,
9690
],
[
9704,
9704
],
[
9712,
9712
],
[
9718,
9718
],
[
9738,
9738
],
[
9740,
9747
],
[
9765,
9765
],
[
9770,
9770
],
[
9772,
9772
],
[
9774,
9774
],
[
9776,
9777
],
[
9785,
9796
],
[
9811,
9811
],
[
9824,
9824
],
[
9830,
9839
],
[
9848,
9849
],
[
9883,
9883
],
[
9885,
9887
],
[
9890,
9892
],
[
9895,
9897
],
[
9900,
9902
],
[
9905,
9907
],
[
9910,
9932
],
[
9935,
9937
],
[
9940,
9942
],
[
9944,
9945
],
[
9947,
9947
],
[
9954,
9954
],
[
9957,
9957
],
[
9966,
9966
],
[
10000,
10000
],
[
10037,
10037
],
[
10049,
10049
],
[
10074,
10074
],
[
10077,
10077
],
[
10079,
10079
],
[
10094,
10094
],
[
10097,
10097
],
[
10119,
10119
],
[
10132,
10132
],
[
10138,
10138
],
[
10140,
10140
],
[
10165,
10165
],
[
10168,
10168
],
[
10173,
10173
],
[
10175,
10175
],
[
10185,
10185
],
[
10190,
10190
],
[
10193,
10193
],
[
10235,
10235
],
[
10238,
10238
],
[
10247,
10247
],
[
10252,
10253
],
[
10266,
10266
],
[
10280,
10280
],
[
10282,
10282
],
[
10286,
10286
],
[
10288,
10288
],
[
10308,
10308
],
[
10332,
10332
],
[
10335,
10335
],
[
10341,
10342
],
[
10344,
10344
],
[
10376,
10376
],
[
10384,
10384
],
[
10394,
10430
],
[
10445,
10445
],
[
10462,
10475
],
[
10478,
10478
],
[
10485,
10485
],
[
10494,
10494
],
[
10499,
10499
],
[
10501,
10501
],
[
10504,
10505
],
[
10507,
10507
],
[
10509,
10509
],
[
10535,
10559
],
[
10570,
10572
],
[
10577,
10578
],
[
10595,
10595
],
[
10609,
10609
],
[
10616,
10616
],
[
10618,
10618
],
[
10620,
10625
],
[
10628,
10628
],
[
10636,
10636
],
[
10641,
10642
],
[
10650,
10650
],
[
10653,
10653
],
[
10662,
10662
],
[
10666,
10668
],
[
10674,
10674
],
[
10727,
10727
],
[
10729,
10729
],
[
10748,
10749
],
[
10787,
10787
],
[
10900,
10906
],
[
10908,
10914
],
[
10916,
10921
],
[
10929,
10935
],
[
10938,
10938
],
[
10941,
10941
],
[
10959,
10959
],
[
10993,
10993
],
[
11008,
11008
],
[
11015,
11015
],
[
11026,
11026
],
[
11036,
11036
],
[
11058,
11058
],
[
11074,
11080
],
[
11084,
11084
],
[
11089,
11089
],
[
11101,
11101
],
[
11111,
11111
],
[
11132,
11132
],
[
11157,
11163
],
[
11171,
11171
],
[
11187,
11187
],
[
11194,
11194
],
[
11223,
11223
],
[
11239,
11239
],
[
11243,
11243
],
[
11263,
11263
],
[
11270,
11270
],
[
11282,
11282
],
[
11287,
11287
],
[
11307,
11310
],
[
11318,
11318
],
[
11363,
11365
],
[
11393,
11777
]
]
]
|
b277f88766f722651e0a44d94bca8c4ce03c5bf8 | 4aefe3448abf56efce33557fab74117d1c668ae6 | /jdata-view-classes/jDataViewClasses/tableData.h | d47c51cecb3b41f8fb2999a866e0d7b99c03989a | []
| no_license | andriybun/gdata-view-classes | 9132a66667cddaf388a5ba447f40f660895c2c02 | 8aa3f0fa57dedbfe52a01f01cdfe9aa4f8601e0c | refs/heads/master | 2021-01-01T06:17:56.144322 | 2011-06-27T13:14:33 | 2011-06-27T13:14:33 | 32,204,796 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,620 | h | // Name: tableData class
// Author: Andriy Bun
// Date: 13.11.09
// Modified: 11.01.10 (Andriy Bun)
// Description: Class for storing and producing data for viewing with
// GDagaView Software. Is a friend class for MDT class.
#ifndef TABLEDATA_H_
#define TABLEDATA_H_
#include <map>
#include <set>
#include <vector>
#include <fstream>
#include <string>
#include <cmath>
#include "common.h"
#include "endianness.h"
#include "IntToStr.h"
#include "MDT.h"
#include "baseData.h"
class tableData : public baseData
{
private:
std::map<long long, float> data;
public:
tableData();
tableData(std::string fileNameGdc);
~tableData();
// Inserts a value "val" corresponding to a vector of string coordinates "point" into the list.
void insert(float val, str_vector_t point);
// Inserts a value "val" corresponding to a vector of integer coordinates "point" into the list.
void insert(float val, int_vector_t point);
// ... inserts value for current point and paramName set in last position in point, then it clears last param
void insert(float val, std::string paramName);
// Updates a value "val" corresponding to a vector of coordinates "point" into the list.
void update(float val, str_vector_t point);
void updateDimEl(std::string dimName, int posEl, std::string element);
// Clearing object
void clear();
// Append table by one of the dimensions
int append(tableData & another, int dim);
// Writing object to files *.GDT and *.GDC files
bool SaveToFile(std::string outDir, std::string fileName);
};
#endif
| [
"andr.bun@70e4ddfa-eeda-11de-aed4-3956c0e5a634"
]
| [
[
[
1,
49
]
]
]
|
157ab86ee0f2ddd5ace817fb1bf0c2e154248d8d | 2dbbca065b62a24f47aeb7ec5cd7a4fd82083dd4 | /OUAN/OUAN/Src/Audio/AudioSubsystem.cpp | 25b4ef76df5f2a9445feadc82aacb8cf27b74539 | []
| no_license | juanjmostazo/once-upon-a-night | 9651dc4dcebef80f0475e2e61865193ad61edaaa | f8d5d3a62952c45093a94c8b073cbb70f8146a53 | refs/heads/master | 2020-05-28T05:45:17.386664 | 2010-10-06T12:49:50 | 2010-10-06T12:49:50 | 38,101,059 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 25,020 | cpp | #include "OUAN_Precompiled.h"
#include "AudioSubsystem.h"
#include "Channel.h"
#include "AudioScriptLoader.h"
#include "../Application.h"
#include "../Utils/Utils.h"
#include "../Event/Event.h"
#include "../Event/EventManager.h"
using namespace OUAN;
//--- Audio subsystem config data
void TAudioSubsystemConfigData::set(ConfigurationPtr config)
{
if (config.get() && !config->isEmpty())
{
// 3D sound attributes
try
{
mDopplerScale=config->parseDouble(CONFIG_KEYS_DOPPLER_SCALE);
mDistanceFactor=config->parseDouble(CONFIG_KEYS_DISTANCE_FACTOR);
mRollOffScale=config->parseDouble(CONFIG_KEYS_ROLLOFF_SCALE);
mMasterVolume=config->parseDouble(CONFIG_KEYS_MASTER_VOLUME);
mMasterPitch=config->parseDouble(CONFIG_KEYS_MASTER_PITCH);
mMasterVolumeEnabled=config->parseBool(CONFIG_KEYS_MASTER_ENABLED);
mNumChannels=config->parseInt(CONFIG_KEYS_MASTER_NUM_CHANNELS);
mMusicVolume=config->parseDouble(CONFIG_KEYS_MUSIC_VOLUME);
mMusicPitch=config->parseDouble(CONFIG_KEYS_MUSIC_PITCH);
mMusicVolumeEnabled=config->parseBool(CONFIG_KEYS_MUSIC_ENABLED);
mMusicNumChannels=config->parseInt(CONFIG_KEYS_MUSIC_NUM_CHANNELS);
mSfxVolume=config->parseDouble(CONFIG_KEYS_SFX_VOLUME);
mSfxPitch=config->parseDouble(CONFIG_KEYS_SFX_PITCH);
mSfxVolumeEnabled=config->parseBool(CONFIG_KEYS_SFX_ENABLED);
mSfxNumChannels=config->parseInt(CONFIG_KEYS_SFX_NUM_CHANNELS);
mFrameSkip=config->parseInt(CONFIG_KEYS_AUDIO_SUBSYSTEM_FRAME_SKIP);
}
catch (const std::exception& e)
{
Logger::getInstance()->log("[AudioSubsystemConfigData::set]An error happened while parsing the audio config file");
Logger::getInstance()->log(e.what());
}
}
}
//--- FMOD'S VECTOR CONVERSION AUXILIARY FUNCTIONS
FMOD_VECTOR FMODHelper::toFMODVec(const Ogre::Vector3 &vec)
{
FMOD_VECTOR rc;
rc.x=vec.x;
rc.y=vec.y;
rc.z=vec.z;
return rc;
}
Ogre::Vector3 FMODHelper::toOgreVec3(const FMOD_VECTOR& vec)
{
Ogre::Vector3 rc;
rc.x=vec.x;
rc.y=vec.y;
rc.z=vec.z;
return rc;
}
//--- AUDIO SUBSYSTEM DEFS
AudioSubsystem::AudioSubsystem()
{
mSystem=NULL;
}
AudioSubsystem::~AudioSubsystem()
{
}
void AudioSubsystem::cleanUp()
{
for(TChannelGroupMap::iterator i=mChannelGroupMap.begin();
i!=mChannelGroupMap.end(); i++)
{
(i->second)->release();
}
mLastMusic.clear();
mChannelGroupMap.clear();
mSystem->close();
mSystem->release();
Ogre::ResourceGroupManager::getSingleton()._unregisterResourceManager(mResourceType);
}
bool AudioSubsystem::init(TAudioSubsystemConfigData& desc, ApplicationPtr app)
{
mApp=app;
mFrameSkip=desc.mFrameSkip;
bool rc = false;
//attempt to create the system
mOldConfigData=desc;
mConfigData=desc;
// m_logFile.push_back("SoundManager::init()");
if (FMOD_OK ==FMOD::System_Create(&mSystem))
{
//m_logFile.push_back("SoundManager::init create system Okay");
rc = true;
}
if(rc && FMOD_OK == mSystem->init(desc.mNumChannels, FMOD_INIT_NORMAL, 0))
{
//m_logFile.push_back("SoundManager::init system ok");
rc = true;
}
mSystem->set3DSettings(desc.mDopplerScale,desc.mDistanceFactor,
desc.mRollOffScale);
if(rc)
{
FMOD::ChannelGroup* channelGroups[3];
//get the master group
mSystem->getMasterChannelGroup(&channelGroups[0]);
//create various channel groups
mSystem->createChannelGroup(SM_CHANNEL_MUSIC_GROUP.c_str(),
&channelGroups[1]);
mSystem->createChannelGroup(SM_CHANNEL_SFX_GROUP.c_str(),
&channelGroups[2]);
//add these groups to the master group
channelGroups[0]->addGroup(channelGroups[1]);
channelGroups[0]->addGroup(channelGroups[2]);
mChannelGroupMap.clear();
mChannelGroupMap[SM_CHANNEL_MASTER_GROUP] = ChannelGroupPtr(new ChannelGroup(channelGroups[0]));
channelGroups[0]->setVolume(desc.mMasterVolume);
channelGroups[1]->setVolume(desc.mMusicVolume);
channelGroups[2]->setVolume(desc.mSfxVolume);
channelGroups[0]->setPitch(desc.mMasterPitch);
channelGroups[1]->setPitch(desc.mMusicPitch);
channelGroups[2]->setPitch(desc.mSfxPitch);
int offset = 0;
mChannelGroupMap[SM_CHANNEL_MUSIC_GROUP] = ChannelGroupPtr(
new ChannelGroup(channelGroups[1],desc.mMusicNumChannels,
mSystem,offset));
mChannelGroupMap[SM_CHANNEL_SFX_GROUP] = ChannelGroupPtr(
new ChannelGroup(channelGroups[2],desc.mSfxNumChannels,
mSystem,offset));
if (!desc.mMasterVolumeEnabled)
{
pauseChannelGroup(SM_CHANNEL_MASTER_GROUP,true);
}
if (!desc.mMusicVolumeEnabled)
{
pauseChannelGroup(SM_CHANNEL_MUSIC_GROUP,true);
}
if (!desc.mSfxVolumeEnabled)
{
pauseChannelGroup(SM_CHANNEL_SFX_GROUP,true);
}
}
//Resource management init
mResourceType = "Sound";
// low, because it will likely reference other resources
mLoadOrder = 30.0f;
mScriptPatterns.push_back("*.sound");
Ogre::ResourceGroupManager::getSingleton()._registerScriptLoader(this);
// this is how we register the ResourceManager with OGRE
Ogre::ResourceGroupManager::getSingleton()._registerResourceManager(mResourceType, this);
return rc;
}
void AudioSubsystem::set3DMinMaxDistance(const std::string& channelID,
double minDistance,
double maxDistance)
{
if(mChannelGroupMap.find( channelID ) != mChannelGroupMap.end())
{
mChannelGroupMap[channelID]->set3DMinMaxDistance(minDistance,
maxDistance);
}
}
//
//bool AudioSubsystem::addSound(const std::string& soundID,
// const std::string& sound,
// const std::string& channelID,
// int soundFlag)
//{
// TSoundData sndData;
// sndData.mId=soundID;
// sndData.mFileName=sound;
// sndData.mChannelGroupID= channelID;
// sndData.mLoop=sndData.mStream=sndData.m3D=sndData.mHardware=false;
//
// if(soundFlag&SOUND_FLAG_LOOP)
// {
// sndData.mLoop=true;
// }
// if(soundFlag&SOUND_FLAG_HARDWARE)
// {
// sndData.mHardware=true;
// }
// if(soundFlag&SOUND_FLAG_3D)
// {
// sndData.m3D=true;
// }
// if(soundFlag&SOUND_FLAG_STREAM)
// {
// sndData.mStream=true;
// }
//
// return addSound(sndData);
//}
//
//bool AudioSubsystem::addSound(const TSoundData& desc)
//{
// bool rc = false;
// FMOD_MODE flag = 0;
// FMOD_RESULT result;
// if(mSystem)
// {
// if(desc.mLoop)
// {
// flag |= FMOD_LOOP_NORMAL;
// }
// if(desc.mHardware)
// {
// flag |= FMOD_HARDWARE;
// }
//
// if(desc.m3D)
// {
// flag |= FMOD_3D;
// }else{
// flag |= FMOD_2D;
// }
// //m_logFile.push_back("AddSound" + desc.id + " fn: " + desc.fn);
// FMOD::Sound* soundPtr;
// std::string filename=AUDIO_RESOURCE_PATH+desc.mFileName;
// if(desc.mStream)
// {
// result = mSystem->createStream(filename.c_str(), flag, 0, &soundPtr);
// }else{
// //MessageBox(0,desc.fn.c_str(),"FILE",0);
// result = mSystem->createSound(filename.c_str(), flag,0, &soundPtr);
// }
// if (result == FMOD_OK)
// {
// rc = true;
//
// //m_logFile.push_back("AddSound" + desc.id + " fn: " + desc.fn + "Ok");
//
// SoundPtr sound(new Sound());
// sound->mSoundData.mChannelGroupID = desc.mChannelGroupID;
// sound->mFMODSound= soundPtr;
// mSoundMap[desc.mId] = sound;
//
// }
// }
// return rc;
//}
bool AudioSubsystem::setChannelGroupVolume(const std::string& id,
double volume)
{
bool rc = false;
if(mChannelGroupMap.find(id)!=mChannelGroupMap.end())
{
if(mChannelGroupMap[id]->setVolume(volume))
{
rc=true;
}
}
return rc;
}
bool AudioSubsystem::setChannelGroupPitch(const std::string& id,
double volume)
{
bool rc = false;
if(mChannelGroupMap.find(id)!=mChannelGroupMap.end())
{
if(mChannelGroupMap[id]->setPitch(volume))
{
rc=true;
}
}
return rc;
}
bool AudioSubsystem::pauseChannelGroup(const std::string& id,
bool overrideMute)
{
bool rc = false;
if(mChannelGroupMap.find(id)!=mChannelGroupMap.end())
{
if(mChannelGroupMap[id]->setPaused(overrideMute))
{
rc=true;
}
}
return rc;
}
bool AudioSubsystem::play3DSound(const std::string& id,
const Ogre::Vector3& pos,
int& channelIndex,
const Ogre::Vector3& vel)
{
bool rc = false;
ChannelGroupPtr outChannel= ChannelGroupPtr();
int cIndex;
if(_playSound(id,outChannel,cIndex))
{
SoundPtr soundPtr = getByName(id);
if (!soundPtr.isNull())
{
std::string cgid = soundPtr->mSoundData.mChannelGroupID;
mChannelGroupMap[cgid]->set3DMinMaxDistance(cIndex,soundPtr->mSoundData.minDistance,soundPtr->mSoundData.maxDistance);
mChannelGroupMap[cgid]->set3DAttributes( cIndex,pos,vel );
mChannelGroupMap[cgid]->play( cIndex);
soundPtr.setNull();
}
channelIndex=cIndex;
rc = true;
}
return rc;
}
bool AudioSubsystem::playMusic(const std::string& id, int& channelIndex,
bool overRide)
{
bool rc = false;
ChannelGroupPtr outChannel = ChannelGroupPtr();
int cIndex;
if(overRide == true || id != mLastMusic)
{
if(_playSound(id,outChannel,cIndex))
{
SoundPtr soundPtr = getByName(id);
if (!soundPtr.isNull())
{
std::string cgid = soundPtr->mSoundData.mChannelGroupID;
mChannelGroupMap[cgid]->play( cIndex);
mLastMusic= id;
soundPtr.setNull();
}
channelIndex=cIndex;
rc = true;
}
}
return rc;
}
bool AudioSubsystem::playSound(const std::string& id,int& channelIndex)
{
bool rc = false;
ChannelGroupPtr outChannel = ChannelGroupPtr();
int cIndex=channelIndex;
if(_playSound(id,outChannel,cIndex))
{
SoundPtr soundPtr = getByName(id);
if (!soundPtr.isNull())
{
std::string cgid = soundPtr->mSoundData.mChannelGroupID;
mChannelGroupMap[cgid]->play( cIndex);
soundPtr.setNull();
}
rc = true;
channelIndex=cIndex;
}
return rc;
}
bool AudioSubsystem::_playSound(const std::string& id,
ChannelGroupPtr outChannel,
int& channelIndex)
{
bool rc = false;
if(mSystem)
{
SoundPtr soundPtr = getByName(id);
if(!soundPtr.isNull())
{
std::string cgid = soundPtr->mSoundData.mChannelGroupID;
if(mChannelGroupMap.find(cgid)!=mChannelGroupMap.end())
{
FMOD_RESULT hr;
outChannel = mChannelGroupMap[cgid];
//find a free channel.
if (!(outChannel->getChannelObject(channelIndex).get() && outChannel->getChannelObject(channelIndex)->isFree()))
channelIndex = mChannelGroupMap[cgid]->getFreeChannelIndex();
if(channelIndex!=-1)
{
bool masterEnabled = mConfigData.mMasterVolumeEnabled;
bool musicEnabled = (cgid==SM_CHANNEL_MUSIC_GROUP) &&
mConfigData.mMusicVolumeEnabled;
bool sfxEnabled = cgid==SM_CHANNEL_SFX_GROUP &&
mConfigData.mSfxVolumeEnabled;
if(musicEnabled || sfxEnabled)
{
int tmp = channelIndex;
FMOD_CHANNELINDEX cid = outChannel->getChannelIndex(tmp);
FMOD::Channel* channel = outChannel->getChannel(tmp);
hr = mSystem->playSound(cid,
soundPtr->getFMODSound(),
true,
&channel);
outChannel->getChannelObject(tmp)->setVolume(soundPtr->mSoundData.volume);
outChannel->setChannel(tmp,channel);
outChannel->getChannelObject(tmp)->setFree(false);
rc = true;
}
}
}
soundPtr.setNull();
}
}
return rc;
}
void AudioSubsystem::set3DAttributes(const Ogre::Vector3& pos,
const Ogre::Vector3& vel,
const Ogre::Vector3& forward,
const Ogre::Vector3& up)
{
FMOD_VECTOR listenerPos = FMODHelper::toFMODVec(pos);
FMOD_VECTOR listenerForward = FMODHelper::toFMODVec(forward);
FMOD_VECTOR listenerUp = FMODHelper::toFMODVec(up);
FMOD_VECTOR listenerVelocity = FMODHelper::toFMODVec(vel);
mSystem->set3DListenerAttributes(0,
&listenerPos,
&listenerVelocity,
&listenerForward,
&listenerUp);
}
bool AudioSubsystem::update(double elapsedSeconds)
{
bool rc = false;
FMOD_RESULT hr;
if(mSystem)
{
if (mOldConfigData.mDopplerScale!=mConfigData.mDopplerScale || mOldConfigData.mDistanceFactor!=mConfigData.mDistanceFactor
|| mOldConfigData.mRollOffScale!=mConfigData.mRollOffScale)
{
mOldConfigData.mDopplerScale=mConfigData.mDopplerScale;
mOldConfigData.mDistanceFactor=mConfigData.mDistanceFactor;
mOldConfigData.mRollOffScale=mConfigData.mRollOffScale;
mSystem->set3DSettings(mConfigData.mDopplerScale,mConfigData.mDistanceFactor,
mConfigData.mRollOffScale);
}
////master group
if(mOldConfigData.mMasterVolumeEnabled!=mConfigData.mMasterVolumeEnabled)
{
bool pauseMasterChannel = !mConfigData.mMasterVolumeEnabled;
//pause master
pauseChannelGroup(SM_CHANNEL_MASTER_GROUP,pauseMasterChannel);
if(!pauseMasterChannel)
{
//pause music
pauseChannelGroup(SM_CHANNEL_MUSIC_GROUP,!mConfigData.mMusicVolumeEnabled);
pauseChannelGroup(SM_CHANNEL_SFX_GROUP,!mConfigData.mSfxVolumeEnabled);
}
mOldConfigData.mMasterVolumeEnabled= mConfigData.mMasterVolumeEnabled;
}
if(mOldConfigData.mMasterPitch!=mConfigData.mMasterPitch)
{
setChannelGroupPitch(SM_CHANNEL_MASTER_GROUP,mConfigData.mMasterPitch);
mOldConfigData.mMasterPitch=mConfigData.mMasterPitch;
}
if(mOldConfigData.mMasterVolume!=mConfigData.mMasterVolume)
{
setChannelGroupVolume(SM_CHANNEL_MASTER_GROUP,mConfigData.mMasterVolume);
mOldConfigData.mMasterVolume = mConfigData.mMasterVolume;
}
//sfx group
if(mOldConfigData.mSfxVolumeEnabled!=mConfigData.mSfxVolumeEnabled)
{
pauseChannelGroup(SM_CHANNEL_SFX_GROUP,!mConfigData.mSfxVolumeEnabled);
mOldConfigData.mSfxVolumeEnabled=mConfigData.mSfxVolumeEnabled;
}
if(mOldConfigData.mSfxPitch!=mConfigData.mSfxPitch)
{
setChannelGroupPitch(SM_CHANNEL_SFX_GROUP,mOldConfigData.mSfxPitch);
mOldConfigData.mSfxPitch= mConfigData.mSfxPitch;
}
if( mOldConfigData.mSfxVolume!=mConfigData.mSfxVolume)
{
setChannelGroupVolume(SM_CHANNEL_SFX_GROUP,mConfigData.mSfxVolume);
mOldConfigData.mSfxVolume= mConfigData.mSfxVolume;
}
//music group
if(mOldConfigData.mMusicVolumeEnabled!=mConfigData.mMusicVolumeEnabled)
{
pauseChannelGroup(SM_CHANNEL_MUSIC_GROUP,!mConfigData.mMusicVolumeEnabled);
mOldConfigData.mMusicVolumeEnabled= mConfigData.mMusicVolumeEnabled;
}
if(mOldConfigData.mMusicPitch!=mConfigData.mMusicPitch)
{
setChannelGroupPitch(SM_CHANNEL_MUSIC_GROUP,mConfigData.mMusicPitch);
mOldConfigData.mMusicPitch= mConfigData.mMusicPitch;
}
if(mOldConfigData.mMusicVolume!=mConfigData.mMusicVolume)
{
setChannelGroupVolume(SM_CHANNEL_MUSIC_GROUP,mConfigData.mMusicVolume);
mOldConfigData.mMusicVolume= mConfigData.mMusicVolume;
}
hr = mSystem->update();
if(hr==FMOD_OK)
{
for(TChannelGroupMap::iterator i=mChannelGroupMap.begin();
i!=mChannelGroupMap.end(); i++)
{
i->second->update(elapsedSeconds);
}
rc=true;
}
}
return rc;
}
TAudioSubsystemConfigData AudioSubsystem::getConfigData()
{
return mConfigData;
}
void AudioSubsystem::setConfigData(const TAudioSubsystemConfigData& configData)
{
mConfigData=configData;
}
double AudioSubsystem::getChannelGroupVolume(const std::string& id)
{
float volume = 1.0;
if(mChannelGroupMap.find(id)!=mChannelGroupMap.end())
{
volume = mChannelGroupMap[id]->getVolume();
}
return volume;
}
double AudioSubsystem::getChannelGroupPitch(const std::string& id)
{
double pitch = 1.0;
if(mChannelGroupMap.find(id)!=mChannelGroupMap.end())
{
pitch = mChannelGroupMap[id]->getPitch();
}
return pitch;
}
bool AudioSubsystem::stopSound(int channelIndex, const std::string& channelGroupID)
{
return mChannelGroupMap[channelGroupID]->stop(channelIndex);
}
bool AudioSubsystem::stopMusic(int channelIndex)
{
try
{
if (channelIndex>=0 && isMusicPlaying(channelIndex))
return stopSound(channelIndex,SM_CHANNEL_MUSIC_GROUP);
else return false;
}
catch (std::exception& e)
{
throw e;
}
}
void AudioSubsystem::stopAllSounds()
{
for(TChannelGroupMap::iterator i=mChannelGroupMap.begin();
i!=mChannelGroupMap.end(); i++)
{
(i->second)->stopSounds();
}
}
bool AudioSubsystem::setPause(int channelIndex, bool pause, const std::string& channelGroup)
{
ChannelPtr ch=mChannelGroupMap[channelGroup]->getChannelObject(channelIndex);
if (ch.get())
{
return ch->setPaused(pause);
}
std::stringstream msg("");
msg<<"AudioSubsystem::setPause() - Channel at index "<<channelIndex<<" is NULL";
throw std::exception (msg.str().c_str());
}
ApplicationPtr AudioSubsystem::getApplication()
{
return mApp;
}
//void AudioSubsystem::removeSound(const std::string& soundID)
//{
// if (!mSoundMap.empty() && mSoundMap.find(soundID)!=mSoundMap.end())
// {
// SoundPtr sound= mSoundMap[soundID];
// sound->mFMODSound->release();
// sound.reset();
// mSoundMap.erase(soundID);
// }
//}
//void AudioSubsystem::loadSounds(std::vector<TSoundData> soundBank)
//{
// unloadSounds();
// if (!soundBank.empty())
// {
// for (std::vector<TSoundData>::iterator it = soundBank.begin();it!=soundBank.end();++it)
// {
//
// addSound(*it);
// }
// }
//}
//void AudioSubsystem::unloadSounds()
//{
// // NOTE: Check if channels should be released as well, in case FMOD
// // does not handle that.
// for(TSoundMapIterator i=mSoundMap.begin();i!=mSoundMap.end(); i++)
// {
// (i->second)->mFMODSound->release();
// }
// mSoundMap.clear();
//}
void AudioSubsystem::saveCurrentConfigData(const std::string& configFileName)
{
ConfigurationPtr config = ConfigurationPtr(new Configuration());
TConfigMap options;
options[CONFIG_KEYS_DOPPLER_SCALE]= Utils::toString(mConfigData.mDopplerScale);
options[CONFIG_KEYS_DISTANCE_FACTOR]= Utils::toString(mConfigData.mDistanceFactor);
options[CONFIG_KEYS_ROLLOFF_SCALE]= Utils::toString(mConfigData.mRollOffScale);
options[CONFIG_KEYS_MASTER_VOLUME]= Utils::toString(mConfigData.mMasterVolume);
options[CONFIG_KEYS_MASTER_PITCH]= Utils::toString(mConfigData.mMasterPitch);
options[CONFIG_KEYS_MASTER_ENABLED]= Utils::toString(mConfigData.mMasterVolumeEnabled);
options[CONFIG_KEYS_MASTER_NUM_CHANNELS]= Utils::toString(mConfigData.mNumChannels);
options[CONFIG_KEYS_SFX_VOLUME]= Utils::toString(mConfigData.mSfxVolume);
options[CONFIG_KEYS_SFX_PITCH]= Utils::toString(mConfigData.mSfxPitch);
options[CONFIG_KEYS_SFX_ENABLED]= Utils::toString(mConfigData.mSfxVolumeEnabled);
options[CONFIG_KEYS_SFX_NUM_CHANNELS]= Utils::toString(mConfigData.mSfxNumChannels);
options[CONFIG_KEYS_MUSIC_VOLUME]= Utils::toString(mConfigData.mMusicVolume);
options[CONFIG_KEYS_MUSIC_PITCH]= Utils::toString(mConfigData.mMusicPitch);
options[CONFIG_KEYS_MUSIC_ENABLED]= Utils::toString(mConfigData.mMusicVolumeEnabled);
options[CONFIG_KEYS_MUSIC_NUM_CHANNELS]= Utils::toString(mConfigData.mMusicNumChannels);
options[CONFIG_KEYS_AUDIO_SUBSYSTEM_FRAME_SKIP]= Utils::toString(mConfigData.mFrameSkip);
config->addOptions(options);
std::string filePath = SOUND_RESOURCES_PATH+"/"+configFileName;
config->saveToFile(filePath);
}
SoundPtr AudioSubsystem::getSound(const std::string& soundID)
{
/*if (!mSoundMap.empty() && mSoundMap.find(soundID)!=mSoundMap.end())
return mSoundMap[soundID];*/
return getByName(soundID);
}
bool AudioSubsystem::is3DSound(const std::string& soundID)
{
SoundPtr sound=getSound(soundID);
if (!sound.isNull())
{
return sound->mSoundData.m3D;
}
std::stringstream msg("");
msg<<"AudioSubsystem::is3DSound - Sound with id "<<soundID<<" does not exist";
throw std::exception (msg.str().c_str());
}
bool AudioSubsystem::isChannelPlaying(int channelID,const std::string& channelGroupID)
{
ChannelPtr ch=mChannelGroupMap[channelGroupID]->getChannelObject(channelID);
if (ch)
return ch->isPlaying();
return false;
}
bool AudioSubsystem::isChannelPaused(int channelID,const std::string& channelGroupID)
{
ChannelPtr ch=mChannelGroupMap[channelGroupID]->getChannelObject(channelID);
if (ch)
return ch->isPaused();
return false;
}
bool AudioSubsystem::isMusicPlaying(int channelID)
{
return mConfigData.mMasterVolumeEnabled && mConfigData.mMusicVolumeEnabled && isChannelPlaying(channelID,SM_CHANNEL_MUSIC_GROUP);
}
bool AudioSubsystem::isSfxPlaying(int channelID)
{
return mConfigData.mMasterVolumeEnabled && mConfigData.mSfxVolumeEnabled && isChannelPlaying(channelID,SM_CHANNEL_SFX_GROUP);
}
void AudioSubsystem::updateChannel3DAttributes(int channelID, const Ogre::Vector3& position,const Ogre::Vector3& velocity)
{
ChannelPtr ch=mChannelGroupMap[SM_CHANNEL_MASTER_GROUP]->getChannelObject(channelID);
if (ch.get())
ch->set3DAttributes(position,velocity);
else
{
std::stringstream msg("");
msg<<"AudioSubsystem::updateChannel3DAttributes- Channel at index"<<channelID<<" is NULL";
throw std::exception (msg.str().c_str());
}
}
void AudioSubsystem::updateChannel3DMinMaxDistance(int channelID, double minDistance, double maxDistance)
{
ChannelPtr ch=mChannelGroupMap[SM_CHANNEL_MASTER_GROUP]->getChannelObject(channelID);
if (ch.get())
ch->set3DMinMaxDistance(minDistance,maxDistance);
else
{
std::stringstream msg("");
msg<<"AudioSubsystem::updateChannel3DMinMaxDistance() - Channel at index"<<channelID<<" is NULL";
throw std::exception (msg.str().c_str());
}
}
int AudioSubsystem::getFrameSkip() const
{
return mFrameSkip;
}
void AudioSubsystem::setFrameSkip(int frameSkip)
{
mFrameSkip=frameSkip;
}
bool AudioSubsystem::setChannelVolume(int channelID,double volume, const std::string& channelGroupID=SM_CHANNEL_SFX_GROUP)
{
ChannelPtr ch=mChannelGroupMap[channelGroupID]->getChannelObject(channelID);
if (ch.get())
return ch->setVolume(volume);
else
{
std::stringstream msg("");
msg<<"AudioSubsystem::setChannelVolume() - Channel at index"<<channelID<<" is NULL";
throw std::exception (msg.str().c_str());
}
}
double AudioSubsystem::getChannelVolume(int channelID,const std::string& channelGroupID=SM_CHANNEL_SFX_GROUP)
{
ChannelPtr ch=mChannelGroupMap[channelGroupID]->getChannelObject(channelID);
if (ch.get())
{
return ch->getVolume();
}
else
{
std::stringstream msg("");
msg<<"AudioSubsystem::getChannelVolume() - Channel at index"<<channelID<<" is NULL";
throw std::exception (msg.str().c_str());
}
}
void AudioSubsystem::setMusicVolume(int channelID,double volume)
{
setChannelVolume(channelID,volume,SM_CHANNEL_MUSIC_GROUP);
}
double AudioSubsystem::getMusicVolume(int channelID)
{
return getChannelVolume(channelID,SM_CHANNEL_MUSIC_GROUP);
}
bool AudioSubsystem::createSoundImplementation(const TSoundData& soundData, FMOD::Sound*& FMODSound)
{
bool rc = false;
FMOD_MODE flag = 0;
FMOD_RESULT result;
if(mSystem)
{
if(soundData.mLoop)
{
flag |= FMOD_LOOP_NORMAL;
}
if(soundData.mHardware)
{
flag |= FMOD_HARDWARE;
}
if(soundData.m3D)
{
flag |= FMOD_3D;
}else{
flag |= FMOD_2D;
}
std::string filename=AUDIO_RESOURCE_PATH+soundData.mFileName;
if(soundData.mStream)
{
result = mSystem->createStream(filename.c_str(), flag, 0, &FMODSound);
}else{
//MessageBox(0,desc.fn.c_str(),"FILE",0);
result = mSystem->createSound(filename.c_str(), flag,0, &FMODSound);
}
if (result==FMOD_OK)
{
rc=true;
}
else
{
std::stringstream errMsg("");
errMsg<<"Error creating FMOD Sound. Error message returned - "<<FMOD_ErrorString(result);
Logger::getInstance()->log(errMsg.str());
}
}
return rc;
}
bool AudioSubsystem::destroySoundImplementation(FMOD::Sound*& FMODSound)
{
if (FMODSound)
{
return (FMODSound->release()==FMOD_OK);
}
return false;
}
//------------------------------
// Resource manager methods
//------------------------------
SoundPtr AudioSubsystem::load(const Ogre::String &name, const Ogre::String &group)
{
SoundPtr snd = getByName(name);
if (snd.isNull())
snd= create(name, group);
snd->load();
return snd;
}
bool AudioSubsystem::isLoaded(const Ogre::String& soundName)
{
SoundPtr snd = getByName(soundName);
return (!snd.isNull() && snd->isLoaded());
}
Ogre::Resource* AudioSubsystem::createImpl(const Ogre::String &name, Ogre::ResourceHandle handle,
const Ogre::String &group, bool isManual, Ogre::ManualResourceLoader *loader,
const Ogre::NameValuePairList *createParams)
{
return new Sound(this, name, handle, group, isManual, loader);
}
void AudioSubsystem::parseScript(Ogre::DataStreamPtr& stream, const Ogre::String& groupName)
{
AudioScriptLoader audioScriptLoader(shared_from_this());
audioScriptLoader.parseScript(stream,groupName);
} | [
"ithiliel@1610d384-d83c-11de-a027-019ae363d039",
"wyern1@1610d384-d83c-11de-a027-019ae363d039",
"juanj.mostazo@1610d384-d83c-11de-a027-019ae363d039"
]
| [
[
[
1,
9
],
[
13,
42
],
[
45,
459
],
[
461,
463
],
[
465,
541
],
[
543,
824
],
[
826,
869
]
],
[
[
10,
12
],
[
460,
460
],
[
464,
464
],
[
542,
542
]
],
[
[
43,
44
],
[
825,
825
]
]
]
|
1673bb5e262ed98bd5981811ba2bcbac60b5221f | cfa6cdfaba310a2fd5f89326690b5c48c6872a2a | /Sources/Library/util/util/stdafx.cpp | a86cac5ce4fce27427a0f6b777b880ca6ad32ec4 | []
| no_license | asdlei00/project-jb | 1cc70130020a5904e0e6a46ace8944a431a358f6 | 0bfaa84ddab946c90245f539c1e7c2e75f65a5c0 | refs/heads/master | 2020-05-07T21:41:16.420207 | 2009-09-12T03:40:17 | 2009-09-12T03:40:17 | 40,292,178 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 330 | cpp | // stdafx.cpp : 표준 포함 파일만 들어 있는 소스 파일입니다.
// util.pch는 미리 컴파일된 헤더가 됩니다.
// stdafx.obj에는 미리 컴파일된 형식 정보가 포함됩니다.
#include "stdafx.h"
// TODO: 필요한 추가 헤더는
// 이 파일이 아닌 STDAFX.H에서 참조합니다.
| [
"[email protected]"
]
| [
[
[
1,
8
]
]
]
|
20937486b2ddfb8240b401204c1a58764c19c64d | 68bfdfc18f1345d1ff394b8115681110644d5794 | /Examples/Example01/Model.cpp | d180af8c7fc91ec8adceb9997556f317c81fc299 | []
| no_license | y-gupta/glwar3 | 43afa1efe475d937ce0439464b165c745e1ec4b1 | bea5135bd13f9791b276b66490db76d866696f9a | refs/heads/master | 2021-05-28T12:20:41.532727 | 2010-12-09T07:52:12 | 2010-12-09T07:52:12 | 32,911,819 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,216 | cpp | //+-----------------------------------------------------------------------------
//| Included files
//+-----------------------------------------------------------------------------
#include "Model.h"
//+-----------------------------------------------------------------------------
//| Global objects
//+-----------------------------------------------------------------------------
MODEL Model;
//+-----------------------------------------------------------------------------
//| Constructor
//+-----------------------------------------------------------------------------
MODEL::MODEL()
{
}
//+-----------------------------------------------------------------------------
//| Destructor
//+-----------------------------------------------------------------------------
MODEL::~MODEL()
{
}
//+-----------------------------------------------------------------------------
//| Returns a reference to the data
//+-----------------------------------------------------------------------------
MODEL_DATA& MODEL::Data()
{
return ModelData;
}
//+-----------------------------------------------------------------------------
//| Clears the model
//+-----------------------------------------------------------------------------
VOID MODEL::Clear()
{
}
//+-----------------------------------------------------------------------------
//| Renders the model
//+-----------------------------------------------------------------------------
VOID MODEL::Render(INT TimeDifference)
{
std::list<INT> RenderOrderList1;
std::list<INT> RenderOrderList2;
std::list<INT> RenderOrderList3;
std::list<INT> RenderOrderList4;
std::list<INT>::iterator j;
for (INT i = 0; i < ModelData.GeosetContainer.GetTotalSize(); i++)
{
if (ModelData.GeosetContainer.ValidIndex(i))
{
switch (ModelData.GeosetContainer[i]->GetRenderOrder())
{
case 1:
{
RenderOrderList1.push_back(i);
break;
}
case 2:
{
RenderOrderList2.push_back(i);
break;
}
case 3:
{
RenderOrderList3.push_back(i);
break;
}
case 4:
{
RenderOrderList4.push_back(i);
break;
}
}
}
}
j = RenderOrderList1.begin();
while (j != RenderOrderList1.end())
{
ModelData.GeosetContainer[*j]->Render(SEQUENCE_TIME(), FALSE);
j++;
}
}
//+-----------------------------------------------------------------------------
//| Adds a geoset
//+-----------------------------------------------------------------------------
BOOL MODEL::AddGeoset(MODEL_GEOSET *Geoset, BOOL Imported)
{
std::stringstream Stream;
if(!ModelData.GeosetContainer.Add(Geoset))
{
Error.SetMessage("Unable to add a new geoset!");
return FALSE;
}
return TRUE;
}
//+-----------------------------------------------------------------------------
//| Adds a texture
//+-----------------------------------------------------------------------------
BOOL MODEL::AddTexture(MODEL_TEXTURE* Texture)
{
std::stringstream Stream;
if(!ModelData.TextureContainer.Add(Texture))
{
Error.SetMessage("Unable to add a new texture!");
return FALSE;
}
return TRUE;
} | [
"sihan6677@deb3bc48-0ee2-faf5-68d7-13371a682d83"
]
| [
[
[
1,
133
]
]
]
|
7648e109d3c8cf4a22663030be8b0460e9267f72 | b84a38aad619acf34c22ed6e6caa0f7b00ebfa0a | /Code/TootleFilesys/IPod/IPodLocalFileSys.h | 095e02e90a9a6759166be68e762c915529f293dc | []
| no_license | SoylentGraham/Tootle | 4ae4e8352f3e778e3743e9167e9b59664d83b9cb | 17002da0936a7af1f9b8d1699d6f3e41bab05137 | refs/heads/master | 2021-01-24T22:44:04.484538 | 2010-11-03T22:53:17 | 2010-11-03T22:53:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,414 | h | /*------------------------------------------------------
Local file system... reads files out of a specific directory
-------------------------------------------------------*/
#pragma once
#include "../TLFileSys.h"
namespace TLFileSys
{
namespace Platform
{
class LocalFileSys;
}
};
//------------------------------------------------------------
//
//------------------------------------------------------------
class TLFileSys::Platform::LocalFileSys : public TLFileSys::TFileSys
{
public:
LocalFileSys(TRefRef FileSysRef,TRefRef FileSysTypeRef);
virtual bool IsWritable() const { return m_IsWritable; }
virtual SyncBool Init(); // check directory exists
virtual SyncBool LoadFileList(); // search for all files
virtual SyncBool LoadFile(TPtr<TFile>& pFile); // load a file
virtual TPtr<TFile> CreateNewFile(const TString& Filename);
virtual SyncBool WriteFile(TPtr<TFile>& pFile);
virtual SyncBool Shutdown();
void SetDirectory(const TString& Directory);
void SetIsWritable(Bool IsWritable) { m_IsWritable = IsWritable; }
protected:
Bool IsDirectoryValid(); // returns FALSE if m_Directory isn't a directory
Bool DoLoadFileList(); // returns number of files found. -1 on error
protected:
Bool m_IsWritable; // overriding readonly setting
TString m_Directory;
};
| [
"[email protected]",
"[email protected]"
]
| [
[
[
1,
31
],
[
33,
41
],
[
43,
48
]
],
[
[
32,
32
],
[
42,
42
]
]
]
|
a0227500078387cfccd4a57720df21bbe0595c79 | d8423c42c510644bed3278077604f26bbcb2da85 | /fleche.cpp | 5d345dfc1ae5d492a7d2d80db81ba76bcb35ea71 | []
| no_license | manudss/automatefini | dd1c4f7fe502e269f8bdca0a360c3043ca5d167c | a5647bd1c24b56a757ac358992310b16b06eaa22 | refs/heads/master | 2020-05-15T15:05:52.857327 | 2007-05-16T20:47:23 | 2007-05-16T20:47:23 | 32,325,757 | 0 | 0 | null | null | null | null | WINDOWS-1250 | C++ | false | false | 595 | cpp | #include "StdAfx.h"
#include "fleche.h"
fleche::fleche(void)
{
}
fleche::~fleche(void)
{
}
void fleche::creation(char *alphabet, int nbrlettre, int nbretat)
{
std::cout << " Quel est la lettre de l'alphabet (Taper votre choix)" << std::endl;
for (int i=0; i < nbrlettre; i ++)
{
std::cout << "Choix " << i + 1 << " : " << alphabet[i] << endl;
}
int choix;
std::cin >> choix;
lettre = alphabet[choix -1];
do {
std::cout << " Fleche va vers quel état ?" << std::endl;
std::cin >> etat;
}while (etat >= 0 && etat <= nbretat);
}
| [
"manu.dss@de21166b-9c30-0410-a108-7d28ce46fe33"
]
| [
[
[
1,
28
]
]
]
|
851147b8960725b1a63b333945986aeb2dbb3bc2 | c79def23ba8a4ad23bb51068d303f3ead942ed2a | /SuperProfilerNet/include/SuperNetPacketIDs.h | 01d2d9f94c6d21e054eab5fa056c8e6497fb99c7 | [
"BSD-3-Clause"
]
| permissive | programmingisgood/superprofiler | a519020250ed236331219dc5da7adf9c8cf8863c | 1fa7d1785ca3c91457c6fb634ab027290a2fa8e6 | refs/heads/master | 2021-01-19T15:02:08.250385 | 2009-08-13T18:37:05 | 2009-08-13T18:37:05 | 32,189,128 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,717 | h | /**
Copyright (c) 2009, Brian Cronin
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions
and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or
promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/
#ifndef SUPERNETPACKETIDS_H
#define SUPERNETPACKETIDS_H
namespace SuperProfiler
{
enum PacketIDs
{
PID_INITIAL_SYNC,
PID_ADD_FUNCTION,
PID_FUNC_LIST_UPDATE,
PID_CALL_TREE_UPDATE
};
}
#endif | [
"programmingisgood@1faae0e8-f407-11dd-984d-ab748d24aa7e"
]
| [
[
[
1,
38
]
]
]
|
2f04039fb5a2c2f164bf1dae0e0782c8fb78a4fd | 03b7ba287ef917b613d83b16ddfb3ff759c53c7f | /Server/mserver.hpp | ba46c35c3ee89bc530a87dda3a13b232bfde2000 | []
| no_license | varesa/ServerManagerCpp | 27a9e7c89a6ccdadd439b87d116f28d1ad3926ec | 6356e37f6f94fb7ab2a13e7c4b5777db9911b54f | refs/heads/master | 2020-06-08T08:48:02.112013 | 2011-11-26T22:17:40 | 2011-11-26T22:17:40 | 2,851,019 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 268 | hpp | #ifndef MSERVER_HPP
#define MSERVER_HPP
#include <string>
class MServer {
public:
int id;
std::string name;
std::string desc;
std::string path;
int port;
bool running;
bool locked;
private:
};
#endif // MSERVER_HPP
| [
"[email protected]"
]
| [
[
[
1,
20
]
]
]
|
7822c0ef616d5b319243109bd86d31cadd15119b | 89d2197ed4531892f005d7ee3804774202b1cb8d | /Game/Math.h | 61e7eca6f935bc46aec4dbee4e7094dcaa5ef40e | [
"MIT",
"Zlib"
]
| permissive | hpidcock/gbsfml | ef8172b6c62b1c17d71d59aec9a7ff2da0131d23 | e3aa990dff8c6b95aef92bab3e94affb978409f2 | refs/heads/master | 2020-05-30T15:01:19.182234 | 2010-09-29T06:53:53 | 2010-09-29T06:53:53 | 35,650,825 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,158 | h | //////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2010 Harry Pidcock
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////////////////////////
#include "Vector.h"
#include "Color.h"
#ifndef __MATH_H__
#define __MATH_H__
template<typename T>
inline T Min(T a, T b)
{
return a < b ? a : b;
}
template<typename T>
inline T Max(T a, T b)
{
return a > b ? a : b;
}
template<typename T>
inline T Wrap(T x, T min, T max)
{
return min + ((x - min) % (max - min + (T)1));
}
template<typename T>
inline T Clamp(T x, T min, T max)
{
if(x < min)
return min;
if(x > max)
return max;
return x;
}
template<typename T>
inline T Lerp(T a, T b, float frac)
{
return a + (b - a) * frac;
}
inline Color Lerp(Color a, Color b, float frac)
{
Color ret;
ret.r = Lerp(a.r, b.r, frac);
ret.g = Lerp(a.g, b.g, frac);
ret.b = Lerp(a.b, b.b, frac);
ret.a = Lerp(a.a, b.a, frac);
return ret;
}
#endif // __MATH_H__ | [
"haza55@5bf3a77f-ad06-ad18-b9fb-7d0f6dabd793"
]
| [
[
[
1,
77
]
]
]
|
bf7ba50b42b1b7491c9b1e2e8f747096c2061461 | e9fd66e6db68ca4d1a9f14aece84a0aff99323e4 | /CCB2010/TCAPI/ColorSpace.cpp | 7259bf610fc489066e4c2ecf8dcabcc4aac3025a | []
| no_license | radtek/bbmonitoring | 70fd4a4c4d553503717a474da39bef67834cc675 | ff77607e77616b84395e095f396df496e7f0054a | refs/heads/master | 2020-09-22T07:27:15.827047 | 2011-01-04T05:37:46 | 2011-01-04T05:37:46 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 16,199 | cpp | // ColorSpace.cpp: implementation of the CColorSpace class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "TCAPI.h"
#include "ColorSpace.h"
//#include "WorkThreadPool.h"
#include <vector>
#define TRACE LogMessage
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
#define asm __asm
//颜色饱和函数
__forceinline long border_color(long color)
{
if (color>255)
return 255;
else if (color<0)
return 0;
else
return color;
}
const int csY_coeff_16 = 1.164383*(1<<16);
const int csU_blue_16 = 2.017232*(1<<16);
const int csU_green_16 = (-0.391762)*(1<<16);
const int csV_green_16 = (-0.812968)*(1<<16);
const int csV_red_16 = 1.596027*(1<<16);
__forceinline void YUVToRGB32_Two(TARGB32* pDst, const TUInt8 Y0, const TUInt8 Y1, const TUInt8 U, const TUInt8 V)
{
int Ye0 = csY_coeff_16 * (Y0 - 16);
int Ye1 = csY_coeff_16 * (Y1 - 16);
int Ue = (U-128);
int Ve = (V-128);
int Ue_blue = csU_blue_16 * Ue;
int Ue_green = csU_green_16 * Ue;
int Ve_green = csV_green_16 * Ve;
int Ve_red = csV_red_16 * Ve;
int UeVe_green = Ue_green + Ve_green;
pDst->b = border_color( ( Ye0 + Ue_blue ) >>16 );
pDst->g = border_color( ( Ye0 + UeVe_green ) >>16 );
pDst->r = border_color( ( Ye0 + Ve_red ) >>16 );
pDst->a = 255;
++pDst;
pDst->b = border_color( ( Ye1 + Ue_blue ) >>16 );
pDst->g = border_color( ( Ye1 + UeVe_green ) >>16 );
pDst->r = border_color( ( Ye1 + Ve_red ) >>16 );
pDst->a = 255;
}
void DECODE_UYVY_Common_line(TARGB32 *pDstLine, const TUInt8 *pUYVY, long width)
{
for (long x = 0 ; x < width ; x += 2)
{
YUVToRGB32_Two(&pDstLine[x], pUYVY[1], pUYVY[3], pUYVY[0], pUYVY[2]);
pUYVY+=4;
}
}
const UInt64 csMMX_16_b = 0x1010101010101010; // byte{16,16,16,16,16,16,16,16}
const UInt64 csMMX_128_w = 0x0080008000800080; //short{ 128, 128, 128, 128}
const UInt64 csMMX_0x00FF_w = 0x00FF00FF00FF00FF; //掩码
const UInt64 csMMX_Y_coeff_w = 0x2543254325432543; //short{ 9539, 9539, 9539, 9539} =1.164383*(1<<13)
const UInt64 csMMX_U_blue_w = 0x408D408D408D408D; //short{16525,16525,16525,16525} =2.017232*(1<<13)
const UInt64 csMMX_U_green_w = 0xF377F377F377F377; //short{-3209,-3209,-3209,-3209} =(-0.391762)*(1<<13)
const UInt64 csMMX_V_green_w = 0xE5FCE5FCE5FCE5FC; //short{-6660,-6660,-6660,-6660} =(-0.812968)*(1<<13)
const UInt64 csMMX_V_red_w = 0x3313331333133313; //short{13075,13075,13075,13075} =1.596027*(1<<13)
//一次处理8个颜色输出
#define YUV422ToRGB32_MMX(out_RGB_reg,WriteCode) \
/*input : mm0 = Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */ \
/* mm1 = 00 u3 00 u2 00 u1 00 u0 */ \
/* mm2 = 00 v3 00 v2 00 v1 00 v0 */ \
/*output : [out_RGB_reg -- out_RGB_reg+8*4] */ \
\
asm psubusb mm0,csMMX_16_b /* mm0 : Y -= 16 */ \
asm psubsw mm1,csMMX_128_w /* mm1 : u -= 128 */ \
asm movq mm7,mm0 \
asm psubsw mm2,csMMX_128_w /* mm2 : v -= 128 */ \
asm pand mm0,csMMX_0x00FF_w /* mm0 = 00 Y6 00 Y4 00 Y2 00 Y0 */ \
asm psllw mm1,3 /* mm1 : u *= 8 */ \
asm psllw mm2,3 /* mm2 : v *= 8 */ \
asm psrlw mm7,8 /* mm7 = 00 Y7 00 Y5 00 Y3 00 Y1 */ \
asm movq mm3,mm1 \
asm movq mm4,mm2 \
\
asm pmulhw mm1,csMMX_U_green_w /* mm1 = u * U_green */ \
asm psllw mm0,3 /* y*=8 */ \
asm pmulhw mm2,csMMX_V_green_w /* mm2 = v * V_green */ \
asm psllw mm7,3 /* y*=8 */ \
asm pmulhw mm3,csMMX_U_blue_w \
asm paddsw mm1,mm2 \
asm pmulhw mm4,csMMX_V_red_w \
asm movq mm2,mm3 \
asm pmulhw mm0,csMMX_Y_coeff_w \
asm movq mm6,mm4 \
asm pmulhw mm7,csMMX_Y_coeff_w \
asm movq mm5,mm1 \
asm paddsw mm3,mm0 /* mm3 = B6 B4 B2 B0 */ \
asm paddsw mm2,mm7 /* mm2 = B7 B5 B3 B1 */ \
asm paddsw mm4,mm0 /* mm4 = R6 R4 R2 R0 */ \
asm paddsw mm6,mm7 /* mm6 = R7 R5 R3 R1 */ \
asm paddsw mm1,mm0 /* mm1 = G6 G4 G2 G0 */ \
asm paddsw mm5,mm7 /* mm5 = G7 G5 G3 G1 */ \
\
asm packuswb mm3,mm4 /* mm3 = R6 R4 R2 R0 B6 B4 B2 B0 to [0-255] */ \
asm packuswb mm2,mm6 /* mm2 = R7 R5 R3 R1 B7 B5 B3 B1 to [0-255] */ \
asm packuswb mm5,mm1 /* mm5 = G6 G4 G2 G0 G7 G5 G3 G1 to [0-255] */ \
asm movq mm4,mm3 \
asm punpcklbw mm3,mm2 /* mm3 = B7 B6 B5 B4 B3 B2 B1 B0 */ \
asm punpckldq mm1,mm5 /* mm1 = G7 G5 G3 G1 xx xx xx xx */ \
asm punpckhbw mm4,mm2 /* mm4 = R7 R6 R5 R4 R3 R2 R1 R0 */ \
asm punpckhbw mm5,mm1 /* mm5 = G7 G6 G5 G4 G3 G2 G1 G0 */ \
\
/*out*/ \
asm pcmpeqb mm2,mm2 /* mm2 = FF FF FF FF FF FF FF FF */ \
\
asm movq mm0,mm3 \
asm movq mm7,mm4 \
asm punpcklbw mm0,mm5 /* mm0 = G3 B3 G2 B2 G1 B1 G0 B0 */ \
asm punpcklbw mm7,mm2 /* mm7 = FF R3 FF R2 FF R1 FF R0 */ \
asm movq mm1,mm0 \
asm movq mm6,mm3 \
asm punpcklwd mm0,mm7 /* mm0 = FF R1 G1 B1 FF R0 G0 B0 */ \
asm punpckhwd mm1,mm7 /* mm1 = FF R3 G3 B3 FF R2 G2 B2 */ \
asm WriteCode [out_RGB_reg],mm0 \
asm movq mm7,mm4 \
asm punpckhbw mm6,mm5 /* mm6 = G7 B7 G6 B6 G5 B5 G4 B4 */ \
asm WriteCode [out_RGB_reg+8],mm1 \
asm punpckhbw mm7,mm2 /* mm7 = FF R7 FF R6 FF R5 FF R4 */ \
asm movq mm0,mm6 \
asm punpcklwd mm6,mm7 /* mm6 = FF R5 G5 B5 FF R4 G4 B4 */ \
asm punpckhwd mm0,mm7 /* mm0 = FF R7 G7 B7 FF R6 G6 B6 */ \
asm WriteCode [out_RGB_reg+8*2],mm6 \
asm WriteCode [out_RGB_reg+8*3],mm0
#define UYVY_Loader_MMX(in_yuv_reg) \
asm movq mm0,[in_yuv_reg ] /*mm0=Y3 V1 Y2 U1 Y1 V0 Y0 U0 */ \
asm movq mm4,[in_yuv_reg+8] /*mm4=Y7 V3 Y6 U3 Y5 V2 Y4 U2 */ \
asm movq mm1,mm0 \
asm movq mm5,mm4 \
asm psrlw mm0,8 /*mm0=00 Y3 00 Y2 00 Y1 00 Y0 */ \
asm psrlw mm4,8 /*mm4=00 Y7 00 Y6 00 Y5 00 Y4 */ \
asm pand mm1,csMMX_0x00FF_w /*mm1=00 V1 00 U1 00 V0 00 U0 */ \
asm pand mm5,csMMX_0x00FF_w /*mm5=00 V3 00 U3 00 V2 00 U2 */ \
asm packuswb mm1,mm5 /*mm1=V3 U3 V2 U2 V1 U1 V0 U0 */ \
asm movq mm2,mm1 \
asm packuswb mm0,mm4 /*mm0=Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */ \
asm psllw mm1,8 /*mm1=U3 00 U2 00 U1 00 U0 00 */ \
asm psrlw mm2,8 /*mm2=00 V3 00 V2 00 V1 00 V0 */ \
asm psrlw mm1,8 /*mm1=00 U3 00 U2 00 U1 00 U0 */
void DECODE_UYVY_MMX_line(TARGB32* pDstLine,const TUInt8* pUYVY,long width)
{
long expand8_width=(width>>3)<<3;
if (expand8_width>0)
{
asm
{
mov ecx,expand8_width
mov eax,pUYVY
mov edx,pDstLine
lea eax,[eax+ecx*2]
lea edx,[edx+ecx*4]
neg ecx
loop_beign:
UYVY_Loader_MMX(eax+ecx*2)
YUV422ToRGB32_MMX(edx+ecx*4,movq)
add ecx,8
jnz loop_beign
mov pUYVY,eax
mov pDstLine,edx
}
}
//处理边界
DECODE_UYVY_Common_line(pDstLine, pUYVY, width-expand8_width);
}
//在x86CPU上可以使用CPUID指令来得到各种关于当前CPU的特性,
//包括制造商、CPU家族号、缓存信息、是否支持MMX\SSE\SSE2指令集 等等;
//要使用CPUID指令,首先应该判断CPU是否支持该指令;方法是判断EFLAGS寄存器的第21位
//是否可以改写;如果可以改写,那么说明这块CPU支持CPUID指令
bool _CPUSupportCPUID()
{
long int CPUIDInfOld = 0;
long int CPUIDInfNew = 0;
try
{
asm
{
pushfd // 保存原 EFLAGS
pop eax
mov edx, eax
mov CPUIDInfOld, eax //
xor eax, 00200000h // 改写 第21位
push eax
popfd // 改写 EFLAGS
pushfd // 保存新 EFLAGS
pop eax
mov CPUIDInfNew, eax
push edx // 恢复原 EFLAGS
popfd
}
return (CPUIDInfOld != CPUIDInfNew); // EFLAGS 第21位 可以改写
}
catch(...)
{
return false;
}
}
//那么判断CPU是否支持MMX指令的函数如下:
bool _CPUSupportMMX() //判断CPU是否支持MMX指令
{
if (!_CPUSupportCPUID())
return false;
long int MMXInf=0;
try
{
asm
{
push ebx
mov eax,1
cpuid
mov MMXInf,edx
pop ebx
}
MMXInf=MMXInf & (1 << 23); //检测edx第23位
return (MMXInf == (1 << 23));
}
catch(...)
{
return false;
}
}
const bool _IS_MMX_ACTIVE = _CPUSupportMMX();
typedef void (*TDECODE_UYVY_line_proc)(TARGB32 *pDstLine, const TUInt8 *pUYVY, long width);
const TDECODE_UYVY_line_proc DECODE_UYVY_Auto_line = ( _IS_MMX_ACTIVE ? DECODE_UYVY_MMX_line : DECODE_UYVY_Common_line );
__forceinline void DECODE_filish()
{
if (_IS_MMX_ACTIVE)
{
asm emms
}
}
void DECODE_UYVY_Auto(const TUInt8 *pUYVY, const TPicRegion &DstPic)
{
long YUV_byte_width = (DstPic.width >> 1) << 2;
TARGB32 *pDstLine = DstPic.pdata;
for (long y = 0 ; y < DstPic.height ; ++y)
{
DECODE_UYVY_Auto_line(pDstLine, pUYVY, DstPic.width);
pUYVY += YUV_byte_width;
((TUInt8*&)pDstLine) += DstPic.byte_width;
}
DECODE_filish();
}
struct TDECODE_UYVY_Parallel_WorkData
{
const TUInt8* pUYVY;
TPicRegion DstPic;
};
void DECODE_UYVY_Parallel_callback(void* wd)
{
TDECODE_UYVY_Parallel_WorkData* WorkData = (TDECODE_UYVY_Parallel_WorkData*)wd;
DECODE_UYVY_Auto(WorkData->pUYVY, WorkData->DstPic);
}
bool DECODE_UYVY_TO_RGB32(const TUInt8 *pUYVY, const TPicRegion &DstPic)
{
if (NULL == pUYVY)
{
TRACE ("DECODE_UYVY_TO_RGB32() error, NULL == pUYVY\n");
return false;
}
if (NULL == DstPic.pdata)
{
TRACE ("DECODE_UYVY_TO_RGB32() error, NULL == DstPic.pdata\n");
return false;
}
//long work_count = CWorkThreadPool::best_work_count(); 将这句话注释掉,改为下面的语句即可
long work_count = 1;
if (work_count > 1)
{
std::vector<TDECODE_UYVY_Parallel_WorkData> work_list(work_count);
std::vector<TDECODE_UYVY_Parallel_WorkData*> pwork_list(work_count);
long cheight = DstPic.height / work_count;
for (long i = 0 ; i < work_count ; ++i)
{
work_list[i].pUYVY = pUYVY + i * cheight * (DstPic.width << 1);
work_list[i].DstPic.pdata = DstPic.pixel_pos(0, cheight*i);
work_list[i].DstPic.byte_width = DstPic.byte_width;
work_list[i].DstPic.width = DstPic.width;
work_list[i].DstPic.height = cheight;
pwork_list[i] = &work_list[i];
}
work_list[work_count-1].DstPic.height = DstPic.height-cheight*(work_count-1);
// CWorkThreadPool::work_execute(DECODE_UYVY_Parallel_callback, (void**)&pwork_list[0],work_count);
}
else
{
DECODE_UYVY_Auto(pUYVY, DstPic);
}
return true;
}
bool DECODE_RGB_TO_BGRA(const unsigned char *pRGB, const TPicRegion &DstPic)
{
DWORD RGBcount = DstPic.width * DstPic.height;
for (register int i=0 ; i<RGBcount ; i++)
{
DstPic.pdata[i].r = pRGB[i*3];
DstPic.pdata[i].g = pRGB[i*3+1];
DstPic.pdata[i].b = pRGB[i*3+2];
DstPic.pdata[i].a = 255;
}
return true;
}
bool DECODE_RGB_TO_BGRA_2(const int width , const int height,const unsigned char *pRGB, unsigned char * pBGR)
{
DWORD RGBcount = width * height;;
for (register int i=0 ; i<RGBcount ; i++)
{
pBGR[i*4+2] = pRGB[i*3];
pBGR[i*4+1] = pRGB[i*3+1];
pBGR[i*4+0] = pRGB[i*3+2];
pBGR[i*4+3] = 0;
}
return true;
}
bool DECODE_RGB_TO_BGR(const int width , const int height,const unsigned char *pRGB, unsigned char * pBGR)
{
DWORD RGBcount = width * height;
for (register int i=0 ; i<RGBcount ; i++)
{
pBGR[i*3+2] = pRGB[i*3];
pBGR[i*3+1] = pRGB[i*3+1];
pBGR[i*3] = pRGB[i*3+2];
}
return true;
} | [
"damoguyan8844@00acd8f4-21d3-11df-8b29-c50f69cede6d"
]
| [
[
[
1,
404
]
]
]
|
01e46337b62f45f41bf5a7b3a83ae03435e2e400 | 0b66a94448cb545504692eafa3a32f435cdf92fa | /branches/nn/cbear.berlios.de/windows/com/isupporterrorinfo.hpp | aeb874b4e086fc38e4facc584d5d2df8dee5a81e | [
"MIT"
]
| permissive | BackupTheBerlios/cbear-svn | e6629dfa5175776fbc41510e2f46ff4ff4280f08 | 0109296039b505d71dc215a0b256f73b1a60b3af | refs/heads/master | 2021-03-12T22:51:43.491728 | 2007-09-28T01:13:48 | 2007-09-28T01:13:48 | 40,608,034 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 350 | hpp | #ifndef CBEAR_BERLIOS_DE_WINDOWS_COM_ISUPPORTERRORINFO_HPP_INCLUDED
#define CBEAR_BERLIOS_DE_WINDOWS_COM_ISUPPORTERRORINFO_HPP_INCLUDED
#include <cbear.berlios.de/windows/com/iunknown.hpp>
namespace cbear_berlios_de
{
namespace windows
{
namespace com
{
typedef pointer< ::ISupportErrorInfo> isupporterrorinfo_t;
}
}
}
#endif
| [
"nn0@e6e9985e-9100-0410-869a-e199dc1b6838"
]
| [
[
[
1,
19
]
]
]
|
13a637abf5ef3789aa363b91ccd2458b4ca7fb9e | 17083b919f058848c3eb038eae37effd1a5b0759 | /SimpleGL/src/GL/GLUniform.cpp | ad25ec3db45b412d126ccb2b3cd1c9870345c9ac | []
| no_license | BackupTheBerlios/sgl | e1ce68dfc2daa011bdcf018ddce744698cc7bc5f | 2ab6e770dfaf5268c1afa41a77c04ad7774a70ed | refs/heads/master | 2021-01-21T12:39:59.048415 | 2011-10-28T16:14:29 | 2011-10-28T16:14:29 | 39,894,148 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,617 | cpp | #include "GL/GLUniform.h"
// uniforms
namespace sgl {
using namespace math;
#define DEFINE_UNIFORM(UTYPE, CTYPE, CAST_TYPE, setFunction, getFunction)\
template<>\
AbstractUniform::TYPE GLUniform<CTYPE>::Type() const\
{\
return UTYPE;\
}\
template<>\
void GLUniform<CTYPE>::Set(const CTYPE& value)\
{\
assert( device->CurrentProgram() == program );\
setFunction(glLocation, 1, (CAST_TYPE*)&value);\
}\
template<>\
void GLUniform<CTYPE>::Set(const CTYPE* values,\
unsigned int count)\
{\
assert( device->CurrentProgram() == program );\
setFunction(glLocation, count, (CAST_TYPE*)values);\
}\
template<>\
CTYPE GLUniform<CTYPE>::Value() const\
{\
assert( device->CurrentProgram() == program );\
CTYPE v;\
getFunction(glProgram, glLocation, (CAST_TYPE*)&v);\
return v;\
}\
template<>\
void GLUniform<CTYPE>::QueryValues(CTYPE* values) const\
{\
assert( device->CurrentProgram() == program );\
for(size_t i = 0; i<numValues; ++i)\
getFunction(glProgram, glLocation, (CAST_TYPE*)&values[i]);\
}
DEFINE_UNIFORM(INT, int, int, glUniform1iv, glGetUniformiv)
DEFINE_UNIFORM(VEC2I, Vector2i, int, glUniform2iv, glGetUniformiv)
DEFINE_UNIFORM(VEC3I, Vector3i, int, glUniform3iv, glGetUniformiv)
DEFINE_UNIFORM(VEC4I, Vector4i, int, glUniform4iv, glGetUniformiv)
DEFINE_UNIFORM(FLOAT, float, float, glUniform1fv, glGetUniformfv)
DEFINE_UNIFORM(VEC2F, Vector2f, float, glUniform2fv, glGetUniformfv)
DEFINE_UNIFORM(VEC3F, Vector3f, float, glUniform3fv, glGetUniformfv)
DEFINE_UNIFORM(VEC4F, Vector4f, float, glUniform4fv, glGetUniformfv)
#undef DEFINE_UNIFORM
#ifdef SIMPLE_GL_ES
# define TRANSPOSE_MATRIX GL_FALSE
#else
# define TRANSPOSE_MATRIX GL_TRUE
#endif
#define DEFINE_MATRIX_UNIFORM(UTYPE, CTYPE, CAST_TYPE, setFunction, getFunction)\
template<>\
AbstractUniform::TYPE GLUniform<CTYPE>::Type() const\
{\
return UTYPE;\
}\
template<>\
void GLUniform<CTYPE>::Set(const CTYPE& value)\
{\
assert( device->CurrentProgram() == program );\
setFunction(glLocation, 1, TRANSPOSE_MATRIX, (CAST_TYPE*)&value);\
}\
template<>\
void GLUniform<CTYPE>::Set(const CTYPE* values,\
unsigned int count)\
{\
assert( device->CurrentProgram() == program );\
setFunction(glLocation, count, TRANSPOSE_MATRIX, (CAST_TYPE*)values);\
}\
template<>\
CTYPE GLUniform<CTYPE>::Value() const\
{\
assert( device->CurrentProgram() == program );\
CTYPE v;\
getFunction(glProgram, glLocation, (CAST_TYPE*)&v);\
return v;\
}\
template<>\
void GLUniform<CTYPE>::QueryValues(CTYPE* values) const\
{\
for(size_t i = 0; i<numValues; ++i)\
getFunction(glProgram, glLocation, (CAST_TYPE*)&values[i]);\
}
DEFINE_MATRIX_UNIFORM(MAT2x2F, Matrix2x2f, float, glUniformMatrix2fv, glGetUniformfv)
#ifndef SIMPLE_GL_ES
DEFINE_MATRIX_UNIFORM(MAT2x3F, Matrix2x3f, float, glUniformMatrix2x3fv, glGetUniformfv)
DEFINE_MATRIX_UNIFORM(MAT2x4F, Matrix2x4f, float, glUniformMatrix2x4fv, glGetUniformfv)
DEFINE_MATRIX_UNIFORM(MAT3x2F, Matrix3x2f, float, glUniformMatrix3x2fv, glGetUniformfv)
#endif
DEFINE_MATRIX_UNIFORM(MAT3x3F, Matrix3x3f, float, glUniformMatrix3fv, glGetUniformfv)
#ifndef SIMPLE_GL_ES
DEFINE_MATRIX_UNIFORM(MAT3x4F, Matrix3x4f, float, glUniformMatrix3x4fv, glGetUniformfv)
DEFINE_MATRIX_UNIFORM(MAT4x2F, Matrix4x2f, float, glUniformMatrix4x2fv, glGetUniformfv)
DEFINE_MATRIX_UNIFORM(MAT4x3F, Matrix4x3f, float, glUniformMatrix4x3fv, glGetUniformfv)
#endif
DEFINE_MATRIX_UNIFORM(MAT4x4F, Matrix4x4f, float, glUniformMatrix4fv, glGetUniformfv)
#undef DEFINE_MATRIX_UNIFORM
template<>
AbstractUniform::TYPE GLSamplerUniform<Texture1D>::Type() const
{
return AbstractUniform::SAMPLER_1D;
}
template<>
AbstractUniform::TYPE GLSamplerUniform<Texture2D>::Type() const
{
return AbstractUniform::SAMPLER_2D;
}
template<>
AbstractUniform::TYPE GLSamplerUniform<Texture3D>::Type() const
{
return AbstractUniform::SAMPLER_3D;
}
template<>
AbstractUniform::TYPE GLSamplerUniform<TextureCube>::Type() const
{
return AbstractUniform::SAMPLER_CUBE;
}
} // namespace sgl
| [
"devnull@localhost"
]
| [
[
[
1,
134
]
]
]
|
9e87a6c31bcfcc2bab7189ddce6c8f386f7e3565 | 8e2c4a71ade4893af8fd0e8f5f2a5f3f7a581022 | /release/slm_machine_1.0-beta/fileSenderThread/filesender.h | 03c4603eef73648e087c34bdd744b230efa1fa85 | []
| no_license | mahdiattarbashi/slmmachine | c6e56d143de8014690bfe3133d0ed3084e91a22e | 2e42b8d9707a6202d55433d4c250966210558cb5 | refs/heads/master | 2021-01-22T11:20:40.679842 | 2009-03-15T08:15:35 | 2009-03-15T08:15:35 | 38,165,106 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,153 | h | #ifndef FILESENDER_H
#define FILESENDER_H
#include <QObject>
#include <QThread>
#include <QTcpSocket>
#include <QFile>
#include <QByteArray>
#include <QDataStream>
class fileSender : public QThread
{
Q_OBJECT
public:
fileSender(QObject *parent=0);
virtual ~fileSender(){}
void run();
QString peerIP;
QString filePathOfOutgoingFile;
bool encOrNot;
private:
QTcpSocket *socket;
QString fileNameofOutgoingFile;
QFile *outgoingFile;
quint16 block_size;
quint32 bytesWritten;
quint32 bytesRemaining;
quint32 fileSizeOfOutgoingFile;
QByteArray fileContensOfOutgoingFile;
void sendFileInfo();
void startFileTransfer();
public slots:
void peerConnectionEstablished();
void continueFileTransfer(qint64);
void peerConnectionBroken();
void readPeerMessage();
signals:
void sendingStarted(quint32);
void sendingCondition(quint32);
void transferFinished();
void unknownMessageReceived();
void peerConnectionClosed();
void transferRejected();
void waitingUserResponse();
};
#endif // FILESENDER_H
| [
"ahmet.kurukose@8c0919e2-fc1a-11dd-a8e2-f7cb3c35fcff"
]
| [
[
[
1,
51
]
]
]
|
6c04d75983b7616f37d855cea17c1097982cfe1f | 9b97e981165cf4a4a00694d51977445b6795499b | /main.cpp | 1153411772b39b13b124fd1032ae5820682f4027 | []
| no_license | trptrp/qtpcap | d81c821ceb5f06f321a96745ef05809f2b77ef7e | cdfbb3b97e75936175aa8b4bf4bc93cc9e1c734e | refs/heads/master | 2021-01-02T09:43:05.593126 | 2010-11-24T08:39:33 | 2010-11-24T08:39:33 | 38,862,879 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,797 | cpp | #include "qtpcap.h"
/*********************************************************
* 进程:
* 这个是程序的核心部分,完成数据包的截获
* 参数:
* pParam: 用户选择的用来捕获数据的网卡的名字
*********************************************************/
int CaptureThread(LPVOID pParam)
{
const char* pCardName=(char*)pParam; // 转换参数,获得网卡名字
pcap_t* adhandle;
char errbuf[PCAP_ERRBUF_SIZE];
// 打开网卡,并且设置为混杂模式
adhandle=pcap_open_live(pCardName,65535,1,1000,errbuf);
pcap_dumper_t* dumpfile;
// 建立存储捕获网络数据包的文件
dumpfile=pcap_dump_open(adhandle, "packet.dat");
int re;
pcap_pkthdr* header; // Header
u_char* pkt_data; // 数据包内容指针
// 从网卡或者文件中不停读取数据包信息
while((re=pcap_next_ex(adhandle,&header,(const u_char**)&pkt_data))>=0)
{
// 将捕获的数据包存入文件
pcap_dump((unsigned char*)dumpfile,header,pkt_data);
}
return 0;
}
int main(int argc, char **argv)
{
pcap_if_t* alldevs;
pcap_if_t* d;
char errbuf[PCAP_ERRBUF_SIZE];
char ** devName;
pcap_findalldevs(&alldevs,errbuf); // 获得网络设备指针
int devIndex=0;
for(d=alldevs;d;d=d->next) // 枚举网卡然后添加到ComboBox中
{
devIndex++;
printf("%d,%s,%s\n",devIndex,d->description,d->name); // d->name就是我们需要的网卡名字字符串
devName[devIndex]=d->name; // 自己的需要保存到你的相应变量中去
}
int i;
printf("请输入一个数字,并以回车结束!\n");
scanf("%d",&i);
printf("%s\n",devName[i]);
CaptureThread(devName[i]);
}
| [
"cn.wei.hp@5204a1b5-1fd8-8296-39ea-a28714a575d6"
]
| [
[
[
1,
52
]
]
]
|
9d19b691caffdd537f37ed38b0e6d20a753cb525 | 44890f9b95a8c77492bf38514d26c0da51d2fae5 | /FlashPlay/flash.cpp | 70bee82d2621bca397984aa636a4c60f3aeb2edd | []
| no_license | winnison/huang-cpp | fd9cd57bd0b97870ae1ca6427d2fc8191cf58a77 | 989fe1d3fdc1c9eae33e0f11fcd6d790e866e4c5 | refs/heads/master | 2021-01-19T18:07:38.882211 | 2008-04-14T16:42:48 | 2008-04-14T16:42:48 | 34,250,385 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 8,393 | cpp | /******************************************************************
***
***
*** FREE WINDOWLESS FLASH CONTROL
***
*** by Makarov Igor
***
*** for questions and remarks mailto: [email protected]
***
***
*******************************************************************/
// flash.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "resource.h"
#include "FlashWnd.h"
#define DllImport __declspec( dllimport )
#define DllExport __declspec( dllexport )
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCE hInstance; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text
BOOL Running = false;
RECT g_rect;
BOOL g_bSkipFrame;
_bstr_t g_url;
HWND g_hWnd = NULL;
CFlashWnd *g_flashWnd = NULL;
// Foward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance();
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
DWORD WINAPI ThreadingRun( PVOID pParam );
DllExport BOOL StartFlash(
HINSTANCE hInst, //启动实例
PCHAR url, //Flash地址
LONG left, //窗口位置
LONG top,
LONG right,
LONG bottom,
BOOL bSkipFrame //选择隔帧显示
)
{
if(Running)
return false;
Running = true;
hInstance = hInst;
g_url = url;
g_rect.left = left;
g_rect.top = top;
g_rect.right = right;
g_rect.bottom = bottom;
g_bSkipFrame = bSkipFrame;
CreateThread(
0, 0, ThreadingRun, NULL, 0, 0);
return true;
}
//---------------------------
//EXE Entry 供测试用 |
//---------------------------
//int APIENTRY WinMain(HINSTANCE hInst,
// HINSTANCE hPrevInst,
// LPSTR lpCmdLn,
// int nCmdSw)
//{
// StartFlash(hInst, "C:\\40.swf", 0,0,1000,1000, false);
// //delay 3 secs for second call.
// Sleep(3000);
// //if last flash is still playing. this call should no effect.
// StartFlash(hInst, "C:\\40.swf", 0,0,400,400, false);
//
// while(Running)
// {
// Sleep(100);
// }
// return 0;
//}
//static int res2file(LPCTSTR lpName,LPCTSTR lpType,LPCTSTR filename)
//{//将从资源写到文件;
// HRSRC myres = FindResource (NULL,lpName,lpType);
// HGLOBAL gl = LoadResource (NULL,myres);
// LPVOID lp = LockResource(gl);
// HANDLE fp = CreateFile(filename ,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,
// 0,NULL);
//
// if (!fp)return false;
//
// DWORD a;
// if (!WriteFile (fp,lp,SizeofResource (NULL,myres),&a,NULL))
// return false;
//
// CloseHandle (fp);
// FreeResource (gl);
// return true;
//
//}
//--------------------
//主显示窗口的线程 |
//--------------------
DWORD WINAPI ThreadingRun( PVOID pParam )
{
MSG msg;
//HACCEL hAccelTable;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_FLASH, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
//
//res2file (MAKEINTRESOURCE(IDR_SWF2),"swf","c:\\40.swf");
// Perform application initialization:
if (!InitInstance ())
{
return FALSE;
}
//hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_FLASH);
OleInitialize(NULL);
g_flashWnd = new CFlashWnd;
g_flashWnd->m_bSkipFrame = g_bSkipFrame;
g_flashWnd->m_url = g_url;
g_flashWnd->m_rcBounds = g_rect;
//create windowless control
g_flashWnd->Create(ShockwaveFlashObjects::CLSID_ShockwaveFlash,
WS_EX_LAYERED | WS_EX_TOPMOST, WS_CHILD | WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS,
g_hWnd, hInstance);
long lTotalFrames, lFrameNum;
g_flashWnd->m_lpControl->get_TotalFrames(&lTotalFrames);
lTotalFrames--;
//to create a windowed control uncomment this
//g_flashWnd->Create(ShockwaveFlashObjects::CLSID_ShockwaveFlash,
// 0, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS,
// g_hWnd, g_hInst);
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
//if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
//{
TranslateMessage(&msg);
DispatchMessage(&msg);
//}
g_flashWnd->m_lpControl->get_FrameNum(&lFrameNum);
if(lFrameNum >= lTotalFrames)
{
PostQuitMessage(0);
}
}
delete g_flashWnd;
OleUninitialize();
Running = false;
return 0;
}
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage is only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_FLASH);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = (LPCSTR)IDC_FLASH;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
return RegisterClassEx(&wcex);
}
//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance()
{
HWND hWnd;
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
CW_USEDEFAULT, CW_USEDEFAULT, 800, 1000, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, SW_HIDE/*SW_SHOW*/);
UpdateWindow(hWnd);
g_hWnd = hWnd;
return TRUE;
}
//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR szHello[MAX_LOADSTRING];
LoadString(hInstance, IDS_HELLO, szHello, MAX_LOADSTRING);
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInstance, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
RECT rt;
GetClientRect(hWnd, &rt);
DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_MOVE:
{
RECT r;
GetWindowRect(hWnd, &r);
if (g_flashWnd)
SetWindowPos(g_flashWnd->GetHWND(), NULL, r.left, r.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
}
break;
case WM_SIZE:
{
RECT r;
GetWindowRect(hWnd, &r);
if (g_flashWnd)
SetWindowPos(g_flashWnd->GetHWND(), NULL, 0, 0, (r.right-r.left), (r.bottom-r.top), SWP_NOMOVE | SWP_NOZORDER);
}
break;
case WM_KEYDOWN:
{
if (VK_ESCAPE == wParam)
PostQuitMessage (0);
}
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
// Mesage handler for about box.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}
| [
"mr.huanghuan@48bf5850-ed27-0410-9317-b938f814dc16"
]
| [
[
[
1,
345
]
]
]
|
d2c55c0bd4fa54f6e64e32c37b5c929d20be6d59 | ab41c2c63e554350ca5b93e41d7321ca127d8d3a | /glm/gtx/color_cast.hpp | 241d951fa678508cd3fbf2684c3be54fd6ace81c | []
| no_license | burner/e3rt | 2dc3bac2b7face3b1606ee1430e7ecfd4523bf2e | 775470cc9b912a8c1199dd1069d7e7d4fc997a52 | refs/heads/master | 2021-01-11T08:08:00.665300 | 2010-04-26T11:42:42 | 2010-04-26T11:42:42 | 337,021 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,331 | hpp | ///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2007-06-21
// Updated : 2009-06-05
// Licence : This source is under MIT License
// File : glm/gtx/color_cast.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
// Dependency:
// - GLM core
// - GLM_GTX_number_precision
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef glm_gtx_color_cast
#define glm_gtx_color_cast
// Dependency:
#include "../glm.hpp"
#include "../gtx/number_precision.hpp"
namespace glm
{
namespace test{
void main_ext_gtx_color_cast();
}//namespace test
namespace gtx{
//! GLM_GTX_color_cast extension: Conversion between two color types
namespace color_cast
{
using namespace gtx::number_precision;
//! Conversion of a floating value into a 8bit unsigned int value.
//! From GLM_GTX_color_cast extension.
template <typename valType> gtc::type_precision::uint8 u8channel_cast(valType a);
//! Conversion of a floating value into a 16bit unsigned int value.
//! From GLM_GTX_color_cast extension.
template <typename valType> gtc::type_precision::uint16 u16channel_cast(valType a);
template <typename T> gtc::type_precision::uint32 u32_rgbx_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::uint32 u32_xrgb_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::uint32 u32_bgrx_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::uint32 u32_xbgr_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::uint32 u32_rgba_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::uint32 u32_argb_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::uint32 u32_bgra_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::uint32 u32_abgr_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::uint64 u64_rgbx_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::uint64 u64_xrgb_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::uint64 u64_bgrx_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::uint64 u64_xbgr_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::uint64 u64_rgba_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::uint64 u64_argb_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::uint64 u64_bgra_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::uint64 u64_abgr_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtx::number_precision::f16vec1 f16_channel_cast(T a); //!< \brief Conversion of a u8 or u16 value to a single channel floating value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::f16vec3 f16_rgbx_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::f16vec3 f16_xrgb_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::f16vec3 f16_bgrx_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::f16vec3 f16_xbgr_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::f16vec4 f16_rgba_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::f16vec4 f16_argb_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::f16vec4 f16_bgra_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::f16vec4 f16_abgr_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtx::number_precision::f32vec1 f32_channel_cast(T a); //!< \brief Conversion of a u8 or u16 value to a single channel floating value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::f32vec3 f32_rgbx_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::f32vec3 f32_xrgb_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::f32vec3 f32_bgrx_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::f32vec3 f32_xbgr_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::f32vec4 f32_rgba_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::f32vec4 f32_argb_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::f32vec4 f32_bgra_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::f32vec4 f32_abgr_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtx::number_precision::f64vec1 f64_channel_cast(T a); //!< \brief Conversion of a u8 or u16 value to a single channel floating value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::f64vec3 f64_rgbx_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::f64vec3 f64_xrgb_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::f64vec3 f64_bgrx_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::f64vec3 f64_xbgr_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::f64vec4 f64_rgba_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::f64vec4 f64_argb_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::f64vec4 f64_bgra_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::type_precision::f64vec4 f64_abgr_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension)
}//namespace color_space
}//namespace gtx
}//namespace glm
#define GLM_GTX_color_cast namespace gtx::color_cast
#ifndef GLM_GTX_GLOBAL
namespace glm {using GLM_GTX_color_cast;}
#endif//GLM_GTC_GLOBAL
#include "color_cast.inl"
#endif//glm_gtx_color_cast
| [
"[email protected]"
]
| [
[
[
1,
110
]
]
]
|
90a016de2b7552b5486336a2012a7d57c67ebcf0 | 54cacc105d6bacdcfc37b10d57016bdd67067383 | /trunk/source/math/geom/AABB.h | 3a929b23e5ab797df79ea1f9ea550570be0ceba6 | []
| no_license | galek/hesperus | 4eb10e05945c6134901cc677c991b74ce6c8ac1e | dabe7ce1bb65ac5aaad144933d0b395556c1adc4 | refs/heads/master | 2020-12-31T05:40:04.121180 | 2009-12-06T17:38:49 | 2009-12-06T17:38:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,183 | h | /***
* hesperus: AABB.h
* Copyright Stuart Golodetz, 2009. All rights reserved.
***/
#ifndef H_HESP_AABB
#define H_HESP_AABB
#include <source/math/vectors/Vector2d.h>
#include <source/math/vectors/Vector3.h>
namespace hesp {
/**
This class template represents axis-aligned bounding boxes.
*/
template <typename Vec>
class AABB
{
//#################### PRIVATE VARIABLES ####################
private:
Vec m_minimum, m_maximum;
//#################### CONSTRUCTORS ####################
public:
AABB(const Vec& minimum, const Vec& maximum);
//#################### PUBLIC METHODS ####################
public:
const Vec& maximum() const;
const Vec& minimum() const;
static bool within_range(const AABB& lhs, const AABB& rhs, double tolerance);
//#################### PRIVATE METHODS ####################
private:
void check_invariant() const;
};
//#################### TYPEDEFS ####################
typedef AABB<Vector2d> AABB2d;
typedef AABB<Vector3d> AABB3d;
//#################### GLOBAL METHODS ####################
template <typename Vec>
AABB<Vec> read_aabb(const std::string& s, double scale = 1.0);
}
#endif
| [
"[email protected]"
]
| [
[
[
1,
49
]
]
]
|
1849e4fecefe86d3ea309921d6a39cf581c852c5 | 4b0f51aeecddecf3f57a29ffa7a184ae48f1dc61 | /CleanProject/Src/ItemBoxWindow.cpp | 9280d2355c4b3087788f1d7643b8f7ed44cf9a16 | []
| no_license | bahao247/apeengine2 | 56560dbf6d262364fbc0f9f96ba4231e5e4ed301 | f2617b2a42bdf2907c6d56e334c0d027fb62062d | refs/heads/master | 2021-01-10T14:04:02.319337 | 2009-08-26T08:23:33 | 2009-08-26T08:23:33 | 45,979,392 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 311 | cpp | /*!
@file
@author Albert Semenov
@date 07/2008
@module
*/
#include "ItemBoxWindow.h"
//#include "EnginePrerequisites.h"
namespace Nebula
{
ItemBoxWindow::ItemBoxWindow(const std::string& _layout) : BaseLayout(_layout)
{
assignBase(mItemBox, "box_Items");
}
} // namespace demo
| [
"pablosn@06488772-1f9a-11de-8b5c-13accb87f508"
]
| [
[
[
1,
19
]
]
]
|
310f9c87f9cb56b49a63234a7ec54264bfe79097 | 3f0690333762888c26c6fe4d5e9034d3b494440e | /codigoEnDesarrollo/Sources/PlataformaEmbedded.hpp | 77a0211b99857f2e5d0a252cb6b856eadc1eddba | []
| no_license | jonyMarino/dhacel-micro-prog-vieja | 56ecdcc6ca2940be7a0c319c8daa6210a876e655 | 1f8f8b1fd08aced557b870e716427d0b5e00618a | refs/heads/master | 2021-01-21T14:12:03.692649 | 2011-08-08T11:36:24 | 2011-08-08T11:36:24 | 34,534,048 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 188 | hpp | #ifndef _PLATAFORMA_EMBEDDED_HPP
#define _PLATAFORMA_EMBEDDED_HPP
class PlataformaEmbedded{
public:
virtual void mainLoop(void);
friend void main (void);
};
#endif | [
"jonymarino@9c8ba4ec-7dbd-852f-d911-916fdc55f737"
]
| [
[
[
1,
12
]
]
]
|
f9210a937de953a5478d30c8883d01e1c4a49d3d | a699a508742a0fd3c07901ab690cdeba2544a5d1 | /RailwayDetection/KellService/KellService/IOCP/BaseSocket.h | 7149c1980dcb0cb4d07821d29a01cf671f912eec | []
| no_license | xiaomailong/railway-detection | 2bf92126bceaa9aebd193b570ca6cd5556faef5b | 62e998f5de86ee2b6282ea71b592bc55ee25fe14 | refs/heads/master | 2021-01-17T06:04:48.782266 | 2011-09-27T15:13:55 | 2011-09-27T15:13:55 | 42,157,845 | 0 | 1 | null | 2015-09-09T05:24:10 | 2015-09-09T05:24:09 | null | GB18030 | C++ | false | false | 1,822 | h | #pragma once
#include <WinSock2.h>
#include <MSWSock.h>
#define BASESOCKET_SENDBUF_SIZE 65536
#define BASESOCKET_REVCBUF_SIZE 65536
class CBaseSocket
{
public:
CBaseSocket(void);
virtual ~CBaseSocket(void);
BOOL AcceptEx(
SOCKET sListenSocket,
SOCKET sAcceptSocket,
PVOID lpOutputBuffer,
DWORD dwReceiveDataLength,
DWORD dwLocalAddressLength,
DWORD dwRemoteAddressLength,
LPDWORD lpdwBytesReceived,
LPOVERLAPPED lpOverlapped
);
bool GetAcceptExSockaddrs(
PVOID lpOutputBuffer,
DWORD dwReceiveDataLength,
DWORD dwLocalAddressLength,
DWORD dwRemoteAddressLength,
LPSOCKADDR* LocalSockaddr,
LPINT LocalSockaddrLength,
LPSOCKADDR* RemoteSockaddr,
LPINT RemoteSockaddrLength
);
bool CreateLocalSocket(int nPort); // 创建一个套接字
bool CloseLocalSocket(); // 关闭套接字
SOCKET GetSocket(){return m_scSocket;}; // 获取当前套接字
void GetServerAddr(sockaddr_in * pscinTcpAddr); // 获取服务套接字的地址信息
static bool InitSocketLib(); // 初始化套接字库
static bool UnInitSocketLib(); // 卸载套接字库
private:
bool CreateSocketInstance(); // 创建重叠模式的套接字实例
bool BindListenSocket(int nPort); // 邦定操作
bool GetSocket2ExFun(); // 获取扩展指针
bool GetAcceptExPointer(); // 获取WinSocket2里的AcceptEx
bool GetAcceptExSockaddrsPointer(); // 获取WinSocket2里的AcceptExSockaddrs
SOCKET m_scSocket; // 当前套接字
sockaddr_in m_tcpAddr; // 服务端地址信息
LPFN_ACCEPTEX m_lpfnAcceptEx; // AcceptEx函数指针
LPFN_GETACCEPTEXSOCKADDRS m_lpfnGetAcceptExSockaddrs; // GetAcceptExSocketAddrs函数指针
};
| [
"[email protected]@4d6b9eea-9d24-033f-dd66-d003eccfd9d3"
]
| [
[
[
1,
55
]
]
]
|
39037b0bb48f5ddcc47085c6bb2518957292d4e5 | 3bc3ce568f1938af569a7f84d1c6e261a6fd4de5 | /StudManager/StudManager/Studman.cpp | 09286680eeb6f2d6bed06f1277b3ec1b92f52d1b | []
| no_license | dekz/uni | 524cc16e706221ad518577e5f00712d5030c035f | 84c2466df43f9dc62425d2b7c0162ac6b0a1244f | refs/heads/master | 2016-09-05T21:07:29.739745 | 2009-05-24T13:12:24 | 2009-05-24T13:12:24 | 195,698 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,625 | cpp |
#include "Coursework.h"
#include "Research.h"
#include <iostream>
#include <list>
#include <string>
using namespace std;
void displayStudents();
void loadStudents(string a_filename);
void loadStudents();
void writeStudents(string a_filename);
void getInput(string keyboardInput);
void displayInstructions();
list<Student*>* g_students;
int main()
{
//Coursework sutdents[20];
string keyboardInput;
displayInstructions();
g_students = new list<Student*>();
while (true)
{
cout << "# ";
cin >> keyboardInput;
if (keyboardInput != "quit")
{
getInput(keyboardInput);
} else break;
}
delete g_students;
return 0;
}
void getInput(string keyboardInput)
{
if (keyboardInput == "input")
{
loadStudents();
} else if (keyboardInput == "inputfile")
{
string textfile;
cout << "Enter the filename\n# ";
cin >> textfile;
loadStudents(textfile);
} else if (keyboardInput == "outputfile")
{
string textfile;
cout << "Enter the filename\n# ";
cin >> textfile;
writeStudents(textfile);
} else if (keyboardInput == "report")
{
displayStudents();
} else if (keyboardInput == "help")
{
displayInstructions();
} else cout << "Unknown command - " << keyboardInput << endl;
}
void displayInstructions()
{
cout << "\nCommands - \n input - input each student indivdually\n inputfile - input a file of studens \n outputfile - output the students to a file \n report - display studens in the terminal \n quit - quit this loop\n help - displays this menu\n";
}
void writeStudents(string a_filename)
{
ofstream thefile;
thefile.open(a_filename.c_str());
int totalStudents = g_students->size();
thefile << totalStudents << endl;
list<Student*>::iterator ci;
for (ci = g_students->begin(); ci != g_students->end(); ++ci)
{
thefile << (*ci)->getFirstName() << " " << (*ci)->getLastName() << " " << (*ci)->getId() << " " << (*ci)->getCategory() << endl;
if ((*ci)->getCategory() == "course")
{
thefile << ((Coursework*)(*ci))->getTotalUnits() << " " << ((Coursework*)(*ci))->getUnits() << endl;
} else if ((*ci)->getCategory() == "research")
{
thefile << ((Research*)(*ci))->getDegreeEnrolled() << " " << ((Research*)(*ci))->getStudyStatus() << endl;
}
}
thefile.close();
}
//overload method, make it take a filename or something
void loadStudents(string a_filename)
{
/*
cin >> textfile
wstring temp(textfile.length(),L' ');
copy(textfile.begin(), textfile.end(), temp.begin());
*/
ifstream thefile;
thefile.open(a_filename.c_str());
//grab our stuff from the text file, assign it to variables and call the constructor
unsigned loop;
thefile >> loop;
Student* student;
for (unsigned i = 0; i < loop; i++)
{
unsigned noUnits;
string id, firstName, lastName, category, degreeType, studyStatus;
thefile >> firstName >> lastName >> id >> category;
bool success = true;
//***** check for a category for the right constructor
if (category == "course")
{
thefile >> noUnits;
Coursework* courseworkStudent = new Coursework(id, firstName, lastName, category);
student = dynamic_cast<Student*>(courseworkStudent);
for (unsigned j = 0; j < noUnits; j++)
{
string unitCode;
int grade;
thefile >> unitCode >> grade;
courseworkStudent->addUnit(unitCode, grade);
}
} else if (category == "research")
{
string degreeType, studyStatus;
thefile >> degreeType >> studyStatus;
Research* researchStudent = new Research(id, firstName, lastName, category, degreeType, studyStatus);
student = dynamic_cast<Student*>(researchStudent);
} else success = false;
if (success)
{
g_students->push_back(student);
}
}
thefile.close();
}
void loadStudents()
{
Student* student;
string id, firstName, lastName, category, degreeType, studyStatus;
cout << "Please enter the student information\n id firstname lastname category\n# ";
cin >> id >> firstName >> lastName >> category ;
bool success = true;
if (category == "course")
{
unsigned noUnits;
cout << "\nEnter how many units taken\n# ";
cin >> noUnits;
//cout << id << firstName << lastName << category << noUnits ;
Coursework* courseworkStudent = new Coursework(id, firstName, lastName, category);
cout << (courseworkStudent)->getFirstName();
student = dynamic_cast<Student*>(courseworkStudent);
for (unsigned j = 0; j < noUnits; j++)
{
cout << "\n Enter Unit details\nunitcode grade\n# ";
string unitCode;
int grade;
cin >> unitCode >> grade;
courseworkStudent->addUnit(unitCode, grade);
}
} else if (category == "research")
{
string degreeType, studyStatus;
cout << "\nEnter degreetype studystatus\n# ";
cin >> degreeType >> studyStatus;
Research* researchStudent = new Research(id, firstName, lastName, category, degreeType, studyStatus);
student = dynamic_cast<Student*>(researchStudent);
}else success = false;
if (success)
{
g_students->push_back(student);
}
}
void displayStudents()
{
cout << "\nCourse Work Students \n---------------------------------\n";
list<Student*>::iterator ci;
for (ci = g_students->begin(); ci != g_students->end(); ++ci)
{
if ((*ci)->getCategory() == "course")
{
(*ci)->displayAssessment();
}
}
cout << "\nResearch Students \n---------------------------------\n";
for (ci = g_students->begin(); ci != g_students->end(); ++ci)
{
if ((*ci)->getCategory() == "research")
{
(*ci)->displayAssessment();
}
}
} | [
"[email protected]"
]
| [
[
[
1,
210
]
]
]
|
1fb3ab2b38ca32a00b824c0b090d425681247a59 | 8d1d891c3a1f9b4c09d6edf8cad30fcf03a214ed | /source/tools/ImageBank.cpp | a8020c52058c1ca6775eae4b9c7be5fecdb56bdf | []
| no_license | mightymouse2016/shootmii | 7a53a70d027ec8bc8e957c7113144de57ecfa1a5 | 6a44637da4db44ba05d5d14c9a742f5d053041fa | refs/heads/master | 2021-01-10T06:36:38.009975 | 2010-07-20T19:43:23 | 2010-07-20T19:43:23 | 54,534,472 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,212 | cpp | #include "../gfx/sun.h"
#include "../gfx/dock.h"
#include "../gfx/tank.h"
#include "../gfx/popup.h"
#include "../gfx/cannon.h"
#include "../gfx/ammo_1.h"
#include "../gfx/ammo_2.h"
#include "../gfx/shield.h"
#include "../gfx/ghost_1.h"
#include "../gfx/ghost_2.h"
#include "../gfx/guided_1.h"
#include "../gfx/guided_2.h"
#include "../gfx/homing_1.h"
#include "../gfx/homing_2.h"
#include "../gfx/button_1.h"
#include "../gfx/tile_set.h"
#include "../gfx/pointer_1.h"
#include "../gfx/pointer_2.h"
#include "../gfx/pointer_3.h"
#include "../gfx/pointer_4.h"
#include "../gfx/bonus_life.h"
#include "../gfx/heat_jauge.h"
#include "../gfx/life_jauge.h"
#include "../gfx/wind_jauge.h"
#include "../gfx/crosshair_1.h"
#include "../gfx/crosshair_2.h"
#include "../gfx/score_panel.h"
#include "../gfx/laser_jauge.h"
#include "../gfx/bonus_shield.h"
#include "../gfx/shield_jauge.h"
#include "../gfx/fury_jauge_1.h"
#include "../gfx/fury_jauge_2.h"
#include "../gfx/title_screen.h"
#include "../gfx/bonus_homing.h"
#include "../gfx/bonus_guided.h"
#include "../gfx/bonus_poison.h"
#include "../gfx/bonus_potion.h"
#include "../gfx/smoke_sprites.h"
#include "../gfx/strength_jauge.h"
#include "../gfx/bonus_cross_hair.h"
#include "../gfx/strength_sprites.h"
#include "../gfx/background_cloud.h"
#include "../gfx/foreground_cloud.h"
#include "../gfx/alpha_fury_jauge_1.h"
#include "../gfx/alpha_fury_jauge_2.h"
#include "../gfx/homing_smoke_sprites.h"
#include "../gfx/cannonball_hit_explosion.h"
#include "../gfx/cannonball_air_explosion.h"
#include "../gfx/cannonball_ground_explosion.h"
#include "ImageBank.h"
namespace shootmii {
ImageBank::ImageBank() {
}
ImageBank::~ImageBank() {
for(int i=0;i<NUMBER_OF_TEXTURES;i++) GRRLIB_FreeTexture(allTextures[i]);
}
void ImageBank::init() {
allTextures.reserve(NUMBER_OF_TEXTURES);
allTextures[TXT_SUN] = GRRLIB_LoadTexture(sun);
allTextures[TXT_DOCK] = GRRLIB_LoadTexture(dock);
allTextures[TXT_TANK] = GRRLIB_LoadTexture(tank);
allTextures[TXT_POPUP] = GRRLIB_LoadTexture(popup);
allTextures[TXT_AMMO1] = GRRLIB_LoadTexture(ammo_1);
allTextures[TXT_AMMO2] = GRRLIB_LoadTexture(ammo_2);
allTextures[TXT_SHIELD] = GRRLIB_LoadTexture(shield);
allTextures[TXT_CANNON] = GRRLIB_LoadTexture(cannon);
allTextures[TXT_GHOST1] = GRRLIB_LoadTexture(ghost_1);
allTextures[TXT_GHOST2] = GRRLIB_LoadTexture(ghost_2);
allTextures[TXT_HOMING1] = GRRLIB_LoadTexture(homing_1);
allTextures[TXT_HOMING2] = GRRLIB_LoadTexture(homing_2);
allTextures[TXT_GUIDED1] = GRRLIB_LoadTexture(guided_1);
allTextures[TXT_GUIDED2] = GRRLIB_LoadTexture(guided_2);
allTextures[TXT_TERRAIN] = GRRLIB_LoadTexture(tile_set);
allTextures[TXT_BUTTON_1] = GRRLIB_LoadTexture(button_1);
allTextures[TXT_POINTER_1] = GRRLIB_LoadTexture(pointer_1);
allTextures[TXT_POINTER_2] = GRRLIB_LoadTexture(pointer_2);
allTextures[TXT_POINTER_3] = GRRLIB_LoadTexture(pointer_3);
allTextures[TXT_POINTER_4] = GRRLIB_LoadTexture(pointer_4);
allTextures[TXT_SMOKE] = GRRLIB_LoadTexture(smoke_sprites);
allTextures[TXT_BONUS_LIFE] = GRRLIB_LoadTexture(bonus_life);
allTextures[TXT_LIFE_JAUGE] = GRRLIB_LoadTexture(life_jauge);
allTextures[TXT_HEAT_JAUGE] = GRRLIB_LoadTexture(heat_jauge);
allTextures[TXT_WIND_JAUGE] = GRRLIB_LoadTexture(wind_jauge);
allTextures[TXT_CROSSHAIR1] = GRRLIB_LoadTexture(crosshair_1);
allTextures[TXT_CROSSHAIR2] = GRRLIB_LoadTexture(crosshair_2);
allTextures[TXT_SCORE_PANEL] = GRRLIB_LoadTexture(score_panel);
allTextures[TXT_LASER_JAUGE] = GRRLIB_LoadTexture(laser_jauge);
allTextures[TXT_FURY_JAUGE1] = GRRLIB_LoadTexture(fury_jauge_1);
allTextures[TXT_FURY_JAUGE2] = GRRLIB_LoadTexture(fury_jauge_2);
allTextures[TXT_SHIELD_JAUGE] = GRRLIB_LoadTexture(shield_jauge);
allTextures[TXT_BONUS_HOMING] = GRRLIB_LoadTexture(bonus_homing);
allTextures[TXT_BONUS_POISON] = GRRLIB_LoadTexture(bonus_poison);
allTextures[TXT_BONUS_GUIDED] = GRRLIB_LoadTexture(bonus_guided);
allTextures[TXT_BONUS_POTION] = GRRLIB_LoadTexture(bonus_potion);
allTextures[TXT_TITLE_SCREEN] = GRRLIB_LoadTexture(title_screen);
allTextures[TXT_BG_CLOUD] = GRRLIB_LoadTexture(background_cloud);
allTextures[TXT_FG_CLOUD] = GRRLIB_LoadTexture(foreground_cloud);
allTextures[TXT_BONUS_SHIELD] = GRRLIB_LoadTexture(bonus_shield);
allTextures[TXT_STRENGTH_JAUGE] = GRRLIB_LoadTexture(strength_jauge);
allTextures[TXT_HOMING_SMOKE] = GRRLIB_LoadTexture(homing_smoke_sprites);
allTextures[TXT_BONUS_CROSS_HAIR] = GRRLIB_LoadTexture(bonus_cross_hair);
allTextures[TXT_STRENGTH_SPRITES] = GRRLIB_LoadTexture(strength_sprites);
allTextures[TXT_ALPHA_FURY_JAUGE1] = GRRLIB_LoadTexture(alpha_fury_jauge_1);
allTextures[TXT_ALPHA_FURY_JAUGE2] = GRRLIB_LoadTexture(alpha_fury_jauge_2);
allTextures[TXT_CANNONBALL_AIR_EXPLOSION] = GRRLIB_LoadTexture(cannonball_air_explosion);
allTextures[TXT_CANNONBALL_HIT_EXPLOSION] = GRRLIB_LoadTexture(cannonball_hit_explosion);
allTextures[TXT_CANNONBALL_GROUND_EXPLOSION] = GRRLIB_LoadTexture(cannonball_ground_explosion);
}
GRRLIB_texImg* ImageBank::get(ImageTexture textureName) {
return allTextures[textureName];
}
}
| [
"Altarfinch@c8eafc54-4d23-11de-9e51-a92ed582648b",
"denisgeorge666@c8eafc54-4d23-11de-9e51-a92ed582648b",
"altarfinch@c8eafc54-4d23-11de-9e51-a92ed582648b"
]
| [
[
[
1,
51
],
[
68,
68
]
],
[
[
52,
54
],
[
80,
80
],
[
107,
107
],
[
120,
120
]
],
[
[
55,
67
],
[
69,
79
],
[
81,
106
],
[
108,
119
]
]
]
|
db8fda8af68d8caef907f2ec0917e7ca54a746b2 | 7b379862f58f587d9327db829ae4c6493b745bb1 | /JuceLibraryCode/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp | c7fec6fe0861b7015480e47a94b105ff14fad90d | []
| no_license | owenvallis/Nomestate | 75e844e8ab68933d481640c12019f0d734c62065 | 7fe7c06c2893421a3c77b5180e5f27ab61dd0ffd | refs/heads/master | 2021-01-19T07:35:14.301832 | 2011-12-28T07:42:50 | 2011-12-28T07:42:50 | 2,950,072 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,802 | cpp | /*
==============================================================================
This file is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-11 by Raw Material Software Ltd.
------------------------------------------------------------------------------
JUCE can be redistributed and/or modified under the terms of the GNU General
Public License (Version 2), as published by the Free Software Foundation.
A copy of the license is included in the JUCE distribution, or can be found
online at www.gnu.org/licenses.
JUCE 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.
------------------------------------------------------------------------------
To release a closed-source product which uses JUCE, commercial licenses are
available: visit www.rawmaterialsoftware.com/juce for more information.
==============================================================================
*/
BEGIN_JUCE_NAMESPACE
//==============================================================================
PreferencesPanel::PreferencesPanel()
: buttonSize (70)
{
}
PreferencesPanel::~PreferencesPanel()
{
}
int PreferencesPanel::getButtonSize() const noexcept
{
return buttonSize;
}
void PreferencesPanel::setButtonSize (int newSize)
{
buttonSize = newSize;
resized();
}
//==============================================================================
void PreferencesPanel::addSettingsPage (const String& title,
const Drawable* icon,
const Drawable* overIcon,
const Drawable* downIcon)
{
DrawableButton* const button = new DrawableButton (title, DrawableButton::ImageAboveTextLabel);
buttons.add (button);
button->setImages (icon, overIcon, downIcon);
button->setRadioGroupId (1);
button->addListener (this);
button->setClickingTogglesState (true);
button->setWantsKeyboardFocus (false);
addAndMakeVisible (button);
resized();
if (currentPage == nullptr)
setCurrentPage (title);
}
void PreferencesPanel::addSettingsPage (const String& title, const void* imageData, const int imageDataSize)
{
DrawableImage icon, iconOver, iconDown;
icon.setImage (ImageCache::getFromMemory (imageData, imageDataSize));
iconOver.setImage (ImageCache::getFromMemory (imageData, imageDataSize));
iconOver.setOverlayColour (Colours::black.withAlpha (0.12f));
iconDown.setImage (ImageCache::getFromMemory (imageData, imageDataSize));
iconDown.setOverlayColour (Colours::black.withAlpha (0.25f));
addSettingsPage (title, &icon, &iconOver, &iconDown);
}
//==============================================================================
void PreferencesPanel::showInDialogBox (const String& dialogTitle, int dialogWidth, int dialogHeight, const Colour& backgroundColour)
{
setSize (dialogWidth, dialogHeight);
DialogWindow::showDialog (dialogTitle, this, 0, backgroundColour, false);
}
//==============================================================================
void PreferencesPanel::resized()
{
for (int i = 0; i < buttons.size(); ++i)
buttons.getUnchecked(i)->setBounds (i * buttonSize, 0, buttonSize, buttonSize);
if (currentPage != nullptr)
currentPage->setBounds (getLocalBounds().withTop (buttonSize + 5));
}
void PreferencesPanel::paint (Graphics& g)
{
g.setColour (Colours::grey);
g.fillRect (0, buttonSize + 2, getWidth(), 1);
}
void PreferencesPanel::setCurrentPage (const String& pageName)
{
if (currentPageName != pageName)
{
currentPageName = pageName;
currentPage = nullptr;
currentPage = createComponentForPage (pageName);
if (currentPage != nullptr)
{
addAndMakeVisible (currentPage);
currentPage->toBack();
resized();
}
for (int i = 0; i < buttons.size(); ++i)
{
if (buttons.getUnchecked(i)->getName() == pageName)
{
buttons.getUnchecked(i)->setToggleState (true, false);
break;
}
}
}
}
void PreferencesPanel::buttonClicked (Button*)
{
for (int i = 0; i < buttons.size(); ++i)
{
if (buttons.getUnchecked(i)->getToggleState())
{
setCurrentPage (buttons.getUnchecked(i)->getName());
break;
}
}
}
END_JUCE_NAMESPACE
| [
"ow3nskip"
]
| [
[
[
1,
147
]
]
]
|
8394b2339f6232713a1dfb66aaa2ba9d8c4f8479 | b08e948c33317a0a67487e497a9afbaf17b0fc4c | /LuaPlus/Samples/UnitTest++/src/tests/TestTestRunner.cpp | e583f158adfffc157a011a66eee8ceb1bdf8e28d | [
"MIT"
]
| permissive | 15831944/bastionlandscape | e1acc932f6b5a452a3bd94471748b0436a96de5d | c8008384cf4e790400f9979b5818a5a3806bd1af | refs/heads/master | 2023-03-16T03:28:55.813938 | 2010-05-21T15:00:07 | 2010-05-21T15:00:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,838 | cpp | #include "../UnitTest++.h"
#include "RecordingReporter.h"
#include "../ReportAssert.h"
#include "../TestList.h"
#include "../TimeHelpers.h"
using namespace UnitTest;
namespace
{
struct MockTest : public Test
{
MockTest(char const* testName, bool const success_, bool const assert_)
: Test(testName)
, success(success_)
, asserted(assert_)
{
}
virtual void RunImpl(TestResults& testResults_) const
{
if (asserted)
ReportAssert("desc", "file", 0);
else if (!success)
testResults_.OnTestFailure("filename", 0, "", "message");
}
bool success;
bool asserted;
};
struct TestRunnerFixture
{
RecordingReporter reporter;
TestList list;
};
TEST_FIXTURE(TestRunnerFixture, TestStartIsReportedCorrectly)
{
MockTest test("goodtest", true, false);
list.Add(&test);
RunAllTests(reporter, list);
CHECK_EQUAL(1, reporter.testRunCount);
CHECK_EQUAL("goodtest", reporter.lastStartedTest);
}
TEST_FIXTURE(TestRunnerFixture, TestFinishIsReportedCorrectly)
{
MockTest test("goodtest", true, false);
list.Add(&test);
RunAllTests(reporter, list);
CHECK_EQUAL(1, reporter.testFinishedCount);
CHECK_EQUAL("goodtest", reporter.lastFinishedTest);
}
class SlowTest : public Test
{
public:
SlowTest() : Test("slow", "filename", 123) {}
virtual void RunImpl(TestResults&) const
{
TimeHelpers::SleepMs(20);
}
};
TEST_FIXTURE(TestRunnerFixture, TestFinishIsCalledWithCorrectTime)
{
SlowTest test;
list.Add(&test);
RunAllTests(reporter, list);
CHECK (reporter.lastFinishedTestTime >= 0.005f && reporter.lastFinishedTestTime <= 0.050f);
}
TEST_FIXTURE(TestRunnerFixture, FailureCountIsZeroWhenNoTestsAreRun)
{
CHECK_EQUAL(0, RunAllTests(reporter, list));
CHECK_EQUAL(0, reporter.testRunCount);
CHECK_EQUAL(0, reporter.testFailedCount);
}
TEST_FIXTURE(TestRunnerFixture, CallsReportFailureOncePerFailingTest)
{
MockTest test1("test", false, false);
list.Add(&test1);
MockTest test2("test", true, false);
list.Add(&test2);
MockTest test3("test", false, false);
list.Add(&test3);
CHECK_EQUAL(2, RunAllTests(reporter, list));
CHECK_EQUAL(2, reporter.testFailedCount);
}
TEST_FIXTURE(TestRunnerFixture, TestsThatAssertAreReportedAsFailing)
{
MockTest test("test", true, true);
list.Add(&test);
RunAllTests(reporter, list);
CHECK_EQUAL(1, reporter.testFailedCount);
}
TEST_FIXTURE(TestRunnerFixture, FinishedTestsReportDone)
{
MockTest test1("test", true, false);
MockTest test2("test", false, false);
list.Add(&test1);
list.Add(&test2);
RunAllTests(reporter, list);
CHECK_EQUAL(2, reporter.summaryTestCount);
CHECK_EQUAL(1, reporter.summaryFailureCount);
}
TEST_FIXTURE(TestRunnerFixture, SlowTestPassesForHighTimeThreshold)
{
SlowTest test;
list.Add(&test);
RunAllTests(reporter, list);
CHECK_EQUAL (0, reporter.testFailedCount);
}
TEST_FIXTURE(TestRunnerFixture, SlowTestFailsForLowTimeThreshold)
{
SlowTest test;
list.Add(&test);
RunAllTests(reporter, list, 3);
CHECK_EQUAL (1, reporter.testFailedCount);
}
TEST_FIXTURE(TestRunnerFixture, SlowTestHasCorrectFailureInformation)
{
SlowTest test;
list.Add(&test);
RunAllTests(reporter, list, 3);
CHECK_EQUAL (test.m_testName, reporter.lastFailedTest);
CHECK (std::strstr(test.m_filename, reporter.lastFailedFile));
CHECK_EQUAL (test.m_lineNumber, reporter.lastFailedLine);
CHECK (std::strstr(reporter.lastFailedMessage, "Global time constraint failed"));
CHECK (std::strstr(reporter.lastFailedMessage, "3ms"));
}
}
| [
"voodoohaust@97c0069c-804f-11de-81da-11cc53ed4329"
]
| [
[
[
1,
150
]
]
]
|
d298534bee8a798483a9651658905969886f9ca4 | 1d2705c9be9ee0f974c224eb794f2f8a9e9a3d50 | /am/am_event_listener_t.h | f7fffe0a630bcdedb251467f9646f81b1e47a9fc | []
| no_license | llvllrbreeze/alcorapp | dfe2551f36d346d73d998f59d602c5de46ef60f7 | 3ad24edd52c19f0896228f55539aa8bbbb011aac | refs/heads/master | 2021-01-10T07:36:01.058011 | 2008-12-16T12:51:50 | 2008-12-16T12:51:50 | 47,865,136 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 655 | h | #ifndef am_event_listener_t_H_INCLUDED
#define am_event_listener_t_H_INCLUDED
#pragma comment(lib,"am_event_listener_t.lib")
#include "alcor/core/i_observer.h"
//#include <boost/shared_ptr.hpp>
#include <memory>
#include "alcor.apps/am/attentive_search_inc.h"
namespace all { namespace am {
struct am_event_listener_t : public all::core::i_observable
{
am_event_listener_t(){};
//virtual void start()=0;
virtual events::tag get_event() const = 0;
};
}}//namespaces
namespace all { namespace am {
std::auto_ptr<am_event_listener_t>
create_listener();
}}//namespaces
#endif //am_event_listener_t_H_INCLUDED | [
"andrea.carbone@1ffd000b-a628-0410-9a29-793f135cad17"
]
| [
[
[
1,
32
]
]
]
|
d397f273800ebc385bee07e26a35306a459d5283 | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/boost/xpressive/detail/core/matcher/regex_byref_matcher.hpp | c03d47764c0ca153eee6c5f01adffbb5ecaa8ff3 | [
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | willrebuild/flyffsf | e5911fb412221e00a20a6867fd00c55afca593c7 | d38cc11790480d617b38bb5fc50729d676aef80d | refs/heads/master | 2021-01-19T20:27:35.200154 | 2011-02-10T12:34:43 | 2011-02-10T12:34:43 | 32,710,780 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,639 | hpp | ///////////////////////////////////////////////////////////////////////////////
// regex_byref_matcher.hpp
//
// Copyright 2004 Eric Niebler. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_REGEX_BYREF_MATCHER_HPP_EAN_10_04_2005
#define BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_REGEX_BYREF_MATCHER_HPP_EAN_10_04_2005
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/assert.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/xpressive/regex_error.hpp>
#include <boost/xpressive/regex_constants.hpp>
#include <boost/xpressive/detail/detail_fwd.hpp>
#include <boost/xpressive/detail/core/quant_style.hpp>
#include <boost/xpressive/detail/core/state.hpp>
#include <boost/xpressive/detail/core/regex_impl.hpp>
#include <boost/xpressive/detail/core/adaptor.hpp>
namespace boost { namespace xpressive { namespace detail
{
///////////////////////////////////////////////////////////////////////////////
// regex_byref_matcher
//
template<typename BidiIter>
struct regex_byref_matcher
: quant_style<quant_variable_width, unknown_width, mpl::false_>
{
// avoid cyclic references by holding a weak_ptr to the
// regex_impl struct
weak_ptr<regex_impl<BidiIter> > wimpl_;
// the basic_regex object holds a ref-count to this regex_impl, so
// we don't have to worry about it going away.
regex_impl<BidiIter> const *pimpl_;
regex_byref_matcher(shared_ptr<regex_impl<BidiIter> > const &impl)
: wimpl_(impl)
, pimpl_(impl.get())
{
BOOST_ASSERT(this->pimpl_);
}
template<typename Next>
bool match(state_type<BidiIter> &state, Next const &next) const
{
// regex_matcher is used for embeding a dynamic regex in a static regex. As such,
// Next will always point to a static regex.
BOOST_MPL_ASSERT((is_static_xpression<Next>));
BOOST_ASSERT(this->pimpl_ == this->wimpl_.lock().get());
ensure(this->pimpl_->xpr_, regex_constants::error_badref, "bad regex reference");
// wrap the static xpression in a matchable interface
xpression_adaptor<Next const &, BidiIter> adaptor(next);
return push_context_match(*this->pimpl_, state, adaptor);
}
};
}}}
#endif
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
69
]
]
]
|
4815aba32b0d7feb27a334a4b11e4110ba64a208 | d8f64a24453c6f077426ea58aaa7313aafafc75c | /AI Sandbox/AIHelper.h | 22c04e8d4486100136704a0be523bf539425cdb5 | []
| no_license | dotted/wfto | 5b98591645f3ddd72cad33736da5def09484a339 | 6eebb66384e6eb519401bdd649ae986d94bcaf27 | refs/heads/master | 2021-01-20T06:25:20.468978 | 2010-11-04T21:01:51 | 2010-11-04T21:01:51 | 32,183,921 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,122 | h | #ifndef AIHELPHER_H
#define AIHELPHER_H
#include <cml/cml.h>
namespace AI
{
class CAIHelper
{
public:
CAIHelper(void);
~CAIHelper(void);
struct sAbstractBlock
{
cml::vector2i position;
int owner;
sAbstractBlock(cml::vector2i position, int owner)
{
this->position = position;
this->owner = owner;
}
};
// methods each creature may use for it's AI
// parameters ending with _ are outgoing params
// Fills blocks_ vector with locations of currently unclaimed blocks.
virtual void getUnclaimedBlocks(std::vector<sAbstractBlock> &blocks_) = 0;
// Runs the threaded calculation of path-ing from 'from' to 'to' using A*.
// Method returns immediately, results should be checked with 'pathIsReady' using an ID generated by this method.
virtual int pathFind(cml::vector2i &from, cml::vector2i &to) = 0;
// Call to see if the path with specified ID has already been found.
// If so, the results are found in 'path_'.
virtual bool pathIsReady(int pathID, std::vector<cml::vector2i> &path_) = 0;
};
};
#endif // AIHELPHER_H | [
"[email protected]"
]
| [
[
[
1,
42
]
]
]
|
794ab464e7fd95fb245d7ceeed5f2d955bd0c6f7 | c5534a6df16a89e0ae8f53bcd49a6417e8d44409 | /trunk/Dependencies/Xerces/include/xercesc/dom/impl/DOMAttrNSImpl.hpp | d7ce2f70cf079d8cac49837a5cc24b952856f921 | []
| no_license | svn2github/ngene | b2cddacf7ec035aa681d5b8989feab3383dac012 | 61850134a354816161859fe86c2907c8e73dc113 | refs/heads/master | 2023-09-03T12:34:18.944872 | 2011-07-27T19:26:04 | 2011-07-27T19:26:04 | 78,163,390 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,788 | hpp | #ifndef DOMAttrNSImpl_HEADER_GUARD_
#define DOMAttrNSImpl_HEADER_GUARD_
/*
* Copyright 2001-2002,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: DOMAttrNSImpl.hpp 176026 2004-09-08 13:57:07Z peiyongz $
*/
//
// This file is part of the internal implementation of the C++ XML DOM.
// It should NOT be included or used directly by application programs.
//
// Applications should include the file <xercesc/dom/DOM.hpp> for the entire
// DOM API, or xercesc/dom/DOM*.hpp for individual DOM classes, where the class
// name is substituded for the *.
//
#include "DOMAttrImpl.hpp"
XERCES_CPP_NAMESPACE_BEGIN
class CDOM_EXPORT DOMAttrNSImpl: public DOMAttrImpl {
protected:
//Introduced in DOM Level 2
const XMLCh * fNamespaceURI; //namespace URI of this node
const XMLCh * fLocalName; //local part of qualified name
const XMLCh * fPrefix; // prefix part of qualified name
// revisit - can return local part
// by pointing into the qualified (L1) name.
public:
DOMAttrNSImpl(DOMDocument *ownerDoc, const XMLCh *name);
DOMAttrNSImpl(DOMDocument *ownerDoc, //DOM Level 2
const XMLCh *namespaceURI, const XMLCh *qualifiedName);
DOMAttrNSImpl(const DOMAttrNSImpl &other, bool deep=false);
virtual DOMNode * cloneNode(bool deep) const;
//Introduced in DOM Level 2
virtual const XMLCh * getNamespaceURI() const;
virtual const XMLCh * getPrefix() const;
virtual const XMLCh * getLocalName() const;
virtual void setPrefix(const XMLCh *prefix);
virtual void release();
// helper function for DOM Level 3 renameNode
virtual DOMNode* rename(const XMLCh* namespaceURI, const XMLCh* name);
void setName(const XMLCh* namespaceURI, const XMLCh* name);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
DOMAttrNSImpl & operator = (const DOMAttrNSImpl &);
};
XERCES_CPP_NAMESPACE_END
#endif
| [
"Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57"
]
| [
[
[
1,
74
]
]
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.