src/windows/native/sun/windows/awt_TextArea.cpp

Print this page




 114     string[length-1] = '\0';
 115     for (size_t i = 0; i < maxlen && i < length - 1; i++) {
 116         if (string[i] == L'\n') {
 117             nNewlines++;
 118         }
 119     }
 120     delete[] string;
 121     return nNewlines;
 122 }
 123 
 124 BOOL AwtTextArea::InheritsNativeMouseWheelBehavior() {return true;}
 125 
 126 
 127 LRESULT
 128 AwtTextArea::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
 129 
 130     LRESULT retValue = 0;
 131     MsgRouting mr = mrDoDefault;
 132 
 133     switch (message) {
 134         case WM_PRINTCLIENT:
 135           {
 136             FORMATRANGE fr;
 137             HDC hPrinterDC = (HDC)wParam;
 138             int nHorizRes = ::GetDeviceCaps(hPrinterDC, HORZRES);
 139             int nVertRes = ::GetDeviceCaps(hPrinterDC, VERTRES);
 140             int nLogPixelsX = ::GetDeviceCaps(hPrinterDC, LOGPIXELSX);
 141             int nLogPixelsY = ::GetDeviceCaps(hPrinterDC, LOGPIXELSY);
 142 
 143             // Ensure the printer DC is in MM_TEXT mode.
 144             ::SetMapMode ( hPrinterDC, MM_TEXT );
 145 
 146             // Rendering to the same DC we are measuring.
 147             ::ZeroMemory(&fr, sizeof(fr));
 148             fr.hdc = fr.hdcTarget = hPrinterDC;
 149             // Set up the page.
 150             fr.rcPage.left     = fr.rcPage.top = 0;
 151             fr.rcPage.right    = (nHorizRes/nLogPixelsX) * 1440; // in twips
 152             fr.rcPage.bottom   = (nVertRes/nLogPixelsY) * 1440;
 153             fr.rc.left   = fr.rcPage.left;
 154             fr.rc.top    = fr.rcPage.top;
 155             fr.rc.right  = fr.rcPage.right;
 156             fr.rc.bottom = fr.rcPage.bottom;
 157 
 158             // start printing from the first visible line
 159             LRESULT nLine = SendMessage(EM_GETFIRSTVISIBLELINE, 0, 0);
 160             LONG startCh = static_cast<LONG>(SendMessage(EM_LINEINDEX,
 161                                                          (WPARAM)nLine, 0));
 162             fr.chrg.cpMin = startCh;
 163             fr.chrg.cpMax = -1;
 164 
 165             SendMessage(EM_FORMATRANGE, TRUE, (LPARAM)&fr);
 166           }
 167 
 168         break;
 169     case EM_SETCHARFORMAT:
 170     case WM_SETFONT:
 171         SetIgnoreEnChange(TRUE);
 172         break;
 173     }
 174 
 175     retValue = AwtComponent::WindowProc(message, wParam, lParam);
 176 
 177     switch (message) {
 178     case EM_SETCHARFORMAT:
 179     case WM_SETFONT:
 180         SetIgnoreEnChange(FALSE);
 181         break;
 182     }
 183 
 184     return retValue;
 185 }
 186 
 187 /*
 188  * This routine is a window procedure for the subclass of the standard edit control
 189  * used to generate context menu. RichEdit controls don't have built-in context menu.
 190  * To implement this functionality we have to create an invisible edit control and
 191  * forward WM_CONTEXTMENU messages from a RichEdit control to this helper edit control.
 192  * While the edit control context menu is active we intercept the message generated in
 193  * response to particular item selection and forward it back to the RichEdit control.
 194  * (See AwtTextArea::WmContextMenu for more details).
 195  */




 114     string[length-1] = '\0';
 115     for (size_t i = 0; i < maxlen && i < length - 1; i++) {
 116         if (string[i] == L'\n') {
 117             nNewlines++;
 118         }
 119     }
 120     delete[] string;
 121     return nNewlines;
 122 }
 123 
 124 BOOL AwtTextArea::InheritsNativeMouseWheelBehavior() {return true;}
 125 
 126 
 127 LRESULT
 128 AwtTextArea::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
 129 
 130     LRESULT retValue = 0;
 131     MsgRouting mr = mrDoDefault;
 132 
 133     switch (message) {



































 134     case EM_SETCHARFORMAT:
 135     case WM_SETFONT:
 136         SetIgnoreEnChange(TRUE);
 137         break;
 138     }
 139 
 140     retValue = AwtTextComponent::WindowProc(message, wParam, lParam);
 141 
 142     switch (message) {
 143     case EM_SETCHARFORMAT:
 144     case WM_SETFONT:
 145         SetIgnoreEnChange(FALSE);
 146         break;
 147     }
 148 
 149     return retValue;
 150 }
 151 
 152 /*
 153  * This routine is a window procedure for the subclass of the standard edit control
 154  * used to generate context menu. RichEdit controls don't have built-in context menu.
 155  * To implement this functionality we have to create an invisible edit control and
 156  * forward WM_CONTEXTMENU messages from a RichEdit control to this helper edit control.
 157  * While the edit control context menu is active we intercept the message generated in
 158  * response to particular item selection and forward it back to the RichEdit control.
 159  * (See AwtTextArea::WmContextMenu for more details).
 160  */