[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]
[XaraXtreme-dev] Commit Complete
Commit by : alex
Repository : xara
Revision : 705
Date : Wed Mar 22 13:12:27 GMT 2006
Changed paths:
M /Trunk/XaraLX/Kernel/Makefile.am
M /Trunk/XaraLX/Kernel/aligndlg.cpp
M /Trunk/XaraLX/Kernel/main3.cpp
M /Trunk/XaraLX/wxOil/dlgmgr.cpp
M /Trunk/XaraLX/wxOil/dlgtypes.h
Enabled align dialog (not yet drawing right)
First stage in Kernel Rendered Dialog support
Diff:
Index: Trunk/XaraLX/Kernel/aligndlg.cpp
===================================================================
--- Trunk/XaraLX/Kernel/aligndlg.cpp (revision 704)
+++ Trunk/XaraLX/Kernel/aligndlg.cpp (revision 705)
@@ -127,6 +127,7 @@
//#include "barsdlgs.h"
#include "keypress.h"
#include "bubbleid.h"
+#include "ophist.h"
CC_IMPLEMENT_DYNCREATE(ArrangeAlignment, DialogOp)
CC_IMPLEMENT_DYNCREATE(OpAlign, TransOperation)
@@ -142,7 +143,7 @@
#ifndef WEBSTER
_R(IDC_ALIGNDIALOG_TOSPREAD),
#endif //webster
- NULL};
+ 0};
// string ID lists for combo boxes (null terminated)
// >>>> NB. must be in same order as AlignType enum <<<<
@@ -154,7 +155,7 @@
_R(IDS_HDISTRIBUTECENTRE),
_R(IDS_HDISTRIBUTERIGHT),
_R(IDS_HDISTRIBUTEEQUI),
- NULL};
+ 0};
const INT32 VAlignIDS[]={_R(IDS_VALIGNNONE),
_R(IDS_VALIGNBOTTOM),
_R(IDS_VALIGNCENTRE),
@@ -163,7 +164,7 @@
_R(IDS_VDISTRIBUTECENTRE),
_R(IDS_VDISTRIBUTETOP),
_R(IDS_VDISTRIBUTEEQUI),
- NULL};
+ 0};
// constants defining the size and position of the rectangles on the align dialog
const INT32 DiagWidth =100;
@@ -213,7 +214,7 @@
return RegisterOpDescriptor(
0, // Tool ID
- _R(IDS_ARRANGEALIGNMENT), // String resource ID
+ _R(IDS_ARRANGE_ALIGNMENT), // String resource ID
CC_RUNTIME_CLASS(ArrangeAlignment), // Runtime class
OPTOKEN_ALIGNDLG, // Token string
ArrangeAlignment::GetState, // GetState function
@@ -375,6 +376,9 @@
Close();
End();
break;
+
+ default:
+ break;
}
}
else if (MESSAGE_IS_A(Message, SelChangingMsg))
@@ -453,10 +457,10 @@
// make a render region
DocRect VirtRendRect;
- VirtRendRect.lox=-1*scale;
- VirtRendRect.loy=-2*scale;
- VirtRendRect.hix=(DiagWidth +1)*scale;
- VirtRendRect.hiy=(DiagHeight+2)*scale;
+ VirtRendRect.lo.x=-1*scale;
+ VirtRendRect.lo.y=-2*scale;
+ VirtRendRect.hi.x=(DiagWidth +1)*scale;
+ VirtRendRect.hi.y=(DiagHeight+2)*scale;
RenderRegion* pRender=CreateGRenderRegion(&VirtRendRect,ExtraInfo);
if (pRender!=NULL)
@@ -583,15 +587,24 @@
{
// update target
CGadgetID Target = ReadRadioGroup(TargetArea,TargetArea[0]);
- switch (Target)
+ if (Target == _R(IDC_ALIGNDIALOG_TOSELECTION))
{
- case _R(IDC_ALIGNDIALOG_TOSELECTION): Align.target=ToSelection; break;
- case _R(IDC_ALIGNDIALOG_TOPAGE): Align.target=ToPage; break;
+ Align.target=ToSelection;
+ }
+ else if (Target == _R(IDC_ALIGNDIALOG_TOPAGE))
+ {
+ Align.target=ToPage;
+ }
// WEBSTER-ranbirr-13/11/96
#ifndef WEBSTER
- case _R(IDC_ALIGNDIALOG_TOSPREAD): Align.target=ToSpread; break;
+ else if (Target == _R(IDC_ALIGNDIALOG_TOSPREAD))
+ {
+ Align.target=ToSpread;
+ }
#endif //webster
- default: ERROR3("ArrangeAlignment::UpdateState() - unknown target");
+ else
+ {
+ ERROR3("ArrangeAlignment::UpdateState() - unknown target");
}
// read alignments from horizontal and vertical combo boxes
@@ -608,7 +621,7 @@
BOOL ApplyButtonState = (NumObjs>0);
if (NumObjs==1 && Target==_R(IDC_ALIGNDIALOG_TOSELECTION)) ApplyButtonState = FALSE;
if (Align.h==AlignNone && Align.v==AlignNone) ApplyButtonState = FALSE;
- EnableGadget(IDOK,ApplyButtonState);
+ EnableGadget(_R(IDOK),ApplyButtonState);
}
@@ -866,18 +879,18 @@
{
DocRect ObjRect=((NodeRenderableBounded*)pObj[i])->GetBoundingRect();
x[i].i=i;
- x[i].lo=ObjRect.lox;
- x[i].hi=ObjRect.hix;
- SumObjWidths+=ObjRect.hix-ObjRect.lox;
+ x[i].lo=ObjRect.lo.x;
+ x[i].hi=ObjRect.hi.x;
+ SumObjWidths+=ObjRect.hi.x-ObjRect.lo.x;
y[i].i=i;
- y[i].lo=ObjRect.loy;
- y[i].hi=ObjRect.hiy;
- SumObjHeights+=ObjRect.hiy-ObjRect.loy;
+ y[i].lo=ObjRect.lo.y;
+ y[i].hi=ObjRect.hi.y;
+ SumObjHeights+=ObjRect.hi.y-ObjRect.lo.y;
}
// for each object, calculate the x and y displacements independently
- AlignOneAxis(pAlign->h,NumObjs,SumObjWidths, TargetRect.lox,TargetRect.hix,x,dx);
- AlignOneAxis(pAlign->v,NumObjs,SumObjHeights,TargetRect.loy,TargetRect.hiy,y,dy);
+ AlignOneAxis(pAlign->h,NumObjs,SumObjWidths, TargetRect.lo.x,TargetRect.hi.x,x,dx);
+ AlignOneAxis(pAlign->v,NumObjs,SumObjHeights,TargetRect.lo.y,TargetRect.hi.y,y,dy);
// apply the x and y displacements simultaneously to each object
for (i=0; i<NumObjs; i++)
Index: Trunk/XaraLX/Kernel/Makefile.am
===================================================================
--- Trunk/XaraLX/Kernel/Makefile.am (revision 704)
+++ Trunk/XaraLX/Kernel/Makefile.am (revision 705)
@@ -57,5 +57,5 @@
zordops.cpp fillndge.cpp pathndge.cpp opbreak.cpp cmdctrl.cpp opsmooth.cpp \
combshps.cpp mkshapes.cpp mkstroke.cpp mrhbits.cpp ndmldink.cpp opfeathr.cpp \
linwthop.cpp sgmenu.cpp draginfo.cpp filelist.cpp statline.cpp pressure.cpp \
- penedit.cpp
+ penedit.cpp aligndlg.cpp
AM_CXXFLAGS = $(XARAFLAGS)
Index: Trunk/XaraLX/Kernel/main3.cpp
===================================================================
--- Trunk/XaraLX/Kernel/main3.cpp (revision 704)
+++ Trunk/XaraLX/Kernel/main3.cpp (revision 705)
@@ -180,9 +180,10 @@
EditSelectionOp::Init() && // Init the "Edit Selection" op
KeyPress::Init() && // Init the key press system
FileInfo::Init() && // Init the document info dialogue
-
+#endif
ArrangeAlignment::Init() && // Init the arrange alignment dialogue
OpAlign::Init() && // Init the align op
+#ifndef EXCLUDE_FROM_XARALX
BmpPrefsDlg::Init() && // Init the export bitmap options dialog
TraceDlg::Init() && // Init the trace dialog
WebAddressDlg::Init() &&
Index: Trunk/XaraLX/wxOil/dlgtypes.h
===================================================================
--- Trunk/XaraLX/wxOil/dlgtypes.h (revision 704)
+++ Trunk/XaraLX/wxOil/dlgtypes.h (revision 705)
@@ -105,6 +105,7 @@
#define INC_DLGTYPES
class CCDC;
+class CCPaintDC;
class DocRect;
class DocCoord;
@@ -259,7 +260,7 @@
// This data is only available during processing of cc_DialogDraw redraws
DocRect* pClipRect; // The rectangle that has actually been invalidated
- CCDC* pDC; // The DC to plot into
+ CCPaintDC* pDC; // The DC to plot into
// This data is only available when processing cc_DialogDraw mouse events
DocCoord *pMousePos; // The position of the mouse at this event
Index: Trunk/XaraLX/wxOil/dlgmgr.cpp
===================================================================
--- Trunk/XaraLX/wxOil/dlgmgr.cpp (revision 704)
+++ Trunk/XaraLX/wxOil/dlgmgr.cpp (revision 705)
@@ -143,6 +143,7 @@
#include "cartprov.h"
#include "cartctl.h"
#include "osrndrgn.h"
+#include "dlgtypes.h"
DECLARE_SOURCE("$Revision: 662 $");
@@ -731,6 +732,9 @@
return;
}
+ wxWindow * pGadget = NULL;
+ if (id) pGadget = GetGadget(pEvtHandler->pwxWindow, id);
+
// Make up a default message
DialogMsg msg(pEvtHandler->pwxWindow, DIM_NONE, id, DlgMsgParam, PageID);
@@ -910,8 +914,78 @@
msg.DlgMsg = ((wxMouseEvent *)&event)->Dragging()?DIM_MOUSE_DRAG:DIM_MOUSE_MOVE;
HandleMessage = TRUE;
}
+ else if (
+ ((EventType == wxEVT_PAINT) && (pGadget)) ||
+ FALSE)
+ {
+ if (CCamApp::IsDisabled())
+ {
+ TRACE( _T("kernel-rendered gadget repaint has been aborted: the system is disabled (due to an error/ensure?)
"));
+ HandleMessage = FALSE;
+ }
+ else
+ {
+ // HDC hDC = pInfo->PaintInfo.hdc;
+ // HPALETTE OldPalette = PaletteManager::StartPaintPalette(hDC);
+
+ ReDrawInfoType ExtraInfo;
+
+ ExtraInfo.pMousePos = NULL; // No mouse position info for redraw events
+ // Build a CC dc out of it for rendering to the screen
+ // Get a MFC CDC to put the DC in
+ CCPaintDC MyDc(pGadget);
+
+ ExtraInfo.pDC = &MyDc;
+
+ // The devices DPI
+ ExtraInfo.Dpi = OSRenderRegion::GetFixedDCPPI(MyDc).GetHeight();
+
+ // How big the window is
+ wxSize WindowSize = pGadget->GetClientSize();
+ ExtraInfo.dx = (((INT32)WindowSize.GetWidth())*72000) / ExtraInfo.Dpi;
+ ExtraInfo.dy = (((INT32)WindowSize.GetHeight())*72000) / ExtraInfo.Dpi;
+
+ MyDc.BeginDrawing();
+
+ wxRegionIterator upd(pGadget->GetUpdateRegion()); // get the update rect list
+
+ while (upd)
+ {
+ // Alternatively we can do this:
+ wxRect ClipRect(upd.GetRect());
+ // Should we clip this to the WindowSize here?
+ // MyDC.SetClipRect(ClipRect);
+
+ DocRect DocClipRect;
+
+ // Convert to millipoints, Also need to flip the y coords to get a
+ // rectangle in with the origin in the bottom left.
+ DocClipRect.lo.x = (ClipRect.GetLeft() * 72000) / ExtraInfo.Dpi;
+ DocClipRect.lo.y = ExtraInfo.dy - ((ClipRect.GetBottom() * 72000) / ExtraInfo.Dpi);
+
+ DocClipRect.hi.x = (ClipRect.GetRight() * 72000) / ExtraInfo.Dpi;
+ DocClipRect.hi.y = ExtraInfo.dy - ((ClipRect.GetTop() * 72000) / ExtraInfo.Dpi);
+
+ // Set the pointer in the extra info structure
+ ExtraInfo.pClipRect = &DocClipRect;
+
+ // Build the message and send it to the dialog op
+ // It is up to the dialog op to build a render region etc and attach the CCDC to it
+ // and to tidy the region up after it has finished drawing in it CDlgMessage
+ BROADCAST_TO_CLASS(DialogMsg(pEvtHandler->pwxWindow, DIM_REDRAW, id, (UINT_PTR)(void *)&ExtraInfo, PageID), DialogOp);
+
+ upd ++ ;
+ }
+
+ MyDc.EndDrawing();
+
+ // if (OldPalette)
+ // PaletteManager::StopPaintPalette(hDC, OldPalette);
+ }
+ }
+
//case wxEVT_COMMAND_TOOL_RCLICKED:
//case wxEVT_COMMAND_TOOL_ENTER:
@@ -4566,8 +4640,6 @@
ReDrawInfoType *ExtraInfo,
DocRect *InvalidRect)
{
- PORTNOTETRACE("dialog","DialogManager::InvalidateGadget - do nothing");
-#ifndef EXCLUDE_FROM_XARALX
if (InvalidRect == NULL) // No rect - invalidate the entire window
{
InvalidateGadget(WindowID, Gadget);
@@ -4581,32 +4653,30 @@
}
ERROR3IF(ExtraInfo->Dpi == 0, "Screen DPI is zero? I think not! Divide-by-zeros imminent!");
+ if (!ExtraInfo->Dpi) return;
INT32 PixelSize = 72000 / ExtraInfo->Dpi; // Size of a pixel in MILLIPOINTS
- RECT ToRedraw;
- ToRedraw.left = InvalidRect->lo.x / PixelSize;
- ToRedraw.right = InvalidRect->hi.x / PixelSize;
- ToRedraw.top = (ExtraInfo->dy - InvalidRect->hi.y) / PixelSize;
- ToRedraw.bottom = (ExtraInfo->dy - InvalidRect->lo.y) / PixelSize;
-
- if (ToRedraw.top > ToRedraw.bottom)
+ DocRect irect=*InvalidRect;
+ if (irect.lo.y > irect.hi.y)
{
// not an ERROR3 because this is in rendering code
TRACEALL( _T("Rectangle upside down in InvalidateGadget
") );
- // swap over the rect Y co-ords usin the amazing XOR trick
- ToRedraw.top ^= ToRedraw.bottom;
- ToRedraw.bottom ^= ToRedraw.top;
- ToRedraw.top ^= ToRedraw.bottom;
+ // swap over the rect Y co-ords
+ INT32 temp=irect.lo.y;
+ irect.lo.y=irect.hi.y;
+ irect.lo.y=temp;
}
+ wxRect ToRedraw(irect.lo.x / PixelSize, (ExtraInfo->dy-irect.lo.y) / PixelSize,
+ ExtraInfo->dx / PixelSize, ExtraInfo->dy/PixelSize);
+
+ wxWindow * pGadget = GetGadget(WindowID, Gadget);
// Invalidate the gadget, but only if we found a legal window to invalidate
- HWND realwid = ::GetDlgItem((HWND)WindowID, (INT32)Gadget);
- ERROR3IF((!realwid), "DialogManager::InvalidateGadget - Gadget not valid");
+ ERROR3IF((!pGadget), "DialogManager::InvalidateGadget - Gadget not valid");
- if (realwid)
- ::InvalidateRect(realwid, &ToRedraw, FALSE);
-#endif
+ if (pGadget)
+ pGadget->Refresh(TRUE, &ToRedraw);
}
Xara