Перевел элемент на FTCG, заработали 2 разных шрифта, из-за того, что FTCG сам по себе так работает, что автоматически создает новые имена всех переменных. Но что-то, всеравно, не так, второй шрифт влияет на первый, переписывая расстояние между строками.
1 шрифт:
2 шрифта:
Может Вам это и не нужно, но на всякий случай, код FTCG. (ini-файл тот-же)
#hws func init() //Unit fvar(old) old = block.select(BLK_UNITS) if(not block.intext('OpenGL')) print(',', 'OpenGL') end block.select(old)
old = block.select(BLK_VAR_LOGIN) lang(base:str,TextH:str,Ptext:str,SizeFont:str,PGL_ARB_window_pos:str) println('var') println(' ',base,' : GLuint;') println(' ',TextH,' : Integer;') println(' ',Ptext,' : string;') println(' ',SizeFont,': TSize;') println(' ',PGL_ARB_window_pos,' : Boolean;') block.select(old)
if (isset(const_ok_) = 0) old = block.select(BLK_CONST_LOGIN) println('const') println(' AnsiCharset = ANSI_CHARSET;') println(' DefaultCharset = DEFAULT_CHARSET;') println(' SymbolCharset = SYMBOL_CHARSET;') println(' RussianCharset = RUSSIAN_CHARSET;') println(' DefaultQuality = DEFAULT_QUALITY;') println(' AntialiasedQuality = ANTIALIASED_QUALITY;') println(' Normal = 0;') println(' Bold = FW_BOLD;') gvar(const_ok_) block.select(old) end
old = block.select(BLK_PRIV_VAR) lang(Viewport:str,ProjMatrix:str,mvMatrix:str,wx:str,wy:str,wz:str,wx1:str,wy1:str,wz1:str,DC:int,XMFont:str) println(' ',Viewport,' : Array [0..3] of GLInt; // параметры viewport-a.') println(' ',ProjMatrix,': Array [0..15] of GLDouble;// матрица проекции.') println(' ',mvMatrix,': Array [0..15] of GLDouble; // видовая матрица.') println(' ',wx,',',wy,',',wz,':GLdouble; // возвращаемые мировые координаты.') println(' ',wx1,',',wy1,',',wz1,':GLdouble;') println(' ',DC,' : Integer;') println(' ',XMFont,': HFONT;') block.select(old)
//временные переменные для событий onWidthText и onTextHeight old = block.select(BLK_PUB_VAR) lang(NTemp1:int,NTemp2:int) println(' ',NTemp1,':integer;') println(' ',NTemp2,':integer;') block.select(old)
old = block.select(BLK_PUB_MTD) lang(glPrint:str,GL_ARB_window_pos:str) println(' procedure ',glPrint,'(text: string);') println(' function ',GL_ARB_window_pos,': boolean;') block.select(old)
//function GL_ARB_window_pos old = block.select(BLK_MTD_BODY) lang(Extensions:str,glGetString:str,Pos:str,glWindowPos2iARB:str,wglGetProcAddress:str) println('function TClass',e1,'.',GL_ARB_window_pos,' : Boolean;') println(' var') println(' ',Extensions,':String;') println('begin') println(Extensions,' := glGetString(GL_EXTENSIONS);') println(PGL_ARB_window_pos,' := Pos(',str('GL_ARB_window_pos'),',',Extensions,') <> 0;') println(' if ',PGL_ARB_window_pos,' then ') println(' begin') println(' glWindowPos2iARB := wglGetProcAddress(',str('glWindowPos2iARB'),');') println(' end') println(' else') println(' begin') println(' Result := false;') println(' end;') println('end;') println('') block.select(old)
//procedure glPrint old = block.select(BLK_MTD_BODY) println('procedure TClass',e1,'.',glPrint,'(text: string);') println('begin') println(' if text = ',str(''),' then exit;') println(' glPushAttrib(GL_LIST_BIT);') println(' glListBase(',base,');') println(' glCallLists(length(text),GL_UNSIGNED_BYTE,Pchar(text));') println(' glPopAttrib;') println('end;') block.select(old)
//конец func init() end
//функции func doInit()
println(' ',DC,' := ',GLHandle,';') println(' ',base,' := glGenLists(',ListStart,');') println(' ',TextH,' := ',TextHeight,';') println(' ',XMFont,' := CreateFont(-',TextH,', // Высота фонта, если (-) то задаётся высота шрифта в пикселях') println(' 0,') println(' 0,') println(' 0,') println(' ',FontWeights,', //Ширина шрифта,') println(' 0, // Курсив') println(' 0, // Подчеркивание') println(' 0, // Перечеркивание') println(' ',Charset,', //Идентификатор набора символов,') println(' OUT_DEFAULT_PRECIS, // Точность вывода,') println(' CLIP_DEFAULT_PRECIS, //Точность отсечения,') println(' ',Quality,', // Качество вывода,') println(' FF_DONTCARE or DEFAULT_PITCH, //Семейство и шаг,') println(' ',Font,'); // Имя шрифта,') println(' SelectObject(',DC,',',XMFont,');') println(' wglUseFontBitmaps(',DC,',0,256,',base,');')
event(onInit)
//конец func doInit() end
func doSetText()
println(Ptext,' := ',Text,';') println('GetTextExtentPoint32(',DC,', PChar(',Ptext,'), Length(',Ptext,'), ',SizeFont,');')
//кешируем println(NTemp1,' := ',SizeFont,'.cx;') println(NTemp2,' := ',SizeFont,'.cy;')
event(onWidthText,NTemp1) event(onTextHeight,NTemp2) event(onSetText)
//конец func doSetText() end
func doDraw()
fvar(old) old = block.select(LOC_VARS) lang(Xset:int,Yset:int,SizeFontY:int) println(' ',Xset,':Integer;') println(' ',Yset,':Integer;') println(' ',SizeFontY,':Integer;') block.select(old)
old = block.select(BLK_BODY) println(' ',Xset,' := ',X,';') println(' ',Yset,' := ',Y,';') println(' //-----------------------------------------------------------------') println(' if ',GL_ARB_window_pos,' then ') println(' begin') println(' glGetIntegerv(GL_VIEWPORT,@',Viewport,');') println(' glWindowPos2iARB(',Xset,',((',viewport,'[3] - ',Yset,')-',TextH,') + (',SizeFont,'.cy - ',TextH,'));') println(' ',glPrint,'(',Ptext,');') println(' end') println(' else') println(' begin') println(' //-----------------------------------------------------------------') println(' glGetIntegerv(GL_VIEWPORT,@',Viewport,'); // узнаём параметры viewport-a.') println(' glGetDoublev(GL_PROJECTION_MATRIX,@',ProjMatrix,'); // узнаём матрицу проекции.') println(' glGetDoublev(GL_MODELVIEW_MATRIX,@',mvMatrix,'); // узнаём видовую матрицу.') println(' gluProject(0,0,0, @',mvMatrix,', @',ProjMatrix,', @',Viewport,', ',wx1,', ',wy1,', ',wz1,');') println(' gluUnProject(1 + ',Xset,',((',viewport,'[3] - ',Yset,')-',TextH,') + (',SizeFont,'.cy - ',TextH,'),') println(' ',wz1,', @',mvMatrix,', @',ProjMatrix,', @',Viewport,', ',wx,', ',wy,', ',wz,');') println(' glRasterPos2f(',wx,', ',wy,');') println(' ',glPrint,'(',Ptext,');') println(' //----------------------------------------------------------------') println(' end;')
event(onDraw) block.select(old) //конец func doDraw() end
func doDelete() println('glDeleteLists(',ListStart,', 256);') end
Тестовая схема:
Add(MainForm,15261923,21,49) { Height=400 Ctl3D=0 WinStyle=1 Caption="Пример использования GL_Text2dEX" BorderStyle=1 Position=1 Point(MouseX) Point(MouseY) Point(onResize) Point(Handle) link(onCreate,16299401:doEvent1,[]) link(onResize,16131419:doWork1,[(77,76)(77,39)(165,39)]) } Add(GL_Main,12986311,189,63) { Color=0 EnvironmentMode=2 Point(doVSync) Point(Vendor) Point(Renderer) Point(VersionGL) Point(Fps) link(onInit,12198675:doInit,[]) link(onViewPort,3410847:doPerspective,[(276,76)(276,125)]) link(Handle,15261923:Handle,[(195,33)(72,33)(72,89)(41,89)]) } Add(GL_GTools,771925,196,210) { Point(doClear) Point(doPushMatrix) Point(doPopMatrix) } Add(Hub,1049454,133,210) { OutCount=5 link(onEvent1,771925:doClear,[]) link(onEvent2,771925:doPushMatrix,[]) link(onEvent3,15526434:doEvent1,[(172,230)(172,202)]) link(onEvent4,771925:doPopMatrix,[(180,237)(180,230)]) link(onEvent5,12986311:doFlip,[(164,244)(164,83)]) } Add(Hub,16299401,91,63) { OutCount=5 link(onEvent1,12986311:doInit,[]) link(onEvent2,16131419:doWork2,[]) link(onEvent4,14919803:doData,[]) link(onEvent5,9134537:doStart,[(111,97)(111,128)(75,128)(75,209)]) } Add(GL_GluTools,12198675,287,63) { link(onInit,1101264:doEnabled,[]) } Add(GL_Light,14989894,462,63) { } Add(GL_Options,1101264,329,63) { link(onEvent,5851269:doEnabled,[]) } Add(GL_Options,5851269,371,63) { Flag=1 link(onEvent,5809249:doEnabled,[]) } Add(GL_Options,5809249,420,63) { Flag=2 link(onEvent,14989894:doEnabled,[]) } Add(GL_Perspective,3410847,287,119) { Fovy=50 zNear=0.1 zFar=1000 link(onPerspective,11268661:doEvent1,[]) } Add(HubEx,16131419,161,70) { link(onEvent,12986311:doViewPort,[]) } Add(LineBreak,13774034,154,112) { Caption="hDC" Type=1 link(Data,12986311:GLHandle,[(160,104)(195,104)]) Primary=[10764968,469,315] } Add(GL_Options,1477332,434,189) { } Add(Memory,5937092,630,371) { Default=String(Тест) } Add(Thread,9134537,84,203) { Delay=0 link(onSyncExec,1049454:doEvent1,[]) } Add(StrList,424452,476,140) { Strings=#20:Vendor: |15391744|20:Renderer: |15391744|20:VersionGL: |15391744|15:FPS: |4760307|13:Pos.X: |65535|13:Pos.Y: |65535| } Add(ArrayEnum,8143604,476,203) { link(onItem,16081414:doSplit,[]) link(Array,424452:Array,[(482,194)(496,194)]) } Add(GL_Color,4024906,525,266) { link(Color,16081414:Right,[]) } Add(StrPart,16081414,518,203) { Char="|" Point(Left) Point(Right) link(onPart,10720353:doData,[]) } Add(LineBreak,8890940,217,175) { Caption="FPS" Type=1 link(Data,12986311:Fps,[]) Primary=[15623780,441,-28] } Add(StrCat,16180197,630,266) { link(onStrCat,6160742:In,[]) link(Str1,16081414:Left,[(636,250)(524,250)]) link(Str2,5212554:Var,[]) } Add(LineBreak,1498707,21,98) { Caption="X" Type=1 link(Data,15261923:MouseX,[]) Primary=[3217132,644,70] } Add(LineBreak,10205144,28,119) { Caption="Y" Type=1 link(Data,15261923:MouseY,[]) Primary=[4551636,644,70] } Add(Hub,6928004,497,364) { OutCount=4 link(onEvent1,14554718:doNext,[]) link(onEvent2,5937092:doValue,[]) link(onEvent3,2113799:doData,[(532,384)(532,475)]) } Add(CounterEx,14554718,707,364) { Max=5 Default=-1 } Add(Math,4730325,700,406) { OpType=2 link(Op2,14554718:Count,[]) } Add(GetIndexData,5212554,637,210) { Count=6 link(onIndex,4024906:doColor,[(709,216)(709,306)(514,306)(514,272)]) link(Data1,2510352:Var,[(643,175)(566,175)]) link(Data2,9353280:Var,[(650,148)(566,148)]) link(Data3,6626809:Var,[]) link(Data4,15623780:Var,[]) link(Data5,3217132:Var,[]) link(Data6,4551636:Var,[]) } Add(DoData,10720353,560,210) { link(onEventData,9673:doEvent1,[]) link(Data,15265171:Var,[]) } Add(Hub,9673,602,210) { link(onEvent1,5212554:doIndex,[]) link(onEvent2,16180197:doStrCat,[(623,223)(623,272)]) } Add(DoData,2113799,553,469) { link(onEventData,3807671:doEvent1,[]) } Add(LineBreak,5140694,560,448) { Caption="InitFont" link(Out,3991113:doInit,[(616,454)(616,468)]) Primary=[6191937,-203,-329] } Add(DoData,14919803,119,84) { Data=Integer(0) link(onEventData,12986311:doVSync,[]) } Add(LineBreak,523457,448,259) { Caption="Индекс" Type=1 link(Data,8143604:Index,[(454,244)(489,244)]) Primary=[15265171,112,-77] } Add(Hub,15526434,399,196) { OutCount=3 link(onEvent1,1477332:doDisabled,[]) link(onEvent2,8143604:doEnum,[]) link(onEvent3,1477332:doEnabled,[(423,216)(423,195)]) } Add(LineBreak,11088666,455,364) { Caption="str" link(Out,6928004:doEvent1,[]) Primary=[6160742,217,-98] } Add(InfoTip,1179810,392,105) { Info=#27:Чтение списка и цвета строк| Width=344 Height=207 } Add(InfoTip,14965503,455,343) { Info=#26:Отрисовка списка построчно| Width=323 Height=179 } Add(Hub,3807671,595,469) { link(onEvent1,3991113:doSetText,[]) link(onEvent2,3991113:doDraw,[]) } Add(LineBreak,4438186,196,112) { Caption="Vendor" Type=1 link(Data,12986311:Vendor,[]) Primary=[2510352,364,42] } Add(LineBreak,15724959,210,154) { Caption="VersionGL" Type=1 link(Data,12986311:VersionGL,[]) Primary=[6626809,441,-28] } Add(LineBreak,12169243,203,133) { Caption="Renderer" Type=1 link(Data,12986311:Renderer,[]) Primary=[9353280,357,-7] } Add(InfoTip,12351241,273,35) { Info=#49:Пример отрисовки 2D текста. Автор MAB| Font=[MS Sans Serif,10,1,8388608,1] Width=463 Height=18 } Add(Hub,11268661,329,119) { link(onEvent1,6191937:In,[]) } Add(FTCG_Tools,3991113,623,462) { link(onTextHeight,4730325:doOperation,[(677,482)(677,412)]) link(GLHandle,10764968:Var,[]) link(Data,5937092:Value,[]) link(Data3,4730325:Result,[(657,450)(706,450)]) } BEGIN_SDK Add(EditMultiEx,8483867,21,21) { WorkCount=#6:doInit|9:doSetText|6:doDraw|8:doDelete| EventCount=#6:onInit|11:onWidthText|12:onTextHeight|9:onSetText|6:onDraw| DataCount=#8:GLHandle|4:Data|5:Data1|5:Data2|5:Data3| Width=482 Height=382 link(doInit,12920990:doEvent1,[(46,27)(46,174)]) link(doSetText,626243:doEvent1,[(98,34)(98,244)]) link(doDraw,4405509:doEvent1,[(37,41)(37,209)]) link(doDelete,13810118:doEvent1,[(29,48)(29,286)]) } Add(FT_GL_Text2dEX,3915953,217,259) { TextHeight=12 Font="Arial" Point(doDelete) Point(TextHeight) Point(X) Point(Y) link(onWidthText,8483867:onWidthText,[(399,272)(399,34)]) link(onTextHeight,8483867:onTextHeight,[(415,279)(415,41)]) link(onSetText,8483867:onSetText,[(434,286)(434,48)]) link(onDraw,8483867:onDraw,[(449,293)(449,55)]) link(GLHandle,6004315:Var2,[]) link(Text,6871961:Var2,[]) link(Y,11892114:Var1,[(251,170)]) } Add(FT_Memory,13946630,105,49) { Default=Integer(0) link(Data,8483867:GLHandle,[(111,40)(27,40)]) } Add(FT_Memory,8996174,154,49) { Default=String() link(Data,8483867:Data,[(160,28)(34,28)]) } Add(FT_Memory,12448986,350,49) { Default=Integer(0) link(Data,8483867:Data3,[(356,35)(55,35)]) } Add(FT_Hub,4405509,49,203) { OutCount=4 link(onEvent1,8996174:doValue,[(145,209)(145,55)]) link(onEvent2,12448986:doValue,[(329,216)(329,55)]) link(onEvent3,3915953:doDraw,[(78,223)(78,279)]) link(onEvent4,5538739:doDraw,[(70,230)(70,356)]) } Add(FT_Hub,12920990,56,168) { OutCount=3 link(onEvent1,13946630:doValue,[(84,174)(84,55)]) link(onEvent2,3915953:doInit,[(84,181)(84,265)]) link(onEvent3,5538739:doInit,[(276,188)(276,342)]) } Add(GetDataEx,6004315,217,245) { link(Data,13946630:Value,[(223,177)(111,177)]) } Add(GetDataEx,6871961,224,231) { link(Data,8996174:Value,[(230,161)(160,161)]) } Add(GetDataEx,11892114,315,165) { Angle=1 link(Data,12448986:Value,[(356,170)]) } Add(FT_Hub,626243,133,238) { link(onEvent1,3915953:doSetText,[(181,244)(181,272)]) link(onEvent2,5538739:doSetText,[(171,251)(171,349)]) } Add(FT_Math,3984350,315,245) { Op2=180 link(Op1,11892114:Var2,[]) } Add(FT_Hub,13810118,182,280) { link(onEvent1,3915953:doDelete,[]) link(onEvent2,5538739:doDelete,[(205,293)(205,363)]) } Add(FT_GL_Text2dEX,5538739,287,336) { TextHeight=19 Font="Comic Sans MS" ListStart=1001 Point(doDelete) Point(TextHeight) Point(X) Point(Y) link(GLHandle,6004315:Var3,[(293,250)]) link(Text,6871961:Var3,[(300,236)]) link(Y,3984350:Result,[]) } END_SDK
чуть не забыл, еще нужен доработанный файл hiEditMultiEx.hws
hieditmultiex.rar
[offtop]в нем все постарому, просто добавлены два новых блока var и const[/offtop]
|