// ServoGraph.h: interface for the CServoGraph class.
|
//
|
//////////////////////////////////////////////////////////////////////
|
|
#if !defined(AFX_SERVOGRAPH_H__FBB8916A_DE77_4EA3_9C21_E51E6B06194C__INCLUDED_)
|
#define AFX_vGRAPH_H__FBB8916A_DE77_4EA3_9C21_E51E6B06194C__INCLUDED_
|
|
|
#pragma comment(lib, "Msimg32.lib") // TransparentBlt
|
#include <vector>
|
|
|
|
//====== ServoGraph =====================================================
|
|
#ifndef NOSERVOGRAPH
|
|
#ifdef _WIN32
|
|
#define BYSERVOGRAPH_CLASSA "BYServoGraph"
|
#define BYSERVOGRAPH_CLASSW L"BYServoGraph"
|
|
#ifdef UNICODE
|
#define BYSERVOGRAPH_CLASS BYSERVOGRAPH_CLASSW
|
#else
|
#define BYSERVOGRAPH_CLASS BYSERVOGRAPH_CLASSA
|
#endif
|
|
#else
|
#define BYSERVOGRAPH_CLASS "BYSERVOGraph"
|
#endif
|
|
|
#define BYSTAG_SERVOGRAPH _T("ISSERVOGRAPH")
|
|
|
//====== WM_NOTIFY codes (NMHDR.code values) ==================================
|
#define BYSERVOGRAPH_FIRST (0U-1390U) //
|
#define BYSERVOGRAPH_LAST (0U-1350U)
|
#define BYSERVOGRAPH_ITEM_CLICKED (BYSERVOGRAPH_FIRST - 1)
|
|
|
typedef struct tagBYSERVOGRAPH_NMHDR
|
{
|
NMHDR nmhdr;
|
DWORD dwData;
|
DWORD dwData1;
|
DWORD dwData2;
|
} BYSERVOGRAPH_NMHDR;
|
|
#endif
|
|
|
|
|
#if _MSC_VER > 1000
|
#pragma once
|
#endif // _MSC_VER > 1000
|
|
|
#define HMGRAPH_HITCODETEST _T("HitCode")
|
#define HMGRAPH_HT_NOWHERE 0x1
|
#define HMGRAPH_HT_ITEM 0x2
|
|
|
class CServoGraph
|
{
|
private:
|
typedef struct tagIMAGE
|
{
|
int id;
|
char szPath[MAX_PATH];
|
int x;
|
int y;
|
HBITMAP hBitmap;
|
int bmWidth;
|
int bmHeight;
|
float angle;
|
} IMAGE;
|
|
|
class INDICATEBOX
|
{
|
public:
|
INDICATEBOX() {
|
this->id = 0;
|
this->x = 0;
|
this->y = 0;
|
this->box1Width = 0;
|
this->box1BackgroundColor = RGB(255, 255, 255);
|
this->box1FrameColor[0] = RGB(22, 22, 22);
|
this->box1FrameColor[1] = RGB(22, 22, 22);
|
this->box2Width = 0;
|
this->box2BackgroundColor = RGB(0, 255, 255);;
|
this->box2FrameColor = RGB(255, 255, 0);;
|
this->bBox2Visible = FALSE;
|
this->m_pData = nullptr;
|
};
|
~INDICATEBOX() {};
|
|
public:
|
int id;
|
int x;
|
int y;
|
int box1Width;
|
COLORREF box1BackgroundColor;
|
COLORREF box1FrameColor[2];
|
char szText[64];
|
int box2Width;
|
COLORREF box2BackgroundColor;
|
COLORREF box2FrameColor;
|
BOOL bBox2Visible;
|
std::vector<void*> m_contexts;
|
void* m_pData;
|
};
|
|
class INDICATEBKGND
|
{
|
public:
|
INDICATEBKGND() {
|
this->id = 0;
|
this->rect = { 0, 0, 10, 10 };
|
this->backgroundColor = RGB(255, 255, 255);;
|
};
|
~INDICATEBKGND() {};
|
|
public:
|
int id;
|
RECT rect;
|
COLORREF backgroundColor;
|
};
|
|
public:
|
CServoGraph();
|
virtual ~CServoGraph();
|
static BOOL RegisterWndClass();
|
static CServoGraph* Hook(HWND hWnd);
|
void Notify(int nCode, int dwData, int dwData1 = 0, int dwData2 = 0);
|
void Release();
|
void SetBkgndColor(COLORREF cr);
|
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
static LRESULT OnNcCreate(HWND hWnd, WPARAM wParam, LPARAM lParam);
|
LRESULT OnDestroy(WPARAM wParam, LPARAM lParam);
|
LRESULT OnTimer(WPARAM wParam, LPARAM lParam);
|
LRESULT OnPaint(WPARAM wParam, LPARAM lParam);
|
LRESULT OnMouseMove(WPARAM wParam, LPARAM lParam);
|
LRESULT OnSize(WPARAM wParam, LPARAM lParam);
|
LRESULT OnLButtonDown(WPARAM wParam, LPARAM lParam);
|
|
public:
|
void AddImage(int id, char* pszPath, int x, int y);
|
void AddIndicateBox(int id, int x, int y, int width);
|
void AddIndicateBox(int id, int x, int y, int width,
|
COLORREF crFrame1, COLORREF crFrame2, COLORREF crBackground);
|
void AddIndicateBoxContext(int id, void* pContext);
|
BOOL RemoveIndicateBoxContext(int id, void* pContext);
|
BOOL RemoveIndicateBoxAllContext(int id);
|
const std::vector<void*>& GetIndicateBoxContexts(int id);
|
bool IsIndicateBoxContextsEmpty(int id);
|
void SetIndicateBoxData(int id, void* pData);
|
void* GetIndicateBoxData(int id);
|
void ShowIndicateBoxInterior(int id, COLORREF color);
|
void HideIndicateBoxInterior(int id);
|
CServoGraph::INDICATEBOX* GetIndicateBox(int id);
|
void AddIndicateBkgnd(int id, int left, int top, int width, int height, COLORREF color);
|
void SetIndicateBkgndColor(int id, COLORREF color);
|
CServoGraph::INDICATEBKGND* GetIndicateBkgnd(int id);
|
void SetResDir(CString strDir);
|
CServoGraph::IMAGE* GetImage(int id);
|
int HitTest(POINT pt, OUT void*& pItem);
|
void GetIndicateBoxRect(INDICATEBOX* pBox, LPRECT lprcBox);
|
BOOL GetIndicateBoxRect(int id, LPRECT lprcBox);
|
void SetBoxText(int id, const char* pszText, const char* pszTooltip);
|
HWND GetSafeWnd();
|
void UpdateImageCoordinates(int id, int newX, int newY);
|
void UpdateIndicateBoxCoordinates(int id, int newX, int newY);
|
void UpdateImageAngle(int id, float angle);
|
void UpdateIndicateBox1Colors(int id, COLORREF newBackgroundColor, COLORREF newFrameColor1, COLORREF newFrameColor2);
|
void UpdateIndicateBox2Colors(int id, COLORREF newBackgroundColor, COLORREF newFrameColor);
|
|
private:
|
void DrawImage(HDC hMemDC, IMAGE& item);
|
|
private:
|
HWND m_hWnd;
|
COLORREF m_crBkgnd;
|
CString m_strResDir;
|
|
private:
|
std::vector<IMAGE> m_images;
|
std::vector<INDICATEBOX> m_indicateBoxs;
|
std::vector<INDICATEBKGND> m_indicateBkgnds;
|
void* m_pHighItem;
|
HWND m_hWndTooltip;
|
};
|
|
#endif // !defined(AFX_EQUIPMENTGRAPH_H__FBB8916A_DE77_4EA3_9C21_E51E6B06194C__INCLUDED_)
|