Skip to content

Commit d24d7a1

Browse files
committed
Added WindowResize and WindowMoveHotspot
1 parent 77a1d28 commit d24d7a1

File tree

9 files changed

+166
-15
lines changed

9 files changed

+166
-15
lines changed

OtherTypes.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,7 @@ class CMiniWindow
11961196

11971197
CDC dc; // our offscreen device context
11981198
CBitmap * m_oldBitmap; // bitmap originally found in CMyMemDC
1199-
CBitmap m_Bitmap; // where it all happens
1199+
CBitmap * m_Bitmap; // where it all happens
12001200
FontMap m_Fonts; // all the fonts they want
12011201
ImageMap m_Images; // other images they may want to blt onto the window
12021202

@@ -1406,6 +1406,11 @@ class CMiniWindow
14061406
long Left, long Top, long Right, long Bottom,
14071407
long SrcLeft, long SrcTop);
14081408

1409+
long Resize(long Width, long Height, long BackgroundColour);
1410+
1411+
long MoveHotspot(LPCTSTR HotspotId, long Left, long Top, long Right, long Bottom);
1412+
1413+
14091414
};
14101415

14111416
typedef map<string, CMiniWindow *> MiniWindowMap;

doc.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,8 @@ BEGIN_DISPATCH_MAP(CMUSHclientDoc, CDocument)
602602
DISP_FUNCTION(CMUSHclientDoc, "WindowDrawImageAlpha", WindowDrawImageAlpha, VT_I4, VTS_BSTR VTS_BSTR VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_R8 VTS_I4 VTS_I4)
603603
DISP_FUNCTION(CMUSHclientDoc, "WindowGetImageAlpha", WindowGetImageAlpha, VT_I4, VTS_BSTR VTS_BSTR VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4)
604604
DISP_FUNCTION(CMUSHclientDoc, "WindowScrollwheelHandler", WindowScrollwheelHandler, VT_I4, VTS_BSTR VTS_BSTR VTS_BSTR)
605+
DISP_FUNCTION(CMUSHclientDoc, "WindowResize", WindowResize, VT_I4, VTS_BSTR VTS_I4 VTS_I4 VTS_I4)
606+
DISP_FUNCTION(CMUSHclientDoc, "WindowMoveHotspot", WindowMoveHotspot, VT_I4, VTS_BSTR VTS_BSTR VTS_I4 VTS_I4 VTS_I4 VTS_I4)
605607
DISP_PROPERTY_PARAM(CMUSHclientDoc, "NormalColour", GetNormalColour, SetNormalColour, VT_I4, VTS_I2)
606608
DISP_PROPERTY_PARAM(CMUSHclientDoc, "BoldColour", GetBoldColour, SetBoldColour, VT_I4, VTS_I2)
607609
DISP_PROPERTY_PARAM(CMUSHclientDoc, "CustomColourText", GetCustomColourText, SetCustomColourText, VT_I4, VTS_I2)

doc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2668,6 +2668,8 @@ class CMUSHclientDoc : public CDocument
26682668
afx_msg long WindowDrawImageAlpha(LPCTSTR Name, LPCTSTR ImageId, long Left, long Top, long Right, long Bottom, double Opacity, long SrcLeft, long SrcTop);
26692669
afx_msg long WindowGetImageAlpha(LPCTSTR Name, LPCTSTR ImageId, long Left, long Top, long Right, long Bottom, long SrcLeft, long SrcTop);
26702670
afx_msg long WindowScrollwheelHandler(LPCTSTR Name, LPCTSTR HotspotId, LPCTSTR MoveCallback);
2671+
afx_msg long WindowResize(LPCTSTR Name, long Width, long Height, long BackgroundColour);
2672+
afx_msg long WindowMoveHotspot(LPCTSTR Name, LPCTSTR HotspotId, long Left, long Top, long Right, long Bottom);
26712673
afx_msg long GetNormalColour(short WhichColour);
26722674
afx_msg void SetNormalColour(short WhichColour, long nNewValue);
26732675
afx_msg long GetBoldColour(short WhichColour);

miniwindow.cpp

Lines changed: 80 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// constructor
1717
CMiniWindow::CMiniWindow () :
1818
m_oldBitmap (NULL),
19+
m_Bitmap (NULL),
1920
m_iWidth (0), m_iHeight (0),
2021
m_iPosition (0), m_iFlags (0),
2122
m_iBackgroundColour (0), m_bShow (false),
@@ -34,12 +35,14 @@ CMiniWindow::~CMiniWindow () // destructor
3435
{
3536

3637
// get rid of old one if any
37-
if ((HBITMAP) m_Bitmap)
38+
if (m_Bitmap)
3839
{
3940
dc.SelectObject(m_oldBitmap); // swap old one back
40-
m_Bitmap.DeleteObject (); // delete the one we made
41+
m_Bitmap->DeleteObject (); // delete the one we made
42+
delete m_Bitmap;
4143
}
4244

45+
4346
// delete our fonts
4447
for (FontMapIterator fit = m_Fonts.begin ();
4548
fit != m_Fonts.end ();
@@ -145,15 +148,17 @@ void CMiniWindow::Create (long Left, long Top, long Width, long Height,
145148
m_iBackgroundColour = BackgroundColour;
146149

147150
// get rid of old one if any
148-
if ((HBITMAP) m_Bitmap)
151+
if (m_Bitmap)
149152
{
150153
dc.SelectObject(m_oldBitmap); // swap old one back
151-
m_Bitmap.DeleteObject ();
154+
m_Bitmap->DeleteObject ();
152155
}
153156

157+
m_Bitmap = new CBitmap;
158+
154159
// CreateBitmap with zero-dimensions creates a monochrome bitmap, so force to be at least 1x1
155-
m_Bitmap.CreateBitmap (MAX (m_iWidth, 1), MAX (m_iHeight, 1), 1, GetDeviceCaps(dc, BITSPIXEL), NULL);
156-
m_oldBitmap = dc.SelectObject (&m_Bitmap);
160+
m_Bitmap->CreateBitmap (MAX (m_iWidth, 1), MAX (m_iHeight, 1), 1, GetDeviceCaps(dc, BITSPIXEL), NULL);
161+
m_oldBitmap = dc.SelectObject (m_Bitmap);
157162
dc.SetWindowOrg(0, 0);
158163

159164
dc.FillSolidRect (0, 0, m_iWidth, m_iHeight, m_iBackgroundColour);
@@ -4131,3 +4136,72 @@ long CMiniWindow::ScrollwheelHandler(CMUSHclientDoc * pDoc, LPCTSTR HotspotId, s
41314136

41324137

41334138
} // end of CMiniWindow::ScrollwheelHandler
4139+
4140+
4141+
// resize a window
4142+
4143+
long CMiniWindow::Resize(long Width, long Height, long BackgroundColour)
4144+
{
4145+
4146+
// no change to size? wow, that was easy ...
4147+
if (Width == m_iWidth && Height == m_iHeight)
4148+
return eOK;
4149+
4150+
// remember new width and height
4151+
4152+
m_iWidth = Width ;
4153+
m_iHeight = Height;
4154+
4155+
CDC bmDC; // for loading bitmaps into
4156+
bmDC.CreateCompatibleDC(&dc);
4157+
4158+
// select original bitmap out of device context
4159+
dc.SelectObject(m_oldBitmap);
4160+
4161+
// save old bitmap for copying from
4162+
CBitmap * previousWindowBitmap = m_Bitmap;
4163+
4164+
// select into new device context
4165+
CBitmap * pOldbmp = bmDC.SelectObject (previousWindowBitmap);
4166+
4167+
// make new bitmap for different size
4168+
m_Bitmap = new CBitmap;
4169+
4170+
// CreateBitmap with zero-dimensions creates a monochrome bitmap, so force to be at least 1x1
4171+
m_Bitmap->CreateBitmap (MAX (m_iWidth, 1), MAX (m_iHeight, 1), 1, GetDeviceCaps(dc, BITSPIXEL), NULL);
4172+
m_oldBitmap = dc.SelectObject (m_Bitmap);
4173+
dc.SetWindowOrg(0, 0);
4174+
4175+
// fill with requested border colour
4176+
dc.FillSolidRect (0, 0, m_iWidth, m_iHeight, BackgroundColour);
4177+
4178+
// copy old contents back
4179+
dc.BitBlt (0, 0, m_iWidth, m_iHeight, &bmDC, 0, 0, SRCCOPY);
4180+
bmDC.SelectObject(pOldbmp);
4181+
4182+
// done with previous bitmap from this miniwindow
4183+
previousWindowBitmap->DeleteObject ();
4184+
delete previousWindowBitmap;
4185+
4186+
return eOK;
4187+
4188+
} // end of CMiniWindow::Resize
4189+
4190+
4191+
4192+
// move a hotspot (maybe the window was resized)
4193+
4194+
long CMiniWindow::MoveHotspot(LPCTSTR HotspotId,
4195+
long Left, long Top, long Right, long Bottom)
4196+
{
4197+
4198+
HotspotMapIterator it = m_Hotspots.find (HotspotId);
4199+
4200+
if (it == m_Hotspots.end ())
4201+
return eHotspotNotInstalled;
4202+
4203+
it->second->m_rect = CRect (Left, Top, FixRight (Right), FixBottom (Bottom));
4204+
4205+
return eOK;
4206+
} // end of CMiniWindow::MoveHotspot
4207+

mushclient.cnt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,9 +547,11 @@
547547
3 WindowLoadImage=FNC_WindowLoadImage
548548
3 WindowMenu=FNC_WindowMenu
549549
3 WindowMergeImageAlpha=FNC_WindowMergeImageAlpha
550+
3 WindowMoveHotspot=FNC_WindowMoveHotspot
550551
3 WindowPolygon=FNC_WindowPolygon
551552
3 WindowPosition=FNC_WindowPosition
552553
3 WindowRectOp=FNC_WindowRectOp
554+
3 WindowResize=FNC_WindowResize
553555
3 WindowScrollwheelHandler=FNC_WindowScrollwheelHandler
554556
3 WindowSetPixel=FNC_WindowSetPixel
555557
3 WindowShow=FNC_WindowShow

mushclient.odl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ library MUSHclient
7070
[id(44)] long SetCommand(BSTR Message);
7171
[id(45)] BSTR GetNotes();
7272
[id(46)] void SetNotes(BSTR Message);
73-
[id(400), propget] long NormalColour(short WhichColour);
74-
[id(400), propput] void NormalColour(short WhichColour, long nNewValue);
75-
[id(401), propget] long BoldColour(short WhichColour);
76-
[id(401), propput] void BoldColour(short WhichColour, long nNewValue);
77-
[id(402), propget] long CustomColourText(short WhichColour);
78-
[id(402), propput] void CustomColourText(short WhichColour, long nNewValue);
79-
[id(403), propget] long CustomColourBackground(short WhichColour);
80-
[id(403), propput] void CustomColourBackground(short WhichColour, long nNewValue);
73+
[id(402), propget] long NormalColour(short WhichColour);
74+
[id(402), propput] void NormalColour(short WhichColour, long nNewValue);
75+
[id(403), propget] long BoldColour(short WhichColour);
76+
[id(403), propput] void BoldColour(short WhichColour, long nNewValue);
77+
[id(404), propget] long CustomColourText(short WhichColour);
78+
[id(404), propput] void CustomColourText(short WhichColour, long nNewValue);
79+
[id(405), propget] long CustomColourBackground(short WhichColour);
80+
[id(405), propput] void CustomColourBackground(short WhichColour, long nNewValue);
8181
[id(47)] void Redraw();
8282
[id(48)] long ResetTimer(BSTR TimerName);
8383
[id(49)] void SetOutputFont(BSTR FontName, short PointSize);
@@ -431,6 +431,8 @@ library MUSHclient
431431
[id(397)] long WindowDrawImageAlpha(BSTR Name, BSTR ImageId, long Left, long Top, long Right, long Bottom, double Opacity, long SrcLeft, long SrcTop);
432432
[id(398)] long WindowGetImageAlpha(BSTR Name, BSTR ImageId, long Left, long Top, long Right, long Bottom, long SrcLeft, long SrcTop);
433433
[id(399)] long WindowScrollwheelHandler(BSTR Name, BSTR HotspotId, BSTR MoveCallback);
434+
[id(400)] long WindowResize(BSTR Name, long Width, long Height, long BackgroundColour);
435+
[id(401)] long WindowMoveHotspot(BSTR Name, BSTR HotspotId, long Left, long Top, long Right, long Bottom);
434436
//}}AFX_ODL_METHOD
435437

436438
};

scripting/functionlist.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,10 @@ tInternalFunctionsTable InternalFunctionsTable [] = {
407407
{ "WindowLoadImage" , "( WindowName , ImageId , FileName )" } ,
408408
{ "WindowMenu" , "( WindowName , Left , Top , Items )" } ,
409409
{ "WindowMergeImageAlpha" , "( WindowName , ImageId , MaskId , Left , Top , Right , Bottom , Mode , Opacity , SrcLeft , SrcTop , SrcRight , SrcBottom )" } ,
410+
{ "WindowMoveHotspot" , "( WindowName , HotspotId , Left , Top , Right , Bottom )" },
410411
{ "WindowPolygon" , "( WindowName , Points , PenColour , PenStyle , PenWidth , BrushColour , BrushStyle , Close , Winding )" } ,
411412
{ "WindowPosition" , "( WindowName , Left , Top , Position , Flags )" } ,
413+
{ "WindowResize", "( WindowName , Width , Height , BackgroundColour )" },
412414
{ "WindowRectOp" , "( WindowName , Action , Left , Top , Right , Bottom , Colour1 , Colour2 )" } ,
413415
{ "WindowScrollwheelHandler" , "( WindowName , HotspotId , MoveCallback )" } ,
414416
{ "WindowSetPixel" , "( WindowName , x , y , Colour )" } ,

scripting/lua_methods.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6147,6 +6147,23 @@ static int L_WindowMergeImageAlpha (lua_State *L)
61476147
} // end of L_WindowMergeImageAlpha
61486148

61496149

6150+
//----------------------------------------
6151+
// world.WindowMoveHotspot
6152+
//----------------------------------------
6153+
static int L_WindowMoveHotspot (lua_State *L)
6154+
{
6155+
CMUSHclientDoc *pDoc = doc (L);
6156+
lua_pushnumber (L, pDoc->WindowMoveHotspot (
6157+
my_checkstring (L, 1), // Name
6158+
my_checkstring (L, 2), // HotspotId
6159+
my_checknumber (L, 3), // Left
6160+
my_checknumber (L, 4), // Top
6161+
my_checknumber (L, 5), // Right
6162+
my_checknumber (L, 6) // Bottom
6163+
));
6164+
return 1; // number of result fields
6165+
} // end of L_WindowMoveHotspot
6166+
61506167
//----------------------------------------
61516168
// world.WindowPolygon
61526169
//----------------------------------------
@@ -6203,6 +6220,23 @@ static int L_WindowRectOp (lua_State *L)
62036220
return 1; // number of result fields
62046221
} // end of L_WindowRectOp
62056222

6223+
6224+
//----------------------------------------
6225+
// world.WindowResize
6226+
//----------------------------------------
6227+
static int L_WindowResize (lua_State *L)
6228+
{
6229+
CMUSHclientDoc *pDoc = doc (L);
6230+
lua_pushnumber (L, pDoc->WindowResize (
6231+
my_checkstring (L, 1), // Name
6232+
my_checknumber (L, 2), // Width
6233+
my_checknumber (L, 3), // Height
6234+
my_checknumber (L, 4) // Background Colour
6235+
));
6236+
6237+
return 1; // number of result fields
6238+
} // end of L_WindowResize
6239+
62066240
//----------------------------------------
62076241
// world.WindowScrollwheelHandler
62086242
//----------------------------------------
@@ -6748,9 +6782,11 @@ static const struct luaL_reg worldlib [] =
67486782
{"WindowLoadImageMemory", L_WindowLoadImageMemory},
67496783
{"WindowMenu", L_WindowMenu},
67506784
{"WindowMergeImageAlpha", L_WindowMergeImageAlpha},
6785+
{"WindowMoveHotspot", L_WindowMoveHotspot},
67516786
{"WindowPolygon", L_WindowPolygon},
67526787
{"WindowPosition", L_WindowPosition},
67536788
{"WindowRectOp", L_WindowRectOp},
6789+
{"WindowResize", L_WindowResize},
67546790
{"WindowScrollwheelHandler", L_WindowScrollwheelHandler},
67556791
{"WindowSetPixel", L_WindowSetPixel},
67566792
{"WindowShow", L_WindowShow},

scripting/methods.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14864,6 +14864,32 @@ long CMUSHclientDoc::WindowGetImageAlpha(LPCTSTR Name, LPCTSTR ImageId, long Lef
1486414864
} // end of CMUSHclientDoc::WindowGetImageAlpha
1486514865

1486614866

14867+
14868+
long CMUSHclientDoc::WindowResize(LPCTSTR Name, long Width, long Height, long BackgroundColour)
14869+
{
14870+
14871+
if (Width < 0 || Height < 0)
14872+
return eBadParameter;
14873+
14874+
MiniWindowMapIterator it = m_MiniWindows.find (Name);
14875+
14876+
if (it == m_MiniWindows.end ())
14877+
return eNoSuchWindow;
14878+
14879+
return it->second->Resize (Width, Height, BackgroundColour);
14880+
} // end of CMUSHclientDoc::WindowResize
14881+
14882+
14883+
long CMUSHclientDoc::WindowMoveHotspot(LPCTSTR Name, LPCTSTR HotspotId, long Left, long Top, long Right, long Bottom)
14884+
{
14885+
MiniWindowMapIterator it = m_MiniWindows.find (Name);
14886+
14887+
if (it == m_MiniWindows.end ())
14888+
return eNoSuchWindow;
14889+
14890+
return it->second->MoveHotspot (HotspotId, Left, Top, Right, Bottom);
14891+
} // end of CMUSHclientDoc::WindowMoveHotspot
14892+
1486714893
/*
1486814894
1486914895
======================================================================

0 commit comments

Comments
 (0)