Is this the only way of doing it, meaning do I have to create a window
or dialog out of PtWindow first and then switch class on them from
PtWindow to PtMyWindow? Why couldn’t PhAB create window from
PtMyWindow from beginning?
Let me just post my PtMyWindow class code and ptpalette and
mywindow.pal
palette.def file
l=ptmywindow,<ptmywindow.h>:ph
p=mywindow,My Window
mywindow.pal file
w=PtMyWindow
m=dw
h=5
PtWidget
PtBasic
PtContainer
PtWindow
PtMyWindow
// Resources
r=Pt_ARG_WINDOW_TITLE,Window Title,18015,4008,0,string,Untitled
r=Pt_ARG_WINDOW_TITLE_COLOR,Window Title
Color,18016,0,0,crgb,0xFFFFFFFD
r=Pt_ARG_WINDOW_ACTIVE_COLOR,Window Active
Color,18018,0,0,crgb,0xFFFFFFFD
r=Pt_ARG_WINDOW_INACTIVE_COLOR,Window Inactive
Color,18019,0,0,crgb,0xFFFFFFFD
i=PtContainer,2002 // Pt_ARG_FILL_COLOR
//i=PtContainer,2006 // Pt_ARG_TOP_BORDER_COLOR
//i=PtContainer,2000 // Pt_ARG_BOT_BORDER_COLOR
i=PtBasic,2022 // Pt_ARG_OUTLINE_COLOR
i=PtBasic,2023 // Pt_ARG_INLINE_COLOR
i=PtBasic,2024 // Pt_ARG_LIGHT_FILL_COLOR
i=PtBasic,2025 // Pt_ARG_DARK_FILL_COLOR
r=Pt_ARG_WINDOW_RENDER_FLAGS,Flags:
Render,18013,4004,0,flag,0x73b0,12
Ph_WM_RENDER_ASDIALOG,0x2,0x7
Ph_WM_RENDER_ASPALETTE,0x4,0x7
Ph_WM_RENDER_BORDER,0x10
Ph_WM_RENDER_RESIZE,0x20
Ph_WM_RENDER_TITLE,0x80
Ph_WM_RENDER_MENU,0x100
Ph_WM_RENDER_CLOSE,0x200
Ph_WM_RENDER_HELP,0x400
Ph_WM_RENDER_MIN,0x1000
Ph_WM_RENDER_MAX,0x2000
Ph_WM_RENDER_COLLAPSE,0x4000
Ph_WM_RENDER_INLINE,0x10000
r=Pt_ARG_WINDOW_MANAGED_FLAGS,Flags:
Managed,18011,4005,0,flag,0x4CB7D,18
Ph_WM_CLOSE,0x1
Ph_WM_FOCUS,0x4
Ph_WM_MENU,0x8
Ph_WM_TOFRONT,0x10
Ph_WM_TOBACK,0x20
Ph_WM_HIDE,0x40
Ph_WM_CONSWITCH,0x80
Ph_WM_RESIZE,0x100
Ph_WM_MOVE,0x200
Ph_WM_ICON,0x400
Ph_WM_MAX,0x800
Ph_WM_BACKDROP,0x1000
Ph_WM_HELP,0x2000
Ph_WM_TASKBAR,0x4000
Ph_WM_RESTORE,0x8000
Ph_WM_FFRONT,0x10000
Ph_WM_COLLAPSE,0x40000
Ph_WM_NO_FOCUS_LIST,0x20000
r=Pt_ARG_WINDOW_NOTIFY_FLAGS,Flags:
Notify,18012,4006,0,flag,0x2101,17
Ph_WM_CLOSE,0x1
Ph_WM_FOCUS,0x4
Ph_WM_MENU,0x8
Ph_WM_TOFRONT,0x10
Ph_WM_TOBACK,0x20
Ph_WM_HIDE,0x40
Ph_WM_CONSWITCH,0x80
Ph_WM_RESIZE,0x100
Ph_WM_MOVE,0x200
Ph_WM_ICON,0x400
Ph_WM_MAX,0x800
Ph_WM_BACKDROP,0x1000
Ph_WM_HELP,0x2000
Ph_WM_TASKBAR,0x4000
Ph_WM_RESTORE,0x8000
Ph_WM_FFRONT,0x10000
Ph_WM_COLLAPSE,0x40000
r=Pt_ARG_WINDOW_STATE,Window State,18014,4007,0,flag,0,7
Ph_WM_STATE_ISNORMAL,0x00,0x907
Ph_WM_STATE_ISHIDDEN,0x01,0x05
Ph_WM_STATE_ISMAX,0x02
Ph_WM_STATE_ISCOLLAPSE,0x800
Ph_WM_STATE_ISBACKDROP,0x04,0x905
Ph_WM_STATE_ISFRONT,0x100,0x104
Ph_WM_STATE_ISALTKEY,0x200
r=Pt_ARG_MIN_HEIGHT,Minimum Window Height,18006,18006,1,ushort,23
r=Pt_ARG_MIN_WIDTH,Minimum Window Width,18007,18007,1,ushort,94
r=Pt_ARG_MAX_HEIGHT,Maximum Window Height,18004,18004,1,ushort,0
r=Pt_ARG_MAX_WIDTH,Maximum Window Width,18005,18005,1,ushort,0
i=PtContainer,10005 // Pt_ARG_CONTAINER_FLAGS
i=PtContainer,10007 // Pt_ARG_CONTAINR_TITLE
i=PtContainer,10008 // Pt_ARG_CONTAINER_FONT
// Similar in PtContainer:
// r=Pt_ARG_CURSOR_TYPE,Cursor Type,1002,1006,1,short,0,18
r=Pt_ARG_CURSOR_TYPE,Cursor Type,1002,1006,1,short,59648,17
Ph_CURSOR_POINTER,0xe900
Ph_CURSOR_BIG_POINTER,0xe902
Ph_CURSOR_MOVE,0xe904
Ph_CURSOR_CROSSHAIR,0xe906
Ph_CURSOR_CLOCK,0xe908
Ph_CURSOR_NOINPUT,0xe90A
Ph_CURSOR_FINGER,0xe90C
Ph_CURSOR_INSERT,0xe90E
Ph_CURSOR_DRAG_VERTICAL,0xe910
Ph_CURSOR_DRAG_HORIZONTAL,0xe912
Ph_CURSOR_DRAG_BACKDIAG,0xe914
Ph_CURSOR_DRAG_FOREDIAG,0xe916
Ph_CURSOR_POINT_WAIT,0xe918
Ph_CURSOR_LONG_WAIT,0xe91a
Ph_CURSOR_QUESTION_POINT,0xe91c
Ph_CURSOR_PASTE,0xe91e
Ph_CURSOR_NONE,0xfd
// Similar in PtContainer:
// r=Pt_ARG_CURSOR_COLOR,Color: Cursor,1003,1007,1,crgb,0xffffe0
r=Pt_ARG_CURSOR_COLOR,Cursor Color,1003,1007,1,crgb,0xffffe0
i=PtContainer,1018 // Pt_ARG_EFLAGS
i=PtBasic,1006 // Pt_ARG_FLAGS
//i=PtContainer,2014 // Pt_ARG_HIGHLIGHT_ROUNDNESS
i=PtBasic,1008 // Pt_ARG_RESIZE_FLAGS
i=PtContainer,10015 // Pt_ARG_LAYOUT_TYPE
i=PtContainer,10016 // Pt_ARG_FILL_LAYOUT_INFO
i=PtContainer,10017 // Pt_ARG_ROW_LAYOUT_INFO
i=PtContainer,10018 // Pt_ARG_GRID_LAYOUT_INFO
i=PtWidget,1035 // Pt_ARG_ROW_LAYOUT_DATA
i=PtWidget,1036 // Pt_ARG_GRID_LAYOUT_DATA
r=Pt_ARG_WINDOW_HELP_ROOT,Help Root,18020,18020,0,string,NULL
i=PtContainer,1015 // Pt_ARG_HELP_TOPIC
i=PtContainer,1014 // Pt_ARG_USER_DATA
// Callbacks
n=PtContainer,2009 // Pt_CB_ACTIVATE
n=PtContainer,2007 // Pt_CB_ARM
n=PtContainer,2008 // Pt_CB_DISARM
n=PtLabel,2012 // Pt_CB_REPEAT
n=PtWidget,1022 // Pt_CB_OUTBOUND
n=PtContainer,2016 // Pt_CB_MENU
n=PtContainer,10003 // Pt_CB_RESIZE
n=PtContainer,2010 // Pt_CB_GOT_FOCUS
n=PtContainer,2011 // Pt_CB_LOST_FOCUS
c=Pt_CB_WINDOW,Window Manager,18017,4013
c=Pt_CB_WINDOW_OPENING,Window Opening,18023,18023
c=Pt_CB_WINDOW_CLOSING,Window Closing,18024,18024
c=Pt_CB_WINDOW_TRANSPORT,Window Transported,18021,18021
n=PtContainer,1010 // Pt_CB_HOTKEY
n=PtWidget,1026 // Pt_CB_FILTER
n=PtContainer,1011 // Pt_CB_RAW
n=PtContainer,10006 // Pt_CB_FILTER
n=PtContainer,1012 // Pt_CB_REALIZED
n=PtContainer,1013 // Pt_CB_UNREALIZED
n=PtContainer,1009 // Pt_CB_DESTROYED
n=PtWidget,1020 // Pt_CB_DND
c=Pt_CB_BLOCKED,Blocked,1016,1016
//ptmywindow.h
#ifndef __PTMYWINDOW_H_INCLUDED
#define __PTMYWINDOW_H_INCLUDED
#ifndef __PT_WINDOW_H_INCLUDED
#include <photon/PtWindow.h>
#endif
#include <photon/PpT.h>
#include <photon/PhPack.h>
#ifdef __cplusplus
extern “C” {
#endif
/*
extern PtWidgetClassRef_t *PtMyWindow;
/* Widget structure */
typedef struct Pt_my_window_widget {
PtWindowWidget_t def_window;
} PtMyWindowWidget_t;
/* Widget union */
typedef union Pt_my_window_union {
PtWidget_t core;
PtBasicWidget_t basic;
PtContainerWidget_t container;
PtDisjointWidget_t disjoint;
PtWindowWidget_t window;
PtMyWindowWidget_t mywindow;
} PtMyWindowUnion_t;
#ifdef __cplusplus
};
#endif
#include <photon/PhPackPop.h>
#endif //PTMYWINDOW_H
//ptmywindow.c
#include <Ph.h>
#include <photon/PpProto.h>
#include <stdlib.h>
#include <string.h>
#include “ptmywindow.h”
static PtWidgetClass_t *PtCreateWindowClass( void );
static PtWidgetClassRef_t window_class_ref = { NULL,
PtCreateWindowClass };
PtWidgetClassRef_t *PtMyWindow = &window_class_ref;
//
// Defaults Function
//
static void window_dflts( PtWidget_t *widget )
{
PtMyWindowWidget_t *window = (PtMyWindowWidget_t *)widget;
PtSetResource( widget, Pt_ARG_FILL_COLOR, Pg_BLUE, 0 );
PtSetResource( widget,Pt_ARG_COLOR,Pg_RED,0);
PtSetResource( widget,Pt_ARG_WINDOW_TITLE,“DSI2”,0);
}
static PtWidgetClass_t *PtCreateWindowClass( void )
{
static const PtClassArg_t args[] = {
{ Pt_SET_DFLTS_F, (long) window_dflts },
{ Pt_SET_DESCRIPTION, (long) “PtMyWindow” },
};
static const PtArg_t roargs[] = {
{ Pt_SET_VERSION, 110 },
{ Pt_SET_STATE_LEN, sizeof( PtMyWindowWidget_t ) },
//{ Pt_SET_FLAGS, Pt_TRUE, Pt_DISJOINT },
//{Pt_SET_FLAGS,Pt_TRUE,Pt_CONTAINER},
//{ Pt_SET_NUM_RESOURCES, sizeof( resources )/sizeof( resources[0] )
},
};
return( PtMyWindow->wclass = PtCreateOptWidgetClass(
PtWindow, 0, sizeof( args )/sizeof( args[0] ), args
,sizeof(roargs)/sizeof(roargs[0]),roargs) );
}