Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

192 lines
4.6 KiB

  1. /************************************************************/
  2. /* Windows Write, Copyright 1985-1992 Microsoft Corporation */
  3. /************************************************************/
  4. #define NOGDICAPMASKS
  5. #define NOVIRTUALKEYCODES
  6. #define NOWINSTYLES
  7. #define NOCLIPBOARD
  8. #define NOSYSMETRICS
  9. #define NOMENUS
  10. #define NOSOUND
  11. #define NOCOMM
  12. #define NOSCROLL
  13. #define NOMB
  14. #include <windows.h>
  15. #include "mw.h"
  16. #include "dlgdefs.h"
  17. #include "cmddefs.h"
  18. #include "dispdefs.h"
  19. #include "wwdefs.h"
  20. #include "str.h"
  21. #include "propdefs.h"
  22. #include "printdef.h" /* printdefs.h */
  23. #include "docdefs.h"
  24. extern int rgval[];
  25. extern struct WWD *pwwdCur;
  26. extern struct DOD (**hpdocdod)[];
  27. extern int docCur; /* Document in current ww */
  28. extern struct SEL selCur; /* Current selection (i.e., sel in current ww */
  29. extern struct SEP vsepNormal;
  30. extern HWND vhWndMsgBoxParent;
  31. extern int vfCursorVisible;
  32. extern HCURSOR vhcArrow;
  33. BOOL far PASCAL DialogGoTo( hDlg, message, wParam, lParam )
  34. HWND hDlg; /* Handle to the dialog box */
  35. unsigned message;
  36. WORD wParam;
  37. LONG lParam;
  38. {
  39. /* This routine handles input to the Go To dialog box. */
  40. /*RECT rc;*/
  41. struct SEP **hsep = (**hpdocdod)[docCur].hsep;
  42. struct SEP *psep;
  43. CHAR szT[cchMaxNum];
  44. CHAR *pch = &szT[0];
  45. extern ferror;
  46. switch (message)
  47. {
  48. case WM_INITDIALOG:
  49. EnableOtherModeless(false);
  50. /* Get a pointer to the section properties. */
  51. psep = (hsep == NULL) ? &vsepNormal : *hsep;
  52. /* Initialize the starting page number. */
  53. if (psep->pgnStart != pgnNil)
  54. {
  55. szT[ncvtu(psep->pgnStart, &pch)] = '\0';
  56. SetDlgItemText(hDlg, idiGtoPage, (LPSTR)szT);
  57. SelectIdiText(hDlg, idiGtoPage);
  58. }
  59. else
  60. {
  61. SetDlgItemText(hDlg, idiGtoPage, (LPSTR)"1");
  62. SelectIdiText(hDlg, idiGtoPage);
  63. }
  64. break;
  65. case WM_SETVISIBLE:
  66. if (wParam)
  67. EndLongOp(vhcArrow);
  68. return(FALSE);
  69. case WM_ACTIVATE:
  70. if (wParam)
  71. vhWndMsgBoxParent = hDlg;
  72. if (vfCursorVisible)
  73. ShowCursor(wParam);
  74. return(FALSE); /* so that we leave the activate message to
  75. the dialog manager to take care of setting the focus correctly */
  76. case WM_COMMAND:
  77. switch (wParam)
  78. {
  79. case idiOk:
  80. if (!WPwFromItW3Id(&rgval[0], hDlg, idiGtoPage, pgnMin, pgnMax, wNormal, IDPMTNPI))
  81. {
  82. ferror = FALSE; /* reset error condition, so as to report any
  83. further error */
  84. break;
  85. }
  86. OurEndDialog(hDlg, TRUE); /* So we take down the dialog box and
  87. only screen update ONCE ..pault */
  88. CmdJumpPage();
  89. if (pwwdCur->fRuler)
  90. UpdateRuler();
  91. break;
  92. case idiCancel:
  93. CancelDlg:
  94. OurEndDialog(hDlg, TRUE);
  95. break;
  96. default:
  97. return(FALSE);
  98. }
  99. break;
  100. case WM_CLOSE:
  101. goto CancelDlg;
  102. default:
  103. return(FALSE);
  104. }
  105. return(TRUE);
  106. }
  107. /* end of DialogGoTo */
  108. /* C M D J U M P P A G E */
  109. CmdJumpPage()
  110. { /* JUMP PAGE:
  111. 0 page number
  112. */
  113. extern typeCP cpMinCur;
  114. int ipgd;
  115. int cpgd;
  116. register struct PGD *ppgd;
  117. struct PGTB **hpgtb = (**hpdocdod)[docCur].hpgtb;
  118. BOOL fWrap = FALSE;
  119. typeCP cpTarget;
  120. ClearInsertLine();
  121. if (hpgtb == NULL)
  122. {
  123. goto SelFirstPage;
  124. }
  125. cpgd = (**hpgtb).cpgd;
  126. TryAgain:
  127. for (ipgd = 0, ppgd = &(**hpgtb).rgpgd[0]; ipgd < cpgd; ipgd++, ppgd++)
  128. {
  129. if (ppgd->pgn == rgval[0] && (fWrap || ipgd + 1 == cpgd ||
  130. (ppgd + 1)->cpMin > selCur.cpFirst))
  131. {
  132. cpTarget = ppgd->cpMin;
  133. goto ShowPage;
  134. }
  135. }
  136. if (!fWrap)
  137. {
  138. fWrap = TRUE;
  139. goto TryAgain;
  140. }
  141. /* If rgval[0] > last page number jump to last page */
  142. if ((ppgd = &(**hpgtb).rgpgd[cpgd - 1])->pgn < rgval[0])
  143. {
  144. cpTarget = ppgd->cpMin;
  145. }
  146. else if (rgval[0] == 1)
  147. {
  148. SelFirstPage:
  149. cpTarget = cpMinCur;
  150. }
  151. else
  152. {
  153. Error(IDPMTNoPage);
  154. return;
  155. }
  156. ShowPage:
  157. /* Position first char of page on the first dl */
  158. DirtyCache(pwwdCur->cpFirst = cpTarget);
  159. pwwdCur->ichCpFirst = 0;
  160. CtrBackDypCtr(0, 0);
  161. /* In this case, CpFirstSty() will update the screen. */
  162. cpTarget = CpFirstSty(cpTarget, styLine);
  163. Select(cpTarget, cpTarget);
  164. }
  165.