23 May 2000,

 

Object oriented analysis

  1. Class modeling – object model similar to ER diagram
  2. Dynamic modeling – finite state machine
  3. Functional modeling – data flow diagram

 

00 process model

                        Forward engineering

                        Operation

            OOT    Test

            OOP    Implementation

                        OOD

                        Planning phase

            OOA    Requirements

 

 

Class responsibility collaboration model (CRC)

 

Card –

  1. Class name
  2. Class type
  3. Characteristics
  4. Collaborators

 

Use cases – scripts and scenarios for how the class is used in the real world

 

 

OO design

 

  1. First undertake object oriented system requirements
  2. Identify objects and their services
  3. Establish object interactions – services required and rendered
  4. Identify reusable components from previous design
  5. Implement low level
  6. Introduce inheritance relationships
  7. Look at class combination and generalization

 

Object candidates

 

  1. External entities—people and devices
  2. Things in probable domain – weapons tools
  3. Occurrences or events – task/level completion
  4. Roles – dungeon master
  5. Organizational units – tribes or sales division
  6. Structures – sensors vehicles etc

Windows programming

 

DirectX is installed in directory DXSDK\lib for lib files and \Include for header files

 

Inside VC++ creating win32 work space – win32 consol applications

Settings dialog box under projects tab – load .lib files that are needed

 

Need to add

Ddraw.lib

Dinput.lib

Dsound.lib

Winmm.lib

 

Run time DLL’s have to be in the windows/system directory

 

Hungarian notation

  1. Variable names are prefixed by 1 or 2 character code indicating type Ί  c – char, by – byte, n – number, I – integer lp – 32 bit pointer fn – function, s – string, dw – double word, l – long word, w – word, msg – message
  2. Classes start with a upper case C

 

 

Always include

#define win32_lean_and_mean

# include <windows.h>

# include <windowsx.h>

 

page 62 lists the parameters that can be included in WinMain

page 73 – example to do to prepare a windows class

 

p73

 

wndclassex wndclass

winclass.cbsize = sizeof(wndclasses);

winclass.style = (see examples)

winclass.lpfnwndproc = windproc // event handler for the window (switch statement)

:

:

:

 

if (registerclass(&wndclass) == 0)

            {

            :

            error processing

 

 

Reviews

P79 program 2.3

P79 figure 2.7

 

PostMessage( ) // send message to the queue for normal processing

SendMessage( ) // sends message directly to the window bypassing queue

 

Ex.

SendMessage(hwnd, wm_paint, 0, 0) // 0,0 are message parameters and don’t do anything

 

SendMessage(hwnd, wm_user,w ,l)

 

Case wm_user:

{

l is in lparam

w is in wparam

}

 

Processing keyboard key presses

 

Wm_char

 

WParam Ί ascii char code

Lparam Ί bit code

 

Virtual key table is on page 154 table 3.8 has all the virtual keys

Vk_escape = 1B Ί esc key etc

 

Wm_keydown Ί activated anytime a key is pressed

Wparam is the key press

Lparam is the bit code

 

Bit code table p153

1 – 15 repeat code

16 – 23 scan code OEM specific

24 Boolean extended key code

25 – 28 reserved

29 flag to indicate if key is down

30 Boolean transition state 1 Ί key is pressed 2 Ί key is being released

 

wm_mousemove

  1. Mouse has to move inside the window
  2. Wparam deals with the button flags
  3. Lparam – low word is x position
  4. Lparam – high word is the y position

 

Review

P159 table 3.9 to get button flags

P160 table 3.10 button values

 

Drawing

 

Whenever you or windows disturbs the client area of a window wm_paint is sent – area to be repainted is called invalid rectangle (shipped with paint message called a validating process)

 

BeginPaint( )

:

:

:

endPaint( )

 

Advantage Ί does all needed validating

Disadvantage Ί invalided rectangle which is repainted is the same as the clipping rectangle

 

getdc( )

:

:
:
releasedc( )

 

Advantage Ί draw outside of invalidate rectangle

Disadvantage Ί need to validate every rectangle manually using validateRect( )

 

 

 

// invalidating the entire window

Case wm_paint:

{

            Invalidaterect(hwnd,

                                   NULL,  // invalided rect

                                    true)

 

hdl = beginpaint(hwnd, &ps);

:

:

endpaint(hwnd, &ps);

return (0);

} break;

 

 

Validate the window

 

Case wm_paint:

{

validrect(hwnd, null);

return (0);

} break;

 

Avoid worrying about repaint use DC

 

Case wm_paint:

{

hdc = getdc(hwnd);

// do graphics here

releasedc(hwnd, hdc);

return (0);

} break;

 

 

Display surface fundamentals (GDI)

  1. Resolution and pixels -- 640 x 480, 800 x 600, 1024 x 768
  2. Color depth – number of color bits per pixel 8, 16, 24, or 32
  3. Color space – actual number of colors available 8 bits ΰ 28 =256 colors etc
  4. RGB mode – true rgb values are encoded
  5. Palette mode – indirect color scheme 256 colors at a time a value from 0 –255 is stored with each pixel (8 bit color) color value is looked up in clut (color look-up table)