Possible bug with FrameWindow?

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

Savail
Quite a regular
Quite a regular
Posts: 50
Joined: Wed Jul 04, 2012 07:54

Possible bug with FrameWindow?

Postby Savail » Fri Jan 25, 2013 16:34

Hey,
I'm not sure but I might have found a bug in FrameWindow. I'm creating a FrameWindow firstly and then adding child windows to it. When I'm setting properties like setTitleBarEnabled(false) (such that change window's state imagery and named areas) for FrameWindow before adding children everything works fine but if I try to add setTitleBarEnabled(false) after adding children to FrameWindow the overall image gets spoilt.

Here's how it looks when I'm setting setTitleBarEnabled(false) before adding children(correct image):
Image

And here when I'm adding that property after adding children(bad look :( and interaction with listbox on the left fails):
Image

CEGUI.log:

Code: Select all

25/01/2013 17:12:21 (Std)    * -------- START OF ESSENTIAL SECTION TO BE POSTED ON THE FORUM       -------- *
25/01/2013 17:12:21 (Std)    ********************************************************************************
25/01/2013 17:12:21 (Std)    ---- Version 0.7.8 (Build: Dec 24 2012 Microsoft Windows MSVC++ 9.0 32 bit) ----
25/01/2013 17:12:21 (Std)    ---- Renderer module is: CEGUI::Direct3D9Renderer - Official Direct3D 9 based 2nd generation renderer module. ----
25/01/2013 17:12:21 (Std)    ---- XML Parser module is: CEGUI::ExpatParser - Official expat based parser module for CEGUI ----
25/01/2013 17:12:21 (Std)    ---- Image Codec module is: SILLYImageCodec - Official SILLY based image codec ----
25/01/2013 17:12:21 (Std)    ---- Scripting module is: None ----
25/01/2013 17:12:21 (Std)    ********************************************************************************
25/01/2013 17:12:21 (Std)    * -------- END OF ESSENTIAL SECTION TO BE POSTED ON THE FORUM         -------- *

My FrameWindow's LookNFeel:

Code: Select all

<!--
    ***************************************************
        Game/FrameWindow
    ***************************************************
    -->
    <WidgetLook name="Game/FrameWindow">
        <PropertyDefinition name="ClientAreaColour" initialValue="FF141B38" redrawOnWrite="true" />
        <PropertyLinkDefinition name="CaptionColour" widget="__auto_titlebar__" targetProperty="CaptionColour" initialValue="FFFFFFFF" />
        <PropertyLinkDefinition name="TitlebarFont" widget="__auto_titlebar__" targetProperty="Font" />
        <Property name="NSSizingCursorImage" value="set:Game image:MouseNoSoCursor" />
        <Property name="EWSizingCursorImage" value="set:Game image:MouseEsWeCursor" />
        <Property name="NWSESizingCursorImage" value="set:Game image:MouseNwSeCursor" />
        <Property name="NESWSizingCursorImage" value="set:Game image:MouseNeSwCursor" />
        <Property name="UnifiedMinSize" value="{{0.1,0},{0.1,0}}" />
        <Property name="AutoRenderingSurface" value="True" />
     <Property name="TitlebarFont" value="NEORD" />
        <NamedArea name="ClientWithTitleWithFrame">
            <Area>
                <Dim type="LeftEdge" ><ImageDim imageset="Game" image="FrameLeft" dimension="Width" /></Dim>
                <Dim type="TopEdge" >
             <WidgetDim widget="__auto_titlebar__" dimension="BottomEdge" >
            <DimOperator op="Subtract">
               <AbsoluteDim value="15" />
            </DimOperator>
         </WidgetDim>
          </Dim>
                <Dim type="RightEdge" >
                    <UnifiedDim scale="1" type="RightEdge">
                        <DimOperator op="Subtract">
                            <ImageDim imageset="Game" image="FrameRight" dimension="Width" />
                        </DimOperator>
                    </UnifiedDim>
                </Dim>
                <Dim type="BottomEdge" >
                    <UnifiedDim scale="1" type="BottomEdge">
                        <DimOperator op="Subtract">
                            <ImageDim imageset="Game" image="FrameBottom" dimension="Height" >
                   <DimOperator op="Subtract">
                  <AbsoluteDim value="10" />
               </DimOperator>
                </ImageDim>
                        </DimOperator>
                    </UnifiedDim>
                </Dim>
            </Area>
        </NamedArea>
        <NamedArea name="ClientWithTitleNoFrame">
            <Area>
                <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
                <Dim type="TopEdge" ><WidgetDim widget="__auto_titlebar__" dimension="BottomEdge" /></Dim>
                <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
                <Dim type="BottomEdge" ><WidgetDim dimension="BottomEdge" /></Dim>
            </Area>
        </NamedArea>
        <NamedArea name="ClientNoTitleWithFrame">
            <Area>
                <Dim type="LeftEdge" ><ImageDim imageset="Game" image="FrameLeft" dimension="Width" /></Dim>
                <Dim type="TopEdge" >
          <ImageDim imageset="Game" image="FrameTop" dimension="Height" >
          <DimOperator op="Subtract">
             <AbsoluteDim value="15" />
          </DimOperator>
          </ImageDim>
          </Dim>
                <Dim type="RightEdge" >
                    <UnifiedDim scale="1" type="RightEdge">
                        <DimOperator op="Subtract">
                            <ImageDim imageset="Game" image="FrameRight" dimension="Width" />
                        </DimOperator>
                    </UnifiedDim>
                </Dim>
                <Dim type="BottomEdge" >
                    <UnifiedDim scale="1" type="BottomEdge">
                        <DimOperator op="Subtract">
                            <ImageDim imageset="Game" image="FrameBottom" dimension="Height" >
                   <DimOperator op="Subtract">
                  <AbsoluteDim value="10" />
               </DimOperator>
                </ImageDim>
                        </DimOperator>
                    </UnifiedDim>
                </Dim>
            </Area>
        </NamedArea>
        <NamedArea name="ClientNoTitleNoFrame">
            <Area>
                <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
                <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
                <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
                <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
            </Area>
        </NamedArea>
        <Child type="Game/Titlebar" nameSuffix="__auto_titlebar__">
            <Area>
                <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
                <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
                <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
                <Dim type="Height" >
             <UnifiedDim scale="0.5" type="Height" >
            <DimOperator op="Multiply">
               <AbsoluteDim value="300">
                  <DimOperator op="Divide">
                     <UnifiedDim scale="1.0" type="Height" />
                  </DimOperator>
               </AbsoluteDim>
            </DimOperator>
         </UnifiedDim>
          </Dim>
            </Area>
            <Property name="AlwaysOnTop" value="False" />
        </Child>
        <Child type="Game/ImageButton" nameSuffix="__auto_closebutton__">
            <Area>
                <Dim type="LeftEdge" ><AbsoluteDim value="30" /></Dim>
                <Dim type="TopEdge" ><AbsoluteDim value="30" /></Dim>
                <Dim type="Width" ><ImageDim imageset="Game" image="CloseButton" dimension="Width" /></Dim>
                <Dim type="Height" ><ImageDim imageset="Game" image="CloseButton" dimension="Width" /></Dim>
            </Area>
            <Property name="AlwaysOnTop" value="True" />
            <!--
      <Property name="NormalImage" value="set:Game image:CloseButtonNormal" />
            <Property name="HoverImage" value="set:Game image:CloseButtonHover" />
            <Property name="PushedImage" value="set:Game image:CloseButtonPressed" />
      -->
            <Property name="NonClient" value="True" />
        </Child>

        <ImagerySection name="with_title_frame-background">
                <ImageryComponent>
                <Area>
                    <Dim type="LeftEdge" ><AbsoluteDim value="32" /></Dim>
                    <Dim type="TopEdge" >
              <WidgetDim widget="__auto_titlebar__" dimension="BottomEdge" >
               <DimOperator op="Subtract">
                  <UnifiedDim scale="0.23" type="Height" >
                     <DimOperator op="Multiply">
                        <AbsoluteDim value="300">
                           <DimOperator op="Divide">
                              <UnifiedDim scale="1.0" type="Height" />
                           </DimOperator>
                        </AbsoluteDim>
                     </DimOperator>
                  </UnifiedDim>
               </DimOperator>
            </WidgetDim>
           </Dim>
                    <Dim type="RightEdge" >
                        <UnifiedDim scale="1" type="Width" >
                 <DimOperator op="Subtract">
                  <AbsoluteDim value="32" />
               </DimOperator>
            </UnifiedDim>
                    </Dim>
                    <Dim type="BottomEdge" >
                        <UnifiedDim scale="1" type="Height">

                    <DimOperator op="Subtract">
                                      <AbsoluteDim value="32" />
                                 </DimOperator>
                        </UnifiedDim>
                    </Dim>
                </Area>
                <Image imageset="Game" image="BackgroundBrush" />
                <ColourProperty name="ClientAreaColour" />
          <Property name="Alpha" value="0.9" />
                <VertFormat type="Stretched" />
                <HorzFormat type="Stretched" />
            </ImageryComponent>
        </ImagerySection>
     <ImagerySection name="just_frame">
        <FrameComponent>
                <Area>
                    <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
                    <Dim type="TopEdge" >
              <WidgetDim widget="__auto_titlebar__" dimension="BottomEdge" >
               <DimOperator op="Subtract">
                  <UnifiedDim scale="0.33" type="Height" >
                     <DimOperator op="Multiply">
                        <AbsoluteDim value="300">
                           <DimOperator op="Divide">
                              <UnifiedDim scale="1.0" type="Height" />
                           </DimOperator>
                        </AbsoluteDim>
                     </DimOperator>
                  </UnifiedDim>
               </DimOperator>
            </WidgetDim>
           </Dim>
                    <Dim type="Width" >
              <UnifiedDim scale="1" type="Width" />
           </Dim>
                    <Dim type="BottomEdge" ><UnifiedDim scale="1" type="BottomEdge" /></Dim>
                </Area>

          <Image type="TopEdge" imageset="Game" image="FrameTop" />
          <Image type="TopLeftCorner" imageset="Game" image="FrameLeftTop" />
                <Image type="TopRightCorner" imageset="Game" image="FrameRightTop" />
                <Image type="BottomLeftCorner" imageset="Game" image="FrameLeftBottom" />
                <Image type="BottomRightCorner" imageset="Game" image="FrameRightBottom" />
                <Image type="LeftEdge" imageset="Game" image="FrameLeft" />
                <Image type="RightEdge" imageset="Game" image="FrameRight" />
                <Image type="BottomEdge" imageset="Game" image="FrameBottom" />
         
            </FrameComponent>
     </ImagerySection>
        <ImagerySection name="notitle_frame-background">
            <ImageryComponent>
                <Area>
                    <Dim type="LeftEdge" >
            <ImageDim imageset="Game" image="FrameLeft" dimension="Width" >
               <DimOperator op="Subtract">
                  <AbsoluteDim value="20" />
               </DimOperator>
            </ImageDim>
           </Dim>
                    <Dim type="TopEdge" >
              <ImageDim imageset="Game" image="FrameTop" dimension="Height" >
               <DimOperator op="Subtract">
                  <AbsoluteDim value="30" />
               </DimOperator>
            </ImageDim>
           </Dim>
                    <Dim type="RightEdge" >
                        <UnifiedDim scale="1" type="Width">
                            <DimOperator op="Subtract">
                                <AbsoluteDim value="25" />
                            </DimOperator>
                        </UnifiedDim>
                    </Dim>
                    <Dim type="BottomEdge" >
                        <UnifiedDim scale="1" type="Height">
               <DimOperator op="Subtract">
                  <AbsoluteDim value="25" />
               </DimOperator>
                        </UnifiedDim>
                    </Dim>
                </Area>
                <Image imageset="Game" image="BackgroundBrush" />
                <ColourProperty name="ClientAreaColour" />
          <Property name="Alpha" value="0.9" />
                <VertFormat type="Stretched" />
                <HorzFormat type="Stretched" />
            </ImageryComponent>
        </ImagerySection>
     <ImagerySection name="just_frame_for_no_title">
        <FrameComponent>
                <Area>
                    <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
                    <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
                    <Dim type="Width" >
              <UnifiedDim scale="1" type="Width" />
           </Dim>
                    <Dim type="BottomEdge" ><UnifiedDim scale="1" type="BottomEdge" /></Dim>
                </Area>

          <Image type="TopEdge" imageset="Game" image="FrameTop" />
          <Image type="TopLeftCorner" imageset="Game" image="FrameLeftTop" />
                <Image type="TopRightCorner" imageset="Game" image="FrameRightTop" />
                <Image type="BottomLeftCorner" imageset="Game" image="FrameLeftBottom" />
                <Image type="BottomRightCorner" imageset="Game" image="FrameRightBottom" />
                <Image type="LeftEdge" imageset="Game" image="FrameLeft" />
                <Image type="RightEdge" imageset="Game" image="FrameRight" />
                <Image type="BottomEdge" imageset="Game" image="FrameBottom" />
         
            </FrameComponent>
     </ImagerySection>
        <ImagerySection name="withtitle_noframe_client_area">
            <ImageryComponent>
                <Area>
                    <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
                    <Dim type="TopEdge" ><WidgetDim widget="__auto_titlebar__" dimension="Height" /></Dim>
                    <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
                    <Dim type="BottomEdge" ><UnifiedDim scale="1" type="BottomEdge" /></Dim>
                </Area>
                <Image imageset="Game" image="BackgroundBrush" />
                <ColourProperty name="ClientAreaColour" />
                <VertFormat type="Stretched" />
                <HorzFormat type="Stretched" />
            </ImageryComponent>
        </ImagerySection>
        <ImagerySection name="notitle_noframe_client_area">
            <ImageryComponent>
                <Area>
                    <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
                    <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
                    <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
                    <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
                </Area>
                <Image imageset="Game" image="BackgroundBrush" />
                <ColourProperty name="ClientAreaColour" />
                <VertFormat type="Stretched" />
                <HorzFormat type="Stretched" />
            </ImageryComponent>
        </ImagerySection>
        <StateImagery name="ActiveWithTitleWithFrame">
            <Layer priority="1">
         <Section section="just_frame" />
      </Layer>
      <Layer>
                <Section section="with_title_frame-background" />
            </Layer>
        </StateImagery>
        <StateImagery name="InactiveWithTitleWithFrame">
            <Layer priority="1">
         <Section section="just_frame" />
      </Layer>
      <Layer>
                <Section section="with_title_frame-background" />
            </Layer>
        </StateImagery>
        <StateImagery name="DisabledWithTitleWithFrame">
            <Layer>
                <Section section="with_title_frame-background">
                    <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
                </Section>
            </Layer>
        </StateImagery>
        <StateImagery name="ActiveWithTitleNoFrame">
            <Layer>
                <Section section="withtitle_noframe_client_area" />
            </Layer>
        </StateImagery>
        <StateImagery name="InactiveWithTitleNoFrame">
            <Layer>
                <Section section="withtitle_noframe_client_area" />
            </Layer>
        </StateImagery>
        <StateImagery name="DisabledWithTitleNoFrame">
            <Layer>
                <Section section="withtitle_noframe_client_area">
                    <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
                </Section>
            </Layer>
        </StateImagery>
        <StateImagery name="ActiveNoTitleWithFrame">
      <Layer priority="1">
         <Section section="just_frame_for_no_title" />
      </Layer>
            <Layer>
                <Section section="notitle_frame-background" />
            </Layer>
        </StateImagery>
        <StateImagery name="InactiveNoTitleWithFrame">
      <Layer priority="1">
         <Section section="just_frame_for_no_title" />
      </Layer>
            <Layer>
                <Section section="notitle_frame-background" />
            </Layer>
        </StateImagery>
        <StateImagery name="DisabledNoTitleWithFrame">
      <Layer priority="1">
         <Section section="just_frame_for_no_title" />
      </Layer>
            <Layer>
                <Section section="notitle_frame-background">
                    <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
                </Section>
            </Layer>
        </StateImagery>
        <StateImagery name="ActiveNoTitleNoFrame">
            <Layer>
                <Section section="notitle_noframe_client_area" />
            </Layer>
        </StateImagery>
        <StateImagery name="InactiveNoTitleNoFrame">
            <Layer>
                <Section section="notitle_noframe_client_area" />
            </Layer>
        </StateImagery>
        <StateImagery name="DisabledNoTitleNoFrame">
            <Layer>
                <Section section="notitle_noframe_client_area">
                    <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
                </Section>
            </Layer>
        </StateImagery>
    </WidgetLook>


Is that possible that it's a bug or that's correct CEGUI behaviour? I will be really grateful for any help in this matter and I really appreciate your time spent here!

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Possible bug with FrameWindow?

Postby CrazyEddie » Sun Jan 27, 2013 08:57

This is probably a bug. Can you reproduce the issue using a stock LookNFeel? If so could you provide the code / layout that you use to reproduce it, then I can have an easy test case for fixing this :)

CE.

Savail
Quite a regular
Quite a regular
Posts: 50
Joined: Wed Jul 04, 2012 07:54

Re: Possible bug with FrameWindow?

Postby Savail » Sun Jan 27, 2013 10:29

Unfortunately I am having hard network connection difficulties. I had to reinstall my system and I can't download now my IDE ;p, but hopefully tommorow I'll have my connection fixed. I'll put the necessary code as soon as possible! Thanks for reply!

Savail
Quite a regular
Quite a regular
Posts: 50
Joined: Wed Jul 04, 2012 07:54

Re: Possible bug with FrameWindow?

Postby Savail » Sun Jan 27, 2013 12:51

xD Thanks god, I could download Visual C++ today becouse I got good connection for a few minutes. Now it sucks again but I can code again at least :). Ok, so here's full code to reproduce the issue. It's using WinAPI and DirectX. The problem is described in function

Code: Select all

bool Render();
. I'm using here standard CEGUI Taharezlook schemes, xml files etc.

Code: Select all

#include <windows.h>
#include <d3dx9.h>
#include <CEGUI.h>
#include <RendererModules\Direct3D9\CEGUIDirect3D9Renderer.h> //bo sciezka w include paths wskazuje na folder gdzie znajduje sie cegui.h
LPDIRECT3DDEVICE9 d3dDevice;
LPDIRECT3D9 d3dObject;
IDirect3DStateBlock9* pStateBlock;
CEGUI::Direct3D9Renderer *myRenderer;
CEGUI::Window* myRoot;

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
bool InitD3D(HWND hWnd);
bool InitCegui();
bool Render();

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR CommandLine, int WindowShow){
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = 0;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = 0;
wc.lpszClassName = "WindowClass";
wc.hIconSm = 0;

RegisterClassEx(&wc);
RECT rc;
rc.top = 0;
rc.left = 0;
rc.right = 800;
rc.bottom = 600;
AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE);
int nWindowWidth = rc.right - rc.left;
int nWindowHeight = rc.bottom - rc.top;

HWND hWnd = CreateWindowEx(WS_EX_WINDOWEDGE, wc.lpszClassName, "CEGUI", WS_OVERLAPPEDWINDOW | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU, GetSystemMetrics(SM_CXSCREEN)/2 - 400, GetSystemMetrics(SM_CYSCREEN)/2 - 300, nWindowWidth, nWindowHeight, NULL, NULL, hInstance, NULL);
if(!hWnd)
{
   MessageBox(NULL, "Failed to create a window", "Error", MB_OK | MB_ICONEXCLAMATION);
   return 0;
}

if(!InitD3D(hWnd))
{
   MessageBox(NULL, "Failed to initialise DirectX", "Error", MB_OK | MB_ICONEXCLAMATION);
   PostQuitMessage(0);
}

if(!InitCegui())
{
   MessageBox(NULL, "Failed to initialise CEGUI", "Error", MB_OK | MB_ICONEXCLAMATION);
   PostQuitMessage(0);
}

ShowWindow(hWnd, WindowShow);
UpdateWindow(hWnd);

MSG msg;
ZeroMemory(&msg, sizeof(msg));
while(msg.message != WM_QUIT)
{
    if(PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
   else
   {
      if(!Render())
      {
         MessageBox(NULL, "Failed to render", "Error", MB_OK | MB_ICONEXCLAMATION);
         PostQuitMessage(0);
      }

   }
}

return(int)msg.wParam;
}
//*********************************************************************************
bool ok[256];
USHORT prev_key[256];

UINT virtualkey2scancode(WPARAM wParam, LPARAM lParam)
{
  if(HIWORD(lParam) & 0x0F00)
  {
    UINT scancode = MapVirtualKey(wParam, 0);
    return scancode | 0x80;
  }
  else
  {
    return HIWORD(lParam) & 0x00FF;
  }
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
   switch(Message)
   {
   case WM_DESTROY:
      PostQuitMessage(0);
      break;
   case WM_KEYUP:
      CEGUI::System::getSingleton().injectKeyUp( virtualkey2scancode(wParam, lParam) );
      break;
   case WM_KEYDOWN:
      switch(wParam)
      {
      case VK_ESCAPE:
         PostQuitMessage(0);
         break;
      }
      CEGUI::System::getSingleton().injectKeyDown( virtualkey2scancode(wParam, lParam) );
      break;
   case WM_CHAR:
      CEGUI::System::getSingleton().injectChar(static_cast<CEGUI::utf32>(wParam));
      break;
   case WM_MOUSEMOVE:
      {
      float Mouse_x=(short)LOWORD(lParam);
      float Mouse_y=(short)HIWORD(lParam);

      CEGUI::System::getSingleton().injectMousePosition( Mouse_x, Mouse_y );
      }
      break;
   case WM_MOUSELEAVE:
      CEGUI::System::getSingleton().injectMouseLeaves();
      break;
   case WM_LBUTTONDOWN:
      CEGUI::System::getSingleton().injectMouseButtonDown( CEGUI::LeftButton );
      break;
   case WM_LBUTTONUP:
      CEGUI::System::getSingleton().injectMouseButtonUp( CEGUI::LeftButton );
      break;
   case WM_MOUSEWHEEL:
      CEGUI::System::getSingleton().injectMouseWheelChange((float)(GET_WHEEL_DELTA_WPARAM(wParam)/120));
      break;
   default:
      return DefWindowProc(hWnd, Message, wParam, lParam);
   }
   return  0;
}

bool InitD3D(HWND hWnd)
{
    d3dObject = Direct3DCreate9(D3D_SDK_VERSION);
    if(!d3dObject) return false;

    D3DPRESENT_PARAMETERS PresParams;
    ZeroMemory(&PresParams, sizeof(PresParams));
    PresParams.Windowed = true;
    PresParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
    PresParams.BackBufferFormat = D3DFMT_UNKNOWN;
    PresParams.EnableAutoDepthStencil = true;
    PresParams.AutoDepthStencilFormat = D3DFMT_D16;

   HRESULT hr = d3dObject->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &PresParams, &d3dDevice);
    if(FAILED(hr))
    {
        hr = d3dObject->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &PresParams, &d3dDevice);
        if(FAILED(hr))
        {
           hr = d3dObject->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_MIXED_VERTEXPROCESSING, &PresParams, &d3dDevice);
            if(FAILED(hr)) return false;
        }
    }
   
   return true;
}

bool InitCegui()
{
   using namespace CEGUI;
   myRenderer = &CEGUI::Direct3D9Renderer::bootstrapSystem( d3dDevice );

   DefaultResourceProvider* rp = static_cast<DefaultResourceProvider*>(CEGUI::System::getSingleton().getResourceProvider());
   
   rp->setResourceGroupDirectory("schemes", "schemes/");
   rp->setResourceGroupDirectory("imagesets", "imagesets/");
   rp->setResourceGroupDirectory("fonts", "fonts/");
   rp->setResourceGroupDirectory("layouts", "layouts/");
   rp->setResourceGroupDirectory("looknfeels", "looknfeel/");

   CEGUI::Imageset::setDefaultResourceGroup("imagesets");
   CEGUI::Font::setDefaultResourceGroup("fonts");
   CEGUI::Scheme::setDefaultResourceGroup("schemes");
   CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels");
   CEGUI::WindowManager::setDefaultResourceGroup("layouts");

   CEGUI::SchemeManager::getSingleton().create( "TaharezLook.scheme" );
   CEGUI::FontManager::getSingleton().create( "DejaVuSans-10.font" );

   System::getSingleton().setDefaultFont( "DejaVuSans-10" );
   System::getSingleton().setDefaultMouseCursor( "TaharezLook", "MouseArrow" );
   d3dDevice->CreateStateBlock( D3DSBT_ALL, &pStateBlock );

   WindowManager& wmgr = WindowManager::getSingleton();
   myRoot = wmgr.createWindow( "DefaultWindow", "root" );//te okno jest niewidzialne i zakrywa cala powierzchnie client window czyli okna ktore tworze po przez winapi tutaj. Mozna dostac uchwyt tego okna po przez: System::getSingleton().getGUISheet()
   System::getSingleton().setGUISheet( myRoot );

   

   return true;
}

bool Render()
{
    HRESULT hr = d3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

    hr = d3dDevice->BeginScene();

   /*************************** CREATING CEGUI windows *******************************/
   static bool createGUI = false;
   if(!createGUI)
   {
      CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();

      CEGUI::FrameWindow * Parent;
      Parent = static_cast<CEGUI::FrameWindow *>(wmgr.createWindow("TaharezLook/FrameWindow", "FWnd"));
      Parent->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0), CEGUI::UDim(0, 0)));
      Parent->setSize(CEGUI::UVector2(CEGUI::UDim(1, 0), CEGUI::UDim(1, 0)));

      //Parent->setTitleBarEnabled(false); //if you uncomment this line and comment the line in the end of this "if instruction" the results will be diffrent

      myRoot->addChildWindow("FWnd");

      CEGUI::Window * Child = wmgr.createWindow("TaharezLook/Listbox", "Listbox");
      Child->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 10), CEGUI::UDim(0, 10)));
      Child->setSize(CEGUI::UVector2(CEGUI::UDim(0.5, 0), CEGUI::UDim(0, 200)));

      Parent->addChildWindow("Listbox");
      Parent->setTitleBarEnabled(false); //with this line uncommented (and the line above commented) CEGUI behaves correctly as far as I'm concerned :P
   }
   createGUI = true;
   /***************************E N D *************************************************/


   CEGUI::System::getSingleton().renderGUI();
   
   pStateBlock->Apply(); //resetowanie ustawien DirectX'a, paramtery resetowane ustawiane w InitCegui()

   hr = d3dDevice->EndScene();

   hr = d3dDevice->Present(NULL, NULL, NULL, NULL);

    return true;
}


Sorry I cannot upload whole solution :/, my internet connection doesn't let me... Hopefully this example code above can make it easier for you to diagnose issue. Let me know about your decision :)! And thanks for your help, I've been reporting some bugs earlier and thanks to your fixes I could continue coding great GUI in CEGUI without any inconvenience!

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Possible bug with FrameWindow?

Postby CrazyEddie » Mon Jan 28, 2013 14:13

Thanks, I'll try to deal with this real soon (hopefully this week).

Btw, I've also been having connectivity issues, it's so frustrating!

CE.


Return to “Help”

Who is online

Users browsing this forum: Google [Bot] and 12 guests