#include <aligndlg.h>
Inheritance diagram for ArrangeAlignment:
Public Member Functions | |
ArrangeAlignment () | |
ArrangeAlignment constructor. | |
void | Do (OpDescriptor *) |
Creates and shows a ArrangeAlignment dialog. | |
virtual MsgResult | Message (Msg *Message) |
Handles all the ArrangeAlignment dialog's messages. | |
Static Public Member Functions | |
static BOOL | Init () |
Creates an OpDescriptor for a ArrangeAlignment dialog. | |
static OpState | GetState (String_256 *, OpDescriptor *) |
Returns the OpState of the ArrangeAlignment dialogue operation ie. whether or not it is greyed on the menu etc!!! | |
static void | CalcDiagramRectsOneAxis (LineData x[8][DiagRects], const INT32 width[DiagRects], const INT32 order[DiagRects], const INT32 gap[DiagRects-1], const INT32 DiagWidth) |
calculate the x positions of the diagram rectangles Written as for x but applys equally to y with different params! | |
Static Public Attributes | |
static LineData | DiagRectX [8][DiagRects] |
static LineData | DiagRectY [8][DiagRects] |
static const UINT32 | IDD = _R(IDD_ALIGNDIALOG) |
static const CDlgMode | Mode = MODELESS |
Private Member Functions | |
void | UpdateState () |
Updates the HState, VState, and Alignments vars in the class Also updates the grey state of all the dialog gadgets. | |
void | DialogOKed () |
invokes the Op | |
void | RedrawDiagram (ReDrawInfoType *ExtraInfo) |
Redraws the diagram on the align dialog Note: Code to render objects with grad-fills commented out As it is allegedly too slow (but this decision will probably be reversed). | |
void | DiagramClicked (ReDrawInfoType *ExtraInfo) |
Handles clicks on the diagram on the align dialog There are 3 zones in each of the X, Y axes. An unmodified click will adjust both axes. Holding down ctrl will constrain the X axis to none while holding down shift will constrain the Y axis to none. (Ctrl+shift = reset both axes). | |
void | BuildIDSDropList (const CGadgetID DropListID, const INT32 *IDSList, INT32 Default) |
Builds a drop down list for a combo box from a null terminated list of string IDs, selecting a default value. | |
void | SetRadioGroup (const CGadgetID *IDCList, const CGadgetID IDC) |
Sets the specified radio button in a group specified in a null terminated list (irespective of whether or not it is greyed) resetting all others in the group. If IDC is not in list, none are set. | |
CGadgetID | ReadRadioGroup (const CGadgetID *IDCList, const CGadgetID IDCDefault=NULL) |
Returns ID of the first set radio button in a group specified in a null terminated list (irespective of greyed state) If none are selected it returns the default ID (default NULL). | |
Static Private Attributes | |
static AlignParam | Align = {AlignNone,AlignNone,ToSelection} |
Definition at line 163 of file aligndlg.h.
|
ArrangeAlignment constructor.
Definition at line 193 of file aligndlg.cpp. 00193 : 00194 DialogOp(ArrangeAlignment::IDD, ArrangeAlignment::Mode) 00195 { 00196 }
|
|
Builds a drop down list for a combo box from a null terminated list of string IDs, selecting a default value.
Definition at line 660 of file aligndlg.cpp. 00662 { 00663 // Make sure the list is empty 00664 DeleteAllValues(DropListID); 00665 00666 // build the list 00667 String_32 Str; 00668 INT32 i=0; 00669 while (IDSList[i]) 00670 { 00671 Str.MakeMsg(IDSList[i]); 00672 SetStringGadgetValue( DropListID, Str ); 00673 i++; 00674 } 00675 SetComboListLength(DropListID); 00676 00677 // select one of the entries in the list 00678 if (Default<0 || Default>=i) 00679 { 00680 ERROR3("BuildIDSDropList() passed a default outside the list"); 00681 Default=0; 00682 } 00683 SetSelectedValueIndex(DropListID,Default); 00684 }
|
|
calculate the x positions of the diagram rectangles Written as for x but applys equally to y with different params!
Definition at line 249 of file aligndlg.cpp. 00256 { 00257 INT32 i; 00258 INT32 sum=0; 00259 for (i=0; i<DiagRects; i++) 00260 sum+=width[i]; 00261 float first=(float)width[order[0]]; 00262 float last =(float)width[order[DiagRects-1]]; 00263 float PosnLeft=(float)0; 00264 float PosnCntr=first/2; 00265 float PosnRght=first; 00266 float PosnEqui=(float)0; 00267 float GapLeft =((float)DiagWidth-last)/3; 00268 float GapCntr =((float)DiagWidth-first/2-last/2)/3; 00269 float GapRght =((float)DiagWidth-first)/3; 00270 float GapEqui =(float)(DiagWidth-sum)/3; 00271 for (i=0; i<DiagRects; i++) 00272 { 00273 INT32 j=order[i]; 00274 x[AlignNone ][j].lo = i ? x[AlignNone][order[i-1]].hi+gap[i-1] : 0; 00275 x[AlignLow ][j].lo = 0; 00276 x[AlignCentre ][j].lo =(DiagWidth-width[j])/2; 00277 x[AlignHigh ][j].lo = DiagWidth-width[j]; 00278 x[DistributeLow ][j].lo = (INT32)PosnLeft; 00279 x[DistributeCentre][j].lo = (INT32)(PosnCntr-width[j]/2); 00280 x[DistributeHigh ][j].lo = (INT32)(PosnRght-width[j]); 00281 x[DistributeEqui ][j].lo = (INT32)PosnEqui; 00282 00283 PosnLeft+=GapLeft; 00284 PosnCntr+=GapCntr; 00285 PosnRght+=GapRght; 00286 PosnEqui+=GapEqui+width[j]; 00287 00288 INT32 w=width[j]; 00289 x[AlignNone ][j].hi = x[AlignNone ][j].lo + w; 00290 x[AlignLow ][j].hi = x[AlignLow ][j].lo + w; 00291 x[AlignCentre ][j].hi = x[AlignCentre ][j].lo + w; 00292 x[AlignHigh ][j].hi = x[AlignHigh ][j].lo + w; 00293 x[DistributeLow ][j].hi = x[DistributeLow ][j].lo + w; 00294 x[DistributeCentre][j].hi = x[DistributeCentre][j].lo + w; 00295 x[DistributeHigh ][j].hi = x[DistributeHigh ][j].lo + w; 00296 x[DistributeEqui ][j].hi = x[DistributeEqui ][j].lo + w; 00297 } 00298 }
|
|
Handles clicks on the diagram on the align dialog There are 3 zones in each of the X, Y axes. An unmodified click will adjust both axes. Holding down ctrl will constrain the X axis to none while holding down shift will constrain the Y axis to none. (Ctrl+shift = reset both axes).
Definition at line 406 of file aligndlg.cpp. 00407 { 00408 // We'll default to resetting any axis not changed below 00409 Align.h = Align.v = AlignNone; 00410 00411 // We only do Y direction if constrain (ctrl) is depressed 00412 if (!KeyPress::IsConstrainPressed()) 00413 { 00414 if (Info->pMousePos->x < Info->dx/3) // Bottom row 00415 Align.h = AlignLow; 00416 else if (Info->pMousePos->x < (2 * Info->dx)/3) // Middle row 00417 Align.h = AlignCentre; 00418 else // Top row 00419 Align.h = AlignHigh; 00420 } 00421 00422 // We only do X direction if adjust (shift) is depressed 00423 if (!KeyPress::IsAdjustPressed()) 00424 { 00425 if (Info->pMousePos->y < Info->dy/3) // Left column 00426 Align.v = AlignLow; 00427 else if (Info->pMousePos->y < (2 * Info->dy)/3) // Middle column 00428 Align.v = AlignCentre; 00429 else // Right column 00430 Align.v = AlignHigh; 00431 } 00432 00433 // Update the drop-down lists 00434 SetSelectedValueIndex(_R(IDC_ALIGNDIALOG_HORIZONTAL), Align.h); 00435 SetSelectedValueIndex(_R(IDC_ALIGNDIALOG_VERTICAL), Align.v); 00436 UpdateState(); 00437 }
|
|
invokes the Op
Definition at line 636 of file aligndlg.cpp. 00637 { 00638 if (Align.h!=AlignNone || Align.v!=AlignNone) 00639 { 00640 OpDescriptor* pOpDesc=OpDescriptor::FindOpDescriptor(OPTOKEN_OPALIGN); 00641 ERROR3IF_PF(pOpDesc==NULL,("Couldn't find OPTOKEN_OPALIGN op descriptor")); 00642 pOpDesc->Invoke((OpParam*)&Align); 00643 } 00644 }
|
|
Creates and shows a ArrangeAlignment dialog.
Reimplemented from Operation. Definition at line 327 of file aligndlg.cpp.
|
|
Returns the OpState of the ArrangeAlignment dialogue operation ie. whether or not it is greyed on the menu etc!!!
Definition at line 309 of file aligndlg.cpp. 00310 { 00311 static OpState DialogState; 00312 DialogState.Greyed=FALSE; 00313 // DialogState.Greyed=GetApplication()->FindSelection()->Count()==0; 00314 // if (DialogState.Greyed) 00315 // pHelpString->MakeMsg(_R(IDS_ARRANGEALIGNMENT_GREY)); 00316 return DialogState; 00317 }
|
|
Creates an OpDescriptor for a ArrangeAlignment dialog.
Reimplemented from SimpleCCObject. Definition at line 207 of file aligndlg.cpp. 00208 { 00209 // init array holding coords of diagram rects on dialog in all alignments 00210 ArrangeAlignment::CalcDiagramRectsOneAxis(ArrangeAlignment::DiagRectX,DiagRectWidth, 00211 DiagRectOrderX,DiagRectGapX,DiagWidth-1); 00212 ArrangeAlignment::CalcDiagramRectsOneAxis(ArrangeAlignment::DiagRectY,DiagRectHeight, 00213 DiagRectOrderY,DiagRectGapY,DiagHeight-1); 00214 00215 return RegisterOpDescriptor( 00216 0, // Tool ID 00217 _R(IDS_ARRANGE_ALIGNMENT), // String resource ID 00218 CC_RUNTIME_CLASS(ArrangeAlignment), // Runtime class 00219 OPTOKEN_ALIGNDLG, // Token string 00220 ArrangeAlignment::GetState, // GetState function 00221 0, // Help ID 00222 _R(IDBBL_ALIGNEMENT), // Bubble ID 00223 _R(IDD_BARCONTROLSTORE), // Resource ID 00224 _R(IDC_ALIGNEMENT), // Control ID 00225 SYSTEMBAR_EDIT, // Bar ID 00226 TRUE, // Recieve system messages 00227 FALSE, // Smart duplicate operation 00228 TRUE, // Clean operation 00229 0, // No vertical counterpart 00230 _R(IDS_ARRANGEALIGNMENT_ONE), // String for one copy only 00231 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC) // Auto state flags 00232 ); 00233 }
|
|
Handles all the ArrangeAlignment dialog's messages.
Reimplemented from DialogOp. Definition at line 341 of file aligndlg.cpp. 00342 { 00343 if (IS_OUR_DIALOG_MSG(Message)) 00344 { 00345 DialogMsg* Msg=(DialogMsg*)Message; 00346 00347 switch (Msg->DlgMsg) 00348 { 00349 case DIM_CREATE: // dialog created - restore its previous state 00350 BuildIDSDropList(_R(IDC_ALIGNDIALOG_HORIZONTAL), HAlignIDS, Align.h); 00351 BuildIDSDropList(_R(IDC_ALIGNDIALOG_VERTICAL), VAlignIDS, Align.v); 00352 SetRadioGroup(TargetArea, TargetArea[Align.target]); 00353 UpdateState(); 00354 break; 00355 00356 case DIM_LFT_BN_CLICKED: // mouse clicks may change greyed state of buttons 00357 case DIM_SELECTION_CHANGED: // mouse clicks may change greyed state of buttons 00358 UpdateState(); 00359 break; 00360 00361 case DIM_LFT_BN_DOWN: // Handle clicks in the diagram control 00362 if (Msg->GadgetID == _R(IDC_ALIGNDIALOG_DIAGRAM)) 00363 DiagramClicked((ReDrawInfoType*) Msg->DlgMsgParam); 00364 break; 00365 00366 case DIM_REDRAW: // handle redraw request for diagram gadget 00367 if (Msg->GadgetID == _R(IDC_ALIGNDIALOG_DIAGRAM)) 00368 RedrawDiagram((ReDrawInfoType*)Msg->DlgMsgParam); 00369 break; 00370 00371 case DIM_COMMIT: // handle left hand OK click 00372 DialogOKed(); 00373 break; 00374 00375 case DIM_CANCEL: // handle cancel 00376 // Close(); 00377 // End(); // Do not call Close() and End(). The base class does this. 00378 break; 00379 00380 default: 00381 break; 00382 } 00383 } 00384 else if (MESSAGE_IS_A(Message, SelChangingMsg)) 00385 { 00386 // if selection has changed, update state of dialog 00387 if ( ((SelChangingMsg*)Message)->State == SelChangingMsg::SELECTIONCHANGED ) 00388 UpdateState(); 00389 } 00390 00391 // Pass all unhandled messages to base class for default processing! 00392 return DialogOp::Message(Message); 00393 }
|
|
Returns ID of the first set radio button in a group specified in a null terminated list (irespective of greyed state) If none are selected it returns the default ID (default NULL).
Definition at line 700 of file aligndlg.cpp. 00702 { 00703 BOOL valid; 00704 INT32 i=0; 00705 while (IDCList[i]) 00706 { 00707 if (GetLongGadgetValue(IDCList[i],0,1,0,&valid)) 00708 return (IDCList[i]); 00709 i++; 00710 } 00711 return (IDCDefault); 00712 }
|
|
Redraws the diagram on the align dialog Note: Code to render objects with grad-fills commented out As it is allegedly too slow (but this decision will probably be reversed).
Definition at line 451 of file aligndlg.cpp. 00452 { 00453 // objects drawn in the render region must be relatively large in the given coord space 00454 // else Gavin's curve flattening results in visible straight lines 00455 // so every dimension is scaled by scale 00456 INT32 scale=1000; 00457 00458 // make a render region 00459 DocRect VirtRendRect; 00460 VirtRendRect.lo.x=-1*scale; 00461 VirtRendRect.lo.y=-2*scale; 00462 VirtRendRect.hi.x=(DiagWidth +1)*scale; 00463 VirtRendRect.hi.y=(DiagHeight+2)*scale; 00464 RenderRegion* pRender=CreateGRenderRegion(&VirtRendRect,ExtraInfo); 00465 00466 if (pRender!=NULL) 00467 { 00468 pRender->SaveContext(); 00469 00470 // currently this must be set here before any colour tables calculated 00471 Quality AntiAliasQuality(Quality::QualityMax); 00472 QualityAttribute AntiAliasQualityAttr(AntiAliasQuality); 00473 pRender->SetQuality(&AntiAliasQualityAttr,FALSE); 00474 00475 // Render the background rectangle 00476 DialogColourInfo RedrawColours; 00477 pRender->SetLineColour(RedrawColours.DialogBack()); 00478 pRender->SetFillColour(RedrawColours.DialogBack()); 00479 pRender->DrawRect(&VirtRendRect); 00480 00481 // declared at this scope else RestoreContext() dies! 00482 RadialFillAttribute Fill; 00483 00484 // set up some defaults used by all objects 00485 Fill.MakeElliptical(); 00486 Fill.Colour=DocColour(255,255,255); 00487 pRender->SetLineColour(BLACK); 00488 pRender->SetLineWidth(0); 00489 00490 for (INT32 i=0; i<DiagRects; i++) 00491 { 00492 // reverse order in which objets are rendered (now filled!) 00493 INT32 j=DiagRects-1-i; 00494 00495 // set fill colour of each object 00496 switch (j) 00497 { 00498 case 0: Fill.EndColour=DocColour(255,255,0); break; 00499 case 1: Fill.EndColour=DocColour(0,0,255); break; 00500 case 2: Fill.EndColour=DocColour(255,0,0); break; 00501 case 3: Fill.EndColour=DocColour(0,160,0); break; 00502 default: Fill.EndColour=DocColour(0,0,0); break; 00503 } 00504 00505 // get bound rect of object to be drawn 00506 INT32 x=DiagRectX[Align.h][j].lo*scale; 00507 INT32 w=DiagRectX[Align.h][j].hi*scale-x; 00508 INT32 y=DiagRectY[Align.v][j].lo*scale; 00509 INT32 h=DiagRectY[Align.v][j].hi*scale-y; 00510 00511 // create shape and fill geometries 00512 Path shape; 00513 shape.Initialise(16,8); 00514 shape.IsFilled=TRUE; 00515 shape.FindStartOfPath(); 00516 switch (j) 00517 { 00518 case 0: 00519 { 00520 // create a rectangle 00521 shape.InsertMoveTo(DocCoord(x,y)); 00522 shape.InsertLineTo(DocCoord(x,y+h)); 00523 shape.InsertLineTo(DocCoord(x+w,y+h)); 00524 shape.InsertLineTo(DocCoord(x+w,y)); 00525 shape.InsertLineTo(DocCoord(x,y)); 00526 00527 // // create a radial fill 00528 // Fill.StartPoint=DocCoord(x+w*3/16,y+h*3/4); 00529 // Fill.EndPoint =DocCoord(x+w*3/8,y+h/2); 00530 // Fill.EndPoint2 =DocCoord(x+w*3/8,y+h); 00531 break; 00532 } 00533 00534 case 1: 00535 { 00536 // create a pseudo ellipse 00537 shape.InsertMoveTo( DocCoord(x,y+h/2)); 00538 shape.InsertCurveTo(DocCoord(x,y+h*3/4), DocCoord(x+w/4,y+h), DocCoord(x+w/2,y+h)); 00539 shape.InsertCurveTo(DocCoord(x+w*3/4,y+h),DocCoord(x+w,y+h*3/4),DocCoord(x+w,y+h/2)); 00540 shape.InsertCurveTo(DocCoord(x+w,y+h/4), DocCoord(x+w*3/4,y), DocCoord(x+w/2,y)); 00541 shape.InsertCurveTo(DocCoord(x+w/4,y), DocCoord(x,y+h/4), DocCoord(x,y+h/2)); 00542 00543 // // create a radial fill 00544 // Fill.StartPoint=DocCoord(x+w*3/8,y+h*5/8); 00545 // Fill.EndPoint =DocCoord(x+w*6/8,y+h/4); 00546 // Fill.EndPoint2 =DocCoord(x+w*6/8,y+h); 00547 break; 00548 } 00549 00550 default: 00551 { 00552 // create a rounded rectangle 00553 shape.InsertMoveTo( DocCoord(x,y+h/2)); 00554 shape.InsertCurveTo(DocCoord(x,y+h), DocCoord(x,y+h), DocCoord(x+w/2,y+h)); 00555 shape.InsertCurveTo(DocCoord(x+w,y+h),DocCoord(x+w,y+h),DocCoord(x+w,y+h/2)); 00556 shape.InsertCurveTo(DocCoord(x+w,y), DocCoord(x+w,y), DocCoord(x+w/2,y)); 00557 shape.InsertCurveTo(DocCoord(x,y), DocCoord(x,y), DocCoord(x,y+h/2)); 00558 00559 // // create a radial fill 00560 // Fill.StartPoint=DocCoord(x+w*3/16,y+h*3/4); 00561 // Fill.EndPoint =DocCoord(x+w*3/8,y+h/2); 00562 // Fill.EndPoint2 =DocCoord(x+w*3/8,y+h); 00563 break; 00564 } 00565 00566 } 00567 // pRender->SetFillGeometry(&Fill,FALSE); 00568 pRender->SetFillColour(Fill.EndColour); 00569 pRender->DrawPath(&shape); 00570 } 00571 00572 pRender->RestoreContext(); 00573 DestroyGRenderRegion(pRender); // also blt's to screen 00574 } 00575 }
|
|
Sets the specified radio button in a group specified in a null terminated list (irespective of whether or not it is greyed) resetting all others in the group. If IDC is not in list, none are set.
Definition at line 729 of file aligndlg.cpp. 00730 { 00731 INT32 i=0; 00732 while (IDCList[i]) 00733 { 00734 SetLongGadgetValue(IDCList[i],IDCList[i]==IDC); 00735 i++; 00736 } 00737 }
|
|
Updates the HState, VState, and Alignments vars in the class Also updates the grey state of all the dialog gadgets.
Definition at line 586 of file aligndlg.cpp. 00587 { 00588 // update target 00589 CGadgetID Target = ReadRadioGroup(TargetArea,TargetArea[0]); 00590 if (Target == _R(IDC_ALIGNDIALOG_TOSELECTION)) 00591 { 00592 Align.target=ToSelection; 00593 } 00594 else if (Target == _R(IDC_ALIGNDIALOG_TOPAGE)) 00595 { 00596 Align.target=ToPage; 00597 } 00598 // WEBSTER-ranbirr-13/11/96 00599 #ifndef WEBSTER 00600 else if (Target == _R(IDC_ALIGNDIALOG_TOSPREAD)) 00601 { 00602 Align.target=ToSpread; 00603 } 00604 #endif //webster 00605 else 00606 { 00607 ERROR3("ArrangeAlignment::UpdateState() - unknown target"); 00608 } 00609 00610 // read alignments from horizontal and vertical combo boxes 00611 Align.h = (AlignType)GetSelectedValueIndex(_R(IDC_ALIGNDIALOG_HORIZONTAL)); 00612 Align.v = (AlignType)GetSelectedValueIndex(_R(IDC_ALIGNDIALOG_VERTICAL)); 00613 00614 // force the diagram to redraw 00615 InvalidateGadget(_R(IDC_ALIGNDIALOG_DIAGRAM)); 00616 00617 // set state of Apply button 00618 INT32 NumObjs = 0; 00619 if (Document::GetSelected()) 00620 NumObjs = GetApplication()->FindSelection()->Count(); 00621 BOOL ApplyButtonState = (NumObjs>0); 00622 if (NumObjs==1 && Target==_R(IDC_ALIGNDIALOG_TOSELECTION)) ApplyButtonState = FALSE; 00623 if (Align.h==AlignNone && Align.v==AlignNone) ApplyButtonState = FALSE; 00624 EnableGadget(_R(IDOK),ApplyButtonState); 00625 }
|
|
Definition at line 196 of file aligndlg.h. |
|
Definition at line 181 of file aligndlg.h. |
|
Definition at line 182 of file aligndlg.h. |
|
Definition at line 184 of file aligndlg.h. |
|
Definition at line 185 of file aligndlg.h. |