Re: MleText window does not show text
- Posted by DerekParnell (admin) Nov 24, 2012
- 1301 views
sergelli said...
If you believe that there is something I do not know, please let me know
Here is a simpler technique that works quite well, I think.
-- 11/11/12 sintaxColor.exw -- separa e coloriza trecho digitado em lista de opções include WIN32lib.ew constant version="1.1" -- ,FONTWH={12,12} ,WIN1 =create(Window,"Pedido - "&version,0,00,00,900,720,0) -- col,lin ,NOMBOX=create(SleText ,"",WIN1,240,03,420,30, -- cx entrada nome cliente { WS_CLIPPINGCHILD, WS_VISIBLE,WS_TABSTOP, ES_SAVESEL ,WS_BORDER } ) ,FINDNOM=create(Window ,"",WIN1,220,55,626,240, -- *8 Para font default { WS_CLIPPINGCHILD, WS_VISIBLE,WS_TABSTOP, ES_SAVESEL ,WS_BORDER } ) ,FINDPMAP=create(Pixmap ,"",0,0,0,626,240, 0 ) -- Where text gets drawn to ,FONE =create(SleText ,"",WIN1,680,03,160,30, -- cx entrada nome cliente { WS_CLIPPINGCHILD, WS_VISIBLE,WS_TABSTOP, ES_SAVESEL ,WS_BORDER } ) ----------------------------------------------------------------------------------- setWindowBackColor( WIN1,{200,255,230}) setFont({FINDPMAP,FONE,NOMBOX},"Courier New", 12, Bold ) -- setVisible(FINDNOM,0) setFocus(NOMBOX) ----------------------------------------------------------------------------------- atom Li1,Choice Li1=1 Choice=2 sequence LisCli,Linhas,PARMS LisCli={"0001|sem cadastro |11 97222-6461" ,"0002|Dudu e Isa |11 91234-1234" ,"0003|Jerry |12 91234-1234" ,"0004|Alcindo e Silvana |12 91234-1234" ,"0005|Sergio Gelli |11 97222-6461" ,"0006|Jose Inacio |11 91234-1234"} ---------------------------------------------------------------------------------------------------------- procedure printText(integer id,sequence block,integer colunaX, integer linhaY ) -- Draw text to a pixmap, which is copied to the display window when needed. integer colTempX, fontwidth, fontheight sequence comboline, textline, text, colourline, backcolour, data -- early out? if length( block ) = 0 then -- block=bloco usando o texto formatado c/TextToAnalysedLine(junk) return end if data = getTextExtent(FINDPMAP, "W") fontwidth = data[1] fontheight = data[2] + 1 -- Add a one-pixel gap between lines. ------------------- ------------------- -- display the text ------------------- ------------------- setBackColor(FINDPMAP, Pink) -- Clears the text area setPenBkMode(FINDPMAP, OPAQUE) -- Ensure we see back ground text colors for i = 1 to length(block) do comboline = block[i] -- extract data for the current line textline = comboline[1] -- extract text for the current line colourline = comboline[2] -- extract color text for the current line backcolour = comboline[3] -- extract backGround for the current line colTempX = colunaX for j = 1 to length(textline) do text = textline[j] -- set the Pen Position setPenPos(FINDPMAP, colTempX,linhaY) setTextColor(FINDPMAP, colourline[j] ) setPenBkColor(FINDPMAP, backcolour[j] ) wPuts({FINDPMAP, colTempX, linhaY}, text) colTempX += length(text) * fontwidth end for -- advance row to next position linhaY += fontheight end for -- Force a repaint of the viewport repaintFG(id) end procedure ------------------------------------------------------------------------------------------------------- procedure fazLinha(sequence preDigi,sequence digi2,sequence posDigi,sequence data4) sequence text integer textlen sequence colors textlen = length(preDigi) + length(digi2) + length(posDigi) + length(data4) if textlen < 60 then textlen = 60 - textlen else textlen = 0 end if text = {preDigi, digi2, posDigi, repeat(' ', textlen) & data4} if Li1=Choice then colors = {{Yellow,Red,Yellow,Yellow},{Red,Yellow,Red,Red}} else colors = {{65200,Blue,65200,65200},{Blue,65200,Blue,Blue}} end if Linhas=append (Linhas,{ text, colors[1], colors[2] } ) Li1+=1 end procedure -------------------------------------------------------------------------------------------------------------- procedure afterKeyUp(integer id, integer event, sequence parms) atom zzz sequence text1 sequence CompText if id != NOMBOX then return end if zzz=0 text1 = getText(NOMBOX) if length(text1) = 0 then setVisible(FINDNOM,0) return end if clearWindow(FINDNOM) Linhas = {} Li1=1 for i=1 to length(LisCli) do CompText = w32trim(LisCli[i]) event = match(upper(text1),upper(CompText)) -- event>0 = encontrou nome com texto digitado if event > 0 then -- encontrou texto digitado zzz=1 fazLinha(CompText[1..event-1] -- antes do digitado ,CompText[event .. event+length(text1) - 1] -- texto digitado ,CompText[event+length(text1)..length(CompText)] -- depois do digitado ,"" ) -- telefone end if end for if zzz = 0 then setVisible(FINDNOM,0) else setVisible(FINDNOM,1) -- abre janela FINDNOM printText(FINDNOM,Linhas,03, 03) -- procedure em resources.ew end if end procedure ----------------------------------------------------------------------------------------------------------- procedure afterKEY(integer id, integer event, sequence parms) afterKeyUp( id, event, parms) --PARMS) end procedure ----------------------------------------------------------------------------------------------------------- setHandler({NOMBOX},w32HChange ,routine_id("afterKEY")) -- teclado numérico e Enter procedure onPaintView(integer id, integer event, sequence parms) copyBlt(id, 0, 0, FINDPMAP) end procedure ----------------------------------------------------------------------------------------------------------- setHandler(FINDNOM,w32HPaint ,routine_id("onPaintView")) -- teclado numérico e Enter WinMain(WIN1,Normal)