home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2002 January / VPR0201B.ISO / APUPDATE / VC / TXC0601S / TXC0601S.LZH / _IDMDISP.C < prev    next >
C/C++ Source or Header  |  2001-05-31  |  10KB  |  448 lines

  1. /*
  2.     表示関係のIDMコマンド処理群
  3.         Start 99年11月19日
  4. */
  5.  
  6. #if __TXC__
  7.     #include <_wz.h>
  8.     #include <windows.h>
  9.     #include <windowsx.h>
  10.     #include <_idm.h>
  11. #else
  12.     #include "_sys.h"
  13. #endif
  14. #include "_idmlib.h"
  15.  
  16. //##各種表示の切替
  17.  
  18. BOOL txIDM_SWITCHDISPUNDER(TX* text)
  19. {
  20.     text->fDispUnder ^= TRUE;
  21.     txConfigSet(text);//WZ3.90J 981109 
  22.     txDispAll(text);txFlushMenuCheckAll(text);
  23.     return TRUE;
  24. }
  25.  
  26. BOOL txIDM_SWITCHDISPLINE(TX* text)
  27. {
  28.     text->fDispLine ^= TRUE;
  29.     txConfigSet(text);//WZ3.90J 981109 
  30.     txFlushCxBase(text);txDispAll(text);txFlushMenuCheckAll(text);txRulerFlushDisp(text);
  31.     return TRUE;
  32. }
  33.  
  34. #if !POCKETWZ
  35. BOOL txIDM_SWITCHDISPTOOLBAR(TX* text)
  36. {
  37.     text->fDispToolbar ^= TRUE;txConfigSet(text);txFlushMenuCheckAll(text);txFlush(text);
  38.     return TRUE;
  39. }
  40. BOOL txIDM_SWITCHDISPRULER(TX* text)
  41. {
  42.     text->fDispRuler ^= TRUE;txConfigSet(text);txFlushMenuCheckAll(text);txFlush(text);
  43.     return TRUE;
  44. }
  45. BOOL txIDM_SWITCHDISPTAB(TX* text)
  46. {
  47.     text->fDispTab ^= TRUE;txConfigSet(text);txFlushMenuCheckAll(text);txFlush(text);
  48.     return TRUE;
  49. }
  50. BOOL txIDM_SWITCHDISPJSPACE(TX* text)
  51. {
  52.     text->fDispJspace ^= TRUE;txConfigSet(text);txFlushMenuCheckAll(text);txFlush(text);
  53.     return TRUE;
  54. }
  55. BOOL txIDM_SWITCHWINDOWFULLY(TX* text)
  56. {
  57.     HWND hwnd = text->hwndbase;
  58.     text->fDispFull ^= TRUE;txFlushMenuCheckAll(text);
  59.     txFlush(text);
  60.     if (text->fDispFull) {
  61.         {
  62.             RECT r;
  63.             RECT rc;
  64.             RECT rWork;
  65. //wndtxGetOriginalRect(hwnd,&r);information("%d %d %d %d",r.top,r.left,r.right,r.bottom);
  66.             GetWindowRect(hwnd,&r);wndtxSetOriginalRect(hwnd,&r);
  67.             GetClientRect(hwnd,&rc);
  68.             ClientToScreen(hwnd,(POINT*)&rc);
  69.             GetWorkRect(&rWork);
  70.             r.top = rWork.top - (rc.top - r.top) + 2;    // +2: for menubar access by mouse
  71.             r.bottom = rWork.bottom;
  72. //information("%d %d %d %d",r.left,r.top,rectCx(&r),rectCy(&r));
  73.             wndtxSetPosSizeWork(hwnd,r.left,r.top,rectCx(&r),rectCy(&r));
  74.         }
  75.     } else {
  76.         RECT r;
  77.         wndtxGetOriginalRect(hwnd,&r);
  78. //information("%d %d %d %d",r.top,r.left,r.right,r.bottom);
  79.         wndSetPosSize(hwnd,r.left,r.top,rectCx(&r),rectCy(&r));
  80.     }
  81.     return TRUE;
  82. }
  83. #endif
  84.  
  85. BOOL txIDM_SWITCHDISPTAG(TX* text)
  86. {
  87.     txfTagSwitchDisp(text);
  88.     return TRUE;
  89. }
  90.  
  91. BOOL txIDM_SWITCHSCROLLBARV(TX* text)
  92. {
  93.     text->fScrollBarV ^= TRUE;
  94.     txFlushScrollBar(text);
  95.     txFlushMenuCheckAll(text);
  96.     return TRUE;
  97. }
  98.  
  99. BOOL txIDM_SWITCHOUTLINE(TX* text)
  100. {
  101.     if (text->hwndOutline) {
  102.         txolClose(text);
  103.     } else {
  104.         txolOpen(text);
  105.     }
  106.     txFlushMenuCheck(text,FMC_CONFIG);    //WZ4.00Ec 010124 
  107.     return TRUE;
  108. }
  109.  
  110. BOOL txIDM_SWITCHLY(TX* text)
  111. {
  112.     if (text->ly == text->lcySmupper) {
  113.         txSetLyCenter(text);
  114.     } else if (text->ly == txGetLyCenter(text)) {
  115.         txSetLy(text,text->lcywindow);
  116.     } else {
  117.         txSetLy(text,text->lcySmupper);
  118.     }
  119.     return TRUE;
  120. }
  121.  
  122. //##表示の更新
  123.  
  124. static BOOL _txIDM_DISPALL(TX* text,int idm)
  125. {
  126. //WZ3.90H 980921 カーソル位置によって桁揃えがフラッシュされなかったのをなおした。
  127. //WZ3.90J 981109 IDM_DISPALLでIDM_FLUSHTABLEを兼ねるようにした for メニュー割り当てコマンド数削減。
  128.     if (idm == IDM_DISPALL) text->fUndisp++;
  129.     if (text->fTxf) {
  130. #if 0//WZ3.90O 981203 変だった。
  131.         if (txKeisenIsNeedOp(text,0) && txKeisenOp(text,0,"")) {
  132.         }
  133. #endif
  134.         txfCellFlush(text);
  135.         txfBeamFlush(text,2);
  136.         text->fNoCheckEdit = TRUE;
  137.     } else if (text->fApfuBeamtab) {
  138.         txfBeamFlush(text,2);
  139.         text->fNoCheckEdit = TRUE;
  140.     }
  141.     if (idm == IDM_DISPALL) {
  142.         text->fUndisp--;
  143.         txDispAll(text);
  144.     }
  145.     return TRUE;
  146. }
  147.  
  148. BOOL txIDM_DISPALL(TX* text)
  149. {
  150.     return _txIDM_DISPALL(text,IDM_DISPALL);
  151. }
  152.  
  153. BOOL txIDM_FLUSHTABLE(TX* text)
  154. {
  155.     return _txIDM_DISPALL(text,IDM_FLUSHTABLE);
  156. }
  157.  
  158. #if !__TXC__
  159. BOOL txIDM_FLUSHTABLEALL(TX* text)
  160. {
  161.     if (text->fTxf) {
  162.         txfCellFlushAll(text);
  163.     } else if (text->fApfuBeamtab) {
  164.         txBeamtabFlushAll(text);
  165.     }
  166.     return TRUE;
  167. }
  168. #endif // !__TXC__
  169.  
  170. BOOL txIDM_FLUSHOUTLINE(TX* text)
  171. {
  172.     txolFlush(text);
  173.     return TRUE;
  174. }
  175.  
  176. //##表示
  177.  
  178. BOOL txIDM_SETLYTOP(TX* text)
  179. {
  180.     txSetLy(text,text->lcySmupper);
  181.     return TRUE;
  182. }
  183.  
  184. BOOL txIDM_DISPCUR(TX* text)
  185. {
  186.     TXCHAR ch = txGetChar(text);
  187. #ifdef UNICODE
  188.     wstatprintf(TEXT("%d桁 %d行 文字コード:%04X"),text->lx+1,text->fLineD ? text->nline : text->npara,ch);
  189. #else
  190.     statprintf(TEXT("%d桁 %d行 文字コード:%04X"),text->lx+1,text->fLineD ? text->nline : text->npara,ch);
  191. #endif
  192.     // カーソルを大きく表示
  193.     text->fCursorBold++;
  194.     txDispCursor(text);
  195.     text->fCursorBold--;
  196.     return TRUE;
  197. }
  198.  
  199. //##メニュー
  200.  
  201. #if !__TXC__
  202. BOOL txIDM_CONTEXTMENU(TX* text)
  203. {
  204. #if 0//WZ4.00Ea 001202 
  205.     if (text->fMailPreview) {
  206.         #if WZFUNC_EMAIL
  207.         mailerOpenMenuMouseRMessage(text);
  208.         #endif
  209.     } else 
  210. #endif
  211.     if (text->fContexthelp) {
  212.         //WZ4.00Dc 000326 コンテキストヘルプで、コンテキストメニューが出ないようにした。検索等すると落ちるので。
  213.         return FALSE;
  214.     } else {
  215.         HMENU hmenu = NULL;
  216.         #if WINDOWSCE
  217.         hmenu = LoadMenu(_hinstance,text->fClip ? IDM_CONTEXTMENU_EDITORCLIP : IDM_CONTEXTMENU_EDITOR);
  218.         if (hmenu) {
  219.             _txFlushMenuCheckExec(text,hmenu,FMC_ALL);
  220.             if (text->fByMouse) {
  221.                 menuOpenMouse(GetSubMenu(hmenu,0));
  222.             } else {
  223.                 txHmenuOpenKey(text,GetSubMenu(hmenu,0));
  224.             }
  225.             menuDelete(hmenu);
  226.         }
  227.         #else
  228.         if (text->fClip) {
  229.             hmenu = menuLoadMouseR(_szuiwz,text->szMenuMouseRClip[0] ? text->szMenuMouseRClip : (text->fTxf ? "TmlClip" : "StdClip"));
  230.         } else {
  231.             if (text->flpPreview) {
  232.                 hmenu = menuLoad(_szuiwz,"Preview");
  233.             } else {
  234.                 hmenu = menuLoadMouseR(_szuiwz,text->szMenuMouseR[0] ? text->szMenuMouseR : (text->fTxf ? "Tml" : "Std"));
  235.             }
  236.         }
  237.         if (hmenu) {
  238. #if 1    //WZ3.90P 981207 WZテキストボックスでの右クリックメニューが死んでいた。
  239.             _txFlushMenuCheckExec(text,hmenu,FMC_ALL);
  240.             if (text->fFrame) {
  241.                 if (text->fByMouse) {    //WZ4.00Bl 990909 キーでコンテキストメニューを開いたときは、カーソル位置に表示。
  242.                     menuOpenMouse(hmenu);
  243.                 } else {
  244.                     txHmenuOpenKey(text,hmenu);
  245.                 }
  246.                 menuDelete(hmenu);
  247.             } else {
  248.                 int idm;
  249.                 myEnableMenuItem(hmenu,IDM_UISAVE,FALSE);
  250.                 myEnableMenuItem(hmenu,IDM_UICLOSE,FALSE);
  251.                 if (text->fByMouse) {    //WZ4.00Bl 990909 
  252.                     //WZ4.00Bn 991005 MENU_MOUSEを追加。
  253.                     idm = menuOpenEx(hmenu,MENU_CMD|MENU_DELETE|MENU_MOUSE,0,0,text->hwndtext);
  254.                 } else {
  255.                     idm = txHmenuSelect(text,hmenu);
  256.                 }
  257.                 txIdmExec(text,idm);
  258.             }
  259. #else
  260.             _txFlushMenuCheckExec(text,hmenu,FMC_ALL);
  261.             menuOpenMouse(hmenu);
  262.             menuDelete(hmenu);
  263. #endif
  264.         }
  265.         #endif
  266.     }
  267.     return TRUE;
  268. }
  269. #endif    // !__TXC__
  270.  
  271. //##ウィンドウ
  272.  
  273. #if !WINDOWSCE
  274. BOOL txIDM_WINDOWFULLY(TX* text)
  275. {
  276.     HWND hwnd = text->hwndbase;
  277.     RECT rWork;
  278.     RECT r;
  279.     //
  280. #if 1    //WZ4.00Ec 010129 
  281.     hwndGetWorkRect(hwnd,&rWork);    //WZ4.00Ec 010129 マルチモニタ環境で、セカンダリで「高さを最大化」コマンドが効くようにした。動作未確認。
  282. #else
  283.     #if UNIX
  284.     GetWorkRect(&rWork);
  285.     #else
  286.     SystemParametersInfo(SPI_GETWORKAREA,sizeof(RECT),&rWork,0);
  287.     #endif
  288. #endif
  289.     GetWindowRect(hwnd,&r);
  290.     r.top = rWork.top;r.bottom = rWork.bottom;
  291.     wndSetPosSize(hwnd,r.left,r.top,rectCx(&r),rectCy(&r));
  292.     return TRUE;
  293. }
  294. #endif
  295.  
  296. #if !WINDOWSCE && !__TXC__ && WZFUNC_EDITOR
  297. BOOL txIDM_WINDOWMULTI(TX* text)
  298. {
  299.     txMultiWindow(text,FALSE);
  300.     return TRUE;
  301. }
  302. #endif
  303.  
  304. //##印刷
  305.  
  306. #if WZFUNC_PRINT
  307. BOOL txIDM_SWITCHDETAIL(TX* text)
  308. {
  309.     text->fDispDetail = text->fDispDetail ^ TRUE;    // for __TXC__
  310.     if (text->fDispDetail) {
  311.         if (!text->flpPreview) txLpSwitchPreview(text);
  312.     } else {
  313.         if (text->flpPreview) txLpSwitchPreview(text);
  314.     }
  315.     return TRUE;
  316. }
  317.  
  318. BOOL txIDM_UIPRINTSTYLE(TX* text)
  319. {
  320.     txuiLpStyle(text);
  321.     return TRUE;
  322. }
  323.  
  324. #if !__TXC__
  325. BOOL txIDM_UIPRINTSTYLESET(TX* text)
  326. {
  327. //WZ4.00Ed 010302 new
  328.     txuiLpStyleDetail(text);
  329.     return TRUE;
  330. }
  331. #endif
  332.  
  333. BOOL txIDM_UIPRINT(TX* text)
  334. {
  335.     txuiLprint(text);
  336.     return TRUE;
  337. }
  338.  
  339. #if !__TXC__
  340. BOOL txIDM_UIPRINTEXEC(TX* text)
  341. {
  342.     txuiLprintExec(text);
  343.     PostMessage(text->hwndbase,WM_CLOSE,0,0);    // 印刷が終わったら閉じる。
  344.     return TRUE;
  345. }
  346. #endif // !__TXC__
  347.  
  348. BOOL txIDM_PV_SWITCH(TX* text)
  349. {
  350.     txLpSwitchPreview(text);
  351.     return TRUE;
  352. }
  353.  
  354. static BOOL _txIDM_PV_ZOOMIN(TX* text,int idm)
  355. {
  356.     int d = (idm == IDM_PV_ZOOMOUT) ? -1 : 1;
  357.     int skey = GetShiftKey();
  358.     int rate = 5;
  359.     //WZ4.00Bj 990830 プレビューの拡大縮小をShiftを押しながら行うと大きく、Ctrlを押しながらだと小さく行うようにした。
  360.     if (skey == SKEY_SHIFT) {
  361.         rate = 25;
  362.     } else if (skey == SKEY_CONTROL) {
  363.         rate = 1;
  364.     } else if (skey == SKEY_ALT) {
  365.         //WZ4.00Bj 990830 Alt+縮小でページ全体表示、Alt+拡大でページ横幅表示にした。
  366.         txLpSetRateAuto(text,(d == 1));
  367.         return TRUE;
  368.     }
  369.     txLpAddRate(text,rate*d);
  370.     return TRUE;
  371. }
  372.  
  373. BOOL txIDM_PV_ZOOMOUT(TX* text)
  374. {
  375.     return _txIDM_PV_ZOOMIN(text,IDM_PV_ZOOMOUT);
  376. }
  377.  
  378. BOOL txIDM_PV_ZOOMIN(TX* text)
  379. {
  380.     return _txIDM_PV_ZOOMIN(text,IDM_PV_ZOOMIN);
  381. }
  382.  
  383. BOOL txIDM_PV_ZOOMOUTD(TX* text)
  384. {
  385.     txLpAddRate(text,-1);
  386.     return TRUE;
  387. }
  388.  
  389. BOOL txIDM_PV_ZOOMIND(TX* text)
  390. {
  391.     txLpAddRate(text,1);
  392.     return TRUE;
  393. }
  394.  
  395. BOOL txIDM_PV_ZOOMFIT(TX* text)
  396. {
  397.     txLpSetRateAuto(text,0);
  398.     return TRUE;
  399. }
  400.  
  401. BOOL txIDM_PV_ZOOMFITX(TX* text)
  402. {
  403.     txLpSetRateAuto(text,1);
  404.     return TRUE;
  405. }
  406.  
  407. BOOL txIDM_PV_ZOOMUNDO(TX* text)
  408. {
  409.     if (text->pvRate0) txLpSetRate(text,text->pvRate0);
  410.     text->pvRate0 = 0;
  411.     return TRUE;
  412. }
  413. #endif    // WZFUNC_PRINT
  414.  
  415. //##プラグイン
  416.  
  417. #if __TXC__
  418. void __pluginGetProperty(mchar* prop,txstr res)
  419. {
  420. //information("%s",prop);
  421.     if (!stricmp(prop,"name")) res = "表示IDM処理";
  422.     if (!stricmp(prop,"author")) res = sysGetName();
  423.     if (!stricmp(prop,"version")) res = sysGetVersionPrim();
  424. }
  425.  
  426. static HOOKRESULT CALLBACK wndprocTextHook(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
  427. {
  428.     if (message == WM_TXEVENT && wParam == TXEVENT_IDMEXEC) {
  429.         TX* text = hwndtextGetText(hwnd);
  430.         int idm = lParam;
  431.         switch(idm) {
  432.             case IDM_FLUSHOUTLINE: {    // サンプル
  433. statprintf("IDM_FLUSHOUTLINE by macro");
  434.                 txIDM_FLUSHOUTLINE(text);
  435.                 return HOOK_CAPTURE;
  436.             }
  437.         }
  438.     }
  439.     return HOOK_CONTINUE;
  440. }
  441.  
  442. void __on_txFrameNew(TX* text)
  443. {
  444.     txSetHookWndproctextTxpcode(text,wndprocTextHook);
  445. }
  446.  
  447. #endif
  448.